Class: RokuBuilder::Stager
- Inherits:
-
Object
- Object
- RokuBuilder::Stager
- Defined in:
- lib/roku_builder/stager.rb
Overview
Change stage of roku application
Instance Method Summary collapse
-
#initialize(key: nil, method:, root_dir:, logger:) ⇒ Stager
constructor
A new instance of Stager.
-
#method ⇒ Symbol
Helper method to get the staging method being used.
-
#stage ⇒ Boolean
Change the stage of the app depending on the method.
-
#unstage ⇒ Boolean
Revert the change that the stage method made.
Constructor Details
#initialize(key: nil, method:, root_dir:, logger:) ⇒ Stager
Returns a new instance of Stager.
6 7 8 9 10 11 12 13 |
# File 'lib/roku_builder/stager.rb', line 6 def initialize(key: nil, method:, root_dir:, logger:) @method = method @key = key @root_dir = root_dir @logger = logger @stage_success = true @orginal_directory = Dir.pwd end |
Instance Method Details
#method ⇒ Symbol
Helper method to get the staging method being used
17 18 19 |
# File 'lib/roku_builder/stager.rb', line 17 def method @method end |
#stage ⇒ Boolean
Change the stage of the app depending on the method
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/roku_builder/stager.rb', line 24 def stage Dir.chdir(@root_dir) unless @root_dir == @orginal_directory case @method when :current # Do Nothing when :working # Do Nothing when :git begin git_switch_to(branch: @key) rescue Git::GitExecuteError git_rescue @stage_success = false end when :script Controller.system(command: @key[:stage]) end @stage_success end |
#unstage ⇒ Boolean
Revert the change that the stage method made
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/roku_builder/stager.rb', line 46 def unstage unstage_success = true case @method when :current # Do Nothing when :working # Do Nothing when :git begin git_switch_from(branch: @key, checkout: @stage_success) rescue Git::GitExecuteError git_rescue unstage_success = false end when :script Controller.system(command: @key[:unstage]) end Dir.chdir(@orginal_directory) unless @root_dir == @orginal_directory unstage_success end |