rg_stats 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +0 -1
- data/Gemfile.lock +1 -1
- data/bin/rg_stats +15 -6
- data/lib/rg_stats/statistic.rb +5 -1
- data/lib/rg_stats/version.rb +1 -1
- data/spec/rg_stats/statistic_spec.rb +6 -1
- metadata +2 -2
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/bin/rg_stats
CHANGED
@@ -26,7 +26,15 @@ if user_name.nil?
|
|
26
26
|
end
|
27
27
|
|
28
28
|
url = "https://rubygems.org/api/v1/owners/#{user_name}/gems.json"
|
29
|
-
|
29
|
+
begin
|
30
|
+
data_as_json = open(url)
|
31
|
+
rescue SocketError => e
|
32
|
+
puts "It seems connection is not available. (#{e.message})"
|
33
|
+
exit
|
34
|
+
rescue OpenURI::HTTPError => e
|
35
|
+
puts "User #{user_name} has not been found. (#{e.message})"
|
36
|
+
exit
|
37
|
+
end
|
30
38
|
old_data = PersistDataBetweenSessions.load
|
31
39
|
old_map = {}
|
32
40
|
old_data.each do |old_gem_info|
|
@@ -35,13 +43,14 @@ end
|
|
35
43
|
|
36
44
|
stat = Statistic.new
|
37
45
|
stat.load data_as_json
|
46
|
+
|
38
47
|
puts ""
|
39
|
-
puts "*" *
|
40
|
-
stat.
|
48
|
+
puts "*" * (stat.max_gem_name_size + 30)
|
49
|
+
stat.gem_infos.each do |gem_info|
|
41
50
|
broj_izmjena = gem_info[1] - (old_map[gem_info[0]].nil? ? 0 : old_map[gem_info[0]])
|
42
51
|
diff_from_last_time = broj_izmjena == 0 ? "" : " (+\e[32m#{broj_izmjena}\e[0m)"
|
43
|
-
puts "
|
52
|
+
puts "%-#{stat.max_gem_name_size + 1}s=> %6d %6s" % [ gem_info[0] , gem_info[1], diff_from_last_time ]
|
44
53
|
end
|
45
|
-
puts "*" *
|
46
|
-
PersistDataBetweenSessions.save(stat.
|
54
|
+
puts "*" * (stat.max_gem_name_size + 30)
|
55
|
+
PersistDataBetweenSessions.save(stat.gem_infos)
|
47
56
|
|
data/lib/rg_stats/statistic.rb
CHANGED
@@ -5,9 +5,13 @@ class Statistic
|
|
5
5
|
@data = JSON.load data
|
6
6
|
end
|
7
7
|
|
8
|
-
def
|
8
|
+
def gem_infos
|
9
9
|
@data.reduce([]) do |result, gem_info|
|
10
10
|
result << [ gem_info['name'], gem_info['downloads']]
|
11
11
|
end.sort! { |a,b| a[1] <=> b[1] }.reverse
|
12
12
|
end
|
13
|
+
|
14
|
+
def max_gem_name_size
|
15
|
+
gem_infos.map { |info| info[0].size }.sort[-1]
|
16
|
+
end
|
13
17
|
end
|
data/lib/rg_stats/version.rb
CHANGED
@@ -4,7 +4,12 @@ require 'rg_stats'
|
|
4
4
|
describe Statistic do
|
5
5
|
it 'should water my plants' do
|
6
6
|
subject.load TEST_DATA
|
7
|
-
subject.
|
7
|
+
subject.gem_infos.should == [["guerrilla_patch", 485], ["cube", 409]]
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should know size of longest named gem' do
|
11
|
+
subject.load TEST_DATA
|
12
|
+
subject.max_gem_name_size.should == 15
|
8
13
|
end
|
9
14
|
end
|
10
15
|
|
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.0.
|
4
|
+
version: 1.0.1
|
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-04-
|
12
|
+
date: 2012-04-07 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description: Get download statistic of yours gems on RubyGems
|
15
15
|
email:
|