Class: Cejo::Distro::Main

Inherits:
Object
  • Object
show all
Defined in:
lib/cejo/distro/main.rb

Overview

Main

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(folder, utils) ⇒ Main



11
12
13
14
15
# File 'lib/cejo/distro/main.rb', line 11

def initialize(folder, utils)
  @folder = folder
  @utils = utils
  @action = action
end

Instance Attribute Details

#actionObject

Returns the value of attribute action.



9
10
11
# File 'lib/cejo/distro/main.rb', line 9

def action
  @action
end

#argumentsObject

Returns the value of attribute arguments.



9
10
11
# File 'lib/cejo/distro/main.rb', line 9

def arguments
  @arguments
end

#folderObject (readonly)

Returns the value of attribute folder.



8
9
10
# File 'lib/cejo/distro/main.rb', line 8

def folder
  @folder
end

#utilsObject (readonly)

Returns the value of attribute utils.



8
9
10
# File 'lib/cejo/distro/main.rb', line 8

def utils
  @utils
end

Instance Method Details

#commandsObject



17
18
19
20
21
22
23
# File 'lib/cejo/distro/main.rb', line 17

def commands
  parsed_commands = ParsedCommands.new(utils, folder).found
  commands = Commands.new parsed_commands

  exit unless commands.any?
  commands.all
end

#final_commandObject



39
40
41
42
43
44
# File 'lib/cejo/distro/main.rb', line 39

def final_command
  result = packager, real_action
  result.append arguments
  result.prepend 'sudo' if need.admin?
  result.join ' '
end

#needObject



35
36
37
# File 'lib/cejo/distro/main.rb', line 35

def need
  Need.new action
end

#packagerObject



25
26
27
28
# File 'lib/cejo/distro/main.rb', line 25

def packager
  current_packager = CurrentPackager.new utils
  current_packager.packager commands.keys
end

#real_actionObject



30
31
32
33
# File 'lib/cejo/distro/main.rb', line 30

def real_action
  result = TranslateAction.new
  result.real_action commands, packager, action
end

#runObject



46
47
48
# File 'lib/cejo/distro/main.rb', line 46

def run
  system final_command
end