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(config:, options:) ⇒ 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(config:, options:) ⇒ Stager
Returns a new instance of Stager.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/roku_builder/stager.rb', line 8 def initialize(config:, options:) @config = config @options = @method = get_method @ref = get_git_ref @scripts = get_scripts @plugin = get_plugin @root_dir = config.root_dir @logger = Logger.instance @stage_success = true @stash_key = "roku-builder-temp-stash" end |
Instance Method Details
#method ⇒ Symbol
Helper method to get the staging method being used
23 24 25 |
# File 'lib/roku_builder/stager.rb', line 23 def method @method end |
#stage ⇒ Boolean
Change the stage of the app depending on the method
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/roku_builder/stager.rb', line 30 def stage @orginal_directory = Dir.pwd case @method when :current, :in # Do Nothing when :working switch_directory when :git switch_directory begin git_switch_to(branch: @ref) rescue Git::GitExecuteError git_rescue @stage_success = false end when :script switch_directory staging_logs = RokuBuilder.system(command: @scripts[:stage]) if !staging_logs.empty? @logger.warn "===== Staging Logs Start =====" puts staging_logs @logger.warn "===== Staging Logs End =======" end when :plugin @plugin.stage(options: @options) end RokuBuilder.process_hook(hook: "post_stage", params: {config: @config, options: @options}) @stage_success end |
#unstage ⇒ Boolean
Revert the change that the stage method made
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/roku_builder/stager.rb', line 62 def unstage @orginal_directory ||= Dir.pwd unstage_success = true case @method when :current, :in, :working # Do Nothing when :git switch_directory begin git_switch_from(branch: @ref, checkout: @stage_success) rescue Git::GitExecuteError git_rescue unstage_success = false end switch_directory_back when :script switch_directory if @scripts[:unstage] unstaging_logs = RokuBuilder.system(command: @scripts[:unstage]) if !unstaging_logs.empty? @logger.warn "===== Unstaging Logs Start =====" puts unstaging_logs @logger.warn "===== Unstaging Logs End =======" end end switch_directory_back when :plugin @plugin.unstage(options: @options) end RokuBuilder.process_hook(hook: "post_unstage", params: {config: @config, options: @options}) unstage_success end |