Class: Qas::Main

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

Overview

Main start point

Defined Under Namespace

Classes: GitMustBeAvailable

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command, names = nil) ⇒ Main

Returns a new instance of Main.



10
11
12
13
# File 'lib/qas/main.rb', line 10

def initialize(command, names = nil)
  @command = command
  @names = names
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



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

def command
  @command
end

#foldersObject (readonly)

Returns the value of attribute folders.



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

def folders
  @folders
end

#projectsObject (readonly)

Returns the value of attribute projects.



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

def projects
  @projects
end

#utilsObject (readonly)

Returns the value of attribute utils.



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

def utils
  @utils
end

Instance Method Details

#actionsObject



28
29
30
31
32
33
# File 'lib/qas/main.rb', line 28

def actions
  {
    grab: ->(project) { Grab.new(project) }.curry,
    archive: ->(project) { Archive.new(project, @names) }.curry
  }
end

#current_projectObject



20
21
22
23
24
25
26
# File 'lib/qas/main.rb', line 20

def current_project
  projects.each do |_, repos|
    repos.each do |project|
      yield project if block_given?
    end
  end
end

#runObject

Raises:



35
36
37
38
39
40
41
# File 'lib/qas/main.rb', line 35

def run
  raise GitMustBeAvailable, 'Git was not found!' unless Utils.which?('git').any?

  current_project do |project|
    actions[command].call(project).run
  end
end