librarian 0.0.23 → 0.0.24

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,319 @@
1
+ require "fileutils"
2
+ require "pathname"
3
+ require "yaml"
4
+
5
+ require "fakefs/spec_helpers"
6
+
7
+ require "librarian/config/database"
8
+
9
+ describe Librarian::Config::Database do
10
+ include FakeFS::SpecHelpers
11
+
12
+ def write_yaml!(path, *yamlables)
13
+ dir = File.dirname(path)
14
+ FileUtils.mkpath(dir) unless File.directory?(dir)
15
+ File.open(path, "wb"){|f| yamlables.each{|y| YAML.dump(y, f)}}
16
+ end
17
+
18
+ let(:adapter_name) { "gem" }
19
+
20
+ let(:env) { { } }
21
+ let(:pwd) { Pathname("/tmp") }
22
+ let(:home) { Pathname("~").expand_path }
23
+ let(:project_path) { nil }
24
+ let(:specfile_name) { nil }
25
+ let(:global) { home.join(".librarian/gem/config") }
26
+ let(:local) { pwd.join(".librarian/gem/config") }
27
+ let(:specfile) { pwd.join("Gemfile") }
28
+
29
+ before do
30
+ FileUtils.mkpath(pwd)
31
+ FileUtils.touch(specfile)
32
+ end
33
+
34
+ let(:database) do
35
+ described_class.new(adapter_name,
36
+ :env => env,
37
+ :pwd => pwd.to_s,
38
+ :home => home.to_s,
39
+ :project_path => project_path,
40
+ :specfile_name => specfile_name
41
+ )
42
+ end
43
+
44
+ context "when a key is given globally" do
45
+ let(:key) { "jam" }
46
+ let(:value) { "jelly" }
47
+ let(:raw_key) { "LIBRARIAN_GEM_JAM" }
48
+
49
+ before do
50
+ write_yaml! global, raw_key => value
51
+ end
52
+
53
+ it "should have the key globally" do
54
+ database.global[key].should == value
55
+ end
56
+
57
+ it "should not have the key in the env" do
58
+ database.env[key].should be_nil
59
+ end
60
+
61
+ it "should not have the key locally" do
62
+ database.local[key].should be_nil
63
+ end
64
+
65
+ it "should have the key generally" do
66
+ database[key].should == value
67
+ end
68
+ end
69
+
70
+ context "when a key is set globally" do
71
+ let(:key) { "jam" }
72
+ let(:value) { "jelly" }
73
+ let(:raw_key) { "LIBRARIAN_GEM_JAM" }
74
+
75
+ before do
76
+ database.global[key] = value
77
+ end
78
+
79
+ it "should have the key globally" do
80
+ database.global[key].should == value
81
+ end
82
+
83
+ it "should not have the key in the env" do
84
+ database.env[key].should be_nil
85
+ end
86
+
87
+ it "should not have the key locally" do
88
+ database.local[key].should be_nil
89
+ end
90
+
91
+ it "should have the key generally" do
92
+ database[key].should == value
93
+ end
94
+
95
+ it "should persist the key" do
96
+ data = YAML.load_file(global)
97
+
98
+ data.should == {raw_key => value}
99
+ end
100
+ end
101
+
102
+ context "when the key is set and unset globally" do
103
+ let(:key) { "jam" }
104
+ let(:value) { "jelly" }
105
+ let(:raw_key) { "LIBRARIAN_GEM_JAM" }
106
+
107
+ before do
108
+ database.global[key] = value
109
+ database.global[key] = nil
110
+ end
111
+
112
+ it "should not have the key globally" do
113
+ database.global[key].should be_nil
114
+ end
115
+
116
+ it "should not have the key in the env" do
117
+ database.env[key].should be_nil
118
+ end
119
+
120
+ it "should not have the key locally" do
121
+ database.local[key].should be_nil
122
+ end
123
+
124
+ it "should not have the key generally" do
125
+ database[key].should be_nil
126
+ end
127
+
128
+ it "should unpersist the key" do
129
+ File.should_not exist global
130
+ end
131
+ end
132
+
133
+ context "when a key is given in the env" do
134
+ let(:key) { "jam" }
135
+ let(:value) { "jelly" }
136
+ let(:raw_key) { "LIBRARIAN_GEM_JAM" }
137
+
138
+ #override
139
+ let(:env) { {raw_key => value} }
140
+
141
+ it "should not have the key globally" do
142
+ database.global[key].should be_nil
143
+ end
144
+
145
+ it "should have the key in the env" do
146
+ database.env[key].should == value
147
+ end
148
+
149
+ it "should not have the key locally" do
150
+ database.local[key].should be_nil
151
+ end
152
+
153
+ it "should have the key generally" do
154
+ database[key].should == value
155
+ end
156
+ end
157
+
158
+ context "when a key is given locally" do
159
+ let(:key) { "jam" }
160
+ let(:value) { "jelly" }
161
+ let(:raw_key) { "LIBRARIAN_GEM_JAM" }
162
+
163
+ before do
164
+ write_yaml! local, raw_key => value
165
+ end
166
+
167
+ it "should not have the key globally" do
168
+ database.global[key].should be_nil
169
+ end
170
+
171
+ it "should not have the key in the env" do
172
+ database.env[key].should be_nil
173
+ end
174
+
175
+ it "should have the key locally" do
176
+ database.local[key].should == value
177
+ end
178
+
179
+ it "should have the key generally" do
180
+ database[key].should == value
181
+ end
182
+ end
183
+
184
+ context "when a key is set locally" do
185
+ let(:key) { "jam" }
186
+ let(:value) { "jelly" }
187
+ let(:raw_key) { "LIBRARIAN_GEM_JAM" }
188
+
189
+ before do
190
+ database.local[key] = value
191
+ end
192
+
193
+ it "should not have the key globally" do
194
+ database.global[key].should be_nil
195
+ end
196
+
197
+ it "should not have the key in the env" do
198
+ database.env[key].should be_nil
199
+ end
200
+
201
+ it "should have the key locally" do
202
+ database.local[key].should == value
203
+ end
204
+
205
+ it "should have the key generally" do
206
+ database[key].should == value
207
+ end
208
+
209
+ it "should persist the key" do
210
+ data = YAML.load_file(local)
211
+
212
+ data.should == {raw_key => value}
213
+ end
214
+ end
215
+
216
+ context "when the key is set and unset locally" do
217
+ let(:key) { "jam" }
218
+ let(:value) { "jelly" }
219
+ let(:raw_key) { "LIBRARIAN_GEM_JAM" }
220
+
221
+ before do
222
+ database.local[key] = value
223
+ database.local[key] = nil
224
+ end
225
+
226
+ it "should not have the key globally" do
227
+ database.global[key].should be_nil
228
+ end
229
+
230
+ it "should not have the key in the env" do
231
+ database.env[key].should be_nil
232
+ end
233
+
234
+ it "should not have the key locally" do
235
+ database.local[key].should be_nil
236
+ end
237
+
238
+ it "should not have the key generally" do
239
+ database[key].should be_nil
240
+ end
241
+
242
+ it "should unpersist the key" do
243
+ File.should_not exist local
244
+ end
245
+ end
246
+
247
+ context "setting malformatted keys" do
248
+ it "should ban caps" do
249
+ expect { database.global["JAM"] = "jelly" }.
250
+ to raise_error Librarian::Error, %[key not permitted: "JAM"]
251
+ end
252
+
253
+ it "should ban double dots" do
254
+ expect { database.global["jam..jam"] = "jelly" }.
255
+ to raise_error Librarian::Error, %[key not permitted: "jam..jam"]
256
+ end
257
+ end
258
+
259
+ context "setting banned keys" do
260
+ it "should ban the specfile key" do
261
+ expect { database.global["gemfile"] = "jelly" }.
262
+ to raise_error Librarian::Error, %[key not permitted: "gemfile"]
263
+ end
264
+
265
+ it "should ban the global-config key" do
266
+ expect { database.global["config"] = "jelly" }.
267
+ to raise_error Librarian::Error, %[key not permitted: "config"]
268
+ end
269
+ end
270
+
271
+ context "project_path" do
272
+ context "by default" do
273
+ it "should give the default project path" do
274
+ database.project_path.should == Pathname("/tmp")
275
+ end
276
+ end
277
+
278
+ context "when the specfile is set in the env" do
279
+ let(:env) { {"LIBRARIAN_GEM_GEMFILE" => "/non/sense/path/to/Sillyfile"} }
280
+
281
+ it "should give the project path from the env-set specfile" do
282
+ database.project_path.should == Pathname("/non/sense/path/to")
283
+ end
284
+ end
285
+ end
286
+
287
+ context "specfile_path" do
288
+ context "by default" do
289
+ it "should give the default specfile path" do
290
+ database.specfile_path.should == specfile
291
+ end
292
+ end
293
+
294
+ context "when set in the env" do
295
+ let(:env) { {"LIBRARIAN_GEM_GEMFILE" => "/non/sense/path/to/Sillyfile"} }
296
+
297
+ it "should give the given specfile path" do
298
+ database.specfile_path.should == Pathname("/non/sense/path/to/Sillyfile")
299
+ end
300
+ end
301
+
302
+ context "when the project_path is assigned" do
303
+ let(:project_path) { "/non/sense/path/to" }
304
+
305
+ it "should give the assigned specfile path" do
306
+ database.specfile_path.should == Pathname("/non/sense/path/to/Gemfile")
307
+ end
308
+ end
309
+
310
+ context "when the specfile_name is assigned" do
311
+ let(:specfile_name) { "Sillyfile" }
312
+
313
+ it "should give the assigned specfile path" do
314
+ database.specfile_path.should == Pathname("/tmp/Sillyfile")
315
+ end
316
+ end
317
+ end
318
+
319
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: librarian
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.23
4
+ version: 0.0.24
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-14 00:00:00.000000000 Z
12
+ date: 2012-06-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
16
- requirement: &9010000 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0.15'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *9010000
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '0.15'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rake
27
- requirement: &9008640 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0'
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *9008640
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: rspec
38
- requirement: &9006600 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: '0'
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *9006600
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: cucumber
49
- requirement: &9004980 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: '0'
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *9004980
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: aruba
60
- requirement: &9003760 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ! '>='
@@ -65,10 +85,31 @@ dependencies:
65
85
  version: '0'
66
86
  type: :development
67
87
  prerelease: false
68
- version_requirements: *9003760
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
69
94
  - !ruby/object:Gem::Dependency
70
95
  name: webmock
71
- requirement: &8997140 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: fakefs
112
+ requirement: !ruby/object:Gem::Requirement
72
113
  none: false
73
114
  requirements:
74
115
  - - ! '>='
@@ -76,10 +117,15 @@ dependencies:
76
117
  version: '0'
77
118
  type: :development
78
119
  prerelease: false
79
- version_requirements: *8997140
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
80
126
  - !ruby/object:Gem::Dependency
81
127
  name: chef
82
- requirement: &8956960 !ruby/object:Gem::Requirement
128
+ requirement: !ruby/object:Gem::Requirement
83
129
  none: false
84
130
  requirements:
85
131
  - - ! '>='
@@ -87,10 +133,15 @@ dependencies:
87
133
  version: '0.10'
88
134
  type: :runtime
89
135
  prerelease: false
90
- version_requirements: *8956960
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0.10'
91
142
  - !ruby/object:Gem::Dependency
92
143
  name: highline
93
- requirement: &8951000 !ruby/object:Gem::Requirement
144
+ requirement: !ruby/object:Gem::Requirement
94
145
  none: false
95
146
  requirements:
96
147
  - - ! '>='
@@ -98,10 +149,15 @@ dependencies:
98
149
  version: '0'
99
150
  type: :runtime
100
151
  prerelease: false
101
- version_requirements: *8951000
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
102
158
  - !ruby/object:Gem::Dependency
103
159
  name: archive-tar-minitar
104
- requirement: &8947440 !ruby/object:Gem::Requirement
160
+ requirement: !ruby/object:Gem::Requirement
105
161
  none: false
106
162
  requirements:
107
163
  - - ! '>='
@@ -109,7 +165,12 @@ dependencies:
109
165
  version: 0.5.2
110
166
  type: :runtime
111
167
  prerelease: false
112
- version_requirements: *8947440
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: 0.5.2
113
174
  description: Librarian
114
175
  email:
115
176
  - y_feldblum@yahoo.com
@@ -158,6 +219,11 @@ files:
158
219
  - lib/librarian/chef/templates/Cheffile
159
220
  - lib/librarian/cli.rb
160
221
  - lib/librarian/cli/manifest_presenter.rb
222
+ - lib/librarian/config.rb
223
+ - lib/librarian/config/database.rb
224
+ - lib/librarian/config/file_source.rb
225
+ - lib/librarian/config/hash_source.rb
226
+ - lib/librarian/config/source.rb
161
227
  - lib/librarian/dependency.rb
162
228
  - lib/librarian/dsl.rb
163
229
  - lib/librarian/dsl/receiver.rb
@@ -196,10 +262,12 @@ files:
196
262
  - librarian.gemspec
197
263
  - spec/functional/chef/source/git_spec.rb
198
264
  - spec/functional/chef/source/site_spec.rb
265
+ - spec/functional/source/git/repository_spec.rb
199
266
  - spec/unit/action/base_spec.rb
200
267
  - spec/unit/action/clean_spec.rb
201
268
  - spec/unit/action/ensure_spec.rb
202
269
  - spec/unit/action/install_spec.rb
270
+ - spec/unit/config/database_spec.rb
203
271
  - spec/unit/dependency_spec.rb
204
272
  - spec/unit/dsl_spec.rb
205
273
  - spec/unit/environment_spec.rb
@@ -223,6 +291,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
223
291
  - - ! '>='
224
292
  - !ruby/object:Gem::Version
225
293
  version: '0'
294
+ segments:
295
+ - 0
296
+ hash: 1740169763066753251
226
297
  required_rubygems_version: !ruby/object:Gem::Requirement
227
298
  none: false
228
299
  requirements:
@@ -231,9 +302,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
231
302
  version: '0'
232
303
  requirements: []
233
304
  rubyforge_project: librarian
234
- rubygems_version: 1.8.17
305
+ rubygems_version: 1.8.24
235
306
  signing_key:
236
307
  specification_version: 3
237
308
  summary: Librarian
238
309
  test_files: []
239
- has_rdoc: