Class: TiyoHw::Runners::Ruby

Inherits:
Base
  • Object
show all
Defined in:
lib/tiyo_hw/runners/ruby.rb

Instance Attribute Summary

Attributes inherited from Base

#commands, #pwd

Instance Method Summary collapse

Methods inherited from Base

#add_command, #file?, #file_contents?, #file_path, get_commands, #initialize

Constructor Details

This class inherits a constructor from TiyoHw::Runners::Base

Instance Method Details

#_rails_commandsObject



16
17
18
19
20
21
22
# File 'lib/tiyo_hw/runners/ruby.rb', line 16

def _rails_commands
  add_command "spring stop" if spring?
  add_command "bin/rake db:setup"
  add_command "bin/rails s & sleep #{SLEEP_TIME} && open http://localhost:3000"
  add_command "bin/rake test"
  add_command "sleep 1 && %%" # Reown the rails s process
end

#gemfile?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/tiyo_hw/runners/ruby.rb', line 8

def gemfile?
  file?("Gemfile")
end

#prepare_commandsObject



24
25
26
27
# File 'lib/tiyo_hw/runners/ruby.rb', line 24

def prepare_commands
  add_command "bundle install" if gemfile?
  _rails_commands if rails?
end

#rails?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/tiyo_hw/runners/ruby.rb', line 4

def rails?
  file?("bin", "rails")
end

#spring?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/tiyo_hw/runners/ruby.rb', line 12

def spring?
  file_contents?(/spring/, "Gemfile.lock")
end