trades 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/trades +3 -2
  2. data/lib/trades/options.rb +12 -6
  3. metadata +10 -9
data/bin/trades CHANGED
@@ -13,7 +13,7 @@ begin
13
13
  # Connect to Bitcoincharts.com
14
14
  puts "Connecting to bitcoincharts.com..."
15
15
  if socket = TCPSocket.open("bitcoincharts.com", 27007)
16
- puts "Connected.\n".green
16
+ puts options.color ? "Connected.".green : "Connected.\n"
17
17
  puts "Market | Time | Currency | Price | Volume"
18
18
 
19
19
  options.logger.info "Trades has been started.\n" if options.log
@@ -28,12 +28,13 @@ begin
28
28
  if options.filter == :markets && options.markets.length > 0
29
29
  next unless options.markets.include? trade.market
30
30
  end
31
+
31
32
  if options.filter == :currencies && options.currencies.length > 0
32
33
  next unless options.currencies.include? trade.currency
33
34
  end
34
35
 
35
36
  # Compare price of this trade with last trade
36
- if last_price.key? trade.market
37
+ if options.color && last_price.key?(trade.market)
37
38
  color = 'green' if trade.price > last_price[trade.market]
38
39
  color = 'red' if trade.price < last_price[trade.market]
39
40
  end
@@ -44,6 +44,7 @@ class TradeOptions
44
44
  options.filter = :markets
45
45
  options.markets = []
46
46
  options.currencies = []
47
+ options.color = true
47
48
 
48
49
  opts = OptionParser.new do |opts|
49
50
  opts.banner = "Usage: trades [options]\n\n"
@@ -70,12 +71,11 @@ class TradeOptions
70
71
  options.logger = Logger.new File.new(file, 'a+')
71
72
  options.logger.formatter = proc { |s, d, p, m| "#{m}\n" }
72
73
  end
73
-
74
- # Help
75
- opts.on_tail("-h", "--help", "Show this message") do
76
- puts "#{opts}\n\nMore info: https://github.com/britishtea/Trades"
77
- exit
78
- end
74
+
75
+ # No-color
76
+ opts.on_tail("--no-color", "Plain text instead of output colorized") do
77
+ options.color = false
78
+ end
79
79
 
80
80
  # List of markets
81
81
  opts.on_tail("--markets", "Show a list of all markets") do
@@ -89,6 +89,12 @@ class TradeOptions
89
89
  puts "Currencies: #{CURRENCIES.values.uniq.join ', '}"
90
90
  exit
91
91
  end
92
+
93
+ # Help
94
+ opts.on_tail("-h", "--help", "Show this message") do
95
+ puts "#{opts}\n\nMore info: https://github.com/britishtea/Trades"
96
+ exit
97
+ end
92
98
  end
93
99
 
94
100
  opts.parse!(args)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trades
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-18 00:00:00.000000000Z
12
+ date: 2012-03-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
- requirement: &2152294840 !ruby/object:Gem::Requirement
16
+ requirement: &2152742620 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2152294840
24
+ version_requirements: *2152742620
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: colored
27
- requirement: &2152294360 !ruby/object:Gem::Requirement
27
+ requirement: &2152742140 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '1.2'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2152294360
35
+ version_requirements: *2152742140
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: json
38
- requirement: &2152293900 !ruby/object:Gem::Requirement
38
+ requirement: &2152741680 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 1.6.1
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2152293900
46
+ version_requirements: *2152741680
47
47
  description: Displays the trading data that Bitcoincharts monitors nicely
48
48
  email:
49
49
  executables:
@@ -77,9 +77,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  requirements:
78
78
  - Ruby version 1.9.2 or higher
79
79
  rubyforge_project:
80
- rubygems_version: 1.8.11
80
+ rubygems_version: 1.8.13
81
81
  signing_key:
82
82
  specification_version: 3
83
83
  summary: Bitcoin trading data on the command line
84
84
  test_files:
85
85
  - tests/trade.rb
86
+ has_rdoc: