Class: Gem::Commands::BundleCommand

Inherits:
Gem::Command
  • Object
show all
Defined in:
lib/bundler/commands/bundle_command.rb

Instance Method Summary collapse

Constructor Details

#initializeBundleCommand

Returns a new instance of BundleCommand.



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/bundler/commands/bundle_command.rb', line 3

def initialize
  super('bundle', 'Create a gem bundle based on your Gemfile', {:manifest => nil, :update => false})

  add_option('-m', '--manifest MANIFEST', "Specify the path to the manifest file") do |manifest, options|
    options[:manifest] = manifest
  end

  add_option('-u', '--update', "Force a remote check for newer gems") do
    options[:update] = true
  end

  add_option('--cached', "Only use cached gems when expanding the bundle") do
    options[:cached] = true
  end

  add_option('--cache GEM', "Specify a path to a .gem file to add to the bundled gem cache") do |gem, options|
    options[:cache] = gem
  end

  add_option('--prune-cache', "Removes all .gem files from the bundle's cache") do
    options[:prune] = true
  end

  add_option('--list', "List all gems that are part of the active bundle") do
    options[:list] = true
  end

  add_option('--list-outdated', "List all outdated gems that are part of the active bundle") do
    options[:list_outdated] = true
  end

  add_option('-b', '--build-options OPTION_FILE', "Specify a path to a yml file with build options for binary gems") do |option_file, options|
    if File.exist?(option_file)
      options[:build_options] = YAML.load_file(option_file)
    end
  end

  add_option('--only ENV', "Only expand the given environment.  To specify multiple environments, use --only multiple times.") do |env, options|
    options[:only] ||= []
    options[:only] << env
  end
end

Instance Method Details

#descriptionObject

:nodoc:



50
51
52
53
54
# File 'lib/bundler/commands/bundle_command.rb', line 50

def description # :nodoc:
  <<-EOF
Bundle stuff
  EOF
end

#executeObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/bundler/commands/bundle_command.rb', line 56

def execute
  # Prevent the bundler from getting required unless it is actually being used
  require 'bundler'
  if options[:cache]
    Bundler::CLI.run(:cache, options)
  elsif options[:prune]
    Bundler::CLI.run(:prune, options)
  elsif options[:list]
    Bundler::CLI.run(:list, options)
  elsif options[:list_outdated]
    Bundler::CLI.run(:list_outdated, options)
  else
    Bundler::CLI.run(:bundle, options)
  end
end

#usageObject



46
47
48
# File 'lib/bundler/commands/bundle_command.rb', line 46

def usage
  "#{program_name}"
end