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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTY0MTNhN2U5NjI2OTFlY2Y5YjgwN2ViMGRkMzU3MDIyYTk4ZmNlMw==
4
+ ODdhMWQ4MGJjOWY1OTQ3ZjMwOTFjYWMxZDg3ZGQzZmY0OGQ2ZWY1MA==
5
5
  data.tar.gz: !binary |-
6
- ZmQzODllYzhjZDlkYTczODdiYmY2YTgyNDMzOGQ3Y2ZhMTA1MTQyMQ==
6
+ MmY2ZTU4NTZiNmI1ODZlMDk5NmI4YmUwZmFlYzkyN2JjZmIzMzEzYw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NjA5NGQ0NDViMjIzNDAyMTNiOTkwNWQ0MTg0OGU2OTE3NDZkOTgzMmU1M2Rl
10
- MGJmZjE2NTkxOWEwM2ZjOTA1MTBmZTA0NmIwZjNkZmE3MTIzODUyZmI5ZDQ5
11
- YzM3NmM4NzUxNjY4OWFlMTk1ZGU4N2UwYjY3YjFiODgzMGU0MDI=
9
+ ZjA2YmM0Yjc1NWFkMmIzZDFkYTU1MTljOGFmMjVkNGYzNzUyY2JjMjBhM2M3
10
+ MThiNjIxNjk2ODcyNzAzNGFmYmQyNjIwYmEzMTg5OGZhZDM2OTZlYzUxNDI3
11
+ MTVkMTc2MmQ4YTIzYmJkNzBmNDkyODIzZDU2Y2Y1NWYzOTA0NWE=
12
12
  data.tar.gz: !binary |-
13
- MjZiZThhNWZlNGJkNmVkODIwZjM1YmFjN2QyZWEwNDUwOTgyZmJmMzFlOTEy
14
- YjhlZWJhZjNhYzhkNmQ1MWRhYWNhZjM1MTAxNjFkODkwZmQyMGQyNzEwZDA2
15
- NDE0MzM4ZjFiM2EyZThhYzM5ZWY1NjJhY2JkNzQxNmQ2MzhkMDI=
13
+ OTdlM2U4MDA5OTg2NjY4NmQyMWJhOTgzNmNiN2NmNjY4MTdhNTllMTIzNDg4
14
+ MjNkNjFkYmYxZjk5OTRjNGU2N2JhNGM4MTNlNDQwNGNlMWE2ZDIwZTVjMzgx
15
+ YjgyNWVkYmQ2NmMwMWU4ZjA2YWRlMGQ3OGU5M2ZlOWUyZDBhMTI=
@@ -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
- sec.attributes({ key => { 'xmlns' => query_spec } }, false)
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
- sec[key].attributes({ type => { 'xmlns' => data_type } }, false)
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
 
@@ -2,5 +2,5 @@
2
2
  # Knowledge Direct API.
3
3
  module Reuters
4
4
  # Current version of the Reuters gem.
5
- VERSION = '0.9.0'
5
+ VERSION = '0.9.2'
6
6
  end
@@ -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
@@ -30,7 +30,6 @@ describe Reuters::Client::Search::All do
30
30
  describe "return value of #query_spec" do
31
31
 
32
32
  it "should be a string" do
33
- puts subject.operations.inspect
34
33
  expect(subject.query_spec).to be_a(String)
35
34
  end
36
35
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reuters
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stockflare