Class: Standup::Scripts::Base
- Inherits:
-
Object
- Object
- Standup::Scripts::Base
- Defined in:
- lib/standup/scripts/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#params ⇒ Object
Returns the value of attribute params.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ Base
constructor
A new instance of Base.
- #name ⇒ Object
- #put_title ⇒ Object
- #script_file(filename) ⇒ Object
- #with_processed_file(filename) ⇒ Object
Constructor Details
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
18 19 20 |
# File 'lib/standup/scripts/base.rb', line 18 def params @params end |
Class Method Details
.execute ⇒ Object
48 49 50 |
# File 'lib/standup/scripts/base.rb', line 48 def self.execute new.run end |
Instance Method Details
#name ⇒ Object
20 21 22 |
# File 'lib/standup/scripts/base.rb', line 20 def name self.class.name end |
#put_title ⇒ Object
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.("#{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. File.basename(filename), dir File.open(tmp_filename, 'w') {|f| f.write result} yield tmp_filename end end |