Class: Gem::Commands::BundleCommand

Inherits:
Gem::Command
  • Object
show all
Defined in:
lib/bundler08/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
45
46
47
48
49
# File 'lib/bundler08/commands/bundle_command.rb', line 3

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

  add_option('-i', '--init',"Create a Gemfile") do
    options[:init] = true
  end

  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 that are not a part of the bundle from the 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)
      require 'yaml'
      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:



55
56
57
58
59
# File 'lib/bundler08/commands/bundle_command.rb', line 55

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

#executeObject



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/bundler08/commands/bundle_command.rb', line 61

def execute
  # Prevent the bundler from getting required unless it is actually being used
  require 'bundler08'
  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)
  elsif options[:init]
    if File.exists?("Gemfile")
      Bundler.logger.error "The Gemfile already exists"
    else
      FileUtils.cp File.expand_path("../../templates/Gemfile", __FILE__), "Gemfile"
      Bundler.logger.info "Initialized Gemfile in #{Dir.pwd}"
    end
  else
    Bundler::CLI.run(:bundle, options)
  end
end

#usageObject



51
52
53
# File 'lib/bundler08/commands/bundle_command.rb', line 51

def usage
  "#{program_name}"
end