conecta_address_br 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +20 -0
- data/README.md +33 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/conecta_address_br.gemspec +31 -0
- data/lib/conecta_address_br.rb +28 -0
- data/lib/conecta_address_br/states/states.rb +7 -0
- data/lib/conecta_address_br/version.rb +3 -0
- data/lib/locales/addressList.yml +32 -0
- metadata +83 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1f2c3f0f4ec5466f048ce3ff648bc69d167caced131d06a725c19a1d0f5df49f
|
4
|
+
data.tar.gz: 2ce9412887f26d241fe597ca726067af2eec4e8bf9a6f9844d8ac4b89d802fd1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c2c46d72d0269bec5a024c3ec5687f14f0b28683e28f9dbceb37e1a7e44faecbeae88d1fd67e9c3c421df6e48fa453b907ac238eb615abc6c9d96e63a6334f5a
|
7
|
+
data.tar.gz: fc4a7023824fe56e2d6b7dd63f9bbb61f593ed0810fa7902eca1a2fa38585027a651a42460702bc840bca15c413bd4b43da8206aec77a04a25b111fedb02b102
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
conecta_address_br (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
rake (10.5.0)
|
10
|
+
|
11
|
+
PLATFORMS
|
12
|
+
ruby
|
13
|
+
|
14
|
+
DEPENDENCIES
|
15
|
+
bundler (~> 2.0)
|
16
|
+
conecta_address_br!
|
17
|
+
rake (~> 10.0)
|
18
|
+
|
19
|
+
BUNDLED WITH
|
20
|
+
2.0.2
|
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Conecta Address BR
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/conecta_address_br`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'conecta_address_br'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install conecta_address_br
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Development
|
26
|
+
|
27
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
28
|
+
|
29
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/conectaai/conecta_address_br.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "conecta_address_br"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "conecta_address_br/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "conecta_address_br"
|
7
|
+
spec.version = ConectaAddressBr::VERSION
|
8
|
+
spec.authors = ["Eduardo Martins"]
|
9
|
+
spec.email = ["eduardomg@id.uff.br"]
|
10
|
+
|
11
|
+
spec.summary = %q{Estados e Cidades do Brasil.}
|
12
|
+
spec.description = %q{Responsável por relacionar localmente os estados e as cidades brasileiras.}
|
13
|
+
spec.homepage = "https://github.com/conectaai/address-br"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
17
|
+
# spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
# spec.metadata["source_code_uri"] = "https://github.com/conectaai/address-br"
|
19
|
+
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
23
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
|
+
end
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
|
29
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
30
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
31
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "conecta_address_br"
|
2
|
+
|
3
|
+
module ConectaAddressBr
|
4
|
+
def regexify(reg)
|
5
|
+
reg = reg.source if reg.respond_to?(:source) # Handle either a Regexp or a String that looks like a Regexp
|
6
|
+
reg
|
7
|
+
.gsub(%r{^\/?\^?}, '').gsub(%r{\$?\/?$}, '') # Ditch the anchors
|
8
|
+
.gsub(/\{(\d+)\}/, '{\1,\1}').gsub(/\?/, '{0,1}') # All {2} become {2,2} and ? become {0,1}
|
9
|
+
.gsub(/(\[[^\]]+\])\{(\d+),(\d+)\}/) { |_match| Regexp.last_match(1) * sample(Array(Range.new(Regexp.last_match(2).to_i, Regexp.last_match(3).to_i))) } # [12]{1,2} becomes [12] or [12][12]
|
10
|
+
.gsub(/(\([^\)]+\))\{(\d+),(\d+)\}/) { |_match| Regexp.last_match(1) * sample(Array(Range.new(Regexp.last_match(2).to_i, Regexp.last_match(3).to_i))) } # (12|34){1,2} becomes (12|34) or (12|34)(12|34)
|
11
|
+
.gsub(/(\\?.)\{(\d+),(\d+)\}/) { |_match| Regexp.last_match(1) * sample(Array(Range.new(Regexp.last_match(2).to_i, Regexp.last_match(3).to_i))) } # A{1,2} becomes A or AA or \d{3} becomes \d\d\d
|
12
|
+
.gsub(/\((.*?)\)/) { |match| sample(match.gsub(/[\(\)]/, '').split('|')) } # (this|that) becomes 'this' or 'that'
|
13
|
+
.gsub(/\[([^\]]+)\]/) { |match| match.gsub(/(\w\-\w)/) { |range| sample(Array(Range.new(*range.split('-')))) } } # All A-Z inside of [] become C (or X, or whatever)
|
14
|
+
.gsub(/\[([^\]]+)\]/) { |_match| sample(Regexp.last_match(1).split('')) } # All [ABC] become B (or A or C)
|
15
|
+
.gsub('\d') { |_match| sample(Numbers) }
|
16
|
+
.gsub('\w') { |_match| sample(Letters) }
|
17
|
+
end
|
18
|
+
|
19
|
+
def fetch(keys)
|
20
|
+
fetched = translate("faker.#{key}")
|
21
|
+
fetched = fetched.last if fetched.size <= 1
|
22
|
+
if !fetched.respond_to?(:sample) && fetched.match(%r{^\/}) && fetched.match(%r{\/$}) # A regex
|
23
|
+
regexify(fetched)
|
24
|
+
else
|
25
|
+
fetched
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
brasil:
|
2
|
+
AC:
|
3
|
+
AL:
|
4
|
+
AP:
|
5
|
+
AM:
|
6
|
+
BA:
|
7
|
+
DF:
|
8
|
+
ES:
|
9
|
+
GO:
|
10
|
+
MA:
|
11
|
+
MT:
|
12
|
+
MS:
|
13
|
+
MG:
|
14
|
+
PB:
|
15
|
+
PR:
|
16
|
+
PE:
|
17
|
+
PI:
|
18
|
+
RJ:
|
19
|
+
[
|
20
|
+
"Niterói",
|
21
|
+
"Rio de Janeiro",
|
22
|
+
"São Gonçalo",
|
23
|
+
"Macaé"
|
24
|
+
]
|
25
|
+
RN:
|
26
|
+
RS:
|
27
|
+
RO:
|
28
|
+
RR:
|
29
|
+
SC:
|
30
|
+
SP:
|
31
|
+
SE:
|
32
|
+
TO:
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: conecta_address_br
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Eduardo Martins
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-11-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Responsável por relacionar localmente os estados e as cidades brasileiras.
|
42
|
+
email:
|
43
|
+
- eduardomg@id.uff.br
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- Gemfile.lock
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- bin/console
|
54
|
+
- bin/setup
|
55
|
+
- conecta_address_br.gemspec
|
56
|
+
- lib/conecta_address_br.rb
|
57
|
+
- lib/conecta_address_br/states/states.rb
|
58
|
+
- lib/conecta_address_br/version.rb
|
59
|
+
- lib/locales/addressList.yml
|
60
|
+
homepage: https://github.com/conectaai/address-br
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubygems_version: 3.0.6
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: Estados e Cidades do Brasil.
|
83
|
+
test_files: []
|