Class: Bundler::CLI::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, args, thor) ⇒ Config

Returns a new instance of Config.



7
8
9
10
11
12
13
14
15
16
# File 'lib/bundler/cli/config.rb', line 7

def initialize(options, args, thor)
  @options = options
  @args = args
  @thor = thor
  @name = peek = args.shift
  @scope = "global"
  return unless peek && peek.start_with?("--")
  @name = args.shift
  @scope = peek[2..-1]
end

Instance Attribute Details

#argsObject

Returns the value of attribute args.



5
6
7
# File 'lib/bundler/cli/config.rb', line 5

def args
  @args
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/bundler/cli/config.rb', line 4

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/bundler/cli/config.rb', line 4

def options
  @options
end

#scopeObject (readonly)

Returns the value of attribute scope.



4
5
6
# File 'lib/bundler/cli/config.rb', line 4

def scope
  @scope
end

#thorObject (readonly)

Returns the value of attribute thor.



4
5
6
# File 'lib/bundler/cli/config.rb', line 4

def thor
  @thor
end

Instance Method Details

#runObject



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

def run
  unless name
    confirm_all
    return
  end

  unless valid_scope?(scope)
    Bundler.ui.error "Invalid scope --#{scope} given. Please use --local or --global."
    exit 1
  end

  if scope == "delete"
    Bundler.settings.set_local(name, nil)
    Bundler.settings.set_global(name, nil)
    return
  end

  if args.empty?
    confirm(name)
    return
  end

  Bundler.ui.info(message) if message
  Bundler.settings.send("set_#{scope}", name, new_value)
end