event_finda_ruby 0.2.3 → 0.2.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: affae5663dcb294b5eed5fbff3c0e36d954c9d80
4
- data.tar.gz: 1239cd7c8d60f064d5d84d12c65a891289dbe3ed
3
+ metadata.gz: 71803acdd2a022f323cbe805482b8f1fcbab2edc
4
+ data.tar.gz: 5a7f5736c027be91794b7a263566458a4b27fe27
5
5
  SHA512:
6
- metadata.gz: 7d90709e30918c26844f82234efd15b174e843f70c6d8f5b175bfbb8e8638c811cbd238e05fb6d28d10effffc6749e4a90ba429d75216c5327ae72505cafd63c
7
- data.tar.gz: d2678da0d056118ad4dc317b908981d9be26da56a7dbc510ad7fd36262f2c82dc7b7d4139495438734125cf7c7d86b8dc29f3ae6629975f7b62ebcee664d956e
6
+ metadata.gz: 26bf303b040b28e039d88b2d89ddf8abbd3c7108450b80b79f50f4821a4f5acc4bf393a384cffd6033e8dc632f0198738ea81fb459b097223412890567cdc89c
7
+ data.tar.gz: 1d184025885c34402d79ced0c15205a494937ba351aa11999ca1c2388f1d1096140a10ae2471430bb44c8421dbadfa10a9522fc3cc18c886e280016c5b68ac22
@@ -7,12 +7,12 @@ class Base
7
7
 
8
8
  attr_reader :api_extension
9
9
  attr_reader :auth
10
- attr_reader :url
10
+ attr_reader :filters
11
11
 
12
12
  def initialize(auth)
13
13
  @api_extension = "json"
14
14
  @auth = auth
15
- @url = base_path
15
+ @filters = { "rows" => "20" }
16
16
  end
17
17
 
18
18
  def by_keywords_and(keywords)
@@ -27,8 +27,6 @@ class Base
27
27
  self
28
28
  end
29
29
 
30
- # allowing AND/OR behavior customized by developer
31
- # /events.xml?q=(cycling+AND+running+AND+swimming)+OR+triathlon
32
30
  def by_query(query)
33
31
  apply_filter "q", query
34
32
 
@@ -41,6 +39,10 @@ class Base
41
39
  self
42
40
  end
43
41
 
42
+ def url
43
+ "#{BASE_URL}.#{api_extension}?#{get_filters}"
44
+ end
45
+
44
46
  def with_extension(extension)
45
47
  if ["json", "xml"].include? extension
46
48
  @api_extension = extension
@@ -51,13 +53,12 @@ class Base
51
53
 
52
54
  private
53
55
 
54
- # retrieving maximum set of results by default: 20
55
- def base_path
56
- "#{BASE_URL}.#{api_extension}?rows=20"
56
+ def apply_filter(filter_name, value)
57
+ filters[filter_name] = value
57
58
  end
58
59
 
59
- def apply_filter(filter_name, value)
60
- @url = "#{url}&#{filter_name}=#{value}"
60
+ def get_filters
61
+ filters.map { |k,v| "#{k}=#{v}" }.join("&")
61
62
  end
62
63
 
63
64
  def set_keywords_or(keywords)
@@ -21,32 +21,6 @@ module EventFindaRuby
21
21
  self
22
22
  end
23
23
 
24
- def by_keywords_and(keywords)
25
- apply_filter "q", set_keywords_and(keywords)
26
-
27
- self
28
- end
29
-
30
- def by_keywords_or(keywords)
31
- apply_filter "q", set_keywords_or(keywords)
32
-
33
- self
34
- end
35
-
36
- # allowing AND/OR behavior customized by developer
37
- # /events.xml?q=(cycling+AND+running+AND+swimming)+OR+triathlon
38
- def by_query(query)
39
- apply_filter "q", query
40
-
41
- self
42
- end
43
-
44
- def by_rows(rows)
45
- apply_filter "rows", rows
46
-
47
- self
48
- end
49
-
50
24
  # price_max format "35.0" or "35"
51
25
  def by_price_max(price_max)
52
26
  apply_filter "price_max", price_max
@@ -85,14 +59,5 @@ module EventFindaRuby
85
59
  @results = response["events"]
86
60
  end
87
61
 
88
- private
89
-
90
- def set_keywords_or(keywords)
91
- keywords.to_a.join("+OR+")
92
- end
93
-
94
- def set_keywords_and(keywords)
95
- keywords.to_a.join("+AND+")
96
- end
97
62
  end
98
63
  end
@@ -1,3 +1,3 @@
1
1
  module EventFindaRuby
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: event_finda_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Roldan