fxpotato 0.5.5 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3cb19ff5a22db69cb6d60bd12959b3d8a72f67df
4
- data.tar.gz: 76310c9c2b689e48e7b59bc46b3e60c01edc1bd9
3
+ metadata.gz: fc257637544d6f9b0d7f487ebbd242e98dacfc3e
4
+ data.tar.gz: dfd4392a024947d1e597d8d5e751f0ab388e457f
5
5
  SHA512:
6
- metadata.gz: 133dbc6c1d3a9c30047b63701520c3370e5d6a202bbd530df37cdc92461b344b3e179b22dc800d2d92cdd052d0884e81939c3919235aec36ff72906076d1cfba
7
- data.tar.gz: 773522d731f22928f34403eab8ac260801ebb3b1bc282fb8b8fcad7bcc80afafc88e4aee3530f7596ec6601a467b70d702a0df09480093e7b1939b098d70d894
6
+ metadata.gz: 021fe499b989bcd4a9cd6dc7cf3cbf69eee6078769b99c9292ccdea652de4eda59f988c23eb6a8d281535cc5ec0580130d6c11c53067d802d6e265236ed4ab66
7
+ data.tar.gz: 2547544a57f5ba2d207ffd5da2bfb367d7e2b7b71a89b99ad88e418181e9d7df9038ce90cfcf00dd97c242d6cbfa629a08a87c82f1ef50360f1faefe34e8842e
@@ -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
- DATA_SOURCE_URL = 'http://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml'
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
@@ -5,9 +5,5 @@ module FxPotato
5
5
  load 'tasks/update_crontab.rake'
6
6
  load 'tasks/clear_crontab.rake'
7
7
  end
8
-
9
- config.after_initialize do
10
- FxPotato::DATA_DIRECTORY = File.join(Rails.root, "data")
11
- end
12
8
  end
13
9
  end
@@ -1,3 +1,3 @@
1
1
  module FxPotato
2
- VERSION = '0.5.5'
2
+ VERSION = '0.6.0'
3
3
  end
@@ -8,8 +8,9 @@ module FxPotato
8
8
  end
9
9
 
10
10
  def local_data
11
- FxPotato::fetch_new_rates if !File.exists? File.join(DATA_DIRECTORY, DATA_FILE)
12
- source_file = File.join(DATA_DIRECTORY, DATA_FILE)
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
- Dir.mkdir DATA_DIRECTORY if !File.exists? DATA_DIRECTORY
26
- destination = File.join(DATA_DIRECTORY, DATA_FILE)
27
- RateFetcher.fetch(DATA_SOURCE_URL, destination)
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.5.5
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-03 00:00:00.000000000 Z
11
+ date: 2017-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler