Skip to content

Commit

Permalink
v1.0.0: First release
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelmhtr committed Nov 3, 2020
0 parents commit a2677fc
Show file tree
Hide file tree
Showing 9 changed files with 400 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
*.gem
*.rbc
/.config
/coverage/
/InstalledFiles
/pkg/
/spec/reports/
/spec/examples.txt
/test/tmp/
/test/version_tmp/
/tmp/

# Used by dotenv library to load environment variables.
# .env

# Ignore Byebug command history file.
.byebug_history

## Specific to RubyMotion:
.dat*
.repl_history
build/
*.bridgesupport
build-iPhoneOS/
build-iPhoneSimulator/

## Specific to RubyMotion (use of CocoaPods):
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# vendor/Pods/

## Documentation cache and generated files:
/.yardoc/
/_yardoc/
/doc/
/rdoc/

## Environment normalization:
/.bundle/
/vendor/bundle
/lib/bundler/man/

# for a library or gem, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# Gemfile.lock
# .ruby-version
# .ruby-gemset

# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc

# Used by RuboCop. Remote config files pulled in from inherit_from directive.
# .rubocop-https?--*
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--require spec_helper
192 changes: 192 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
require:
- rubocop-performance

AllCops:
Exclude:
- 'vendor/**/*'
- 'spec/factories/**/*'
- 'tmp/**/*'
- 'bin/*'
- 'Gemfile'
- 'buro_analyzer.gemspec'
- 'config/environments/*'
TargetRubyVersion: 2.6
NewCops: enable

# Too short methods lead to extraction of single-use methods, which can make
# the code easier to read (by naming things), but can also clutter the class
Metrics/MethodLength:
Max: 50

# The guiding principle of classes is SRP, SRP can't be accurately measured by LoC
Metrics/ClassLength:
Max: 1500

Metrics/AbcSize:
Enabled: false

# Other option to do this is to use the option ExcludedMethods: ['method_1', 'method_2']
Metrics/BlockLength:
Exclude:
- 'Rakefile'
- '**/*/.rake'
- 'spec/**/*.rb'

# Commonly used screens these days easily fit more than 80 characters.
Layout/LineLength:
Max: 120

# No space makes the method definition shorter and differentiates
# from a regular assignment.
Layout/SpaceAroundEqualsInParameterDefault:
EnforcedStyle: no_space

Layout/MultilineMethodCallIndentation:
Enabled: false

# Single quotes being faster is hardly measurable and only affects parse time.
# Enforcing double quotes reduces the times where you need to change them
# when introducing an interpolation. Use single quotes only if their semantics
# are needed.
Style/StringLiterals:
Enabled: false

# We do not need to support Ruby 1.9, so this is good to use.
Style/SymbolArray:
Enabled: true

# Most readable form.
Layout/HashAlignment:
EnforcedHashRocketStyle: table
EnforcedColonStyle: table

# Mixing the styles looks just silly.
Style/HashSyntax:
EnforcedStyle: ruby19_no_mixed_keys

# has_key? and has_value? are far more readable than key? and value?
Style/PreferredHashMethods:
Enabled: false

# String#% is by far the least verbose and only object oriented variant.
Style/FormatString:
EnforcedStyle: percent

Style/CollectionMethods:
Enabled: true
PreferredMethods:
# inject seems more common in the community.
reduce: "inject"

Style/ExpandPathArguments:
Enabled: false

# Either allow this style or don't. Marking it as safe with parenthesis
# is silly. Let's try to live without them for now.
Style/ParenthesesAroundCondition:
AllowSafeAssignment: false
Lint/AssignmentInCondition:
AllowSafeAssignment: false

# A specialized exception class will take one or more arguments and construct the message from it.
# So both variants make sense.
Style/RaiseArgs:
Enabled: false

# Indenting the chained dots beneath each other is not supported by this cop,
# see https://github.com/bbatsov/rubocop/issues/1633
Layout/MultilineOperationIndentation:
Enabled: false

# Fail is an alias of raise. Avoid aliases, it's more cognitive load for no gain.
# The argument that fail should be used to abort the program is wrong too,
# there's Kernel#abort for that.
Style/SignalException:
EnforcedStyle: only_raise

# Suppressing exceptions can be perfectly fine, and be it to avoid to
# explicitly type nil into the rescue since that's what you want to return,
# or suppressing LoadError for optional dependencies
Lint/SuppressedException:
Enabled: false

# No trailing space differentiates better from the block:
# foo} means hash, foo } means block.
Layout/SpaceInsideHashLiteralBraces:
EnforcedStyle: space

# { ... } for multi-line blocks is okay, follow Weirichs rule instead:
# https://web.archive.org/web/20140221124509/http://onestepback.org/index.cgi/Tech/Ruby/BraceVsDoEnd.rdoc
Style/BlockDelimiters:
Enabled: false

# do / end blocks should be used for side effects,
# methods that run a block for side effects and have
# a useful return value are rare, assign the return
# value to a local variable for those cases.
Style/MethodCalledOnDoEndBlock:
Enabled: true

# Enforcing the names of variables? To single letter ones? Just no.
Style/SingleLineBlockParams:
Enabled: false

# Shadowing outer local variables with block parameters is often useful
# to not reinvent a new name for the same thing, it highlights the relation
# between the outer variable and the parameter. The cases where it's actually
# confusing are rare, and usually bad for other reasons already, for example
# because the method is too long.
Lint/ShadowingOuterLocalVariable:
Enabled: false

# Check with yard instead.
Style/Documentation:
Enabled: false

# This is just silly. Calling the argument `other` in all cases makes no sense.
Naming/BinaryOperatorParameterName:
Enabled: false

# There are valid cases, for example debugging Cucumber steps,
# also they'll fail CI anyway
Lint/Debugger:
Enabled: false

# Style preference
Style/MethodDefParentheses:
Enabled: false

# Frozen String Literal
Style/FrozenStringLiteralComment:
Enabled: false
Exclude:
- 'config.ru'
- 'Dangerfile'
- 'Gemfile'
- 'Rakefile'
- 'config/**/*'
- 'lib/tasks/**/*'
- 'rubocop/**/*'
- 'scripts/**/*'
- 'spec/**/*'

Layout/SpaceInsideBlockBraces:
Enabled: false

Style/BlockComments:
Enabled: false

Layout/SpaceInsideArrayLiteralBrackets:
EnforcedStyle: no_space

Style/NumericLiterals:
Enabled: false

Style/ClassAndModuleChildren:
Enabled: false

Layout/FirstHashElementIndentation:
EnforcedStyle: consistent

Style/AccessorGrouping:
Enabled: false
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby-2.6.5@curp-generator
9 changes: 9 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
source 'https://rubygems.org'

ruby '2.6.5'

group :development, :test do
gem "rspec", "~> 3.10"
gem "rubocop-performance", "~> 1.8"
gem "rubocop", "~> 1.1"
end
54 changes: 54 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
GEM
remote: https://rubygems.org/
specs:
ast (2.4.1)
diff-lcs (1.4.4)
parallel (1.19.2)
parser (2.7.2.0)
ast (~> 2.4.1)
rainbow (3.0.0)
regexp_parser (1.8.2)
rexml (3.2.4)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0)
rspec-core (3.10.0)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-mocks (3.10.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (3.10.0)
rubocop (1.1.0)
parallel (~> 1.10)
parser (>= 2.7.1.5)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8)
rexml
rubocop-ast (>= 1.0.1)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (1.1.0)
parser (>= 2.7.1.5)
rubocop-performance (1.8.1)
rubocop (>= 0.87.0)
rubocop-ast (>= 0.4.0)
ruby-progressbar (1.10.1)
unicode-display_width (1.7.0)

PLATFORMS
ruby

DEPENDENCIES
rspec (~> 3.10)
rubocop (~> 1.1)
rubocop-performance (~> 1.8)

RUBY VERSION
ruby 2.6.5p114

BUNDLED WITH
1.17.3
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2020 COMUNIDAD DE PRESTAMOS SAPI DE CV

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# CURP Generator

![](https://img.shields.io/badge/build-passing-green)
![](https://img.shields.io/badge/ruby-%3E%3D%202.6.5-blue)
![](https://img.shields.io/github/license/yotepresto-com/curp-generator?color=blue)

Ruby Gem to generate mexican [CURPs](https://en.wikipedia.org/wiki/Unique_Population_Registry_Code).

### Install

Just add the gem to your project:

```sh
gem install curp_generator

# Or using bundler
bundle add curp_generator
```

### Usage

The main class is `CurpGenerator::Curp`. It accepts the following parameters:

| Parameter | Type | Description |
| --------- | ---- | ----------- |
|`first_name`|String|The first name of the person.|
|`second_name`|String|The middle name of the person.|
|`first_last_name`|String|The father's last name of the person.|
|`second_last_name`|String|The mother's last name of the person.|
|`gender`|String|The gender of the person. Possible values: `male`, `female`,|
|`birth_date`|String|The date when the person was born.|
|`birth_state`|String|The mexican state where the person was born. Possible values are listed in the [Catalogs module](/lib/catalogs.rb).|

Then, just call the `.generate` method and it will return the CURP for that person.

**Example:**

```rb
require 'curp_generator'

curp = CurpGenerator::Curp.new(
first_name: 'Maria',
second_name: 'Alejandra',
first_last_name: 'De la Rosa',
second_last_name: 'Ruiz',
gender: 'female',
birth_date: DateTime.parse('1989-10-14 06:00:00'),
birth_state: 'JALISCO'
)

curp.generate # Returns: RORA891014MJCSZL03
```

## License

MIT
Loading

0 comments on commit a2677fc

Please sign in to comment.