~ubuntu-branches/ubuntu/quantal/ruby1.9.1/quantal

« back to all changes in this revision

Viewing changes to lib/rubygems/commands/specification_command.rb

  • Committer: Bazaar Package Importer
  • Author(s): Lucas Nussbaum
  • Date: 2010-07-31 17:08:39 UTC
  • mfrom: (1.1.4 upstream) (8.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20100731170839-j034dmpdqt1cc4p6
Tags: 1.9.2~svn28788-1
* New release based on upstream snapshot from the 1.9.2 branch,
  after 1.9.2 RC2. That branch is (supposed to be) binary-compatible
  with the 1.9.1 branch.
  + Builds fine on i386. Closes: #580852.
* Upgrade to Standards-Version: 3.9.1. No changes needed.
* Updated generated incs.
* Patches that still need work:
  + Unclear status, need more investigation:
   090729_fix_Makefile_deps.dpatch
   090803_exclude_rdoc.dpatch
   203_adjust_base_of_search_path.dpatch
   902_define_YAML_in_yaml_stringio.rb.dpatch
   919_common.mk_tweaks.dpatch
   931_libruby_suffix.dpatch
   940_test_thread_mutex_sync_shorter.dpatch
  + Maybe not needed anymore, keeping but not applying.
   102_skip_test_copy_stream.dpatch (test doesn't block anymore?)
   104_skip_btest_io.dpatch (test doesn't block anymore?)
   201_gem_prelude.dpatch (we don't use that rubygems anyway?)
   202_gem_default_dir.dpatch (we don't use that rubygems anyway?)
   940_test_file_exhaustive_fails_as_root.dpatch
   940_test_priority_fails.dpatch
   100518_load_libc_libm.dpatch
* Add disable-tests.diff: disable some tests that cause failures on FreeBSD.
  Closes: #590002, #543805, #542927.
* However, many new failures on FreeBSD. Since that version is still an
  improvement, add the check that makes test suite failures non-fatal on
  FreeBSD again. That still needs to be investigated.
* Re-add 903_skip_base_ruby_check.dpatch
* Add build-dependency on ruby1.8 and drop all pre-generated files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
 
13
13
  def initialize
14
14
    super 'specification', 'Display gem specification (in yaml)',
15
 
          :domain => :local, :version => Gem::Requirement.default
 
15
          :domain => :local, :version => Gem::Requirement.default,
 
16
          :format => :yaml
16
17
 
17
18
    add_version_option('examine')
18
19
    add_platform_option
22
23
      options[:all] = true
23
24
    end
24
25
 
 
26
    add_option('--ruby', 'Output ruby format') do |value, options|
 
27
      options[:format] = :ruby
 
28
    end
 
29
 
 
30
    add_option('--yaml', 'Output RUBY format') do |value, options|
 
31
      options[:format] = :yaml
 
32
    end
 
33
 
 
34
    add_option('--marshal', 'Output Marshal format') do |value, options|
 
35
      options[:format] = :marshal
 
36
    end
 
37
 
25
38
    add_local_remote_options
26
39
  end
27
40
 
28
41
  def arguments # :nodoc:
29
 
    "GEMFILE       name of gem to show the gemspec for"
 
42
    <<-ARGS
 
43
GEMFILE       name of gem to show the gemspec for
 
44
FIELD         name of gemspec field to show
 
45
    ARGS
30
46
  end
31
47
 
32
48
  def defaults_str # :nodoc:
33
 
    "--local --version '#{Gem::Requirement.default}'"
 
49
    "--local --version '#{Gem::Requirement.default}' --yaml"
34
50
  end
35
51
 
36
52
  def usage # :nodoc:
37
 
    "#{program_name} [GEMFILE]"
 
53
    "#{program_name} [GEMFILE] [FIELD]"
38
54
  end
39
55
 
40
56
  def execute
41
57
    specs = []
42
 
    gem = get_one_gem_name
 
58
    gem = options[:args].shift
 
59
 
 
60
    unless gem then
 
61
      raise Gem::CommandLineError,
 
62
            "Please specify a gem name or file on the command line"
 
63
    end
 
64
 
43
65
    dep = Gem::Dependency.new gem, options[:version]
44
66
 
 
67
    field = get_one_optional_argument
 
68
 
 
69
    if field then
 
70
      field = field.intern
 
71
 
 
72
      if options[:format] == :ruby then
 
73
        raise Gem::CommandLineError, "--ruby and FIELD are mutually exclusive"
 
74
      end
 
75
 
 
76
      unless Gem::Specification.attribute_names.include? field then
 
77
        raise Gem::CommandLineError,
 
78
              "no field %p on Gem::Specification" % field.to_s
 
79
      end
 
80
    end
 
81
 
45
82
    if local? then
46
83
      if File.exist? gem then
47
84
        specs << Gem::Format.from_file_by_path(gem).spec rescue nil
63
100
      terminate_interaction 1
64
101
    end
65
102
 
66
 
    output = lambda { |s| say s.to_yaml; say "\n" }
 
103
    output = lambda do |s|
 
104
      s = s.send field if field
 
105
 
 
106
      say case options[:format]
 
107
          when :ruby then s.to_ruby
 
108
          when :marshal then Marshal.dump s
 
109
          else s.to_yaml
 
110
          end
 
111
 
 
112
      say "\n"
 
113
    end
67
114
 
68
115
    if options[:all] then
69
116
      specs.each(&output)