rg_stats 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rg_stats (1.1.0)
4
+ rg_stats (1.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/bin/rg_stats CHANGED
@@ -63,13 +63,18 @@ ARGV.each do |user_name|
63
63
  stat = Statistic.new
64
64
  stat.load data_as_json
65
65
 
66
+ total_downloads = stat.gem_infos.reduce(0) { |sum, gem_info| sum + gem_info[1] }
67
+ last_total_downloads = stat.gem_infos.reduce(0) { |sum, gem_info| sum + (old_map[gem_info[0]].nil? ? 0 : old_map[gem_info[0]]) }
68
+ total_diff = total_downloads - last_total_downloads
69
+ diff_text = total_diff > 0 ? ", \e[32m+#{stat.number_with_delimiter(total_diff)}\e[0m since last check" : ""
70
+
66
71
  puts ""
67
- puts "\e[32m#{user_name}\e[0m"
72
+ puts "\e[32m#{user_name}\e[0m (Total downloads: #{stat.number_with_delimiter(total_downloads)}#{diff_text})"
68
73
  puts "-" *(stat.max_gem_name_size + 30)
69
74
  stat.gem_infos.each do |gem_info|
70
75
  number_of_changes = gem_info[1] - (old_map[gem_info[0]].nil? ? 0 : old_map[gem_info[0]])
71
- diff_from_last_time = number_of_changes == 0 ? "" : " (+\e[32m#{number_of_changes}\e[0m)"
72
- puts "%-#{stat.max_gem_name_size + 1}s=> %6d %6s" % [ gem_info[0] , gem_info[1], diff_from_last_time ]
76
+ diff_from_last_time = number_of_changes == 0 ? "" : " (\e[32m+#{stat.number_with_delimiter(number_of_changes)}\e[0m)"
77
+ puts "%-#{stat.max_gem_name_size + 1}s=> %6s %6s" % [ gem_info[0] , stat.number_with_delimiter(gem_info[1]), diff_from_last_time ]
73
78
  puts "-" *(stat.max_gem_name_size + 30)
74
79
  end
75
80
  all_data[user_name] = stat.gem_infos
@@ -14,4 +14,8 @@ class Statistic
14
14
  def max_gem_name_size
15
15
  gem_infos.map { |info| info[0].size }.sort[-1]
16
16
  end
17
+
18
+ def number_with_delimiter(number, delimiter=",")
19
+ number.to_s.gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{delimiter}")
20
+ end
17
21
  end
@@ -1,3 +1,3 @@
1
1
  module RgStats
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rg_stats
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-08 00:00:00.000000000Z
12
+ date: 2012-05-12 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description: Get download statistic of yours gems on RubyGems
15
15
  email: