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.
8 9 10 11 12 13 14 15 |
# File 'lib/roku_builder/stager.rb', line 8 def initialize(key: nil, method:, root_dir:, logger:) @method = method @key = key @root_dir = root_dir @logger = logger @stage_success = true @stash_key = "roku-builder-temp-stash" end |
Instance Method Details
#method ⇒ Symbol
Helper method to get the staging method being used
19 20 21 |
# File 'lib/roku_builder/stager.rb', line 19 def method @method end |
#stage ⇒ Boolean
Change the stage of the app depending on the method
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/roku_builder/stager.rb', line 26 def stage @orginal_directory = Dir.pwd 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
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/roku_builder/stager.rb', line 49 def unstage @orginal_directory ||= Dir.pwd Dir.chdir(@root_dir) unless @root_dir == @orginal_directory 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]) if @key[:unstage] end Dir.chdir(@orginal_directory) unless @root_dir == @orginal_directory unstage_success end |