Class: Standup::Scripts::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/standup/scripts/base.rb

Direct Known Subclasses

Node

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Base

Returns a new instance of Base.



6
7
8
9
# File 'lib/standup/scripts/base.rb', line 6

def initialize *args
  merge_params self.class.default_params
  merge_params Settings[name]
end

Instance Attribute Details

#paramsObject

Returns the value of attribute params.



18
19
20
# File 'lib/standup/scripts/base.rb', line 18

def params
  @params
end

Class Method Details

.executeObject



48
49
50
# File 'lib/standup/scripts/base.rb', line 48

def self.execute
  new.run
end

Instance Method Details

#nameObject



20
21
22
# File 'lib/standup/scripts/base.rb', line 20

def name
  self.class.name
end

#put_titleObject



24
25
26
# File 'lib/standup/scripts/base.rb', line 24

def put_title
  bright_p name, HighLine::CYAN
end

#script_file(filename) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/standup/scripts/base.rb', line 28

def script_file filename
  [Standup.local_scripts_path, Standup.conf_scripts_path, Standup.gem_scripts_path].compact.each do |dir|
    next unless dir
    path = File.expand_path("#{name}/#{filename}", dir)
    return path if File.exists? path
  end
  nil
end

#with_processed_file(filename) ⇒ Object



37
38
39
40
41
42
43
44
45
46
# File 'lib/standup/scripts/base.rb', line 37

def with_processed_file filename
  Dir.mktmpdir do |dir|
    erb = ERB.new File.read(filename)
    erb.filename = filename
    result = erb.result get_binding
    tmp_filename = File.expand_path File.basename(filename), dir
    File.open(tmp_filename, 'w') {|f| f.write result}
    yield tmp_filename
  end
end