heroku_san 4.2.1 → 4.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/heroku_san/configuration.rb +2 -1
- data/lib/heroku_san/parser.rb +8 -7
- data/lib/heroku_san/project.rb +13 -8
- data/lib/heroku_san/version.rb +1 -1
- data/spec/heroku_san/parser_spec.rb +14 -14
- data/spec/heroku_san/project_spec.rb +9 -3
- data/spec/support/mocks.rb +1 -1
- metadata +4 -4
@@ -2,6 +2,7 @@ module HerokuSan
|
|
2
2
|
class Configuration
|
3
3
|
attr_reader :config_file
|
4
4
|
attr_accessor :configuration
|
5
|
+
attr_accessor :external_configuration
|
5
6
|
attr_reader :options
|
6
7
|
|
7
8
|
def initialize(configurable)
|
@@ -42,4 +43,4 @@ module HerokuSan
|
|
42
43
|
end
|
43
44
|
end
|
44
45
|
end
|
45
|
-
end
|
46
|
+
end
|
data/lib/heroku_san/parser.rb
CHANGED
@@ -6,8 +6,9 @@ module HerokuSan
|
|
6
6
|
@settings = parse_yaml(parseable.config_file)
|
7
7
|
convert_from_heroku_san_format
|
8
8
|
each_setting_has_a_config_section
|
9
|
-
|
9
|
+
parseable.external_configuration = @settings.delete 'config_repo'
|
10
10
|
parseable.configuration = @settings
|
11
|
+
|
11
12
|
end
|
12
13
|
|
13
14
|
def convert_from_heroku_san_format
|
@@ -23,15 +24,15 @@ module HerokuSan
|
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
26
|
-
def merge_external_config
|
27
|
-
extra_config = parse_external_config(
|
27
|
+
def merge_external_config!(parseable, stages)
|
28
|
+
extra_config = parse_external_config!(parseable.external_configuration)
|
28
29
|
return unless extra_config
|
29
|
-
|
30
|
-
|
30
|
+
stages.each do |stage|
|
31
|
+
stage.config.merge!(extra_config[stage.name]) if extra_config[stage.name]
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
34
|
-
def parse_external_config(config_repo)
|
35
|
+
def parse_external_config!(config_repo)
|
35
36
|
return if config_repo.nil?
|
36
37
|
require 'tmpdir'
|
37
38
|
Dir.mktmpdir do |dir|
|
@@ -54,4 +55,4 @@ module HerokuSan
|
|
54
55
|
end
|
55
56
|
end
|
56
57
|
end
|
57
|
-
end
|
58
|
+
end
|
data/lib/heroku_san/project.rb
CHANGED
@@ -11,8 +11,12 @@ module HerokuSan
|
|
11
11
|
@apps = []
|
12
12
|
end
|
13
13
|
|
14
|
+
def stages
|
15
|
+
@stages ||= configuration.stages
|
16
|
+
end
|
17
|
+
|
14
18
|
def configuration
|
15
|
-
@configuration ||= HerokuSan::Configuration.new(self)
|
19
|
+
@configuration ||= HerokuSan::Configuration.new(self)
|
16
20
|
end
|
17
21
|
|
18
22
|
def create_config
|
@@ -20,20 +24,20 @@ module HerokuSan
|
|
20
24
|
end
|
21
25
|
|
22
26
|
def all
|
23
|
-
|
27
|
+
stages.keys
|
24
28
|
end
|
25
|
-
|
29
|
+
|
26
30
|
def [](stage)
|
27
|
-
|
31
|
+
stages[stage]
|
28
32
|
end
|
29
|
-
|
33
|
+
|
30
34
|
def <<(*app)
|
31
35
|
app.flatten.each do |a|
|
32
36
|
@apps << a if all.include?(a)
|
33
37
|
end
|
34
38
|
self
|
35
39
|
end
|
36
|
-
|
40
|
+
|
37
41
|
def apps
|
38
42
|
if @apps && !@apps.empty?
|
39
43
|
@apps
|
@@ -43,15 +47,16 @@ module HerokuSan
|
|
43
47
|
all
|
44
48
|
else
|
45
49
|
active_branch = self.git_active_branch
|
46
|
-
all.select do |app|
|
50
|
+
all.select do |app|
|
47
51
|
app == active_branch and ($stdout.puts("Defaulting to '#{app}' as it matches the current branch"); true)
|
48
52
|
end
|
49
53
|
end
|
50
54
|
end
|
51
55
|
end
|
52
|
-
|
56
|
+
|
53
57
|
def each_app
|
54
58
|
raise NoApps if apps.empty?
|
59
|
+
HerokuSan::Parser.new.merge_external_config!(configuration, stages.values)
|
55
60
|
apps.each do |stage|
|
56
61
|
yield self[stage]
|
57
62
|
end
|
data/lib/heroku_san/version.rb
CHANGED
@@ -53,36 +53,36 @@ describe HerokuSan::Parser do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
describe "#merge_external_config" do
|
56
|
+
let(:stages) { [stub(name: 'production', config: prod_config), stub(name: 'staging', config: staging_config)] }
|
57
|
+
let(:prod_config) { mock('Production Config') }
|
58
|
+
let(:staging_config) { {'EXTRA' => 'bar'} }
|
56
59
|
let(:extras) { {'production' => {'EXTRA' => 'bar'}, 'staging' => {'EXTRA' => 'foo'}} }
|
57
60
|
|
58
61
|
context "with no extras" do
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
62
|
+
let(:parseable) { stub external_configuration: nil }
|
63
|
+
|
64
|
+
it "doesn't change prod_config" do
|
65
|
+
prod_config.should_not_receive :merge!
|
66
|
+
parser.merge_external_config! parseable, stages
|
64
67
|
end
|
65
68
|
end
|
66
69
|
|
67
70
|
context "with extra" do
|
71
|
+
let(:parseable) { stub external_configuration: 'config_repos' }
|
68
72
|
before(:each) do
|
69
73
|
parser.should_receive(:git_clone).with('config_repos', anything)
|
70
74
|
parser.should_receive(:parse_yaml).and_return(extras)
|
71
75
|
end
|
72
76
|
|
73
77
|
it "merges extra configuration bits" do
|
74
|
-
|
75
|
-
|
76
|
-
parser.merge_external_config
|
77
|
-
}.to change(parser, :settings).to({"production" => {"config" => {"EXTRA" => "bar"}}})
|
78
|
+
prod_config.should_receive(:merge!).with extras['production']
|
79
|
+
parser.merge_external_config! parseable, [stages.first]
|
78
80
|
end
|
79
81
|
|
80
82
|
it "overrides the main configuration" do
|
81
|
-
parser.
|
82
|
-
|
83
|
-
parser.merge_external_config
|
84
|
-
}.to change(parser, :settings).to({"staging" => {"config" => {"EXTRA" => "foo"}}})
|
83
|
+
parser.merge_external_config! parseable, [stages.last]
|
84
|
+
staging_config.should == {"EXTRA" => "foo"}
|
85
85
|
end
|
86
86
|
end
|
87
87
|
end
|
88
|
-
end
|
88
|
+
end
|
@@ -7,7 +7,7 @@ describe HerokuSan::Project do
|
|
7
7
|
before do
|
8
8
|
HerokuSan::Configuration.new(Configurable.new).tap do |config|
|
9
9
|
config.configuration = {'production' => {}, 'staging' => {}, 'demo' => {}}
|
10
|
-
heroku_san.configuration = config
|
10
|
+
heroku_san.configuration = config
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -42,8 +42,14 @@ describe HerokuSan::Project do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
context "with only a single configured app" do
|
45
|
+
before do
|
46
|
+
HerokuSan::Configuration.new(Configurable.new).tap do |config|
|
47
|
+
config.configuration = {'production' => {}}
|
48
|
+
heroku_san.configuration = config
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
45
52
|
it "returns the app" do
|
46
|
-
heroku_san.configuration= {'production' => {}}
|
47
53
|
$stdout.should_receive(:puts).with('Defaulting to "production" since only one app is defined')
|
48
54
|
expect {
|
49
55
|
heroku_san.apps.should == %w[production]
|
@@ -75,4 +81,4 @@ describe HerokuSan::Project do
|
|
75
81
|
end
|
76
82
|
end
|
77
83
|
end
|
78
|
-
end
|
84
|
+
end
|
data/spec/support/mocks.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
Configurable = Struct.new(:config_file, :configuration, :options)
|
2
|
-
Parseable = Struct.new(:config_file, :configuration)
|
2
|
+
Parseable = Struct.new(:config_file, :configuration, :external_configuration)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: heroku_san
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.2.
|
4
|
+
version: 4.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2013-02-
|
15
|
+
date: 2013-02-09 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: heroku-api
|
@@ -245,7 +245,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
245
245
|
version: '0'
|
246
246
|
segments:
|
247
247
|
- 0
|
248
|
-
hash:
|
248
|
+
hash: 68468035742296088
|
249
249
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
250
250
|
none: false
|
251
251
|
requirements:
|
@@ -254,7 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
254
254
|
version: '0'
|
255
255
|
requirements: []
|
256
256
|
rubyforge_project:
|
257
|
-
rubygems_version: 1.8.
|
257
|
+
rubygems_version: 1.8.23
|
258
258
|
signing_key:
|
259
259
|
specification_version: 3
|
260
260
|
summary: ! 'A bunch of useful Rake tasks for managing your Heroku apps. NOTE: The
|