Class: LearnConfig::Setup

Inherits:
Object
  • Object
show all
Defined in:
lib/learn_config/setup.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Setup

Returns a new instance of Setup.



9
10
11
12
13
14
15
# File 'lib/learn_config/setup.rb', line 9

def initialize(args)
  @args    = args
  @netrc   = LearnConfig::NetrcInteractor.new
  @reset   = !!args.include?('--reset')
  @whoami  = !!args.include?('--whoami')
  @set_dir = !!args.include?('--set-directory')
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



3
4
5
# File 'lib/learn_config/setup.rb', line 3

def args
  @args
end

#netrcObject (readonly)

Returns the value of attribute netrc.



3
4
5
# File 'lib/learn_config/setup.rb', line 3

def netrc
  @netrc
end

#resetObject (readonly)

Returns the value of attribute reset.



3
4
5
# File 'lib/learn_config/setup.rb', line 3

def reset
  @reset
end

#set_dirObject (readonly)

Returns the value of attribute set_dir.



3
4
5
# File 'lib/learn_config/setup.rb', line 3

def set_dir
  @set_dir
end

#whoamiObject (readonly)

Returns the value of attribute whoami.



3
4
5
# File 'lib/learn_config/setup.rb', line 3

def whoami
  @whoami
end

Class Method Details

.run(args) ⇒ Object



5
6
7
# File 'lib/learn_config/setup.rb', line 5

def self.run(args)
  new(args).run
end

Instance Method Details

#runObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/learn_config/setup.rb', line 17

def run
  if reset
    args.delete('--reset')
    confirm_and_reset!
  elsif whoami
    args.delete('--whoami')
    check_config
    whoami?
  elsif set_dir
    args.delete('--set-directory')
    check_config
    set_directory!
  else
    check_config
  end
end