loquor 0.7.0 → 0.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 837513aa345f52c304b8524e4e0c7f8b12dd5869
4
- data.tar.gz: 13a5373cc387569f252695d476fd03ec5a477fc5
3
+ metadata.gz: 28dd6aeff0ac0f2ded967b9dd124469cc0762619
4
+ data.tar.gz: e23c26471f5cc34d54594273f3636b642117d99e
5
5
  SHA512:
6
- metadata.gz: 3d5a08684effe150f0dad33625649399953dab6c79996c7a9c4c1187e27523c76571902c4a3bbcfba7acd55f8eebf30c3355892bb1ade2cd6f8cf413ca3fb333
7
- data.tar.gz: 10c496162c95d058cd31c1e7299c9e62c0d32d8203ef0ce7998429fb4e4f8756c6c649a8c2a56e347ec3fec4b62142f4c417f08bd5682ea4cd454bf34506b8f1
6
+ metadata.gz: cdd7ab5e8e4dce7118a558add6f02621117aaad7836fb468b642ed83fec5cea250f6e85965f2665a042cc9057318cf01cddf943890e7ef785f9c511375a11d25
7
+ data.tar.gz: 9a210c1b605c2ee3c54a2c30b3c0df378c02ed40677a36e1139b90a05ffbcaf6cd2301d4f10eeb754af2a4ea43ae333546f0d584990de9a26fc1f4c22d70aa5a
@@ -1,3 +1,6 @@
1
+ # 0.8.0 / 2013-12-16
2
+ * [FEATURE] Add substitute values
3
+
1
4
  # 0.7.0 / 2013-12-16
2
5
  * [FEATURE] Use Payload for POST
3
6
 
data/README.md CHANGED
@@ -26,6 +26,8 @@ Loquor.config do |config|
26
26
  config.access_id = "Username"
27
27
  config.secret_key = "SecretKey1929292"
28
28
  config.endpoint = "http://www.meducation.net"
29
+ config.substitute_values[true] = ":__true__"
30
+ config.substitute_values[false] = ":__false__"
29
31
  end
30
32
  ```
31
33
 
@@ -52,6 +52,16 @@ module Loquor
52
52
  def generate_url
53
53
  query_string = []
54
54
  @criteria.each do |key,value|
55
+ add_criteria(query_string, key, value)
56
+ end
57
+ "#{klass.path}?#{query_string.join("&")}"
58
+ end
59
+
60
+ def add_criteria(query_string, key, value)
61
+ substitute_value = Loquor.config.substitute_values[value]
62
+ if !substitute_value.nil?
63
+ query_string << "#{key}=#{URI.encode(substitute_value)}"
64
+ else
55
65
  case value
56
66
  when String, Symbol, Numeric
57
67
  query_string << "#{key}=#{URI.encode(value.to_s)}"
@@ -63,7 +73,6 @@ module Loquor
63
73
  raise LoquorError.new("Filter values must be strings or arrays.")
64
74
  end
65
75
  end
66
- "#{klass.path}?#{query_string.join("&")}"
67
76
  end
68
77
  end
69
78
  end
@@ -7,7 +7,7 @@ module Loquor
7
7
  class Configuration
8
8
 
9
9
  SETTINGS = [
10
- :logger, :access_id, :secret_key, :endpoint
10
+ :logger, :access_id, :secret_key, :endpoint, :substitute_values
11
11
  ]
12
12
 
13
13
  attr_writer *SETTINGS
@@ -17,7 +17,8 @@ module Loquor
17
17
  Filum.config do |config|
18
18
  config.logfile = "./log/loquor.log"
19
19
  end
20
- logger = Filum.logger
20
+ self.logger = Filum.logger
21
+ self.substitute_values = {}
21
22
  end
22
23
 
23
24
  SETTINGS.each do |setting|
@@ -1,3 +1,3 @@
1
1
  module Loquor
2
- VERSION = "0.7.0"
2
+ VERSION = "0.8.0"
3
3
  end
@@ -74,6 +74,15 @@ module Loquor
74
74
  assert url.include?("thing[]=bar")
75
75
  end
76
76
 
77
+ def test_uses_correct_replacement_strings_in_query
78
+ Loquor.config.substitute_values[true] = ":__true__"
79
+ criteria = {thing: true}
80
+ searcher = ApiCall::Index.new(resource).where(criteria)
81
+ searcher.stubs(path: "foobar")
82
+ url = searcher.send(:generate_url)
83
+ assert url.include?("thing=:__true__")
84
+ end
85
+
77
86
  def test_that_iterating_calls_results
78
87
  searcher = ApiCall::Index.new(resource).where(name: "star_wars")
79
88
  searcher.expects(results: [])
@@ -37,6 +37,17 @@ module Loquor
37
37
  assert_equal endpoint, Loquor.config.endpoint
38
38
  end
39
39
 
40
+ def test_substitute_values
41
+ substitute_values = {foo: 'bar'}
42
+ Loquor.config.substitute_values = substitute_values
43
+ assert_equal substitute_values, Loquor.config.substitute_values
44
+ end
45
+
46
+ def test_substitute_values_writable
47
+ Loquor.config.substitute_values[:foo] = "bar"
48
+ assert_equal "bar", Loquor.config.substitute_values[:foo]
49
+ end
50
+
40
51
  def test_missing_access_id_throws_exception
41
52
  assert_raises(LoquorConfigurationError) do
42
53
  Loquor.config.access_id
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loquor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Walker