Skip to content

Commit

Permalink
Add plugin staging method
Browse files Browse the repository at this point in the history
  • Loading branch information
greeneca committed Jan 21, 2019
1 parent b53a4c4 commit f341c49
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
@@ -1,3 +1,7 @@
= 4.14.0 =

- Add plugin staging method

= 4.13.0 =

- Add combined source_files project config key
Expand Down
7 changes: 4 additions & 3 deletions lib/roku_builder/config_validator.rb
Expand Up @@ -16,7 +16,7 @@ class ConfigValidator
DEVICE_MISSING_PASSWORD = 9
PROJECT_MISSING_APP_NAME = 10
PROJECT_MISSING_DIRECTORY = 11
# = 12
PROJECT_MISSING_PLUGIN = 12
PROJECT_FOLDERS_BAD = 13
PROJECT_MISSING_FILES = 14
PROJECT_FILES_BAD = 15
Expand Down Expand Up @@ -143,7 +143,8 @@ def validate_project(project:)
[PROJECT_MISSING_FILES, (!project[:source_files] and !(project[:files] and project[:folders]))],
[PROJECT_FILES_BAD, (project[:files] and !project[:files].is_a?(Array))],
[MISSING_STAGE_METHOD, ( !project[:stage_method])],
[PROJECT_STAGE_METHOD_BAD, (![:git, :script, nil].include?(project[:stage_method]))],
[PROJECT_STAGE_METHOD_BAD, (![:git, :script, :plugin, nil].include?(project[:stage_method]))],
[PROJECT_MISSING_PLUGIN, (!project[:staging_plugin] and project[:stage_method] == :plugin)],
[DEPRICATED_FILES_FOLDERS, (project[:files] or project[:folders])],
]
process_errors(errors: errors)
Expand Down Expand Up @@ -196,7 +197,7 @@ def error_codes
"A device config is missing its password.",
"A project config is missing its app_name.", #10
"A project config is missing its directorty.",
"",
"A project is missing its staging plugin",
"A project config's folders is not an array.",
"A project config is missing its files.",
"A project config's files is not an array.", #15
Expand Down
11 changes: 11 additions & 0 deletions lib/roku_builder/stager.rb
Expand Up @@ -11,6 +11,7 @@ def initialize(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
Expand Down Expand Up @@ -49,6 +50,8 @@ def stage
puts staging_logs
@logger.warn "===== Staging Logs End ======="
end
when :plugin
@plugin.stage(options: @options)
end
@stage_success
end
Expand Down Expand Up @@ -81,6 +84,8 @@ def unstage
end
end
switch_directory_back
when :plugin
@plugin.unstage(options: @options)
end
unstage_success
end
Expand All @@ -107,6 +112,12 @@ def get_scripts
@config.stage[:script] if @config.stage
end

def get_plugin
if @config.project and @config.project[:staging_plugin]
RokuBuilder.plugins[RokuBuilder.plugins.index{|p| p.to_s == @config.project[:staging_plugin]}].new(config: @config)
end
end

def switch_directory
Dir.chdir(@root_dir) unless @root_dir.nil? or @root_dir == @orginal_directory
end
Expand Down
2 changes: 1 addition & 1 deletion lib/roku_builder/version.rb
Expand Up @@ -2,5 +2,5 @@

module RokuBuilder
# Version of the RokuBuilder Gem
VERSION = "4.13.0"
VERSION = "4.14.0"
end
7 changes: 7 additions & 0 deletions test/roku_builder/test_config_validator.rb
Expand Up @@ -223,5 +223,12 @@ def test_config_manager_validate_project_stage_method_missing
validator = ConfigValidator.new(config: config)
assert_equal [23], validator.instance_variable_get(:@codes)
end

def test_config_manager_validate_project_missing_plugin
config = good_config
config[:projects][:project2][:stage_method] = :plugin
validator = ConfigValidator.new(config: config)
assert_equal [12], validator.instance_variable_get(:@codes)
end
end
end

0 comments on commit f341c49

Please sign in to comment.