gem-versions 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "http://rubygems.org"
2
+ gemspec
data/README.md ADDED
@@ -0,0 +1,21 @@
1
+ gem-versions -- view a gem's versions
2
+ =====================================
3
+
4
+ ## SYNOPSIS
5
+
6
+ gem versions <GEM>
7
+
8
+ ## DESCRIPTION
9
+
10
+ The `gem versions` command can be used to show all versions of
11
+ a gem published on Rubygems.org. Versions you have installed
12
+ locally are asterisked.
13
+
14
+ ## QUICK START
15
+
16
+ gem install gem-versions
17
+ gem versions rails
18
+
19
+ ## INTELLECTUAL PROPERTY
20
+
21
+ Copyright 2011 Andy Stewart <boss@airbladesoftware.com>.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'gem-versions'
6
+ s.version = '0.0.2'
7
+ s.authors = [ 'Andy Stewart' ]
8
+ s.email = 'boss@airbladesoftware.com'
9
+ s.homepage = 'https://github.com/airblade/gem-versions'
10
+ s.summary = 'List all published versions of a gem.'
11
+ s.description = <<END
12
+ The `gem versions` command can be used to show all versions of
13
+ a gem published on Rubygems.org. Versions you have installed
14
+ locally are asterisked.
15
+ END
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+
20
+ s.add_dependency 'httparty', '~> 0.8'
21
+ end
@@ -0,0 +1,49 @@
1
+ require 'httparty'
2
+
3
+ class Gem::Commands::VersionsCommand < Gem::Command
4
+
5
+ def initialize
6
+ super 'versions', description
7
+ end
8
+
9
+ def description
10
+ 'List all published versions of a gem. Versions you have installed locally are asterisked.'
11
+ end
12
+
13
+ def arguments
14
+ 'GEMNAME exact name of gem for which to list versions'
15
+ end
16
+
17
+ def usage
18
+ "#{program_name} GEMNAME"
19
+ end
20
+
21
+ def execute
22
+ name = get_one_gem_name
23
+ locals = local_versions name
24
+
25
+ begin
26
+ response = ::HTTParty.get "https://rubygems.org/api/v1/versions/#{name}.json"
27
+ rescue # Annoyingly Rubygems' API doesn't return JSON on a 404 response, tripping up HTTParty.
28
+ puts "Unable to find #{name}."
29
+ return
30
+ end
31
+
32
+ if response.code == 200
33
+ remotes = response.map { |item| item['number'] }.map { |v| Gem::Version.create v }.sort.reverse.map &:to_s
34
+ remotes.each do |r|
35
+ puts "#{locals.include?(r) ? '*' : ' '} #{r}"
36
+ end
37
+ else
38
+ puts "Unable to find #{name}."
39
+ end
40
+ end
41
+
42
+ def local_versions(name)
43
+ # From Rubygems' Gem::Commands::QueryCommand
44
+ dep = Gem::Dependency.new name, Gem::Requirement.default
45
+ specs = Gem.source_index.search dep
46
+ specs.map { |spec| spec.version.to_s }
47
+ end
48
+
49
+ end
@@ -0,0 +1,3 @@
1
+ require 'rubygems/command_manager'
2
+
3
+ Gem::CommandManager.instance.register_command :versions
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gem-versions
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 2
10
+ version: 0.0.2
11
+ platform: ruby
12
+ authors:
13
+ - Andy Stewart
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-09-22 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: httparty
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 27
30
+ segments:
31
+ - 0
32
+ - 8
33
+ version: "0.8"
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ description: " The `gem versions` command can be used to show all versions of\n a gem published on Rubygems.org. Versions you have installed\n locally are asterisked.\n"
37
+ email: boss@airbladesoftware.com
38
+ executables: []
39
+
40
+ extensions: []
41
+
42
+ extra_rdoc_files: []
43
+
44
+ files:
45
+ - .gitignore
46
+ - Gemfile
47
+ - README.md
48
+ - Rakefile
49
+ - gem-versions.gemspec
50
+ - lib/rubygems/commands/versions_command.rb
51
+ - lib/rubygems_plugin.rb
52
+ has_rdoc: true
53
+ homepage: https://github.com/airblade/gem-versions
54
+ licenses: []
55
+
56
+ post_install_message:
57
+ rdoc_options: []
58
+
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ hash: 3
67
+ segments:
68
+ - 0
69
+ version: "0"
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ hash: 3
76
+ segments:
77
+ - 0
78
+ version: "0"
79
+ requirements: []
80
+
81
+ rubyforge_project:
82
+ rubygems_version: 1.3.7
83
+ signing_key:
84
+ specification_version: 3
85
+ summary: List all published versions of a gem.
86
+ test_files: []
87
+