bibliotech 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b318d37e5ba7da280c1a0107535d13a84f4e4829
4
- data.tar.gz: 4d33472936234fe642d3956fd3eecaf90eb1de26
3
+ metadata.gz: b04dc447d4669ffeabae2e9ac1038121ff6f2708
4
+ data.tar.gz: 2d77acb36eee2bca70ad337af529675423a498a0
5
5
  SHA512:
6
- metadata.gz: d34215be4ff08ebcbd3200b078de05667400eac767454931c8d6240128f9990162545cdeae1d83a0601bc5c5beb63ac14f196130fd6cfdc5a7f70fc050d0caf2
7
- data.tar.gz: b20cd62aa59950be169b404345945819123afc7068d61d8dbadb0f89afb3f958f2a8f226ad00b18d97de9bbfe08ecf2787e8de29a3d1e528aab91240e6564f1f
6
+ metadata.gz: 02fff89fe07d885f4982bb14e740baabf6b0f6f2312e9754f6909dca820e7c5a92085f338be0ef93513d9dbfa960080889461e9f23104dc2317df831f67908fe
7
+ data.tar.gz: e025eb2eb129bdfef117968848896a4a249f311986f2779b8d2b9d08c2932daf527161e581f3bdaddef0814a1cdcd257fc9d539e1d3c56a644ad7bae75e0cc25
@@ -14,7 +14,12 @@ module BiblioTech
14
14
  config.optional{ command.env["PGPASSWORD"] = config.password }
15
15
  config.optional{ command.options << "-p #{config.port}" } #ok
16
16
 
17
- command.options << "-U #{config.username}"
17
+ if config.local == "development"
18
+ config.optional{ command.options << "-U #{config.username}" }
19
+ else
20
+ command.options << "-U #{config.username}"
21
+ end
22
+
18
23
  command.options << "#{config.database}"
19
24
  command
20
25
  end
@@ -32,7 +37,12 @@ module BiblioTech
32
37
  config.optional{ command.env["PGPASSWORD"] = config.password }
33
38
  config.optional{ command.options << "-p #{config.port}" } #ok
34
39
 
35
- command.options << "-U #{config.username}"
40
+ if config.local == "development"
41
+ config.optional{ command.options << "-U #{config.username}" }
42
+ else
43
+ command.options << "-U #{config.username}"
44
+ end
45
+
36
46
  command.options << "-d #{config.database}"
37
47
  command
38
48
  end
@@ -254,7 +254,11 @@ module BiblioTech
254
254
  end
255
255
 
256
256
  def database_config
257
- hash["database_config"] ||=
257
+ local_get(:database_config)
258
+ end
259
+
260
+ def app_db_config
261
+ @app_db_config ||=
258
262
  begin
259
263
  db_config = YAML::load(File::read(local_get(:database_config_file)))
260
264
  db_config.fetch(local_get(:database_config_env)) do
@@ -264,6 +268,12 @@ module BiblioTech
264
268
  end
265
269
  end
266
270
 
271
+ def db_get(field)
272
+ local_get(field)
273
+ rescue MissingConfig
274
+ app_db_config.fetch(steps_for(field).last)
275
+ end
276
+
267
277
  #@group File management
268
278
  def backup_file
269
279
  local_get(:file)
@@ -294,33 +304,27 @@ module BiblioTech
294
304
 
295
305
  #@group Database
296
306
  def adapter
297
- database_config
298
- local_get(:db_adapter)
307
+ db_get(:db_adapter)
299
308
  end
300
309
 
301
310
  def host
302
- database_config
303
- local_get(:db_host)
311
+ db_get(:db_host)
304
312
  end
305
313
 
306
314
  def port
307
- database_config
308
- local_get(:db_port)
315
+ db_get(:db_port)
309
316
  end
310
317
 
311
318
  def username
312
- database_config
313
- local_get(:db_username)
319
+ db_get(:db_username)
314
320
  end
315
321
 
316
322
  def database
317
- database_config
318
- local_get(:db_database)
323
+ db_get(:db_database)
319
324
  end
320
325
 
321
326
  def password
322
- database_config
323
- local_get(:db_password)
327
+ db_get(:db_password)
324
328
  end
325
329
  #@endgroup
326
330
  end
@@ -17,7 +17,9 @@ module BiblioTech
17
17
  let (:base_options){{}}
18
18
 
19
19
  let :base_config_hash do
20
- { "database_config" =>
20
+ {
21
+ "local" => "production",
22
+ "database_config" =>
21
23
  {
22
24
  "adapter" => :postgres,
23
25
  "database" => db_name,
@@ -1,64 +1,92 @@
1
1
  require 'valise'
2
2
  require 'spec_helper'
3
+ require 'file-sandbox'
3
4
 
4
5
  module BiblioTech
5
6
  describe Config do
6
7
  include FileSandbox
7
8
 
8
- describe 'initialization' do
9
+ describe "datatbase.yml" do
9
10
  before :each do
10
11
  sandbox.new :file => 'config/database.yml', :with_contents => YAML::dump(
11
12
  {
12
- "development" =>
13
- { "username" => 'root',
14
- "database" => 'dev_db',
15
- "adapter" => 'mysql',
16
- },
17
- "production" =>
18
- { "username" => 'root',
19
- "database" => 'prod_db',
20
- "adapter" => 'mysql2',
21
- }
22
- })
13
+ "development" =>
14
+ { "username" => 'root',
15
+ "database" => 'dev_db',
16
+ "adapter" => 'mysql',
17
+ },
18
+ "production" =>
19
+ { "username" => 'root',
20
+ "database" => 'prod_db',
21
+ "adapter" => 'mysql2',
22
+ }
23
+ })
23
24
  end
24
25
 
25
- let :valise do
26
- Valise.define do
27
- defaults do
28
- file "config.yaml", {
29
- "database_config_file" => "config/database.yml",
30
- "database_config_env" => "development",
31
- }
26
+ describe 'initialization' do
27
+ let :valise do
28
+ Valise.define do
29
+ defaults do
30
+ file "config.yaml", {
31
+ "database_config_file" => "config/database.yml",
32
+ "database_config_env" => "development",
33
+ }
34
+ end
32
35
  end
33
36
  end
34
- end
35
37
 
36
- subject :config do
37
- BiblioTech::Config.new(valise)
38
- end
38
+ subject :config do
39
+ BiblioTech::Config.new(valise)
40
+ end
41
+
42
+ context "if the file contains database configs" do
43
+ context "with default(development) environment" do
44
+ it "should make the development hash available at config" do
45
+ expect(config.database).to eql "dev_db"
46
+ end
47
+ end
39
48
 
40
- context "if the file contains database configs" do
41
- context "with default(development) environment" do
42
- it "should make the development hash available at config" do
43
- expect(config.database).to eql "dev_db"
49
+ context "with specified environment" do
50
+ it "should make the string-specified hash available at config" do
51
+ expect(config.merge("database_config_env" => "production").database).to eql "prod_db"
52
+ end
44
53
  end
45
54
  end
46
55
 
47
- context "with specified environment" do
48
- it "should make the string-specified hash available at config" do
49
- expect(config.merge("database_config_env" => "production").database).to eql "prod_db"
56
+ context "when the file contains bad configs" do
57
+ context "with no matching environment" do
58
+ it "should raise an error" do
59
+ expect do
60
+ config.merge("database_config_env" => "only_for_pretend").database
61
+ end.to raise_error(KeyError)
62
+ end
50
63
  end
51
64
  end
52
65
  end
53
66
 
54
- context "when the file contains bad configs" do
55
- context "with no matching environment" do
56
- it "should raise an error" do
57
- expect do
58
- config.merge("database_config_env" => "only_for_pretend").database
59
- end.to raise_error(KeyError)
67
+ describe "partial override of database.yml" do
68
+ let :valise do
69
+ Valise.define do
70
+ defaults do
71
+ file "config.yaml", {
72
+ "database_config_file" => "config/database.yml",
73
+ "database_config_env" => "development",
74
+ "database_config" => {
75
+ "username" => "codemonkey"
76
+ }
77
+ }
78
+ end
60
79
  end
61
80
  end
81
+
82
+ subject :config do
83
+ BiblioTech::Config.new(valise)
84
+ end
85
+
86
+ it "should blend the bibliotech config and Rails config" do
87
+ expect(config.database).to eql("dev_db")
88
+ expect(config.username).to eql("codemonkey")
89
+ end
62
90
  end
63
91
  end
64
92
 
@@ -83,9 +111,9 @@ module BiblioTech
83
111
  { "backups" => {
84
112
  "frequency" => 60,
85
113
  "keep" => {
86
- 60 => 24,
87
- 1440 => 7
88
- }}}
114
+ 60 => 24,
115
+ 1440 => 7
116
+ }}}
89
117
  end
90
118
 
91
119
  let :schedule_array do
@@ -105,9 +133,9 @@ module BiblioTech
105
133
  { "backups" => {
106
134
  "frequency" => 59,
107
135
  "keep" => {
108
- 60 => 24,
109
- 1440 => 7
110
- }}}
136
+ 60 => 24,
137
+ 1440 => 7
138
+ }}}
111
139
  end
112
140
 
113
141
  it "should raise an error" do
@@ -122,10 +150,10 @@ module BiblioTech
122
150
  { "backups" => {
123
151
  "frequency" => "sometimes",
124
152
  "keep" => {
125
- "often" => 24,
126
- "regular" => 7,
127
- "chocolate" => 4
128
- }}}
153
+ "often" => 24,
154
+ "regular" => 7,
155
+ "chocolate" => 4
156
+ }}}
129
157
  end
130
158
 
131
159
  it "should raise an error" do
@@ -140,11 +168,11 @@ module BiblioTech
140
168
  { "backups" => {
141
169
  "frequency" => "hourly",
142
170
  "keep" => {
143
- "hourlies" => 24,
144
- "daily" => 7,
145
- "weeklies" => 4,
146
- "monthly" => "all"
147
- }}}
171
+ "hourlies" => 24,
172
+ "daily" => 7,
173
+ "weeklies" => 4,
174
+ "monthly" => "all"
175
+ }}}
148
176
  end
149
177
 
150
178
  it "should produce correct schedule" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bibliotech
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Dorn
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-02-06 00:00:00.000000000 Z
12
+ date: 2015-05-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: caliph
@@ -130,7 +130,7 @@ rdoc_options:
130
130
  - --main
131
131
  - doc/README
132
132
  - --title
133
- - bibliotech-0.4.1 Documentation
133
+ - bibliotech-0.5.0 Documentation
134
134
  require_paths:
135
135
  - lib/
136
136
  required_ruby_version: !ruby/object:Gem::Requirement