Class: PrepKit::Task

Inherits:
Object
  • Object
show all
Defined in:
lib/prep_kit/task.rb

Direct Known Subclasses

With, Within

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ Task

Returns a new instance of Task.



3
4
5
# File 'lib/prep_kit/task.rb', line 3

def initialize(parent)
  @parent = parent
end

Instance Method Details

#action(&block) ⇒ Object



35
36
37
# File 'lib/prep_kit/task.rb', line 35

def action(&block)
  instance_eval &block
end

#download(src, dst) ⇒ Object



19
20
21
# File 'lib/prep_kit/task.rb', line 19

def download(src, dst)
  @parent.download src, dst
end

#sh(command) ⇒ Object



7
8
9
# File 'lib/prep_kit/task.rb', line 7

def sh(command)
  @parent.sh command
end

#test?(path, option) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/prep_kit/task.rb', line 11

def test?(path, option)
  @parent.test? path, option
end

#upload(src, dst) ⇒ Object



15
16
17
# File 'lib/prep_kit/task.rb', line 15

def upload(src, dst)
  @parent.upload src, dst
end

#with(command, &block) ⇒ Object



31
32
33
# File 'lib/prep_kit/task.rb', line 31

def with(command, &block)
  With.new(self, command).action &block
end

#within(directory, &block) ⇒ Object

Raises:

  • (RuntimeError)


23
24
25
26
27
28
29
# File 'lib/prep_kit/task.rb', line 23

def within(directory, &block)
  PrepKit.logger.info "within: ".bold + directory.underline

  raise RuntimeError, directory unless test?(directory, '-d')

  Within.new(self, directory).action &block
end