Permalink
Browse files

Cleanup metric table

  • Loading branch information...
yacc committed Jun 25, 2013
1 parent c889040 commit 9847e92d6cf805f7824c5a8e0633841d3dc34f38
Showing with 24 additions and 14 deletions.
  1. +1 −1 Gemfile.lock
  2. +1 −0 lib/stripemetrics/cli/commands/report.rb
  3. +21 −12 lib/stripemetrics/client/report.rb
  4. +1 −1 stripemetrics-cli.gemspec
View
@@ -2,7 +2,7 @@ PATH
remote: .
specs:
stripemetrics-cli (0.0.1)
- command_line_reporter
+ command_line_reporter (>= 3.0)
faraday_middleware
gli (= 2.6.0rc1)
highline (= 1.6.15)
@@ -12,6 +12,7 @@
say("<%= color('Gathering data from StripeMetrics ....', :yellow) %>")
metrics = @client.get_metrics
token = @client.print metrics, options, args
+ say("<%= color('(*) TSM Average column is the Trailing Six Month Compound Growth Rate', :blue) %>")
rescue Stripemetrics::Client::AuthError
exit_now! "You need to authorize with StripeMetrics.com first!\nTry login in with this command:\nstripemetrics-cli login"
rescue Exception => e
@@ -21,26 +21,35 @@ def print(metrics, options={},args={})
def header
row do
- column('Metric', :width => 15)
- column('This month', :width => 11)
- column('Last month', :width => 11)
- column('% change', :width => 11)
- column('TSM Average', :width => 11)
- column('Goal', :width => 11)
+ column 'Metric', :width => 15, :align => 'left'
+ column 'This month', :width => 11, :align => 'right'
+ column 'Last month', :width => 11, :align => 'right'
+ column '% change', :width => 11, :align => 'right'
+ column 'TSM Average', :width => 11, :align => 'right'
+ column 'Goal', :width => 11, :align => 'right'
end
end
def display_row(metric)
row do
- column(metric['name'])
- column(metric['this_month'])
- column(metric['last_month'])
- column("#{(metric['change'].round(2)*100)}%")
- column("#{metric['tsm_avrg'].round(2)*100}%")
- column(metric['goal'])
+ column metric['name']
+ column with_unit(metric['_type'],metric['this_month'])
+ column with_unit(metric['_type'],metric['last_month'])
+ column rounded_percent(metric['change'])
+ column rounded_percent(metric['tsm_avrg'])
+ column metric['goal']
end
end
+ def rounded_percent(val)
+ '%.2f%' % (val*100)
+ end
+
+ def with_unit(type,val)
+ unit = '$' if type.downcase =~ /revenue/
+ "#{unit}#{val}"
+ end
+
end
end
end
@@ -33,6 +33,6 @@ lib/stripemetrics.rb
s.add_runtime_dependency 'netrc', '0.7.7'
s.add_runtime_dependency 'highline', '1.6.15'
s.add_runtime_dependency 'faraday_middleware'
- s.add_runtime_dependency 'command_line_reporter'
+ s.add_runtime_dependency 'command_line_reporter', '>=3.0'
end

0 comments on commit 9847e92

Please sign in to comment.