make sure git repo discovery digs into any environment [ice cream]

This commit is contained in:
John Bintz 2012-06-21 15:25:46 -04:00
parent dfbe5a7ccf
commit 3fc02e9180
2 changed files with 22 additions and 4 deletions

View File

@ -182,6 +182,18 @@ Feature: Gemfiles
Then I should get the following repositories: Then I should get the following repositories:
| git://github.cats/two.git | | git://github.cats/two.git |
Scenario: Get the list of git repos defined, regardless of environment
Given I have the file "Gemfile.penchant" with the content:
"""
gem 'one', :path => '../%s'
env :remote do
gem 'two', :git => 'git://github.cats/%s.git'
end
"""
When I request the list of git repositories
Then I should get the following repositories:
| git://github.cats/two.git |
Scenario: Propose defaults for a gem Scenario: Propose defaults for a gem
Given I have the file "Gemfile.penchant" with the content: Given I have the file "Gemfile.penchant" with the content:
""" """

View File

@ -102,6 +102,8 @@ module Penchant
class FileProcessor class FileProcessor
attr_reader :environment, :is_deployment, :available_environments, :defined_git_repos attr_reader :environment, :is_deployment, :available_environments, :defined_git_repos
ANY_ENVIRONMENT = :any_environment
def self.result(data, *args) def self.result(data, *args)
new(data).result(*args) new(data).result(*args)
end end
@ -138,7 +140,7 @@ module Penchant
@available_environments += args @available_environments += args
if block_given? if block_given?
if args.include?(environment) if for_environment?(args)
@_current_env_defaults = _defaults_for(Env.new(environment)) @_current_env_defaults = _defaults_for(Env.new(environment))
yield yield
@_current_env_defaults = {} @_current_env_defaults = {}
@ -148,6 +150,10 @@ module Penchant
end end
end end
def for_environment?(envs)
envs.include?(environment) || environment == ANY_ENVIRONMENT
end
def no_deployment def no_deployment
yield if !is_deployment yield if !is_deployment
end end
@ -330,7 +336,7 @@ module Penchant
end end
def defined_git_repos def defined_git_repos
process process(FileProcessor::ANY_ENVIRONMENT)
builder.defined_git_repos builder.defined_git_repos
end end
@ -369,8 +375,8 @@ module Penchant
File.join(@path, file) File.join(@path, file)
end end
def process def process(env = @env)
builder.result(@env, @is_deployment) builder.result(env, @is_deployment)
end end
def builder def builder