lib/rake/funnel/tasks/environments.rb in rake-funnel-0.18.0 vs lib/rake/funnel/tasks/environments.rb in rake-funnel-0.19.0
- old
+ new
@@ -14,20 +14,21 @@
define(args, &task_block)
end
private
+
def setup_ivars(_args)
@store = configatron
@default_env = nil
@default_config = 'default'
@local_config = 'local'
@base_dir = 'config'
end
def define(args, &task_block)
- task_block.call(*[self].slice(0, task_block.arity)) if task_block
+ yield(*[self].slice(0, task_block.arity)) if task_block
environments.each do |env|
desc "Configure for the #{env[:name]} environment"
task(env[:name], *args) do |_, _task_args|
@@ -36,11 +37,11 @@
end
default_environment_setup
end
- def environments
+ def environments # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
default = File.join(base_dir, config_ext(default_config))
local = File.join(base_dir, config_ext(local_config))
Dir[File.join(base_dir, config_ext('*'))]
.reject { |config| config == default || config == local }
@@ -58,30 +59,33 @@
def config_ext(name)
"#{name}.yaml"
end
- def default_environment_setup
+ def default_environment_setup # rubocop:disable Metrics/MethodLength
return unless default_env
- top_level_envs = top_level_env_tasks
- if top_level_envs.empty?
+ envs = top_level_env_tasks
+ if envs.empty?
task = Rake.application.current_scope.path_with_task_name(default_env)
prepend_task(task)
else
- top_level_envs.each do |task|
- Rake.application.top_level_tasks.delete(task)
- prepend_task(task)
+ envs.each do |env|
+ Rake.application.top_level_tasks.delete(env)
+ prepend_task(env)
end
end
end
def prepend_task(task)
Rake.application.top_level_tasks.unshift(task)
end
def top_level_env_tasks
- expect_user_defined = environments.map { |env| Rake.application.current_scope.path_with_task_name(env[:name]) }
+ expect_user_defined = environments.map do |env|
+ Rake.application.current_scope.path_with_task_name(env[:name])
+ end
+
Rake.application.top_level_tasks.select { |t| expect_user_defined.include?(t) }
end
end
end
end