fxpotato 0.5.5 → 0.6.0
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 +4 -4
- data/lib/fxpotato/paths.rb +13 -2
- data/lib/fxpotato/railtie.rb +0 -4
- data/lib/fxpotato/version.rb +1 -1
- data/lib/fxpotato/xml_repo.rb +3 -2
- data/lib/fxpotato.rb +4 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc257637544d6f9b0d7f487ebbd242e98dacfc3e
|
4
|
+
data.tar.gz: dfd4392a024947d1e597d8d5e751f0ab388e457f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 021fe499b989bcd4a9cd6dc7cf3cbf69eee6078769b99c9292ccdea652de4eda59f988c23eb6a8d281535cc5ec0580130d6c11c53067d802d6e265236ed4ab66
|
7
|
+
data.tar.gz: 2547544a57f5ba2d207ffd5da2bfb367d7e2b7b71a89b99ad88e418181e9d7df9038ce90cfcf00dd97c242d6cbfa629a08a87c82f1ef50360f1faefe34e8842e
|
data/lib/fxpotato/paths.rb
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
module FxPotato
|
2
|
-
DATA_DIRECTORY = File.join(File.expand_path(File.dirname(__FILE__) + "/../../"), "data")
|
3
2
|
DATA_FILE = 'rates.xml'
|
4
|
-
|
3
|
+
DEFAULT_SOURCE_URL = 'http://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml'
|
4
|
+
|
5
|
+
class Paths
|
6
|
+
def self.data_directory(in_rails = false, env = ENV)
|
7
|
+
return env["FXPOTATO_DATA_DIR"] unless env["FXPOTATO_DATA_DIR"].nil?
|
8
|
+
in_rails ? Rails.root.join("data") : File.join(File.expand_path(File.dirname(__FILE__) + "/../../"), "data")
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.data_source_url(env = ENV)
|
12
|
+
return env["FXPOTATO_DATA_SOURCE_URL"] unless env["FXPOTATO_DATA_SOURCE_URL"].nil?
|
13
|
+
DEFAULT_SOURCE_URL
|
14
|
+
end
|
15
|
+
end
|
5
16
|
end
|
data/lib/fxpotato/railtie.rb
CHANGED
data/lib/fxpotato/version.rb
CHANGED
data/lib/fxpotato/xml_repo.rb
CHANGED
@@ -8,8 +8,9 @@ module FxPotato
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def local_data
|
11
|
-
|
12
|
-
|
11
|
+
data_dir = Paths.data_directory(defined?(Rails))
|
12
|
+
FxPotato::fetch_new_rates if !File.exists? File.join(data_dir, DATA_FILE)
|
13
|
+
source_file = File.join(data_dir, DATA_FILE)
|
13
14
|
File.open(source_file)
|
14
15
|
end
|
15
16
|
|
data/lib/fxpotato.rb
CHANGED
@@ -22,9 +22,10 @@ module FxPotato
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def self.fetch_new_rates
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
data_dir = Paths.data_directory(defined?(Rails))
|
26
|
+
Dir.mkdir data_dir if !File.exists? data_dir
|
27
|
+
destination = File.join(data_dir, DATA_FILE)
|
28
|
+
RateFetcher.fetch(Paths.data_source_url, destination)
|
28
29
|
end
|
29
30
|
|
30
31
|
module_function
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fxpotato
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Liam Stupid Name Humphreys
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|