dolarblue 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dolarblue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leo Gallucci
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-20 00:00:00.000000000 Z
11
+ date: 2013-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: twitter_anonymous_client
14
+ name: configatron
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.2.0
19
+ version: 3.0.0.rc2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
- version: 1.0.2.0
26
+ version: 3.0.0.rc2
27
27
  - !ruby/object:Gem::Dependency
28
- name: time_ago_in_words
28
+ name: nokogiri
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
- version: 0.1.0
33
+ version: 1.6.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
- version: 0.1.0
40
+ version: 1.6.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
- version: '1.3'
47
+ version: 1.3.5
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
- version: '1.3'
54
+ version: 1.3.5
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
@@ -72,70 +72,80 @@ dependencies:
72
72
  requirements:
73
73
  - - ~>
74
74
  - !ruby/object:Gem::Version
75
- version: '2.13'
75
+ version: '2.14'
76
+ - - '>='
77
+ - !ruby/object:Gem::Version
78
+ version: 2.14.1
76
79
  type: :development
77
80
  prerelease: false
78
81
  version_requirements: !ruby/object:Gem::Requirement
79
82
  requirements:
80
83
  - - ~>
81
84
  - !ruby/object:Gem::Version
82
- version: '2.13'
83
- - !ruby/object:Gem::Dependency
84
- name: redcarpet
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ! '>='
85
+ version: '2.14'
86
+ - - '>='
88
87
  - !ruby/object:Gem::Version
89
- version: 2.2.2
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ! '>='
95
- - !ruby/object:Gem::Version
96
- version: 2.2.2
88
+ version: 2.14.1
97
89
  - !ruby/object:Gem::Dependency
98
- name: yard
90
+ name: vcr
99
91
  requirement: !ruby/object:Gem::Requirement
100
92
  requirements:
101
- - - ! '>='
93
+ - - ~>
94
+ - !ruby/object:Gem::Version
95
+ version: '2.8'
96
+ - - '>='
102
97
  - !ruby/object:Gem::Version
103
- version: 0.8.5.2
98
+ version: 2.8.0
104
99
  type: :development
105
100
  prerelease: false
106
101
  version_requirements: !ruby/object:Gem::Requirement
107
102
  requirements:
108
- - - ! '>='
103
+ - - ~>
104
+ - !ruby/object:Gem::Version
105
+ version: '2.8'
106
+ - - '>='
109
107
  - !ruby/object:Gem::Version
110
- version: 0.8.5.2
108
+ version: 2.8.0
111
109
  - !ruby/object:Gem::Dependency
112
- name: simplecov
110
+ name: webmock
113
111
  requirement: !ruby/object:Gem::Requirement
114
112
  requirements:
115
- - - ! '>='
113
+ - - ~>
116
114
  - !ruby/object:Gem::Version
117
- version: 0.7.1
115
+ version: '1.16'
116
+ - - '>='
117
+ - !ruby/object:Gem::Version
118
+ version: 1.16.1
118
119
  type: :development
119
120
  prerelease: false
120
121
  version_requirements: !ruby/object:Gem::Requirement
121
122
  requirements:
122
- - - ! '>='
123
+ - - ~>
123
124
  - !ruby/object:Gem::Version
124
- version: 0.7.1
125
+ version: '1.16'
126
+ - - '>='
127
+ - !ruby/object:Gem::Version
128
+ version: 1.16.1
125
129
  - !ruby/object:Gem::Dependency
126
- name: coveralls
130
+ name: rubygems-tasks
127
131
  requirement: !ruby/object:Gem::Requirement
128
132
  requirements:
129
- - - ! '>='
133
+ - - ~>
134
+ - !ruby/object:Gem::Version
135
+ version: '0.2'
136
+ - - '>='
130
137
  - !ruby/object:Gem::Version
131
- version: 0.6.2
138
+ version: 0.2.4
132
139
  type: :development
133
140
  prerelease: false
134
141
  version_requirements: !ruby/object:Gem::Requirement
135
142
  requirements:
136
- - - ! '>='
143
+ - - ~>
144
+ - !ruby/object:Gem::Version
145
+ version: '0.2'
146
+ - - '>='
137
147
  - !ruby/object:Gem::Version
138
- version: 0.6.2
148
+ version: 0.2.4
139
149
  description: Query Argentine Peso vs US$ exchange values with particular interest
140
150
  in official vs. street (blue) reference prices.
141
151
  email:
@@ -147,24 +157,31 @@ extra_rdoc_files: []
147
157
  files:
148
158
  - .gitignore
149
159
  - .rspec
160
+ - .ruby-gemset
150
161
  - .ruby-version
151
162
  - .travis.yml
152
163
  - .yardopts
153
164
  - CHANGELOG.md
154
165
  - Gemfile
166
+ - Gemfile.lock
155
167
  - LICENSE.md
156
168
  - README.md
157
169
  - Rakefile
158
170
  - bin/dolarblue
171
+ - config/xpaths.yml
159
172
  - dolarblue.gemspec
160
173
  - lib/dolarblue.rb
161
- - lib/dolarblue/class_methods.rb
174
+ - lib/dolarblue/blue.rb
175
+ - lib/dolarblue/card.rb
162
176
  - lib/dolarblue/configuration.rb
163
- - lib/dolarblue/exchange.rb
177
+ - lib/dolarblue/inflector.rb
164
178
  - lib/dolarblue/instance_methods.rb
179
+ - lib/dolarblue/official.rb
165
180
  - lib/dolarblue/version.rb
181
+ - lib/dolarblue/xchange.rb
182
+ - spec/blue_spec.rb
183
+ - spec/cassettes/.keep
166
184
  - spec/dolarblue_spec.rb
167
- - spec/exchange_spec.rb
168
185
  - spec/spec_helper.rb
169
186
  homepage: https://github.com/elgalu/dolarblue
170
187
  licenses:
@@ -176,23 +193,23 @@ require_paths:
176
193
  - lib
177
194
  required_ruby_version: !ruby/object:Gem::Requirement
178
195
  requirements:
179
- - - ! '>='
196
+ - - '>='
180
197
  - !ruby/object:Gem::Version
181
- version: 1.9.2
198
+ version: 1.9.3
182
199
  required_rubygems_version: !ruby/object:Gem::Requirement
183
200
  requirements:
184
- - - ! '>='
201
+ - - '>='
185
202
  - !ruby/object:Gem::Version
186
- version: 1.3.6
203
+ version: 1.8.25
187
204
  requirements: []
188
205
  rubyforge_project:
189
- rubygems_version: 2.0.3
206
+ rubygems_version: 2.1.11
190
207
  signing_key:
191
208
  specification_version: 4
192
209
  summary: Query Argentine Peso vs US$ exchange values with particular interest in official
193
210
  vs. street (blue) reference prices.
194
211
  test_files:
212
+ - spec/blue_spec.rb
213
+ - spec/cassettes/.keep
195
214
  - spec/dolarblue_spec.rb
196
- - spec/exchange_spec.rb
197
215
  - spec/spec_helper.rb
198
- has_rdoc:
@@ -1,11 +0,0 @@
1
- class Dolarblue
2
- module ClassMethods
3
- # Returns all the dollar exchange 'Blue' vs 'Official' values and percentiles
4
- # suitable for user printing
5
- #
6
- # @return [String] with all dollar exchange 'Blue' vs 'Official' values
7
- def get_output
8
- new.update!.output
9
- end
10
- end
11
- end
@@ -1,108 +0,0 @@
1
- require 'twitter_anonymous_client'
2
- require 'time_ago_in_words'
3
-
4
- class Dolarblue
5
-
6
- # Used to build dollar exchange value object
7
- class Exchange
8
- attr_reader :name, :source_url, :updated_at
9
-
10
- # Create a new dollar exchange value instance
11
- #
12
- # @param [String] name the name of the object
13
- # actual values are 'Blue' and 'Official'
14
- # @param [String] screen_name the twitter screen_name from which to retrieve the values
15
- # @param [Regexp] regexp the regular expressions to be used to parse the dollar values from the tweet text
16
- # @param [Float] buy_sell_factor the factor to multiply sale value in order to get buy value
17
- # difference is usually 1% so a factor of 0.99 would apply to get that
18
- #
19
- # @return [self]
20
- #
21
- # @note Using ruby 2 feature: Keyworded Arguments
22
- def initialize(name, screen_name, regexp, buy_sell_factor)
23
- fail ArgumentError, "name, screen_name, regexp and buy_sell_factor are all required" unless name && screen_name && regexp && buy_sell_factor
24
- @name = name
25
- @screen_name = screen_name
26
- @regexp = regexp
27
- @buy_sell_factor = buy_sell_factor
28
- @sell_value = nil
29
- @source_url = nil
30
- @updated_at = nil
31
- self
32
- end
33
-
34
- # Buy (lowest) dollar exchange value
35
- # usually obtained from sell value multiplied by sell factor
36
- #
37
- # @return [Float] lowest dollar exchange value
38
- def buy_value
39
- ensure_valid
40
- (@sell_value * @buy_sell_factor).round(2)
41
- end
42
-
43
- # Sell (highest) dollar exchange value
44
- # usually obtained directly from the source
45
- #
46
- # @return [Float] highest dollar exchange value
47
- def sell_value
48
- ensure_valid
49
- @sell_value.round(2)
50
- end
51
-
52
- # Returns valid state
53
- #
54
- # @return [true, false] valid boolean state
55
- def valid?
56
- @sell_value && @sell_value.kind_of?(Numeric) && @sell_value > 0
57
- end
58
-
59
- # Connect to the source and retrieve dollar exchange value
60
- #
61
- # @return [self]
62
- def update!
63
- tweet = Twitter::Client.new.last_tweet(@screen_name)
64
- fail "Couldn't obtain value out of #{tweet.text}" unless tweet.text =~ @regexp
65
- @sell_value = Float("#{$1}.#{$2}")
66
- @updated_at = tweet.created_at
67
- @source_url = tweet.status_url
68
- self
69
- end
70
-
71
- # Return the last updated time from now humanized in English words
72
- #
73
- # @return [String] humanized ago date in English
74
- def updated_ago
75
- ensure_valid
76
- @updated_at.to_time.ago_in_words
77
- end
78
-
79
- # Return a string suitable for user output about exchange values
80
- #
81
- # @return [String] output exchange values 1 line string
82
- def output_values
83
- ensure_valid
84
- dots = '.' * (15 - name.size).abs
85
- "- #{name}#{dots}: #{'%.2f' %buy_value} / #{'%.2f' %sell_value} (Updated #{updated_ago})"
86
- end
87
-
88
- # Return a string suitable for user output with the link to the sources
89
- #
90
- # @return [String] output links with sources from which the values where obtained
91
- def output_link
92
- ensure_valid
93
- dots = '.' * (15 - name.size).abs
94
- "#{name}#{dots}: #{source_url}"
95
- end
96
-
97
- private
98
-
99
- # Ensure object is valid before continuing with certain operations
100
- # like getting output strings or last updated date
101
- #
102
- # @private
103
- def ensure_valid
104
- fail "Call update! first" unless valid?
105
- end
106
- end
107
-
108
- end
@@ -1,92 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Dolarblue::Exchange do
4
- let(:screen_name) { 'DolarBlue' }
5
- let(:blue) { described_class.new('Blue', screen_name, /\$(\d+)[\.,](\d+)/, 0.99) }
6
- let(:blue_tweet) do
7
- Twitter::Tweet.new({
8
- id: '309326405148233731',
9
- text: 'Dolar Paralelo: $7,82',
10
- created_at: DateTime.parse('2013-03-06T12:35:36-03:00'),
11
- screen_name: 'DolarBlue'
12
- })
13
- end
14
- let(:official_tweet) do
15
- Twitter::Tweet.new({
16
- id: '309289043722637312',
17
- text: '#Cotizacion cierre promedio parcial 06-03-13: #Dolar: 5.06 // #Euro: 6.71 // #Real: 2.74.',
18
- created_at: DateTime.parse('2013-03-06T10:07:08-03:00'),
19
- screen_name: 'cotizacionhoyar'
20
- })
21
- end
22
-
23
- before do
24
- Twitter::Client.stub_chain(:new, :last_tweet).with(screen_name).and_return(blue_tweet)
25
- end
26
-
27
- describe '#new' do
28
- it 'fails if missing arguments' do
29
- expect { described_class.new(nil) }.to raise_error(ArgumentError)
30
- end
31
-
32
- it 'start as invalid right after creation' do
33
- blue.should_not be_valid
34
- end
35
- end
36
-
37
- describe 'validation' do
38
- it 'fails if you try to use it before is valid' do
39
- expect { blue.buy_value }.to raise_error
40
- expect { blue.sell_value }.to raise_error
41
- expect { blue.updated_ago }.to raise_error
42
- expect { blue.output_values }.to raise_error
43
- expect { blue.output_link }.to raise_error
44
- end
45
- end
46
-
47
- context 'updated' do
48
- before do
49
- blue.update!
50
- end
51
-
52
- describe '#update!' do
53
- it 'becomes valid after calling update!' do
54
- blue.should be_valid
55
- end
56
- end
57
-
58
- describe 'instance methods' do
59
- it 'has the correct name' do
60
- blue.name.should == 'Blue'
61
- end
62
-
63
- it 'has a proper buy_value' do
64
- blue.buy_value.should be > 0
65
- end
66
-
67
- it 'has a proper sell_value' do
68
- blue.sell_value.should be > 0
69
- end
70
-
71
- it 'has a proper updated_at' do
72
- blue.updated_at.should be_a(DateTime)
73
- end
74
-
75
- it 'has a proper updated_ago' do
76
- blue.updated_ago.should be_a(String)
77
- end
78
-
79
- it 'has a source url' do
80
- blue.source_url.should be_a(String)
81
- end
82
-
83
- it 'has a valid output values string' do
84
- blue.output_values.should match(/Blue.*Updated/)
85
- end
86
-
87
- it 'has a valid output link string' do
88
- blue.output_link.should match(/Blue.*http.*twitter/)
89
- end
90
- end
91
- end
92
- end