Class: GDK::Execute::Rake

Inherits:
Object
  • Object
show all
Defined in:
lib/gdk/execute/rake.rb

Overview

Rake adapter to execute tasks in GDK or Gitlab rails environment

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*tasks) ⇒ Rake

Returns a new instance of Rake.

Parameters:

  • *tasks (Array<String>)

    a list of tasks to be executed



10
11
12
# File 'lib/gdk/execute/rake.rb', line 10

def initialize(*tasks)
  @tasks = tasks
end

Instance Attribute Details

#tasksObject (readonly)

Returns the value of attribute tasks.



7
8
9
# File 'lib/gdk/execute/rake.rb', line 7

def tasks
  @tasks
end

Instance Method Details

#execute_in_gdk(**args) ⇒ Object

Execute rake tasks in the GDK root folder and environment

Parameters:

  • *args (Array)

    any arg that Shellout#execute accepts



17
18
19
20
21
# File 'lib/gdk/execute/rake.rb', line 17

def execute_in_gdk(**args)
  @shellout = Shellout.new(rake_command, chdir: GDK.root).execute(**args)

  self
end

#execute_in_gitlab(**args) ⇒ Object

Execute rake tasks in the ‘gitlab` rails environment

Parameters:

  • *args (Array)

    any arg that Shellout#execute accepts



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/gdk/execute/rake.rb', line 26

def execute_in_gitlab(**args)
  if bundler_available?
    Bundler.with_unbundled_env do
      @shellout = Shellout.new(rake_command, chdir: GDK.config.gitlab.dir).execute(**args)
    end
  else
    @shellout = Shellout.new(rake_command, chdir: GDK.config.gitlab.dir).execute(**args)
  end

  self
end

#success?Boolean

Return whether the execution was a success or not

Returns:

  • (Boolean)

    whether the execution was a success



41
42
43
# File 'lib/gdk/execute/rake.rb', line 41

def success?
  @shellout&.success?
end