Class: Pushapp::Tasks::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/pushapp/tasks/base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.



10
11
12
13
# File 'lib/pushapp/tasks/base.rb', line 10

def initialize options={}
  @options = options
  @logger = Pushapp::Logger.new
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



8
9
10
# File 'lib/pushapp/tasks/base.rb', line 8

def logger
  @logger
end

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/pushapp/tasks/base.rb', line 7

def options
  @options
end

Class Method Details

.register_as(name) ⇒ Object



39
40
41
# File 'lib/pushapp/tasks/base.rb', line 39

def self.register_as name
  Pushapp::Config.register_task name, self
end

Instance Method Details

#app_name_from_pathObject



35
36
37
# File 'lib/pushapp/tasks/base.rb', line 35

def app_name_from_path
  options[:remote].path ? options[:remote].path.split('/').last : nil
end

#envObject



18
19
20
# File 'lib/pushapp/tasks/base.rb', line 18

def env
  Hash[env_options.map {|k, v| [k.to_s, v.to_s] }]
end

#env_optionsObject



22
23
24
# File 'lib/pushapp/tasks/base.rb', line 22

def env_options
  options[:env] || {}
end

#inspectObject



43
44
45
# File 'lib/pushapp/tasks/base.rb', line 43

def inspect
  options[:task_name]
end

#runObject



15
16
# File 'lib/pushapp/tasks/base.rb', line 15

def run
end

#sudoObject



26
27
28
# File 'lib/pushapp/tasks/base.rb', line 26

def sudo
  options[:sudo] || 'sudo'
end

#system(cmd) ⇒ Object



30
31
32
33
# File 'lib/pushapp/tasks/base.rb', line 30

def system cmd
  logger.debug cmd
  Pipe.run cmd
end