Class: Bundler::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/bowline/bundler/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ CLI

Returns a new instance of CLI.



33
34
35
36
# File 'lib/bowline/bundler/cli.rb', line 33

def initialize(options)
  @options = options
  @bundle = Bundle.load(@options[:manifest])
end

Class Method Details

.run(command, options = {}) ⇒ Object



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
# File 'lib/bowline/bundler/cli.rb', line 5

def self.run(command, options = {})
  new(options).run(command)
rescue DefaultManifestNotFound => e
  Bundler.logger.error "Could not find a Gemfile to use"
  exit 3
rescue InvalidEnvironmentName => e
  Bundler.logger.error "Gemfile error: #{e.message}"
  exit 4
rescue InvalidRepository => e
  Bundler.logger.error e.message
  exit 5
rescue VersionConflict => e
  Bundler.logger.error e.message
  exit 6
rescue GemNotFound => e
  Bundler.logger.error e.message
  exit 7
rescue InvalidCacheArgument => e
  Bundler.logger.error e.message
  exit 8
rescue SourceNotCached => e
  Bundler.logger.error e.message
  exit 9
rescue ManifestFileNotFound => e
  Bundler.logger.error e.message
  exit 10
end

Instance Method Details

#bundleObject



38
39
40
# File 'lib/bowline/bundler/cli.rb', line 38

def bundle
  @bundle.install(@options)
end

#cacheObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/bowline/bundler/cli.rb', line 42

def cache
  gemfile = @options[:cache]

  if File.extname(gemfile) == ".gem"
    if !File.exist?(gemfile)
      raise InvalidCacheArgument, "'#{gemfile}' does not exist."
    end
    @bundle.cache(gemfile)
  elsif File.directory?(gemfile) || gemfile.include?('/')
    if !File.directory?(gemfile)
      raise InvalidCacheArgument, "'#{gemfile}' does not exist."
    end
    gemfiles = Dir["#{gemfile}/*.gem"]
    if gemfiles.empty?
      raise InvalidCacheArgument, "'#{gemfile}' contains no gemfiles"
    end
    @bundle.cache(*gemfiles)
  else
    raise InvalidCacheArgument, "w0t? '#{gemfile}' means nothing to me."
  end
end

#execObject



76
77
78
79
80
# File 'lib/bowline/bundler/cli.rb', line 76

def exec
  @bundle.setup_environment
  # w0t?
  super(*$command)
end

#listObject



68
69
70
# File 'lib/bowline/bundler/cli.rb', line 68

def list
  @bundle.list(@options)
end

#list_outdatedObject



72
73
74
# File 'lib/bowline/bundler/cli.rb', line 72

def list_outdated
  @bundle.list_outdated(@options)
end

#pruneObject



64
65
66
# File 'lib/bowline/bundler/cli.rb', line 64

def prune
  @bundle.prune(@options)
end

#run(command) ⇒ Object



82
83
84
# File 'lib/bowline/bundler/cli.rb', line 82

def run(command)
  send(command)
end