fxpotato 0.4.1 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9fafa7e4a5b4ec0fefc420f3e1ef22d74e74c4a8
4
- data.tar.gz: 01801982df8f0d735ca6cdc294cec849a4264707
3
+ metadata.gz: 77ec5cac8e5822903ba1ca50a3bc988e0434e89c
4
+ data.tar.gz: 9ffe01bde5b8508c86f1568b94244544f3b577fa
5
5
  SHA512:
6
- metadata.gz: 80a438090e96f688cd6fdd6222fc681550fb72486631ecf6a05ff8d5f97a41b2d6cb60fd0e5b65e73af968cf01995b2a08e20c3c050c0c681eb32ed4cafee1e7
7
- data.tar.gz: 48ff4b73ec974d175ad3e4e04185cd77ba290d83c4fe74cc6e8e499960da54a583673112415874f4660b3e1c155c95f99cd3e6a6ec5c10d9380ca1a7295cd16b
6
+ metadata.gz: 696cfb64d037139e2019e38601d600d5eea86c189ee1bdd792cb76722316b6930138abc9ef5634adc92b69eba88702e0d2f6312e012eeda1593e9f965c5bca5d
7
+ data.tar.gz: fb33b0acf0e464f81c53936a00868e2bf02d0717debe7a4f6fbe20d443ccd4a77fee8f59ccab546d9baccb5d8a3ebb6392c6121e06ae146980221aa606b365e4
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rake/testtask'
3
3
  require 'fxpotato'
4
+ Dir.glob('lib/tasks/*.rake').each { |r| import r }
4
5
 
5
6
  Rake::TestTask.new(:unit_test) do |t|
6
7
  t.libs << 'test'
@@ -8,11 +9,6 @@ Rake::TestTask.new(:unit_test) do |t|
8
9
  t.test_files = FileList['test/**/*_test.rb']
9
10
  end
10
11
 
11
- desc "Update crontab"
12
- task :update_crontab do
13
- sh %{ whenever --update-crontab }
14
- end
15
-
16
12
  desc "Clear crontab"
17
13
  task :clear_crontab do
18
14
  sh %{ whenever -c }
@@ -1,5 +1,5 @@
1
1
  module FxPotato
2
- DATA_DIRECTORY = File.join(File.expand_path(File.dirname(__FILE__) + "/../../"), "data")
2
+ DATA_DIRECTORY = File.join(defined?(Rails) ? Rails.root : (File.expand_path(File.dirname(__FILE__)) + "/../../"), "data")
3
3
  DATA_FILE = 'rates.xml'
4
4
  DATA_SOURCE_URL = 'http://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml'
5
5
  end
@@ -0,0 +1,7 @@
1
+ class FxPotato::Railtie < Rails::Railtie
2
+ rake_tasks do
3
+ load 'tasks/fetch_new_rates.rake'
4
+ load 'tasks/update_crontab.rake'
5
+ load 'tasks/clear_crontab.rake'
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module FxPotato
2
- VERSION = '0.4.1'
2
+ VERSION = '0.5.0'
3
3
  end
data/lib/fxpotato.rb CHANGED
@@ -4,6 +4,7 @@ require 'fxpotato/xml_repo'
4
4
  require 'fxpotato/rate_store'
5
5
  require 'fxpotato/rate_fetcher'
6
6
  require 'fxpotato/rate_calculator'
7
+ require "fxpotato/railtie" if defined?(Rails)
7
8
 
8
9
  module FxPotato
9
10
  def self.at(date, from_currency, to_currency)
@@ -0,0 +1,6 @@
1
+ namespace :fxpotato do
2
+ desc "Clear crontab"
3
+ task :clear_crontab do
4
+ sh %{ whenever -c }
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ namespace :fxpotato do
2
+ desc "Download new exchange rate data"
3
+ task :fetch_new_rates do
4
+ FxPotato.fetch_new_rates
5
+ end
6
+ end
@@ -0,0 +1,11 @@
1
+ namespace :fxpotato do
2
+ desc "Update crontab with fetch_new_rates job"
3
+ task :update_crontab do
4
+ if defined?(Rails)
5
+ source = File.join(Gem.loaded_specs["fxpotato"].full_gem_path, "config", "schedule.rb")
6
+ target = File.join(Rails.root, "config", "schedule.rb")
7
+ FileUtils.cp_r source, target
8
+ end
9
+ sh %{ whenever --update-crontab }
10
+ end
11
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fxpotato
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Liam Stupid Name Humphreys
@@ -161,11 +161,15 @@ files:
161
161
  - lib/fxpotato.rb
162
162
  - lib/fxpotato/cli.rb
163
163
  - lib/fxpotato/paths.rb
164
+ - lib/fxpotato/railtie.rb
164
165
  - lib/fxpotato/rate_calculator.rb
165
166
  - lib/fxpotato/rate_fetcher.rb
166
167
  - lib/fxpotato/rate_store.rb
167
168
  - lib/fxpotato/version.rb
168
169
  - lib/fxpotato/xml_repo.rb
170
+ - lib/tasks/clear_crontab.rake
171
+ - lib/tasks/fetch_new_rates.rake
172
+ - lib/tasks/update_crontab.rake
169
173
  - shippable.yml
170
174
  homepage: https://github.com/Angry-Potato/fxpotato
171
175
  licenses: