gem-stats 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
- require 'httparty'
1
+ require 'open-uri'
2
+ require 'json'
2
3
 
3
4
  class Gem::Commands::StatsCommand < Gem::Command
4
5
  def initialize
@@ -13,10 +14,6 @@ class Gem::Commands::StatsCommand < Gem::Command
13
14
  "#{program_name} [gem-name]"
14
15
  end
15
16
 
16
- def get_stats gem
17
- HTTParty.get "http://gemcutter.org/api/v1/gems/#{gem}.json"
18
- end
19
-
20
17
  def execute
21
18
  begin
22
19
  gem = get_one_gem_name
@@ -25,18 +22,42 @@ class Gem::Commands::StatsCommand < Gem::Command
25
22
  exit
26
23
  end
27
24
 
28
- stats = get_stats gem
29
-
30
- if stats.to_s == 'This rubygem could not be found.'
31
- puts "Sorry kid, doesn't look like that gem exists!"
32
- else
33
- title = "#{stats['name']} by #{stats['authors']}"
25
+ begin
26
+ open "http://gemcutter.org/api/v1/gems/#{gem}.json" do |results|
27
+ results.each do |result|
28
+ stats = JSON.parse result
34
29
 
35
- puts title
36
- puts '-' * title.size
37
- puts "http://gemcutter.org/gems/#{stats['name']}\n\n"
38
- puts "Downloads: #{stats['downloads']}"
39
- puts "Current version: #{stats['version']}"
30
+ puts stats['name'] + ' by ' + stats['authors']
31
+ puts stats['project_uri']
32
+
33
+ puts ''
34
+
35
+ puts 'Total Downloads ' + stats['downloads'].to_s
36
+ puts 'Version Downloads ' + stats['version_downloads'].to_s
37
+ puts 'Current Version ' + stats['version']
38
+
39
+ unless stats['dependencies']['runtime'].empty?
40
+ puts ''
41
+
42
+ puts 'Runtime Dependencies'
43
+ stats['dependencies']['runtime'].each do |dependency|
44
+ puts dependency['name'] + ' ' + dependency['requirements']
45
+ end
46
+ end
47
+
48
+ unless stats['dependencies']['development'].empty?
49
+ puts ''
50
+
51
+ puts 'Development Dependencies'
52
+ stats['dependencies']['development'].each do |dependency|
53
+ puts dependency['name'] + ' ' + dependency['requirements']
54
+ end
55
+ end
56
+ end
57
+ end
58
+ rescue OpenURI::HTTPError
59
+ puts "Whoops, seems as if that gem doesn't exist!"
60
+ exit
40
61
  end
41
62
  end
42
63
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem-stats
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Tatom
@@ -9,19 +9,10 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-22 00:00:00 -08:00
12
+ date: 2010-02-12 00:00:00 -08:00
13
13
  default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: httparty
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 0.4.5
24
- version:
14
+ dependencies: []
15
+
25
16
  description: View gemcutter statistics for any given gem.
26
17
  email: dannytatom@gmail.com
27
18
  executables: []