reuters 0.9.0 → 0.9.2
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 +8 -8
- data/lib/reuters/builder.rb +19 -1
- data/lib/reuters/client/search/equity.rb +8 -2
- data/lib/reuters/version.rb +1 -1
- data/spec/reuters/builder_spec.rb +39 -1
- data/spec/reuters/client/search/all_spec.rb +0 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODdhMWQ4MGJjOWY1OTQ3ZjMwOTFjYWMxZDg3ZGQzZmY0OGQ2ZWY1MA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MmY2ZTU4NTZiNmI1ODZlMDk5NmI4YmUwZmFlYzkyN2JjZmIzMzEzYw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZjA2YmM0Yjc1NWFkMmIzZDFkYTU1MTljOGFmMjVkNGYzNzUyY2JjMjBhM2M3
|
10
|
+
MThiNjIxNjk2ODcyNzAzNGFmYmQyNjIwYmEzMTg5OGZhZDM2OTZlYzUxNDI3
|
11
|
+
MTVkMTc2MmQ4YTIzYmJkNzBmNDkyODIzZDU2Y2Y1NWYzOTA0NWE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OTdlM2U4MDA5OTg2NjY4NmQyMWJhOTgzNmNiN2NmNjY4MTdhNTllMTIzNDg4
|
14
|
+
MjNkNjFkYmYxZjk5OTRjNGU2N2JhNGM4MTNlNDQwNGNlMWE2ZDIwZTVjMzgx
|
15
|
+
YjgyNWVkYmQ2NmMwMWU4ZjA2YWRlMGQ3OGU5M2ZlOWUyZDBhMTI=
|
data/lib/reuters/builder.rb
CHANGED
@@ -77,6 +77,24 @@ module Reuters
|
|
77
77
|
super || super(camelize(key))
|
78
78
|
end
|
79
79
|
|
80
|
+
# Attempts to find a key that exists within the attributes hash.
|
81
|
+
# If the key cannot be found in its current format,
|
82
|
+
# the method attempts to camelcase the key and
|
83
|
+
# search again.
|
84
|
+
#
|
85
|
+
# @return [Boolean] True if the key exists, false otherwise
|
86
|
+
def attribute_key?(key, attr_key)
|
87
|
+
attrs = attribute_keys(key)
|
88
|
+
attrs.include?(camelize(attr_key) || attrs.include?(attr_key))
|
89
|
+
end
|
90
|
+
|
91
|
+
# Returns all keys inside the attributes hash.
|
92
|
+
#
|
93
|
+
# @return [Array] All attribute keys.
|
94
|
+
def attribute_keys(key)
|
95
|
+
(self[:attributes!][camelize(key)] || {}).keys
|
96
|
+
end
|
97
|
+
|
80
98
|
private
|
81
99
|
|
82
100
|
def assign_val(key, body)
|
@@ -114,4 +132,4 @@ module Reuters
|
|
114
132
|
end
|
115
133
|
|
116
134
|
end
|
117
|
-
end
|
135
|
+
end
|
@@ -26,9 +26,15 @@ module Reuters
|
|
26
26
|
sec = req.send(section)
|
27
27
|
|
28
28
|
sec.keys.each do |key|
|
29
|
-
|
29
|
+
# injext xmlns property only if it does not already exist
|
30
|
+
unless sec.attribute_key? key, 'xmlns'
|
31
|
+
sec.attributes({ key => { 'xmlns' => query_spec } }, false)
|
32
|
+
end
|
30
33
|
sec[key].keys.each do |type|
|
31
|
-
|
34
|
+
# injext xmlns property only if it does not already exist
|
35
|
+
unless sec[key].attribute_key? type, 'xmlns'
|
36
|
+
sec[key].attributes({ type => { 'xmlns' => data_type } }, false)
|
37
|
+
end
|
32
38
|
end
|
33
39
|
end
|
34
40
|
|
data/lib/reuters/version.rb
CHANGED
@@ -26,7 +26,45 @@ describe Reuters::Builder do
|
|
26
26
|
expect(b).to include("TestMethod")
|
27
27
|
end
|
28
28
|
|
29
|
+
describe "return value of #attribute_key?" do
|
30
|
+
|
31
|
+
before do
|
32
|
+
@builder.hold_key
|
33
|
+
@builder.attributes(hold_key: { "test_build" => "Type" })
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should allow camelcase keys" do
|
37
|
+
expect(@builder.attribute_key?(:hold_key, "TestBuild")).to be_true
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should allow underscore keys" do
|
41
|
+
expect(@builder.attribute_key?(:hold_key, :test_build)).to be_true
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "return value of #attribute_keys" do
|
47
|
+
|
48
|
+
before do
|
49
|
+
@builder.hold_key
|
50
|
+
@builder.attributes(hold_key: { "test_build" => "Type" })
|
51
|
+
@builder.attributes({ hold_key: { "xml_ns" => "Type" } }, false)
|
52
|
+
end
|
53
|
+
|
54
|
+
subject { @builder.attribute_keys(:hold_key) }
|
55
|
+
|
56
|
+
it { should include "TestBuild", "xml_ns" }
|
57
|
+
|
58
|
+
it { should_not include :attributes! }
|
59
|
+
|
60
|
+
it { should_not be_empty }
|
61
|
+
|
62
|
+
specify { expect { @builder.attributes(hold_key: { "t" => "a" }) }.to change { @builder.attribute_keys(:hold_key) } }
|
63
|
+
|
64
|
+
end
|
65
|
+
|
29
66
|
describe "return value of #keys" do
|
67
|
+
|
30
68
|
before do
|
31
69
|
@builder.foo_test
|
32
70
|
@builder.bar_test
|
@@ -186,4 +224,4 @@ describe Reuters::Builder do
|
|
186
224
|
|
187
225
|
end
|
188
226
|
|
189
|
-
end
|
227
|
+
end
|