Class: BetweenMeals::Cmd
- Inherits:
-
Object
- Object
- BetweenMeals::Cmd
- Defined in:
- lib/between_meals/cmd.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#bin ⇒ Object
Returns the value of attribute bin.
Instance Method Summary collapse
- #cmd(params, cwd = nil) ⇒ Object
-
#initialize(params) ⇒ Cmd
constructor
A new instance of Cmd.
Constructor Details
#initialize(params) ⇒ Cmd
Returns a new instance of Cmd.
23 24 25 26 27 |
# File 'lib/between_meals/cmd.rb', line 23 def initialize(params) @bin = params[:bin] || fail @cwd = params[:cwd] || Dir.pwd @logger = params[:logger] || Logger.new(STDOUT) end |
Instance Attribute Details
#bin ⇒ Object
Returns the value of attribute bin.
21 22 23 |
# File 'lib/between_meals/cmd.rb', line 21 def bin @bin end |
Instance Method Details
#cmd(params, cwd = nil) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/between_meals/cmd.rb', line 29 def cmd(params, cwd = nil) cwd ||= File.(@cwd) cmd = "#{@bin} #{params}" @logger.info("Running \"#{cmd}\"") c = Mixlib::ShellOut.new( cmd, :cwd => cwd, ) # macOS needs /usr/local/bin as hg cannot be installed in /bin or /usr/bin c.environment = { 'PATH' => '/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin', } c.run_command c.error! c end |