rconf 0.5.6 → 0.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/rconf.rb +1 -0
- data/lib/rconf/configurator.rb +17 -1
- data/lib/rconf/configurators/bundler_configurator.rb +1 -2
- data/lib/rconf/profile.rb +80 -0
- data/lib/rconf/version.rb +1 -1
- data/spec/configurator_spec.rb +15 -0
- data/spec/profile_spec.rb +24 -0
- metadata +26 -4
data/lib/rconf.rb
CHANGED
@@ -19,6 +19,7 @@ require File.join(BASE_DIR, 'configurator_registry')
|
|
19
19
|
require File.join(BASE_DIR, 'configurator')
|
20
20
|
require File.join(BASE_DIR, 'language')
|
21
21
|
require File.join(BASE_DIR, 'platform')
|
22
|
+
require File.join(BASE_DIR, 'profile')
|
22
23
|
require File.join(BASE_DIR, 'trollop')
|
23
24
|
require File.join(BASE_DIR, 'version')
|
24
25
|
|
data/lib/rconf/configurator.rb
CHANGED
@@ -9,6 +9,8 @@
|
|
9
9
|
# License Agreement between RightScale.com, Inc. and
|
10
10
|
# the licensee
|
11
11
|
|
12
|
+
require 'digest/sha1'
|
13
|
+
|
12
14
|
module RightConf
|
13
15
|
|
14
16
|
# Configurator mixin, defines DSL and common validation method
|
@@ -118,10 +120,24 @@ module RightConf
|
|
118
120
|
# true:: Always return true
|
119
121
|
def run(*args)
|
120
122
|
init
|
121
|
-
|
123
|
+
sha = Profile.configurator_signature(self.class.key)
|
124
|
+
if sha != signature
|
125
|
+
Platform.dispatch(*args) { :run }
|
126
|
+
Profile.set_configurator_signature(self.class.key, signature)
|
127
|
+
end
|
122
128
|
true
|
123
129
|
end
|
124
130
|
|
131
|
+
# Calculate unique SHA for current settings
|
132
|
+
#
|
133
|
+
# === Return
|
134
|
+
# sha(String):: SHA for current settings
|
135
|
+
def signature
|
136
|
+
return '' if @settings_values.nil?
|
137
|
+
blob = @settings_values.inject('') { |b, (k, v)| b += "#{k}:#{v};" }
|
138
|
+
sha = Digest::SHA1.hexdigest(blob)
|
139
|
+
end
|
140
|
+
|
125
141
|
# Get value of configuration option
|
126
142
|
#
|
127
143
|
# === Parameters
|
@@ -65,8 +65,7 @@ module RightConf
|
|
65
65
|
exists = res.success? && res.output !~ /exec: bundle: not found/
|
66
66
|
if exists
|
67
67
|
report_check('Uninstalling existing versions of bundler')
|
68
|
-
|
69
|
-
:abort_on_failure => 'Failed to uninstall bundler')
|
68
|
+
Command.execute('gem', 'uninstall', 'bundler', '-a', '-x')
|
70
69
|
report_success
|
71
70
|
end
|
72
71
|
report_check("Installing bundler #{version}")
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# Copyright (C) 2011 RightScale, Inc, All Rights Reserved Worldwide.
|
2
|
+
#
|
3
|
+
# THIS PROGRAM IS CONFIDENTIAL AND PROPRIETARY TO RIGHTSCALE
|
4
|
+
# AND CONSTITUTES A VALUABLE TRADE SECRET. Any unauthorized use,
|
5
|
+
# reproduction, modification, or disclosure of this program is
|
6
|
+
# strictly prohibited. Any use of this program by an authorized
|
7
|
+
# licensee is strictly subject to the terms and conditions,
|
8
|
+
# including confidentiality obligations, set forth in the applicable
|
9
|
+
# License Agreement between RightScale.com, Inc. and
|
10
|
+
# the licensee
|
11
|
+
|
12
|
+
module RightConf
|
13
|
+
|
14
|
+
class Profile
|
15
|
+
|
16
|
+
include Singleton
|
17
|
+
|
18
|
+
# Load profile from disk on instantiation
|
19
|
+
def initialize
|
20
|
+
if File.exist?(profile_path)
|
21
|
+
@profile = YAML.load(IO.read(profile_path)) rescue {}
|
22
|
+
puts "LOADED PROFILE: #{@profile}"
|
23
|
+
else
|
24
|
+
@profile = {}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Retrieve persisted configurator signature
|
29
|
+
#
|
30
|
+
# === Return
|
31
|
+
# signature(String):: Persisted configurator signature
|
32
|
+
def configurator_signature(key)
|
33
|
+
sigs = @profile[:configurator_signatures]
|
34
|
+
signature = sigs && sigs[key]
|
35
|
+
end
|
36
|
+
|
37
|
+
# Set signature for given configurator
|
38
|
+
#
|
39
|
+
# === Parameters
|
40
|
+
# key(String):: Configurator key
|
41
|
+
# signature(String):: Persisted configurator signature
|
42
|
+
#
|
43
|
+
# === Return
|
44
|
+
# true:: Always return true
|
45
|
+
def set_configurator_signature(key, signature)
|
46
|
+
@profile[:configurator_signatures] ||= {}
|
47
|
+
@profile[:configurator_signatures][key] = signature
|
48
|
+
persist
|
49
|
+
true
|
50
|
+
end
|
51
|
+
|
52
|
+
# Entire profile with all settings
|
53
|
+
#
|
54
|
+
# === Return
|
55
|
+
# profile(Hash):: Profile settings
|
56
|
+
def profile
|
57
|
+
@profile
|
58
|
+
end
|
59
|
+
|
60
|
+
protected
|
61
|
+
|
62
|
+
# Retrieve profile file path
|
63
|
+
#
|
64
|
+
# === Return
|
65
|
+
# path(String):: Profile file path
|
66
|
+
def profile_path
|
67
|
+
profile_path = ENV['RCONF_PROFILE'] || File.join(ENV['HOME'], '.rconf')
|
68
|
+
end
|
69
|
+
|
70
|
+
# Persist profile to file
|
71
|
+
#
|
72
|
+
# === Return
|
73
|
+
# true:: Always return true
|
74
|
+
def persist
|
75
|
+
File.open(profile_path, 'w') { |f| f.puts YAML.dump(@profile) } unless @profile.nil?
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
data/lib/rconf/version.rb
CHANGED
data/spec/configurator_spec.rb
CHANGED
@@ -21,6 +21,9 @@ describe RightConf::Configurator do
|
|
21
21
|
def test_setter(value)
|
22
22
|
@custom_setting = value
|
23
23
|
end
|
24
|
+
def run_darwin; end
|
25
|
+
alias :run_linux :run_darwin
|
26
|
+
alias :run_windows :run_darwin
|
24
27
|
end
|
25
28
|
|
26
29
|
class AnotherConfigurator
|
@@ -58,6 +61,18 @@ describe RightConf::Configurator do
|
|
58
61
|
@configurator.validate.should be_nil
|
59
62
|
end
|
60
63
|
|
64
|
+
it 'should persist the signature of configurators that ran' do
|
65
|
+
flexmock(RightConf::Profile.instance).should_receive(:set_configurator_signature).once
|
66
|
+
@configurator.run
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should skip configurators that have already run' do
|
70
|
+
flexmock(RightConf::Profile.instance).should_receive(:configurator_signature).with(:test).and_return('42')
|
71
|
+
flexmock(@configurator).should_receive(:signature).and_return('42')
|
72
|
+
flexmock(RightConf::Platform.instance).should_receive(:dispatch).never
|
73
|
+
@configurator.run
|
74
|
+
end
|
75
|
+
|
61
76
|
end
|
62
77
|
|
63
78
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Copyright (C) 2011 RightScale, Inc, All Rights Reserved Worldwide.
|
2
|
+
#
|
3
|
+
# THIS PROGRAM IS CONFIDENTIAL AND PROPRIETARY TO RIGHTSCALE
|
4
|
+
# AND CONSTITUTES A VALUABLE TRADE SECRET. Any unauthorized use,
|
5
|
+
# reproduction, modification, or disclosure of this program is
|
6
|
+
# strictly prohibited. Any use of this program by an authorized
|
7
|
+
# licensee is strictly subject to the terms and conditions,
|
8
|
+
# including confidentiality obligations, set forth in the applicable
|
9
|
+
# License Agreement between RightScale.com, Inc. and
|
10
|
+
# the licensee
|
11
|
+
|
12
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
13
|
+
|
14
|
+
describe RightConf::Profile do
|
15
|
+
|
16
|
+
it 'should save profile to disk when changing values' do
|
17
|
+
flexmock(RightConf::Profile.instance).should_receive(:persist).once
|
18
|
+
RightConf::Profile.set_configurator_signature(:test, '42')
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
metadata
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rconf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 5
|
9
|
+
- 8
|
10
|
+
version: 0.5.8
|
6
11
|
platform: ruby
|
7
12
|
authors:
|
8
13
|
- Raphael Simon
|
@@ -10,7 +15,7 @@ autorequire:
|
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
17
|
|
13
|
-
date: 2011-03-
|
18
|
+
date: 2011-03-07 00:00:00 -08:00
|
14
19
|
default_executable:
|
15
20
|
dependencies:
|
16
21
|
- !ruby/object:Gem::Dependency
|
@@ -21,6 +26,10 @@ dependencies:
|
|
21
26
|
requirements:
|
22
27
|
- - ~>
|
23
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 9
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 5
|
24
33
|
version: "2.5"
|
25
34
|
type: :development
|
26
35
|
version_requirements: *id001
|
@@ -32,6 +41,10 @@ dependencies:
|
|
32
41
|
requirements:
|
33
42
|
- - ~>
|
34
43
|
- !ruby/object:Gem::Version
|
44
|
+
hash: 25
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
- 9
|
35
48
|
version: "0.9"
|
36
49
|
type: :development
|
37
50
|
version_requirements: *id002
|
@@ -70,6 +83,7 @@ files:
|
|
70
83
|
- lib/rconf/platforms/darwin.rb
|
71
84
|
- lib/rconf/platforms/linux.rb
|
72
85
|
- lib/rconf/platforms/windows.rb
|
86
|
+
- lib/rconf/profile.rb
|
73
87
|
- lib/rconf/progress_reporter.rb
|
74
88
|
- lib/rconf/progress_reporters/base_reporter.rb
|
75
89
|
- lib/rconf/progress_reporters/file_reporter.rb
|
@@ -85,6 +99,7 @@ files:
|
|
85
99
|
- spec/configurators/ruby_configurator_spec.rb
|
86
100
|
- spec/language_spec.rb
|
87
101
|
- spec/platform_spec.rb
|
102
|
+
- spec/profile_spec.rb
|
88
103
|
- spec/progress_reporters/base_reporter_spec.rb
|
89
104
|
- spec/progress_reporters/file_reporter_spec.rb
|
90
105
|
- spec/progress_reporters/stdout_reporter_spec.rb
|
@@ -104,17 +119,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
104
119
|
requirements:
|
105
120
|
- - ">="
|
106
121
|
- !ruby/object:Gem::Version
|
122
|
+
hash: 3
|
123
|
+
segments:
|
124
|
+
- 0
|
107
125
|
version: "0"
|
108
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
127
|
none: false
|
110
128
|
requirements:
|
111
129
|
- - ">="
|
112
130
|
- !ruby/object:Gem::Version
|
131
|
+
hash: 3
|
132
|
+
segments:
|
133
|
+
- 0
|
113
134
|
version: "0"
|
114
135
|
requirements: []
|
115
136
|
|
116
137
|
rubyforge_project: rconf
|
117
|
-
rubygems_version: 1.
|
138
|
+
rubygems_version: 1.3.7
|
118
139
|
signing_key:
|
119
140
|
specification_version: 3
|
120
141
|
summary: Cross platform environment configuration
|
@@ -126,6 +147,7 @@ test_files:
|
|
126
147
|
- spec/configurators/ruby_configurator_spec.rb
|
127
148
|
- spec/language_spec.rb
|
128
149
|
- spec/platform_spec.rb
|
150
|
+
- spec/profile_spec.rb
|
129
151
|
- spec/progress_reporters/base_reporter_spec.rb
|
130
152
|
- spec/progress_reporters/file_reporter_spec.rb
|
131
153
|
- spec/progress_reporters/stdout_reporter_spec.rb
|