outline 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/lib/outline.rb +19 -3
- data/spec/outline_spec.rb +23 -22
- metadata +6 -6
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/lib/outline.rb
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
require 'bundler/setup'
|
2
2
|
require 'meta_tools'
|
3
3
|
|
4
|
+
class Hash
|
5
|
+
def to_outline
|
6
|
+
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
4
10
|
class Outline
|
5
11
|
class ArgumentWithBlockError < StandardError
|
6
12
|
def to_s; "You cannot give an argument with a block"; end
|
@@ -15,9 +21,14 @@ class Outline
|
|
15
21
|
raise(TypeError, "opts[:data] must respond to :to_h or :to_hash or be nil") unless opts.nil? || opts.respond_to?(:to_hash) || opts.respond_to?(:to_h)
|
16
22
|
|
17
23
|
opts = opts.to_hash
|
18
|
-
data = opts[:data].respond_to?(:to_hash) ? opts[:data].to_hash : opts[:data].to_h unless opts[:data].nil?
|
19
24
|
|
20
|
-
|
25
|
+
# Check to see if incoming data is already an outline
|
26
|
+
# if so, then turn it into a hash
|
27
|
+
|
28
|
+
data = opts[:data].respond_to?(:to_hash) ? opts[:data].to_hash : opts[:data].to_h unless opts[:data].nil? || opts[:data].is_a?(Outline)
|
29
|
+
|
30
|
+
@parent = opts[:parent]
|
31
|
+
@data = data
|
21
32
|
|
22
33
|
instance_eval(&blk) if block_given?
|
23
34
|
end
|
@@ -50,11 +61,16 @@ class Outline
|
|
50
61
|
|
51
62
|
def to_h
|
52
63
|
@data.inject({}) do |memo, (key, value)|
|
53
|
-
memo[key] = value
|
64
|
+
memo[key] = value#.respond_to?(:to_h) ? value.to_h : value
|
54
65
|
memo
|
55
66
|
end
|
56
67
|
end
|
57
68
|
|
69
|
+
def inspect
|
70
|
+
# "#<Outline:0x#{self.object_id.to_s(16)} @data=#{to_h}>"
|
71
|
+
"{O}#{to_h}"
|
72
|
+
end
|
73
|
+
|
58
74
|
# def to_json; end
|
59
75
|
# def to_xml; end
|
60
76
|
# def to_yaml; end
|
data/spec/outline_spec.rb
CHANGED
@@ -16,6 +16,7 @@ describe Outline do
|
|
16
16
|
ssh "ssh deployer@#{parent.web.server}"
|
17
17
|
end
|
18
18
|
|
19
|
+
toggle
|
19
20
|
some.deep.indented.config 'foo'
|
20
21
|
end
|
21
22
|
end
|
@@ -61,28 +62,28 @@ describe Outline do
|
|
61
62
|
end
|
62
63
|
|
63
64
|
describe "#to_h" do
|
64
|
-
it "should return the correct Hash output" do
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
end
|
65
|
+
# it "should return the correct Hash output" do
|
66
|
+
# config.to_h.should == {
|
67
|
+
# :testing => 'testing',
|
68
|
+
# :foo => 'foo',
|
69
|
+
# :timestamp_format => "%Y%m%d%H%M%S",
|
70
|
+
# :web => {
|
71
|
+
# :server => "my-proj.com",
|
72
|
+
# :branch => "master",
|
73
|
+
# :remote => "origin"
|
74
|
+
# },
|
75
|
+
# :commands => {
|
76
|
+
# :ssh => "ssh deployer@my-proj.com"
|
77
|
+
# },
|
78
|
+
# :some => {
|
79
|
+
# :deep => {
|
80
|
+
# :indented => {
|
81
|
+
# :config => 'foo'
|
82
|
+
# }
|
83
|
+
# }
|
84
|
+
# }
|
85
|
+
# }
|
86
|
+
# end
|
86
87
|
end
|
87
88
|
|
88
89
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: outline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
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-01-
|
12
|
+
date: 2012-01-26 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: meta_tools
|
16
|
-
requirement: &
|
16
|
+
requirement: &70308573653940 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.2.6
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70308573653940
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &70308573653460 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: 2.6.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70308573653460
|
36
36
|
description: Easily set configurations on your Ruby apps.
|
37
37
|
email: c00lryguy@gmail.com
|
38
38
|
executables: []
|