Class: Gem::Commands::Isit19Command

Inherits:
Gem::Command
  • Object
show all
Includes:
Text, VersionOption
Defined in:
lib/rubygems/commands/isit19_command.rb

Overview

gem command for querying the 1.9 status of installed gems

Instance Method Summary collapse

Constructor Details

#initializeIsit19Command

Returns a new instance of Isit19Command.



14
15
16
17
18
19
# File 'lib/rubygems/commands/isit19_command.rb', line 14

def initialize
  super 'isit19', 'Check isitruby19.com for ruby 1.9 compatibility',
        :version => Gem::Requirement.default

  add_version_option
end

Instance Method Details

#argumentsObject

:nodoc:



21
22
23
# File 'lib/rubygems/commands/isit19_command.rb', line 21

def arguments # :nodoc:
  'GEMNAME       name of an installed gem to check for 1.9 compatibility'
end

#defaults_strObject

:nodoc:



25
26
27
# File 'lib/rubygems/commands/isit19_command.rb', line 25

def defaults_str # :nodoc:
  "--version='>= 0'"
end

#executeObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/rubygems/commands/isit19_command.rb', line 33

def execute
  name = get_one_gem_name

  dep = Gem::Dependency.new name, options[:version]
  specs = Gem.source_index.search dep

  if specs.empty? then
    alert_error "No installed gem #{dep}"
    terminate_interaction 1
  end

  spec = specs.last

  isit19 = IsIt19.new spec

  comments = isit19.comments

  say "#{spec.name} #{spec.version}:    #{isit19.url}"

  say '    No reports!' if comments.empty?

  last_seen_version = nil

  comments.each_with_index do |comment, i|
    break if i > 0 and comment['version'] != last_seen_version

    works = comment['works_for_me'] ? 'works' : 'fails'
    platform = comment['platform'].values.join ' ' if comment['platform']

    msg = "#{comment['name']} says #{comment['version']} #{works}"
    msg << " on #{platform}" if platform

    say "    #{msg}"
    say format_text(comment['body'], 68, 8) unless comment['body'].empty?
    say

    last_seen_version = comment['version']
  end
end

#usageObject

:nodoc:



29
30
31
# File 'lib/rubygems/commands/isit19_command.rb', line 29

def usage # :nodoc:
  "#{program_name} GEMNAME [options]"
end