shoppe 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/shoppe.rb +28 -2
- data/lib/shoppe/engine.rb +3 -0
- data/lib/shoppe/errors/invalid_configuration.rb +6 -0
- data/lib/shoppe/version.rb +1 -1
- metadata +5 -4
data/lib/shoppe.rb
CHANGED
@@ -24,8 +24,7 @@ module Shoppe
|
|
24
24
|
setup_config(config)
|
25
25
|
config
|
26
26
|
else
|
27
|
-
|
28
|
-
{}
|
27
|
+
raise InvalidConfiguration, "Shoppe configuration file missing at #{path}"
|
29
28
|
end
|
30
29
|
end
|
31
30
|
end
|
@@ -33,6 +32,33 @@ module Shoppe
|
|
33
32
|
def setup_config(config)
|
34
33
|
ActionMailer::Base.smtp_settings = config[:smtp_settings] if config[:smtp_settings]
|
35
34
|
end
|
35
|
+
|
36
|
+
def validate_live_config(*requirements)
|
37
|
+
validate_config(self.config, [], *requirements)
|
38
|
+
end
|
39
|
+
|
40
|
+
def validate_config(config, scope, *requirements)
|
41
|
+
for req in requirements
|
42
|
+
case req
|
43
|
+
when String, Symbol
|
44
|
+
unless config.keys.include?(req.to_s)
|
45
|
+
raise Shoppe::Errors::InvalidConfiguration, "Missing configuration option '#{scope.join('.')}.#{req}' in shoppe.yml"
|
46
|
+
end
|
47
|
+
when Array
|
48
|
+
validate_config(config, scope, *req)
|
49
|
+
when Hash
|
50
|
+
req.each do |key, value|
|
51
|
+
if config[key] && config[key].is_a?(Hash)
|
52
|
+
scope << key
|
53
|
+
validate_config(config[key], scope, *value)
|
54
|
+
else
|
55
|
+
validate_config(config, scope, key)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
36
62
|
end
|
37
63
|
|
38
64
|
end
|
data/lib/shoppe/engine.rb
CHANGED
@@ -19,6 +19,9 @@ module Shoppe
|
|
19
19
|
# Preload the config
|
20
20
|
Shoppe.config
|
21
21
|
|
22
|
+
# Validate the initial config
|
23
|
+
Shoppe.validate_live_config :store_name, :email_address, :currency_unit, :tax_name
|
24
|
+
|
22
25
|
# Load our migrations into the application's db/migrate path
|
23
26
|
unless app.root.to_s.match root.to_s
|
24
27
|
config.paths["db/migrate"].expanded.each do |expanded_path|
|
data/lib/shoppe/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shoppe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -367,6 +367,7 @@ files:
|
|
367
367
|
- lib/shoppe/engine.rb
|
368
368
|
- lib/shoppe/errors/inappropriate_delivery_service.rb
|
369
369
|
- lib/shoppe/errors/insufficient_stock_to_fulfil.rb
|
370
|
+
- lib/shoppe/errors/invalid_configuration.rb
|
370
371
|
- lib/shoppe/errors/not_enough_stock.rb
|
371
372
|
- lib/shoppe/errors/payment_declined.rb
|
372
373
|
- lib/shoppe/setup_generator.rb
|
@@ -430,7 +431,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
430
431
|
version: '0'
|
431
432
|
segments:
|
432
433
|
- 0
|
433
|
-
hash:
|
434
|
+
hash: 637768647073806952
|
434
435
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
435
436
|
none: false
|
436
437
|
requirements:
|
@@ -439,7 +440,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
439
440
|
version: '0'
|
440
441
|
segments:
|
441
442
|
- 0
|
442
|
-
hash:
|
443
|
+
hash: 637768647073806952
|
443
444
|
requirements: []
|
444
445
|
rubyforge_project:
|
445
446
|
rubygems_version: 1.8.23
|