stockboy 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/lib/stockboy/providers/soap.rb +2 -0
  4. data/lib/stockboy/version.rb +1 -1
  5. data/spec/stockboy/attribute_map_spec.rb +10 -10
  6. data/spec/stockboy/attribute_spec.rb +7 -7
  7. data/spec/stockboy/candidate_record_spec.rb +18 -18
  8. data/spec/stockboy/configuration_spec.rb +4 -4
  9. data/spec/stockboy/configurator_spec.rb +24 -24
  10. data/spec/stockboy/filter_chain_spec.rb +4 -4
  11. data/spec/stockboy/filter_spec.rb +4 -4
  12. data/spec/stockboy/filters/missing_email_spec.rb +4 -4
  13. data/spec/stockboy/filters_spec.rb +4 -4
  14. data/spec/stockboy/job_spec.rb +24 -24
  15. data/spec/stockboy/mapped_record_spec.rb +5 -4
  16. data/spec/stockboy/provider_repeater_spec.rb +2 -2
  17. data/spec/stockboy/provider_spec.rb +3 -3
  18. data/spec/stockboy/providers/file_spec.rb +20 -20
  19. data/spec/stockboy/providers/ftp_spec.rb +20 -20
  20. data/spec/stockboy/providers/http_spec.rb +28 -28
  21. data/spec/stockboy/providers/imap/search_options_spec.rb +11 -11
  22. data/spec/stockboy/providers/imap_spec.rb +23 -23
  23. data/spec/stockboy/providers/soap_spec.rb +17 -17
  24. data/spec/stockboy/providers_spec.rb +4 -4
  25. data/spec/stockboy/readers/csv_spec.rb +13 -9
  26. data/spec/stockboy/readers/fixed_width_spec.rb +6 -6
  27. data/spec/stockboy/readers/json_spec.rb +1 -1
  28. data/spec/stockboy/readers/spreadsheet_spec.rb +15 -15
  29. data/spec/stockboy/readers/xml_spec.rb +12 -12
  30. data/spec/stockboy/readers_spec.rb +3 -3
  31. data/spec/stockboy/source_record_spec.rb +2 -2
  32. data/spec/stockboy/template_file_spec.rb +3 -3
  33. data/spec/stockboy/translations/boolean_spec.rb +1 -1
  34. data/spec/stockboy/translations/date_spec.rb +5 -5
  35. data/spec/stockboy/translations/decimal_spec.rb +3 -3
  36. data/spec/stockboy/translations/default_empty_string_spec.rb +4 -4
  37. data/spec/stockboy/translations/default_false_spec.rb +1 -1
  38. data/spec/stockboy/translations/default_nil_spec.rb +4 -4
  39. data/spec/stockboy/translations/default_true_spec.rb +1 -1
  40. data/spec/stockboy/translations/default_zero_spec.rb +4 -4
  41. data/spec/stockboy/translations/integer_spec.rb +2 -2
  42. data/spec/stockboy/translations/string_spec.rb +2 -2
  43. data/spec/stockboy/translations/time_spec.rb +3 -3
  44. data/spec/stockboy/translations/uk_date_spec.rb +5 -5
  45. data/spec/stockboy/translations/us_date_spec.rb +5 -5
  46. data/spec/stockboy/translations_spec.rb +9 -9
  47. data/spec/stockboy/translator_spec.rb +2 -2
  48. data/stockboy.gemspec +1 -1
  49. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f65df7318f49c88b008b2ee6539b4c32d5bd444
4
- data.tar.gz: ad26b53bcd6f495a5674708922ed41c6fc7a8b69
3
+ metadata.gz: b618c2bafb9061a14b04ae6d571e42a119aa2a90
4
+ data.tar.gz: 8772582062024383ea452a5f20d2e4975b7b810e
5
5
  SHA512:
6
- metadata.gz: 97195c3f0d8b9b98b00657fdd035e5b4e3d9804bad40c186103a54dd6344472723a1c9703e259ba57e030a4560f8888513efc8079d6724648c60ff7178035d2f
7
- data.tar.gz: ff23c429b975eba2c558aa376debe315f9e771e9af087aa15200335905ed5ceaff4363bed0acfd5b7c4b37caf5bfa1792a833db1bbd7dfbed3c8f78df560a660
6
+ metadata.gz: 7d55abefd7dbeb962d641ec9639823406f180da9d55196b85f6383be5e67f39fb9827f1df485d24f9aa68d80ade1364b697b497745f7c99a03b29cb66a3c9317
7
+ data.tar.gz: 23f36e47763251d1f98351b339d3121d7ea6d322fc5b64e2d6943116c38f2e48d2edab20841ac569d192ff594ef07942be02d9a784a963ec0b78427d718c8559
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.1 / 2016-03-08
4
+
5
+ * [BUGFIX] Timeouts on SOAP connections were ignored
6
+
3
7
  ## 1.1.0 / 2016-02-19
4
8
 
5
9
  * [ENHANCEMENT] Allow `:read_timeout` and `:open_timeout` on SOAP connections
@@ -165,6 +165,8 @@ module Stockboy::Providers
165
165
  #
166
166
  def client
167
167
  @client ||= Savon.client(client_options)
168
+ @client.globals.open_timeout(open_timeout) if open_timeout
169
+ @client.globals.read_timeout(read_timeout) if read_timeout
168
170
  yield @client if block_given?
169
171
  @client
170
172
  end
@@ -1,3 +1,3 @@
1
1
  module Stockboy
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
@@ -17,31 +17,31 @@ module Stockboy
17
17
 
18
18
  it "initializes from hash attribute" do
19
19
  map = AttributeMap.new(:email => row)
20
- map[:email].should == row
20
+ expect(map[:email]).to eq row
21
21
  end
22
22
  end
23
23
 
24
24
  it "sets same destination as default" do
25
- subject[:email].should == Attribute.new(:email, "email", [])
25
+ expect(subject[:email]).to eq Attribute.new(:email, "email", [])
26
26
  end
27
27
 
28
28
  it "sets source from string to string" do
29
29
  map = AttributeMap.new { updated_at from: "statusDate" }
30
- map[:updated_at].from.should == "statusDate"
30
+ expect(map[:updated_at].from).to eq "statusDate"
31
31
  end
32
32
 
33
33
  it "sets source from symbol to string" do
34
34
  map = AttributeMap.new { updated_at from: :statusDate }
35
- map[:updated_at].from.should == "statusDate"
35
+ expect(map[:updated_at].from).to eq "statusDate"
36
36
  end
37
37
 
38
38
  it "sets source from number to number" do
39
39
  map = AttributeMap.new { email from: 12 }
40
- map[:email].from.should == 12
40
+ expect(map[:email].from).to eq 12
41
41
  end
42
42
 
43
43
  it "sets callable translators" do
44
- subject[:updated_at].translators.first.call("2012-01-01").should == Date.new(2012,1,1)
44
+ expect(subject[:updated_at].translators.first.call("2012-01-01")).to eq Date.new(2012,1,1)
45
45
  end
46
46
 
47
47
  it "sets ignore conditions" do
@@ -49,7 +49,7 @@ module Stockboy
49
49
  end
50
50
 
51
51
  it "has attr accessors" do
52
- subject.email.should be_a Attribute
52
+ expect(subject.email).to be_a Attribute
53
53
  end
54
54
 
55
55
  it "raises error for undefined attrs" do
@@ -57,8 +57,8 @@ module Stockboy
57
57
  end
58
58
 
59
59
  it "is enumerable" do
60
- subject.map(&:from).should == ["email", "score", "statusDate"]
61
- subject.map(&:to).should == [:email, :score, :updated_at]
60
+ expect(subject.map(&:from)).to eq ["email", "score", "statusDate"]
61
+ expect(subject.map(&:to)).to eq [:email, :score, :updated_at]
62
62
  end
63
63
 
64
64
  describe "#insert" do
@@ -67,7 +67,7 @@ module Stockboy
67
67
  it "sets options from hash" do
68
68
  upcase = ->(r) { r.upcase }
69
69
  map.insert :test, from: "Test", as: upcase
70
- map[:test].should == Attribute.new(:test, "Test", [upcase])
70
+ expect(map[:test]).to eq Attribute.new(:test, "Test", [upcase])
71
71
  end
72
72
  end
73
73
 
@@ -5,30 +5,30 @@ module Stockboy
5
5
  describe Attribute do
6
6
  it "describes its attrs" do
7
7
  attr = Attribute.new :outfield, "infield", [:one, :two], :nil?
8
- attr.inspect.should == %{#<Stockboy::Attribute to=:outfield, from="infield", translators=[:one, :two], ignore=:nil?>}
8
+ expect(attr.inspect).to eq %{#<Stockboy::Attribute to=:outfield, from="infield", translators=[:one, :two], ignore=:nil?>}
9
9
  end
10
10
 
11
11
  describe :ignore? do
12
12
  it "is false by default" do
13
13
  attr = Attribute.new :email, "email", []
14
- attr.ignore?(double email: "").should be false
14
+ expect(attr.ignore?(double email: "")).to be false
15
15
  end
16
16
 
17
17
  it "extracts symbols from a record" do
18
18
  attr = Attribute.new :email, "email", [], :blank?
19
- attr.ignore?(double email: "").should be true
20
- attr.ignore?(double email: "@").should be false
19
+ expect(attr.ignore?(double email: "")).to be true
20
+ expect(attr.ignore?(double email: "@")).to be false
21
21
  end
22
22
 
23
23
  it "is true with a truthy value" do
24
24
  attr = Attribute.new :email, "email", [], 1
25
- attr.ignore?(double email: "").should be true
25
+ expect(attr.ignore?(double email: "")).to be true
26
26
  end
27
27
 
28
28
  it "yields records to a proc" do
29
29
  attr = Attribute.new :email, "email", [], ->(r) { not r.email.include? "@" }
30
- attr.ignore?(double email: "").should be true
31
- attr.ignore?(double email: "@").should be false
30
+ expect(attr.ignore?(double email: "")).to be true
31
+ expect(attr.ignore?(double email: "@")).to be false
32
32
  end
33
33
 
34
34
  end
@@ -23,7 +23,7 @@ module Stockboy
23
23
  it "remaps attributes" do
24
24
  map = AttributeMap.new { name from: 'full_name' }
25
25
  subject = CandidateRecord.new(hash_attrs, map).to_hash
26
- subject.should == { :name => 'Arthur Dent' }
26
+ expect(subject).to eq({ :name => 'Arthur Dent' })
27
27
  end
28
28
 
29
29
  it "converts String subclasses to clean strings" do
@@ -31,14 +31,14 @@ module Stockboy
31
31
  map = AttributeMap.new { full_name }
32
32
  hash_attrs['full_name'] = Nori::StringWithAttributes.new('Arthur')
33
33
  subject = CandidateRecord.new(hash_attrs, map).to_hash
34
- subject[:full_name].class.should == String
34
+ expect(subject[:full_name].class).to eq String
35
35
  end
36
36
 
37
37
  it "omits ignored attributes" do
38
38
  invalid_email = ->(r) { r.email.include?('example.com') }
39
39
  map = AttributeMap.new { id ; email ignore: invalid_email }
40
40
  subject = CandidateRecord.new(hash_attrs, map).to_hash
41
- subject.should == { :id => '1' }
41
+ expect(subject).to eq({ :id => '1' })
42
42
  end
43
43
  end
44
44
 
@@ -46,13 +46,13 @@ module Stockboy
46
46
  it "remaps attributes" do
47
47
  map = AttributeMap.new { name from: 'full_name' }
48
48
  subject = CandidateRecord.new(hash_attrs, map).raw_hash
49
- subject.should == { :name => 'Arthur Dent' }
49
+ expect(subject).to eq({ :name => 'Arthur Dent' })
50
50
  end
51
51
 
52
52
  it "does not translate attributes" do
53
53
  map = AttributeMap.new { birthday as: ->(r) { Date.parse(r.birthday) } }
54
54
  subject = CandidateRecord.new(hash_attrs, map).raw_hash
55
- subject.should == { :birthday => "1980-01-01" }
55
+ expect(subject).to eq({ :birthday => "1980-01-01" })
56
56
  end
57
57
  end
58
58
 
@@ -61,28 +61,28 @@ module Stockboy
61
61
 
62
62
  context "from lambda" do
63
63
  let(:map) { AttributeMap.new{ birthday as: ->(r){ Date.parse(r.birthday) } } }
64
- it { should == {birthday: Date.new(1980,1,1)} }
64
+ it { should eq({birthday: Date.new(1980,1,1)}) }
65
65
  end
66
66
 
67
67
  context "from symbol lookup" do
68
68
  before { Stockboy::Translations.register :date, ->(r){ Date.parse(r.birthday) } }
69
69
  let(:map) { AttributeMap.new{ birthday :as => :date } }
70
- it { should == {birthday: Date.new(1980,1,1)} }
70
+ it { should eq({birthday: Date.new(1980,1,1)}) }
71
71
  end
72
72
 
73
73
  context "chaining" do
74
74
  let(:map) { AttributeMap.new{ id as: [->(r){r.id.next}, ->(r){r.id.next}] } }
75
- it { should == {id: '3'} }
75
+ it { should eq({id: '3'}) }
76
76
  end
77
77
 
78
78
  context "with exception" do
79
79
  let(:map) { AttributeMap.new{ id as: [->(r){r.id.to_i}, ->(r){r.id / 0}] } }
80
- it { should == {id: nil} }
80
+ it { should eq({id: nil}) }
81
81
  end
82
82
 
83
83
  context "dynamic without an input field" do
84
84
  let(:map) { AttributeMap.new{ generated as: [->(r){ "from lambda" }] } }
85
- it { should == {generated: "from lambda"} }
85
+ it { should eq({generated: "from lambda"}) }
86
86
  end
87
87
  end
88
88
 
@@ -102,14 +102,14 @@ module Stockboy
102
102
  it "fetches raw values for raw input keys" do
103
103
  map = AttributeMap.new { name from: 'full_name' }
104
104
  subject = CandidateRecord.new(hash_attrs, map)
105
- subject.input['full_name'].should == 'Arthur Dent'
105
+ expect(subject.input['full_name']).to eq 'Arthur Dent'
106
106
  end
107
107
  end
108
108
 
109
109
  it "accesses fields by mapped name before translation" do
110
110
  map = AttributeMap.new { name from: 'full_name', as: ->(r){ r.name.upcase } }
111
111
  subject = CandidateRecord.new(hash_attrs, map)
112
- subject.input.name.should == 'Arthur Dent'
112
+ expect(subject.input.name).to eq 'Arthur Dent'
113
113
  end
114
114
  end
115
115
 
@@ -118,13 +118,13 @@ module Stockboy
118
118
  it "fetches translated values for raw input keys" do
119
119
  map = AttributeMap.new { name from: 'full_name' }
120
120
  subject = CandidateRecord.new(hash_attrs, map)
121
- subject.output.name.should == 'Arthur Dent'
121
+ expect(subject.output.name).to eq 'Arthur Dent'
122
122
  end
123
123
 
124
124
  it "returns translated values for ignored keys" do
125
125
  map = AttributeMap.new { email ignore: ->(r){ r.email.include?("example.com") } }
126
126
  subject = CandidateRecord.new(hash_attrs, map)
127
- subject.output.email.should == "adent@example.com"
127
+ expect(subject.output.email).to eq "adent@example.com"
128
128
  end
129
129
  end
130
130
  end
@@ -137,7 +137,7 @@ module Stockboy
137
137
  it "returns first matched filter key" do
138
138
  key = subject.partition(zeta: proc{ |raw| raw.name =~ /Z/ },
139
139
  alpha: proc{ |raw| raw.name =~ /A/ })
140
- key.should == :alpha
140
+ expect(key).to eq :alpha
141
141
  end
142
142
 
143
143
  it "returns a match for translated block argument" do
@@ -145,17 +145,17 @@ module Stockboy
145
145
  subject = CandidateRecord.new({'name' =>'Arthur'}, map)
146
146
 
147
147
  key = subject.partition(down: proc{ |raw,out| out.name[0] == "a" })
148
- key.should == :down
148
+ expect(key).to eq :down
149
149
  end
150
150
 
151
151
  it "returns nil when raw field is unmatched" do
152
152
  key = subject.partition({beta: proc{ |raw| raw.name =~ /B/ }})
153
- key.should be nil
153
+ expect(key).to be nil
154
154
  end
155
155
 
156
156
  it "returns nil when translated field is unmatched" do
157
157
  key = subject.partition({beta: proc{ |raw,out| out.name =~ /B/ }})
158
- key.should be nil
158
+ expect(key).to be nil
159
159
  end
160
160
  end
161
161
 
@@ -8,20 +8,20 @@ module Stockboy
8
8
 
9
9
  it "yields a config block" do
10
10
  Stockboy::Configuration.new do |c|
11
- c.should be_a Stockboy::Configuration
11
+ expect(c).to be_a Stockboy::Configuration
12
12
  end
13
13
  end
14
14
 
15
15
  it "is accessible from top namespace" do
16
- Stockboy.configuration.should be_a Stockboy::Configuration
16
+ expect(Stockboy.configuration).to be_a Stockboy::Configuration
17
17
  end
18
18
 
19
19
  specify "#template_load_paths" do
20
20
  config.template_load_paths.clear
21
21
  config.template_load_paths << "/some_path"
22
- config.template_load_paths.should == ["/some_path"]
22
+ expect(config.template_load_paths).to eq ["/some_path"]
23
23
  config.template_load_paths = ["/other_path"]
24
- config.template_load_paths.should == ["/other_path"]
24
+ expect(config.template_load_paths).to eq ["/other_path"]
25
25
  end
26
26
 
27
27
  end
@@ -28,12 +28,12 @@ module Stockboy
28
28
 
29
29
  it "registers with a symbol" do
30
30
  subject.provider :ftp
31
- subject.config[:provider].should be_a(provider_class)
31
+ expect(subject.config[:provider]).to be_a(provider_class)
32
32
  end
33
33
 
34
34
  it "registers with a class" do
35
35
  subject.provider provider_class
36
- subject.config[:provider].should be_a(provider_class)
36
+ expect(subject.config[:provider]).to be_a(provider_class)
37
37
  end
38
38
 
39
39
  it "initializes arguments" do
@@ -58,19 +58,19 @@ module Stockboy
58
58
 
59
59
  it "registers with a symbol" do
60
60
  subject.reader :csv
61
- subject.config[:reader].should be_a(reader_class)
61
+ expect(subject.config[:reader]).to be_a(reader_class)
62
62
  end
63
63
 
64
64
  it "registers with a class" do
65
65
  subject.reader reader_class
66
- subject.config[:reader].should be_a(reader_class)
66
+ expect(subject.config[:reader]).to be_a(reader_class)
67
67
  end
68
68
 
69
69
  it "initializes arguments" do
70
70
  reader_stub = double(:reader)
71
71
  expect(reader_class).to receive(:new).with(col_sep: '|').and_return(reader_stub)
72
72
  subject.reader reader_class, col_sep: '|'
73
- subject.config[:reader].should == reader_stub
73
+ expect(subject.config[:reader]).to eq reader_stub
74
74
  end
75
75
  end
76
76
 
@@ -79,28 +79,28 @@ module Stockboy
79
79
  attribute_map = double
80
80
  expect(AttributeMap).to receive(:new).and_return(attribute_map)
81
81
  subject.attributes &proc{}
82
- subject.config[:attributes].should be attribute_map
82
+ expect(subject.config[:attributes]).to be attribute_map
83
83
  end
84
84
 
85
85
  it "replaces existing attributes" do
86
86
  subject.attribute :first_name
87
87
  subject.attributes do last_name end
88
- subject.config[:attributes][:first_name].should be nil
89
- subject.config[:attributes][:last_name].should be_an Attribute
88
+ expect(subject.config[:attributes][:first_name]).to be nil
89
+ expect(subject.config[:attributes][:last_name]).to be_an Attribute
90
90
  end
91
91
  end
92
92
 
93
93
  describe "#attribute" do
94
94
  it "inserts a single attribute" do
95
95
  subject.attribute :test, from: "Test"
96
- subject.config[:attributes][:test].should == Attribute.new(:test, "Test", [])
96
+ expect(subject.config[:attributes][:test]).to eq Attribute.new(:test, "Test", [])
97
97
  end
98
98
 
99
99
  it "respects existing attributes added first" do
100
100
  subject.attributes do first_name end
101
101
  subject.attribute :last_name
102
- subject.config[:attributes][:first_name].should be_an Attribute
103
- subject.config[:attributes][:last_name].should be_an Attribute
102
+ expect(subject.config[:attributes][:first_name]).to be_an Attribute
103
+ expect(subject.config[:attributes][:last_name]).to be_an Attribute
104
104
  end
105
105
  end
106
106
 
@@ -114,7 +114,7 @@ module Stockboy
114
114
  job.process
115
115
  end
116
116
 
117
- subject.config[:triggers][:reprocess][0].should be_a Proc
117
+ expect(subject.config[:triggers][:reprocess][0]).to be_a Proc
118
118
  end
119
119
 
120
120
  end
@@ -123,14 +123,14 @@ module Stockboy
123
123
  it "initializes a callable" do
124
124
  filter_stub = double(call: true)
125
125
  subject.filter :pass, filter_stub
126
- subject.config[:filters][:pass].should == filter_stub
126
+ expect(subject.config[:filters][:pass]).to eq filter_stub
127
127
  end
128
128
 
129
129
  it "initializes a block" do
130
130
  subject.filter :pass do |r|
131
131
  true if r == 42
132
132
  end
133
- subject.config[:filters][:pass].call(42).should == true
133
+ expect(subject.config[:filters][:pass].call(42)).to eq true
134
134
  end
135
135
 
136
136
  context "with a class" do
@@ -144,22 +144,22 @@ module Stockboy
144
144
 
145
145
  it "passes arguments to a registered class symbol" do
146
146
  subject.filter :pass, :test, 42
147
- subject.config[:filters][:pass].args.should == [42]
147
+ expect(subject.config[:filters][:pass].args).to eq [42]
148
148
  end
149
149
 
150
150
  it "passes a block to a registered class symbol" do
151
151
  subject.filter :pass, :test do 42 end
152
- subject.config[:filters][:pass].block[].should == 42
152
+ expect(subject.config[:filters][:pass].block[]).to eq 42
153
153
  end
154
154
 
155
155
  it "passes arguments to a given class" do
156
156
  subject.filter :pass, TestFilter, 42
157
- subject.config[:filters][:pass].args.should == [42]
157
+ expect(subject.config[:filters][:pass].args).to eq [42]
158
158
  end
159
159
 
160
160
  it "uses an instance directly" do
161
161
  subject.filter :pass, TestFilter.new(42)
162
- subject.config[:filters][:pass].args.should == [42]
162
+ expect(subject.config[:filters][:pass].args).to eq [42]
163
163
  end
164
164
  end
165
165
 
@@ -176,10 +176,10 @@ module Stockboy
176
176
 
177
177
  it "returns a Job instance" do
178
178
  job = subject.to_job
179
- job.should be_a(Job)
180
- job.provider.should be_a(provider_class)
181
- job.reader.should be_a(reader_class)
182
- job.attributes.should be_a(AttributeMap)
179
+ expect(job).to be_a(Job)
180
+ expect(job.provider).to be_a(provider_class)
181
+ expect(job.reader).to be_a(reader_class)
182
+ expect(job.attributes).to be_a(AttributeMap)
183
183
  end
184
184
 
185
185
  context "with a repeat block" do
@@ -189,8 +189,8 @@ module Stockboy
189
189
 
190
190
  it "adds a repeater to the provider" do
191
191
  job = subject.to_job
192
- job.provider.should be_a ProviderRepeater
193
- job.provider.base_provider.should be_a provider_class
192
+ expect(job.provider).to be_a ProviderRepeater
193
+ expect(job.provider.base_provider).to be_a provider_class
194
194
  end
195
195
  end
196
196
  end