municipitaly 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/Gemfile.lock +1 -1
- data/README.md +5 -1
- data/lib/municipitaly/data.rb +1 -1
- data/lib/municipitaly/search.rb +16 -6
- data/lib/municipitaly/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac3d4c00b1b7bdb813715e766feda06ea45c699871cfa5275a1be11b14d8040a
|
4
|
+
data.tar.gz: 85371d88cda566a0a57eb2e425cd024378a94741ab5f90ab57ea8bb37f439aac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c47bcf525cc0a6d73fb8023f182330797ab38be769619bdcc919d513115f8f7d1c37ec369f86ee12e024586cfbd752e5e96207b8e96a6c224f6945eb1f4184dd
|
7
|
+
data.tar.gz: 61ea4f864d72f403033089f5ad8b32601e15fb0af321246e80720488f4e5e8c76416cea2861760abed5343f13216b7e0ad1f766a7bc636fe3b1a5180cf5a3126
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -55,6 +55,9 @@ Returned data are stored in 4 different types of entity models:
|
|
55
55
|
Retrieve all zones (return an array of `Municipitaly::Zone` objects):
|
56
56
|
|
57
57
|
```ruby
|
58
|
+
# inside an irb or rails console:
|
59
|
+
require 'municipitaly'
|
60
|
+
|
58
61
|
zones = Municipitaly::Zone.all
|
59
62
|
# => [#<Municipitaly::Zone:0x0000...]
|
60
63
|
```
|
@@ -69,6 +72,7 @@ retrive data zone:
|
|
69
72
|
```ruby
|
70
73
|
zone.name
|
71
74
|
# => "Centro"
|
75
|
+
|
72
76
|
zone.code
|
73
77
|
# => "3"
|
74
78
|
```
|
@@ -179,7 +183,7 @@ If you want to contribute keep these guidelines in mind:
|
|
179
183
|
Steps to submit your code:
|
180
184
|
|
181
185
|
1. Fork the repo.
|
182
|
-
2.
|
186
|
+
2. Open your feature/namespaced branch
|
183
187
|
3. Commit your code following Github guidelines.
|
184
188
|
4. Make a PR with an exhaustive description.
|
185
189
|
|
data/lib/municipitaly/data.rb
CHANGED
data/lib/municipitaly/search.rb
CHANGED
@@ -26,15 +26,16 @@ module Municipitaly
|
|
26
26
|
municipalities_from_zone_code].freeze # :nodoc:
|
27
27
|
|
28
28
|
CLASS_METHODS.each do |method|
|
29
|
-
define_singleton_method method do |message|
|
30
|
-
Search.new(message).send(method)
|
29
|
+
define_singleton_method method do |message, opts = {}|
|
30
|
+
Search.new(message, opts).send(method)
|
31
31
|
end
|
32
32
|
end # :nodoc:
|
33
33
|
|
34
|
-
attr_accessor :term # :nodoc:
|
34
|
+
attr_accessor :term, :opts # :nodoc:
|
35
35
|
|
36
|
-
def initialize(term) # :nodoc:
|
36
|
+
def initialize(term, opts = {}) # :nodoc:
|
37
37
|
@term = term.to_s.strip
|
38
|
+
@opts = opts
|
38
39
|
end
|
39
40
|
|
40
41
|
protected
|
@@ -117,13 +118,22 @@ module Municipitaly
|
|
117
118
|
|
118
119
|
# returns an array of +Municipitaly::Municipality+ objects from a
|
119
120
|
# <b>municipality name</b> term.
|
120
|
-
# Term can be a partial string and is case insensitive.
|
121
|
+
# Term can be a partial string and is case insensitive.
|
122
|
+
# The optional parameter +greedy+ [boolean] permit to serch exact term
|
123
|
+
# name (if false) or partial word (true by default).
|
121
124
|
#
|
122
125
|
# example usage:
|
123
126
|
# municipalities = Search.municipalities_from_name('monte')
|
127
|
+
# municipalities = Search.municipalities_from_name('monte', greedy: false)
|
124
128
|
def municipalities_from_name # :doc:
|
129
|
+
greedy = opts.fetch(:greedy, true)
|
130
|
+
regexp = if greedy
|
131
|
+
Regexp.new(term, true)
|
132
|
+
else
|
133
|
+
Regexp.new("^#{term}$", true)
|
134
|
+
end
|
125
135
|
data.municipalities.select do |m|
|
126
|
-
m.name =~
|
136
|
+
m.name =~ regexp
|
127
137
|
end
|
128
138
|
end
|
129
139
|
|
data/lib/municipitaly/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: municipitaly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- NatyDev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|