abyss 0.2.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +5 -0
- data/Gemfile +2 -0
- data/README.md +2 -0
- data/lib/abyss.rb +30 -0
- data/lib/abyss/version.rb +1 -1
- data/spec/abyss/store_spec.rb +0 -15
- data/spec/abyss_spec.rb +54 -0
- metadata +30 -50
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
data/lib/abyss.rb
CHANGED
@@ -17,4 +17,34 @@ module Abyss
|
|
17
17
|
self.configuration.instance_eval &block
|
18
18
|
end
|
19
19
|
|
20
|
+
# Check to see if a configuration has been defined.
|
21
|
+
#
|
22
|
+
# Examples:
|
23
|
+
#
|
24
|
+
# Abyss.configure do
|
25
|
+
# three do
|
26
|
+
# levels do
|
27
|
+
# deep do
|
28
|
+
# day "Monday"
|
29
|
+
# end
|
30
|
+
# end
|
31
|
+
# end
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
# Abyss.has?("three/levels/deep/day") #=> true
|
35
|
+
# Abyss.has?("non/existent/thing") #=> false
|
36
|
+
#
|
37
|
+
def self.has?(path)
|
38
|
+
path.split('/').inject(Abyss.configuration) do |acc, current_path_item|
|
39
|
+
begin
|
40
|
+
target = acc.send(current_path_item)
|
41
|
+
return false if target.nil?
|
42
|
+
rescue NoMethodError
|
43
|
+
return false
|
44
|
+
end
|
45
|
+
target
|
46
|
+
end
|
47
|
+
true
|
48
|
+
end
|
49
|
+
|
20
50
|
end
|
data/lib/abyss/version.rb
CHANGED
data/spec/abyss/store_spec.rb
CHANGED
@@ -2,21 +2,6 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Abyss
|
4
4
|
|
5
|
-
describe ".configure" do
|
6
|
-
|
7
|
-
before { Abyss.configuration = nil }
|
8
|
-
|
9
|
-
it 'is shorthand for the Abyss Store API' do
|
10
|
-
expected_block = Proc.new { }
|
11
|
-
fake_config = mock()
|
12
|
-
Store.stub(:new).and_return(fake_config)
|
13
|
-
fake_config.should_receive(:instance_eval).with(&expected_block)
|
14
|
-
|
15
|
-
Abyss.configure &expected_block
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
5
|
describe Store do
|
21
6
|
|
22
7
|
subject { Store.new }
|
data/spec/abyss_spec.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Abyss do
|
4
|
+
|
5
|
+
before { Abyss.configuration = nil }
|
6
|
+
after { Abyss.configuration = nil }
|
7
|
+
|
8
|
+
describe ".configure" do
|
9
|
+
|
10
|
+
it 'is shorthand for the Abyss Store API' do
|
11
|
+
expected_block = Proc.new { }
|
12
|
+
fake_config = mock()
|
13
|
+
Abyss::Store.stub(:new).and_return(fake_config)
|
14
|
+
fake_config.should_receive(:instance_eval).with(&expected_block)
|
15
|
+
|
16
|
+
Abyss.configure &expected_block
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '.has?' do
|
22
|
+
|
23
|
+
context "when given a path to an existing configuration" do
|
24
|
+
|
25
|
+
before do
|
26
|
+
Abyss.configure do
|
27
|
+
three do
|
28
|
+
levels do
|
29
|
+
deep do
|
30
|
+
here "hey!"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
specify { Abyss.has?('three/levels/deep/here').should be_true }
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
context "when the config doesn't exist" do
|
42
|
+
|
43
|
+
before do
|
44
|
+
Abyss.configure {}
|
45
|
+
end
|
46
|
+
|
47
|
+
specify { Abyss.has?('three/levels/deep/here').should be_false }
|
48
|
+
specify { Abyss.has?('nope').should be_false }
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
metadata
CHANGED
@@ -1,50 +1,37 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: abyss
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.2
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
- 1
|
10
|
-
version: 0.2.1
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Jesse Trimble
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-05-31 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: activesupport
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70318152924440 !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
18
|
+
requirements:
|
26
19
|
- - ~>
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 15
|
29
|
-
segments:
|
30
|
-
- 3
|
31
|
-
- 2
|
32
|
-
- 0
|
20
|
+
- !ruby/object:Gem::Version
|
33
21
|
version: 3.2.0
|
34
22
|
type: :runtime
|
35
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70318152924440
|
36
25
|
description: Manage arbitrarily-deep configurations through a friendly DSL.
|
37
|
-
email:
|
26
|
+
email:
|
38
27
|
- jesseltrimble@gmail.com
|
39
28
|
executables: []
|
40
|
-
|
41
29
|
extensions: []
|
42
|
-
|
43
30
|
extra_rdoc_files: []
|
44
|
-
|
45
|
-
files:
|
31
|
+
files:
|
46
32
|
- .gitignore
|
47
33
|
- .rspec
|
34
|
+
- .travis.yml
|
48
35
|
- Gemfile
|
49
36
|
- LICENSE
|
50
37
|
- README.md
|
@@ -57,41 +44,34 @@ files:
|
|
57
44
|
- lib/abyss/version.rb
|
58
45
|
- spec/abyss/deep_store_spec.rb
|
59
46
|
- spec/abyss/store_spec.rb
|
47
|
+
- spec/abyss_spec.rb
|
60
48
|
- spec/spec_helper.rb
|
61
|
-
homepage:
|
49
|
+
homepage: ''
|
62
50
|
licenses: []
|
63
|
-
|
64
51
|
post_install_message:
|
65
52
|
rdoc_options: []
|
66
|
-
|
67
|
-
require_paths:
|
53
|
+
require_paths:
|
68
54
|
- lib
|
69
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
56
|
none: false
|
71
|
-
requirements:
|
72
|
-
- -
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
|
75
|
-
|
76
|
-
- 0
|
77
|
-
version: "0"
|
78
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
62
|
none: false
|
80
|
-
requirements:
|
81
|
-
- -
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
|
84
|
-
segments:
|
85
|
-
- 0
|
86
|
-
version: "0"
|
63
|
+
requirements:
|
64
|
+
- - ! '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
87
67
|
requirements: []
|
88
|
-
|
89
68
|
rubyforge_project:
|
90
69
|
rubygems_version: 1.8.10
|
91
70
|
signing_key:
|
92
71
|
specification_version: 3
|
93
72
|
summary: Manage arbitrarily-deep configurations through a friendly DSL.
|
94
|
-
test_files:
|
73
|
+
test_files:
|
95
74
|
- spec/abyss/deep_store_spec.rb
|
96
75
|
- spec/abyss/store_spec.rb
|
76
|
+
- spec/abyss_spec.rb
|
97
77
|
- spec/spec_helper.rb
|