reuters 0.8.1

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.
Files changed (67) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +23 -0
  3. data/.rubocop.enabled.yml +23 -0
  4. data/.rubocop.yml +15 -0
  5. data/.ruby-gemset +1 -0
  6. data/.ruby-version +1 -0
  7. data/.travis.yml +28 -0
  8. data/CONTRIBUTING.md +37 -0
  9. data/Gemfile +4 -0
  10. data/LICENSE.txt +22 -0
  11. data/README.md +209 -0
  12. data/Rakefile +5 -0
  13. data/lib/reuters.rb +98 -0
  14. data/lib/reuters/builder.rb +117 -0
  15. data/lib/reuters/client.rb +12 -0
  16. data/lib/reuters/client/base.rb +132 -0
  17. data/lib/reuters/client/fundamentals.rb +20 -0
  18. data/lib/reuters/client/search.rb +19 -0
  19. data/lib/reuters/client/search/base.rb +26 -0
  20. data/lib/reuters/client/search/equity.rb +64 -0
  21. data/lib/reuters/client/token.rb +101 -0
  22. data/lib/reuters/credentials.rb +79 -0
  23. data/lib/reuters/namespaces.rb +25 -0
  24. data/lib/reuters/namespaces/base.rb +47 -0
  25. data/lib/reuters/namespaces/common.rb +30 -0
  26. data/lib/reuters/namespaces/fundamentals.rb +31 -0
  27. data/lib/reuters/namespaces/search.rb +48 -0
  28. data/lib/reuters/namespaces/search/equity.rb +32 -0
  29. data/lib/reuters/namespaces/token.rb +30 -0
  30. data/lib/reuters/response.rb +32 -0
  31. data/lib/reuters/version.rb +6 -0
  32. data/lib/reuters/wsdls.rb +25 -0
  33. data/lib/reuters/wsdls/base.rb +44 -0
  34. data/lib/reuters/wsdls/fundamentals.rb +21 -0
  35. data/lib/reuters/wsdls/search.rb +13 -0
  36. data/lib/reuters/wsdls/search/equity.rb +25 -0
  37. data/lib/reuters/wsdls/token.rb +22 -0
  38. data/reuters.gemspec +41 -0
  39. data/spec/fixtures/responses/token.xml +11 -0
  40. data/spec/reuters/builder_spec.rb +189 -0
  41. data/spec/reuters/client/fundamentals_spec.rb +11 -0
  42. data/spec/reuters/client/search/equity_spec.rb +46 -0
  43. data/spec/reuters/client/token_spec.rb +91 -0
  44. data/spec/reuters/client_spec.rb +0 -0
  45. data/spec/reuters/credentials_spec.rb +68 -0
  46. data/spec/reuters/namespaces/common_spec.rb +5 -0
  47. data/spec/reuters/namespaces/fundamentals_spec.rb +5 -0
  48. data/spec/reuters/namespaces/search/equity_spec.rb +5 -0
  49. data/spec/reuters/namespaces/search_spec.rb +31 -0
  50. data/spec/reuters/namespaces/token_spec.rb +5 -0
  51. data/spec/reuters/namespaces_spec.rb +31 -0
  52. data/spec/reuters/response_spec.rb +54 -0
  53. data/spec/reuters/version_spec.rb +9 -0
  54. data/spec/reuters/wsdls/fundamentals_spec.rb +5 -0
  55. data/spec/reuters/wsdls/search/equity_spec.rb +5 -0
  56. data/spec/reuters/wsdls/token_spec.rb +5 -0
  57. data/spec/reuters/wsdls_spec.rb +31 -0
  58. data/spec/reuters_spec.rb +10 -0
  59. data/spec/spec_helper.rb +17 -0
  60. data/spec/support/client/search_shared.rb +5 -0
  61. data/spec/support/client_shared.rb +70 -0
  62. data/spec/support/configurable_shared.rb +9 -0
  63. data/spec/support/namespaces_actions_shared.rb +36 -0
  64. data/spec/support/namespaces_shared.rb +42 -0
  65. data/spec/support/wsdls_actions_shared.rb +36 -0
  66. data/spec/support/wsdls_shared.rb +53 -0
  67. metadata +333 -0
File without changes
@@ -0,0 +1,68 @@
1
+ require 'spec_helper'
2
+
3
+ describe Reuters::Credentials do
4
+
5
+ it { should respond_to(:username) }
6
+ it { should respond_to(:username=) }
7
+ it { should respond_to(:password) }
8
+ it { should respond_to(:password=) }
9
+ it { should respond_to(:app_id) }
10
+ it { should respond_to(:app_id=) }
11
+
12
+ it { should respond_to(:details) }
13
+
14
+ it_behaves_like "a configurable class"
15
+
16
+ describe "when credentials are set" do
17
+
18
+ let(:test_username) { "david" }
19
+ let(:test_password) { "1234" }
20
+ let(:test_app_id) { "123" }
21
+
22
+ before do
23
+ subject.configure do |c|
24
+ c.username = test_username
25
+ c.password = test_password
26
+ c.app_id = test_app_id
27
+ end
28
+ end
29
+
30
+ it "should return the correct username" do
31
+ expect(subject.username).to eq test_username
32
+ end
33
+
34
+ it "should return the correct password" do
35
+ expect(subject.password).to eq test_password
36
+ end
37
+
38
+ it "should return the correct app_id" do
39
+ expect(subject.app_id).to eq test_app_id
40
+ end
41
+
42
+ describe "when #details is called" do
43
+
44
+ it "should yield a block once" do
45
+ expect { |b| subject.details &b }.to yield_control.once
46
+ end
47
+
48
+ it "shoud yield the correct arguments" do
49
+ expect { |b| subject.details &b }.to yield_with_args(test_username, test_password, test_app_id)
50
+ end
51
+
52
+ end
53
+
54
+ end
55
+
56
+ describe "return value of #to_h" do
57
+
58
+ it "should be a hash" do
59
+ expect(subject.to_h).to be_a(Hash)
60
+ end
61
+
62
+ it "should include credentials" do
63
+ expect(subject.to_h).to include(:username, :password, :app_id)
64
+ end
65
+
66
+ end
67
+
68
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe Reuters::Namespaces::Common do
4
+ it_behaves_like "a namespace module"
5
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe Reuters::Namespaces::Fundamentals do
4
+ it_behaves_like "a namespace module"
5
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe Reuters::Namespaces::Search::Equity do
4
+ it_behaves_like "a namespace module"
5
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe Reuters::Namespaces::Search do
4
+
5
+ it { should respond_to(:define) }
6
+
7
+ it_behaves_like "a namespace module"
8
+
9
+ describe "return value of #define" do
10
+
11
+ it "should resolve the full endpoint" do
12
+ expect(subject.define(:test)).to include Reuters.namespaces_endpoint
13
+ end
14
+
15
+ it "should camelize strings" do
16
+ expect(subject.define(:test_spec)).to include "TestSpec"
17
+ end
18
+
19
+ it "should camelize multiple strings" do
20
+ response = subject.define(:test, :hello)
21
+ expect(response).to include("Test", "Hello")
22
+ end
23
+
24
+ it "should separate multiple strings with underscores" do
25
+ response = subject.define(:test, :hello)
26
+ expect(response).to include("Test_Hello")
27
+ end
28
+
29
+ end
30
+
31
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe Reuters::Namespaces::Token do
4
+ it_behaves_like "a namespace module"
5
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe Reuters::Namespaces do
4
+
5
+ it { should respond_to(:configure) }
6
+
7
+ describe "when a namespace is defined" do
8
+
9
+ before do
10
+ module Reuters::Namespaces
11
+ module TestNamespace
12
+ include Base
13
+ end
14
+ end
15
+ end
16
+
17
+ it "should enable configuration of a namespace" do
18
+ expect { |b| subject.configure("TestNamespace", &b) }.to yield_with_args Reuters::Namespaces::TestNamespace
19
+ end
20
+
21
+ end
22
+
23
+ describe "when a namespace is not defined" do
24
+
25
+ it "should raise an error" do
26
+ expect { |b| subject.configure("FuddyWsdl", &b) }.to raise_error
27
+ end
28
+
29
+ end
30
+
31
+ end
@@ -0,0 +1,54 @@
1
+ require 'spec_helper'
2
+
3
+ describe Reuters::Response do
4
+
5
+ let(:test_hash) {
6
+ {
7
+ info: {
8
+ ticker: "ABC",
9
+ name: {
10
+ full_name: "ABC Solutions Ltd.",
11
+ short_name: "ABC Ltd."
12
+ }
13
+ },
14
+ :@type => "ORD"
15
+ }
16
+ }
17
+
18
+ before do
19
+ @response = Reuters::Response.new(test_hash)
20
+ end
21
+
22
+ subject { @response }
23
+
24
+ it { should respond_to(:attributes) }
25
+
26
+ describe "a nested response object" do
27
+
28
+ it "should return a nested response object" do
29
+ expect(@response.info).to be_an_instance_of Reuters::Response
30
+ end
31
+
32
+ it "should include a nested key" do
33
+ expect(@response.info.keys).to include :ticker
34
+ end
35
+
36
+ it "should return the correct value for #full_name" do
37
+ expect(@response.info.name.full_name).to eq "ABC Solutions Ltd."
38
+ end
39
+
40
+ end
41
+
42
+ describe "when attributes are accessed" do
43
+
44
+ it "should return a hash" do
45
+ expect(@response.attributes).to be_a Hash
46
+ end
47
+
48
+ it "should return the attribute value" do
49
+ expect(@response.attributes.type).to eq "ORD"
50
+ end
51
+
52
+ end
53
+
54
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe Reuters do
4
+
5
+ it "should have a valid version number" do
6
+ expect(Gem::Version.correct?(Reuters::VERSION)).to eq(0)
7
+ end
8
+
9
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe Reuters::Wsdls::Fundamentals do
4
+ it_behaves_like "a wsdl module"
5
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe Reuters::Wsdls::Search::Equity do
4
+ it_behaves_like "a wsdl module"
5
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe Reuters::Wsdls::Token do
4
+ it_behaves_like "a wsdl module"
5
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe Reuters::Wsdls do
4
+
5
+ it { should respond_to(:configure) }
6
+
7
+ describe "when a wsdl is defined" do
8
+
9
+ before do
10
+ module Reuters::Wsdls
11
+ module TestWsdl
12
+ include Base
13
+ end
14
+ end
15
+ end
16
+
17
+ it "should enable configuration of a wsdl" do
18
+ expect { |b| subject.configure("TestWsdl", &b) }.to yield_with_args Reuters::Wsdls::TestWsdl
19
+ end
20
+
21
+ end
22
+
23
+ describe "when a wsdl is not defined" do
24
+
25
+ it "should raise an error" do
26
+ expect { |b| subject.configure("FuddyWsdl", &b) }.to raise_error
27
+ end
28
+
29
+ end
30
+
31
+ end
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe Reuters do
4
+
5
+ it { should respond_to(:namespaces_endpoint) }
6
+ it { should respond_to(:wsdl_endpoint) }
7
+
8
+ it_behaves_like "a configurable class"
9
+
10
+ end
@@ -0,0 +1,17 @@
1
+ require "codeclimate-test-reporter"
2
+ CodeClimate::TestReporter.start
3
+
4
+ require 'coveralls'
5
+ Coveralls.wear!
6
+
7
+ require "savon/mock/spec_helper"
8
+ require 'factory_girl'
9
+ require 'reuters'
10
+
11
+ Dir["./spec/support/**/*.rb"].sort.each {|f| require f}
12
+
13
+ FactoryGirl.find_definitions
14
+
15
+ RSpec.configure do |config|
16
+ config.include FactoryGirl::Syntax::Methods
17
+ end
@@ -0,0 +1,5 @@
1
+ shared_examples "a search client class" do
2
+
3
+ it_behaves_like "a client class"
4
+
5
+ end
@@ -0,0 +1,70 @@
1
+ shared_examples "a client class" do
2
+
3
+ include Savon::SpecHelper
4
+
5
+ before(:all) { savon.mock! }
6
+ after(:all) { savon.unmock! }
7
+
8
+ it { should respond_to(:request) }
9
+ it { should respond_to(:client) }
10
+ it { should respond_to(:operations) }
11
+
12
+ it { should respond_to(:before_request) }
13
+ it { should respond_to(:after_request) }
14
+
15
+ describe "return value of #client.operations" do
16
+ it "should be an Array" do
17
+ expect(subject.client.operations).to be_a(Array)
18
+ end
19
+
20
+ it "should not be empty" do
21
+ expect(subject.client.operations).to_not be_empty
22
+ end
23
+ end
24
+
25
+ describe "when an operation is called" do
26
+
27
+ describe "when the operation does not exist" do
28
+ it "should raise a no method error" do
29
+ expect { subject.not_a_valid_op }.to raise_error(NoMethodError)
30
+ end
31
+ end
32
+
33
+ describe "when the operation exists" do
34
+
35
+ let(:test_op) { :test }
36
+ let(:message) { Reuters::Builder.new }
37
+
38
+ before do
39
+ subject.stub_chain(:client, :operations).and_return([test_op])
40
+ end
41
+
42
+ it "should attempt a request" do
43
+ subject.should_receive(:request).with(test_op, message)
44
+ subject.test(message)
45
+ end
46
+
47
+ describe "when additional request attributes are passed" do
48
+
49
+ let(:attribs) { {:a => 1, :b => true} }
50
+
51
+ it "should pass attributes to the request" do
52
+ subject.should_receive(:request).with(test_op, message, attribs)
53
+ subject.test(message, attribs)
54
+ end
55
+
56
+ end
57
+
58
+ end
59
+
60
+ end
61
+
62
+ describe "return value of #client" do
63
+
64
+ it "should be a Savon Client" do
65
+ expect(subject.client).to be_a(Savon::Client)
66
+ end
67
+
68
+ end
69
+
70
+ end
@@ -0,0 +1,9 @@
1
+ shared_examples "a configurable class" do
2
+
3
+ it { should respond_to(:configure) }
4
+
5
+ it "should be configurable" do
6
+ expect { |b| subject.configure &b }.to yield_with_args(subject)
7
+ end
8
+
9
+ end
@@ -0,0 +1,36 @@
1
+ shared_examples "a namespace with actions" do
2
+
3
+ it "should include namespace actions" do
4
+ expect(subject.constants).to include(:Actions)
5
+ end
6
+
7
+ describe "the shared Actions of a Namespace" do
8
+
9
+ before do
10
+ module subject::Actions
11
+ def self.test
12
+ @@test
13
+ end
14
+ def self.test=(val)
15
+ @@test=val
16
+ end
17
+ @@test = nil
18
+ end
19
+ end
20
+
21
+ specify { expect(subject::Actions).to respond_to(:test) }
22
+ specify { expect(subject::Actions).to respond_to(:test=) }
23
+
24
+ it "should modify the value" do
25
+ expect { subject::Actions.test = 1 }.to change { subject::Actions.test }
26
+ end
27
+
28
+ it "should include the action in the endpoint" do
29
+ test_action = "foobar"
30
+ subject::Actions.test = test_action
31
+ expect(subject.endpoint(:test)).to include(test_action)
32
+ end
33
+
34
+ end
35
+
36
+ end