This repository has been archived by the owner on Jun 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 240
/
Rakefile
72 lines (54 loc) · 2.3 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
require "bundler/gem_tasks"
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)
task :default => :spec
task :console do
require 'pry'
require 'cryptoexchange'
def reload!
files = $LOADED_FEATURES.select { |feat| feat =~ /\/cryptoexchange\// }
files.each { |file| load file }
end
ARGV.clear
Pry.start
end
task :add_exchange do
require "cryptoexchange/exchange_template"
identifier = ARGV.last
if ARGV.count == 2
template = Cryptoexchange::ExchangeTemplate.new(identifier)
FileUtils.mkdir "lib/cryptoexchange/exchanges/#{identifier}/"
FileUtils.mkdir "lib/cryptoexchange/exchanges/#{identifier}/services/"
FileUtils.mkdir "spec/exchanges/#{identifier}/"
FileUtils.mkdir "spec/exchanges/#{identifier}/integration/"
File.open("lib/cryptoexchange/exchanges/#{identifier}/market.rb", "w+") { |file| file.write(template.market) }
File.open("lib/cryptoexchange/exchanges/#{identifier}/services/pairs.rb", "w+") { |file| file.write(template.pairs) }
File.open("lib/cryptoexchange/exchanges/#{identifier}/services/market.rb", "w+") { |file| file.write(template.tickers) }
File.open("lib/cryptoexchange/exchanges/#{identifier}/services/order_book.rb", "w+") { |file| file.write(template.order_book) }
File.open("lib/cryptoexchange/exchanges/#{identifier}/services/trades.rb", "w+") { |file| file.write(template.trades) }
File.open("spec/exchanges/#{identifier}/market_spec.rb", "w+") { |file| file.write(template.market_spec) }
File.open("spec/exchanges/#{identifier}/integration/market_spec.rb", "w+") { |file| file.write(template.integration_spec) }
task puts "#{identifier} create successfully"
else
task puts "Please insert correct exchange name"
end
task identifier.to_sym do ; end
end
task :reset_cassette do
require 'pry'
puts ARGV
exchange_name = ARGV.last
if exchange_name.nil?
puts "no exchange name given."
next
end
exchange_name = exchange_name.capitalize
cassette_types = ["pairs", "ticker", "order_book", "trade"]
cassette_paths = cassette_types.map do |cassette_type|
"spec/cassettes/vcr_cassettes/#{exchange_name}/integration_specs_fetch_#{cassette_type}.yml"
end
cassette_paths.each do |path|
File.delete(path) if File.exist?(path)
puts "#{path} deleted for #{exchange_name}"
end
end