dolarblue 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -2
- data/.rspec +1 -1
- data/.ruby-gemset +2 -0
- data/.ruby-version +1 -1
- data/.travis.yml +9 -4
- data/CHANGELOG.md +9 -4
- data/Gemfile +20 -0
- data/Gemfile.lock +110 -0
- data/README.md +12 -11
- data/Rakefile +3 -2
- data/config/xpaths.yml +17 -0
- data/dolarblue.gemspec +20 -16
- data/lib/dolarblue.rb +9 -4
- data/lib/dolarblue/blue.rb +7 -0
- data/lib/dolarblue/card.rb +20 -0
- data/lib/dolarblue/configuration.rb +17 -48
- data/lib/dolarblue/inflector.rb +23 -0
- data/lib/dolarblue/instance_methods.rb +88 -80
- data/lib/dolarblue/official.rb +7 -0
- data/lib/dolarblue/version.rb +1 -1
- data/lib/dolarblue/xchange.rb +86 -0
- data/spec/blue_spec.rb +5 -0
- data/spec/cassettes/.keep +0 -0
- data/spec/dolarblue_spec.rb +17 -87
- data/spec/spec_helper.rb +21 -11
- metadata +75 -58
- data/lib/dolarblue/class_methods.rb +0 -11
- data/lib/dolarblue/exchange.rb +0 -108
- data/spec/exchange_spec.rb +0 -92
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1cbb622c30b3231b15718679c1a52cb01a218ef2
|
4
|
+
data.tar.gz: 3a53a71be05412121055ea332c969c71129e5b20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5857781bc52a75bf4bb5f087a5c609e28cb5c8fe2d1d0f78c998f0ce8e5f57ecc13ec629022c4e181ef76f60ba0c1411232f3c640dec85c61370bef077ac234
|
7
|
+
data.tar.gz: 384d51da5d47da674b16f0c8f66d13346a3d5457f5affbc81d44697991befccbeb5fda1bd05d54ff47085fd8b15fa64776ea0d3439e36c184310ae00b42703bf
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
data/.ruby-gemset
ADDED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,13 +1,18 @@
|
|
1
|
-
## [In git](https://github.com/elgalu/dolarblue/compare/v0.
|
1
|
+
## [In git](https://github.com/elgalu/dolarblue/compare/v0.4.0...HEAD)
|
2
2
|
|
3
|
-
### New Features
|
4
3
|
* n/a
|
5
4
|
|
5
|
+
## [v0.4.0](https://github.com/elgalu/dolarblue/tree/v0.4.0)
|
6
|
+
|
7
|
+
### New Features
|
8
|
+
* Changed information source from twitter to ambito.com. (Leo Gallucci)
|
9
|
+
|
6
10
|
### Bug Fixes
|
7
|
-
*
|
11
|
+
* Twitter anonymous access was discontinued so to avoid the user having to install their API token i moved to web-scraping. (Leo Gallucci)
|
8
12
|
|
9
13
|
### Chores
|
10
|
-
*
|
14
|
+
* Complete refactor of the app. (Leo Gallucci)
|
15
|
+
* Updated RSpec to use new syntax `expect` and remove `should` [expectation syntax](http://goo.gl/BGxqP). (Leo Gallucci)
|
11
16
|
|
12
17
|
## [v0.3.0](https://github.com/elgalu/dolarblue/tree/v0.3.0)
|
13
18
|
|
data/Gemfile
CHANGED
@@ -2,3 +2,23 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in dolarblue.gemspec
|
4
4
|
gemspec
|
5
|
+
|
6
|
+
group :development do
|
7
|
+
gem 'pry' # core replacement for irb
|
8
|
+
gem 'pry-doc' # gives MRI core documentation and source code
|
9
|
+
end
|
10
|
+
|
11
|
+
unless %w(jruby rbx).include? RUBY_ENGINE
|
12
|
+
group :test do
|
13
|
+
# Coverage reports only for MRI
|
14
|
+
gem 'simplecov', '>= 0.8.2'
|
15
|
+
gem 'coveralls', '>= 0.7.0'
|
16
|
+
end
|
17
|
+
|
18
|
+
group :development do
|
19
|
+
gem 'redcarpet', '>= 3' # redcarpet doesn't currently works with jruby nor rbx. kramdown is a possible alternative
|
20
|
+
gem 'yard', '>= 0.8.7.3' # no need to generate yard docs from jruby nor rbx
|
21
|
+
gem 'pry-stack_explorer' # adds command `show-stack`
|
22
|
+
gem 'pry-debugger' # adds commands `continue, step, next, finish`
|
23
|
+
end
|
24
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
dolarblue (0.4.0)
|
5
|
+
configatron (>= 3.0.0.rc2)
|
6
|
+
nokogiri (>= 1.6.1)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.3.5)
|
12
|
+
binding_of_caller (0.7.2)
|
13
|
+
debug_inspector (>= 0.0.1)
|
14
|
+
coderay (1.1.0)
|
15
|
+
columnize (0.3.6)
|
16
|
+
configatron (3.0.0.rc2)
|
17
|
+
coveralls (0.7.0)
|
18
|
+
multi_json (~> 1.3)
|
19
|
+
rest-client
|
20
|
+
simplecov (>= 0.7)
|
21
|
+
term-ansicolor
|
22
|
+
thor
|
23
|
+
crack (0.4.1)
|
24
|
+
safe_yaml (~> 0.9.0)
|
25
|
+
debug_inspector (0.0.2)
|
26
|
+
debugger (1.6.3)
|
27
|
+
columnize (>= 0.3.1)
|
28
|
+
debugger-linecache (~> 1.2.0)
|
29
|
+
debugger-ruby_core_source (~> 1.2.4)
|
30
|
+
debugger-linecache (1.2.0)
|
31
|
+
debugger-ruby_core_source (1.2.4)
|
32
|
+
diff-lcs (1.2.5)
|
33
|
+
docile (1.1.1)
|
34
|
+
ffi (1.9.3-java)
|
35
|
+
method_source (0.8.2)
|
36
|
+
mime-types (2.0)
|
37
|
+
mini_portile (0.5.2)
|
38
|
+
multi_json (1.8.2)
|
39
|
+
nokogiri (1.6.1)
|
40
|
+
mini_portile (~> 0.5.0)
|
41
|
+
pry (0.9.12.4)
|
42
|
+
coderay (~> 1.0)
|
43
|
+
method_source (~> 0.8)
|
44
|
+
slop (~> 3.4)
|
45
|
+
pry (0.9.12.4-java)
|
46
|
+
coderay (~> 1.0)
|
47
|
+
method_source (~> 0.8)
|
48
|
+
slop (~> 3.4)
|
49
|
+
spoon (~> 0.0)
|
50
|
+
pry-debugger (0.2.2)
|
51
|
+
debugger (~> 1.3)
|
52
|
+
pry (~> 0.9.10)
|
53
|
+
pry-doc (0.4.6)
|
54
|
+
pry (>= 0.9)
|
55
|
+
yard (>= 0.8)
|
56
|
+
pry-stack_explorer (0.4.9.1)
|
57
|
+
binding_of_caller (>= 0.7)
|
58
|
+
pry (>= 0.9.11)
|
59
|
+
rake (10.1.0)
|
60
|
+
redcarpet (3.0.0)
|
61
|
+
rest-client (1.6.7)
|
62
|
+
mime-types (>= 1.16)
|
63
|
+
rspec (2.14.1)
|
64
|
+
rspec-core (~> 2.14.0)
|
65
|
+
rspec-expectations (~> 2.14.0)
|
66
|
+
rspec-mocks (~> 2.14.0)
|
67
|
+
rspec-core (2.14.7)
|
68
|
+
rspec-expectations (2.14.4)
|
69
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
70
|
+
rspec-mocks (2.14.4)
|
71
|
+
rubygems-tasks (0.2.4)
|
72
|
+
safe_yaml (0.9.7)
|
73
|
+
simplecov (0.8.2)
|
74
|
+
docile (~> 1.1.0)
|
75
|
+
multi_json
|
76
|
+
simplecov-html (~> 0.8.0)
|
77
|
+
simplecov-html (0.8.0)
|
78
|
+
slop (3.4.7)
|
79
|
+
spoon (0.0.4)
|
80
|
+
ffi
|
81
|
+
term-ansicolor (1.2.2)
|
82
|
+
tins (~> 0.8)
|
83
|
+
thor (0.18.1)
|
84
|
+
tins (0.13.1)
|
85
|
+
vcr (2.8.0)
|
86
|
+
webmock (1.16.1)
|
87
|
+
addressable (>= 2.2.7)
|
88
|
+
crack (>= 0.3.2)
|
89
|
+
yard (0.8.7.3)
|
90
|
+
|
91
|
+
PLATFORMS
|
92
|
+
java
|
93
|
+
ruby
|
94
|
+
|
95
|
+
DEPENDENCIES
|
96
|
+
bundler (>= 1.3.5)
|
97
|
+
coveralls (>= 0.7.0)
|
98
|
+
dolarblue!
|
99
|
+
pry
|
100
|
+
pry-debugger
|
101
|
+
pry-doc
|
102
|
+
pry-stack_explorer
|
103
|
+
rake
|
104
|
+
redcarpet (>= 3)
|
105
|
+
rspec (~> 2.14, >= 2.14.1)
|
106
|
+
rubygems-tasks (~> 0.2, >= 0.2.4)
|
107
|
+
simplecov (>= 0.8.2)
|
108
|
+
vcr (~> 2.8, >= 2.8.0)
|
109
|
+
webmock (~> 1.16, >= 1.16.1)
|
110
|
+
yard (>= 0.8.7.3)
|
data/README.md
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
[![Dependency Status][DS img]][Dependency Status]
|
6
6
|
[![Code Climate][CC img]][Code Climate]
|
7
7
|
[![Coverage Status][CS img]][Coverage Status]
|
8
|
+
[![githalytics.com alpha](https://cruel-carlota.pagodabox.com/4a6a5549e2d3b59f3b59b12ab0ab70e9 "githalytics.com")](http://githalytics.com/elgalu/dolarblue)
|
8
9
|
|
9
10
|
## Description
|
10
11
|
|
@@ -26,18 +27,18 @@ Query latest values
|
|
26
27
|
|
27
28
|
Sample result:
|
28
29
|
|
29
|
-
Obtaining latest AR$ vs US$ exchange values...
|
30
|
+
Obtaining latest AR$ vs US$ exchange values...Parsing values...
|
31
|
+
Done: 2013-12-15 19:20:41 -0300
|
30
32
|
|
31
|
-
- Official
|
32
|
-
-
|
33
|
-
- Blue
|
34
|
-
- Gap "tarjeta"..: 43%
|
35
|
-
- Gap (official).: 72%
|
33
|
+
- Dollar Official....: 6.25 / 6.30
|
34
|
+
- Dollar Card........: n/a / 8.50
|
35
|
+
- Dollar Blue........: 9.55 / 9.60
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
Blue...........: https://twitter.com/DolarBlue/status/314445874556190720
|
37
|
+
- Gap card.......blue: 13%
|
38
|
+
- Gap official...blue: 52%
|
40
39
|
|
40
|
+
Information source:
|
41
|
+
http://ambito.com/economia/mercados/monedas/dolar/
|
41
42
|
|
42
43
|
## Contributing
|
43
44
|
|
@@ -57,8 +58,8 @@ Released under the MIT License. See the [LICENSE][] file for further details.
|
|
57
58
|
[RubyGems][] | [Documentation][] | [Source][] | [Bugtracker][] | [Build Status][] | [Dependency Status][] | [Code Climate][]
|
58
59
|
|
59
60
|
|
60
|
-
[bundle install]: http://gembundler.com/man/bundle-install.1.html
|
61
|
-
[Gemfile]: http://gembundler.com/
|
61
|
+
[bundle install]: http://gembundler.com/v1.3/man/bundle-install.1.html
|
62
|
+
[Gemfile]: http://gembundler.com/v1.3/gemfile.html
|
62
63
|
[LICENSE]: LICENSE.md
|
63
64
|
[Change Log]: CHANGELOG.md
|
64
65
|
|
data/Rakefile
CHANGED
data/config/xpaths.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
base_url: 'http://ambito.com/economia/mercados/monedas/dolar/'
|
2
|
+
|
3
|
+
blue:
|
4
|
+
buy:
|
5
|
+
xpath: '//*[@id="contenido"]/div[1]/div[2]/div/div/div[2]/big'
|
6
|
+
sell:
|
7
|
+
xpath: '//*[@id="contenido"]/div[1]/div[2]/div/div/div[3]/big'
|
8
|
+
|
9
|
+
official:
|
10
|
+
buy:
|
11
|
+
xpath: '//*[@id="contenido"]/div[1]/div[1]/div/div/div[2]/big'
|
12
|
+
sell:
|
13
|
+
xpath: '//*[@id="contenido"]/div[1]/div[1]/div/div/div[3]/big'
|
14
|
+
|
15
|
+
card:
|
16
|
+
sell:
|
17
|
+
xpath: '//*[@id="contenido"]/div[4]/div/div/div[2]/big'
|
data/dolarblue.gemspec
CHANGED
@@ -5,34 +5,38 @@ require 'dolarblue/version'
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
|
7
7
|
spec.platform = Gem::Platform::RUBY
|
8
|
-
spec.name =
|
8
|
+
spec.name = 'dolarblue'
|
9
9
|
spec.version = Dolarblue::VERSION
|
10
10
|
spec.summary = %q{Query Argentine Peso vs US$ exchange values with particular interest in official vs. street (blue) reference prices.}
|
11
11
|
spec.description = spec.summary
|
12
12
|
|
13
|
-
spec.required_ruby_version = '>= 1.9.
|
14
|
-
spec.required_rubygems_version = '>= 1.
|
13
|
+
spec.required_ruby_version = '>= 1.9.3'
|
14
|
+
spec.required_rubygems_version = '>= 1.8.25'
|
15
15
|
|
16
16
|
spec.license = 'MIT'
|
17
17
|
|
18
|
-
spec.authors = [
|
19
|
-
spec.email = [
|
20
|
-
spec.homepage =
|
18
|
+
spec.authors = ['Leo Gallucci']
|
19
|
+
spec.email = ['elgalu3@gmail.com']
|
20
|
+
spec.homepage = 'https://github.com/elgalu/dolarblue'
|
21
21
|
|
22
|
-
spec.require_paths = [
|
22
|
+
spec.require_paths = ['lib']
|
23
23
|
spec.files = `git ls-files`.split($/)
|
24
24
|
spec.executables = spec.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
25
25
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
26
26
|
|
27
|
-
spec.add_runtime_dependency
|
28
|
-
spec.add_runtime_dependency
|
27
|
+
spec.add_runtime_dependency 'configatron', '>= 3.0.0.rc2'
|
28
|
+
spec.add_runtime_dependency 'nokogiri', '>= 1.6.1'
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
spec.add_development_dependency
|
36
|
-
spec.add_development_dependency '
|
30
|
+
if RUBY_ENGINE == 'rbx'
|
31
|
+
spec.add_runtime_dependency 'rubysl'
|
32
|
+
spec.add_runtime_dependency 'racc' # Solves https://github.com/rubinius/rubinius/issues/2632#issuecomment-26954565
|
33
|
+
end
|
34
|
+
|
35
|
+
spec.add_development_dependency 'bundler', '>= 1.3.5'
|
36
|
+
spec.add_development_dependency 'rake'
|
37
|
+
spec.add_development_dependency 'rspec', '~> 2.14', '>= 2.14.1'
|
38
|
+
spec.add_development_dependency 'vcr', '~> 2.8', '>= 2.8.0'
|
39
|
+
spec.add_development_dependency 'webmock', '~> 1.16', '>= 1.16.1'
|
40
|
+
spec.add_development_dependency 'rubygems-tasks', '~> 0.2', '>= 0.2.4'
|
37
41
|
|
38
42
|
end
|
data/lib/dolarblue.rb
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
require 'dolarblue/version'
|
2
2
|
require 'dolarblue/configuration'
|
3
|
-
require 'dolarblue/class_methods'
|
4
3
|
require 'dolarblue/instance_methods'
|
5
|
-
require 'dolarblue/exchange'
|
6
4
|
|
7
5
|
# Main class used as builder and also as Dolarblue namespace
|
8
6
|
class Dolarblue
|
9
|
-
|
10
|
-
|
7
|
+
class << self
|
8
|
+
# Returns all the dollar exchange 'Blue' vs 'Official' values and percentiles
|
9
|
+
# suitable for user printing
|
10
|
+
#
|
11
|
+
# @return [String] with all dollar exchange 'Blue' vs 'Official' values
|
12
|
+
def get_output
|
13
|
+
new.update!.output
|
14
|
+
end
|
15
|
+
end
|
11
16
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'dolarblue/xchange'
|
2
|
+
|
3
|
+
class Dolarblue
|
4
|
+
# Class used to hold sell/buy values functionality for dollar "Official"
|
5
|
+
class Card < XChange
|
6
|
+
# Override extract_values since dollar "tarjeta" only has a sell value
|
7
|
+
#
|
8
|
+
# @param doc [Nokogiri::HTML] the html document to extract values from
|
9
|
+
def extract_values(doc)
|
10
|
+
@sell = extract_val(doc, 'sell')
|
11
|
+
end
|
12
|
+
|
13
|
+
# Override buy_output since dollar "tarjeta" only has a sell value
|
14
|
+
#
|
15
|
+
# @return [String] formatted output buy exchange value, in this case n/a for not available
|
16
|
+
def buy_output
|
17
|
+
'n/a'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
require '
|
1
|
+
require 'configatron/core' # gem 'configatron'
|
2
|
+
require 'singleton' # stdlib
|
3
|
+
require 'yaml' # stdlib
|
2
4
|
|
3
5
|
class Dolarblue
|
4
6
|
|
@@ -6,57 +8,24 @@ class Dolarblue
|
|
6
8
|
class Configuration
|
7
9
|
include Singleton
|
8
10
|
|
9
|
-
#
|
10
|
-
# Usually 1.5%
|
11
|
+
# Give memoized defaults for locked configuration options found in /config/xpaths.yml file
|
11
12
|
#
|
12
|
-
# @
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
# Default gap factor between the blue sale value vs. the buy value
|
18
|
-
# Usually 4.5%
|
19
|
-
#
|
20
|
-
# @return [Float] the percentile between 0..1
|
21
|
-
def buy_sell_blue_factor
|
22
|
-
Float(0.965)
|
23
|
-
end
|
24
|
-
|
25
|
-
# Twitter screen name for the `blue` dollar value
|
13
|
+
# @example Usage
|
14
|
+
# conf = Configuration.instance.defaults
|
15
|
+
# conf.base_url #=> "http://ambito.com/economia/mercados/monedas/dolar/"
|
16
|
+
# conf.blue.buy.xpath #=> "//*[@id=\"contenido\"]/div[1]/div[2]/div/div/div[2]/big"
|
26
17
|
#
|
27
|
-
# @return [
|
28
|
-
def
|
29
|
-
|
30
|
-
end
|
18
|
+
# @return [Configatron::Store] the magic configuration instance with hash and dot '.' indifferent access
|
19
|
+
def defaults
|
20
|
+
return @config if @config
|
31
21
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
# @return [Regexp] the regular expression to be used to match the Tweet text for `blue` value
|
36
|
-
def blue_regexp
|
37
|
-
/\$(\d+)[\.,](\d+)/
|
38
|
-
end
|
22
|
+
@config = Configatron::Store.new
|
23
|
+
file_path = File.expand_path('../../../config/xpaths.yml', __FILE__)
|
24
|
+
hash_config = YAML::load_file(file_path)
|
39
25
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
def official_screen_name
|
44
|
-
'cotizacionhoyar'
|
45
|
-
end
|
46
|
-
|
47
|
-
# Regular expression to be used to match the Tweet text for official value
|
48
|
-
# In order to extract the integer value from $1 and the decimal value from $2
|
49
|
-
#
|
50
|
-
# @return [Regexp] the regular expression to be used to match the Tweet text for official value
|
51
|
-
def official_regexp
|
52
|
-
/[Dd]olar: (\d+)[\.,](\d+)/
|
53
|
-
end
|
54
|
-
|
55
|
-
# Dollar "tarjeta" AR fee on top of official value
|
56
|
-
#
|
57
|
-
# @return [Float] the dollar "tarjeta" AR fee to be applied, e.g. 1.2 for an extra 20% charge
|
58
|
-
def card_fee
|
59
|
-
1.2
|
26
|
+
@config.configure_from_hash(hash_config)
|
27
|
+
@config.lock!
|
28
|
+
@config
|
60
29
|
end
|
61
30
|
end
|
62
31
|
|