Class: NewlineHw::Shell::Runners::Base
- Inherits:
-
Object
- Object
- NewlineHw::Shell::Runners::Base
- Defined in:
- lib/newline_hw/shell/runners/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#commands ⇒ Object
readonly
Returns the value of attribute commands.
-
#pwd ⇒ Object
readonly
Returns the value of attribute pwd.
Class Method Summary collapse
Instance Method Summary collapse
- #add_command(cmd) ⇒ Object
- #file?(*args) ⇒ Boolean
- #file_contents?(regex, *args) ⇒ Boolean
- #file_path(*args) ⇒ Object
-
#initialize(pwd) ⇒ Base
constructor
A new instance of Base.
- #prepare_commands ⇒ Object
Constructor Details
#initialize(pwd) ⇒ Base
Returns a new instance of Base.
7 8 9 10 11 |
# File 'lib/newline_hw/shell/runners/base.rb', line 7 def initialize(pwd) @commands = [] @pwd = pwd prepare_commands end |
Instance Attribute Details
#commands ⇒ Object (readonly)
Returns the value of attribute commands.
5 6 7 |
# File 'lib/newline_hw/shell/runners/base.rb', line 5 def commands @commands end |
#pwd ⇒ Object (readonly)
Returns the value of attribute pwd.
5 6 7 |
# File 'lib/newline_hw/shell/runners/base.rb', line 5 def pwd @pwd end |
Class Method Details
.get_commands(pwd) ⇒ Object
34 35 36 |
# File 'lib/newline_hw/shell/runners/base.rb', line 34 def self.get_commands(pwd) new(pwd).commands end |
Instance Method Details
#add_command(cmd) ⇒ Object
13 14 15 |
# File 'lib/newline_hw/shell/runners/base.rb', line 13 def add_command(cmd) @commands << cmd end |
#file?(*args) ⇒ Boolean
21 22 23 |
# File 'lib/newline_hw/shell/runners/base.rb', line 21 def file?(*args) File.exist?(file_path(*args)) end |
#file_contents?(regex, *args) ⇒ Boolean
25 26 27 28 |
# File 'lib/newline_hw/shell/runners/base.rb', line 25 def file_contents?(regex, *args) return false unless file?(*args) !File.readlines(file_path(*args)).grep(regex).empty? end |
#file_path(*args) ⇒ Object
17 18 19 |
# File 'lib/newline_hw/shell/runners/base.rb', line 17 def file_path(*args) File.(File.join(pwd, *args)) end |
#prepare_commands ⇒ Object
30 31 32 |
# File 'lib/newline_hw/shell/runners/base.rb', line 30 def prepare_commands raise NotImplementedError, "Subclases of Tiyo::Runners::Base must implement prepare_commands" end |