Skip to content

Commit

Permalink
Fixed erroneous writing of json files in spec/data
Browse files Browse the repository at this point in the history
  • Loading branch information
ngiger committed Apr 5, 2017
1 parent 5d212d0 commit a92141d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/rapflag/poloniex.rb
Expand Up @@ -272,12 +272,13 @@ def check_config
private
def load_or_save_json(name, param = nil)
json_file = File.join(@spec_data, name.to_s + '.json')
if File.exist?(json_file) && defined?(RSpec)
body = nil
if File.directory?(@spec_data) && File.exist?(json_file) && defined?(RSpec)
body = IO.read(json_file)
else
cmd = param ? "::Poloniex.#{name.to_s}('#{param}').body" : "::Poloniex.#{name.to_s}.body"
body = eval(cmd)
File.open(json_file, 'w+') { |f| f.write(body)}
File.open(json_file, 'w+') { |f| f.write(body)} if defined?(RSpec)
end
eval("@#{name} = JSON.parse(body)")
end
Expand All @@ -289,6 +290,7 @@ def load_history_info
puts "Error was #{error.inspect}"
puts "Calling @balances from poloniex failed. Configuration was"
pp ::Poloniex.configuration
puts "Backtrace #{error.backtrace.join("\n")}"
exit 1
end
@active_loans = load_or_save_json(:active_loans)
Expand Down
2 changes: 1 addition & 1 deletion lib/rapflag/version.rb
@@ -1,4 +1,4 @@
module RAPFLAG
Wallets = ['trading', 'exchange', 'deposit']
VERSION='0.0.3'
VERSION='0.0.4'
end

0 comments on commit a92141d

Please sign in to comment.