scrawl 1.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/scrawl.rb +13 -13
- data/lib/scrawl/version.rb +1 -1
- data/spec/lib/scrawl_spec.rb +1 -1
- data/spec/spec_helper.rb +22 -2
- metadata +34 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51f49457e302b9c0332607ec11823a28e2e79c2a
|
4
|
+
data.tar.gz: 24c3bbfe67bf1735272b29794b03cd0362e13831
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e0f7c6228413eee997cd4eddf79657d1e440e1bc54a7532feb35515c1795a6ed20ed4eef23def92059ee0479cee5ae1e2dae48564394f71ea3e458006818786
|
7
|
+
data.tar.gz: a398998d1a96fb411b9798eddf5872dec657ca7cc962a3ffb8a9e530fc7493630ab3ec4fa412e95afce31347dca4eee2332eaf9e06ec335ed608850a34c550cf
|
data/lib/scrawl.rb
CHANGED
@@ -1,8 +1,4 @@
|
|
1
|
-
require "forwardable"
|
2
|
-
|
3
1
|
class Scrawl
|
4
|
-
extend Forwardable
|
5
|
-
|
6
2
|
KEY_VALUE_DELIMITER = "="
|
7
3
|
PAIR_DELIMITER = " "
|
8
4
|
NAMESPACE_DELIMITER = "."
|
@@ -10,8 +6,6 @@ class Scrawl
|
|
10
6
|
require_relative "scrawl/version"
|
11
7
|
|
12
8
|
attr_reader :tree
|
13
|
-
def_delegator :tree, :to_hash
|
14
|
-
def_delegator :tree, :to_h
|
15
9
|
|
16
10
|
def initialize(*trees)
|
17
11
|
@tree = trees.inject({}) { |global, tree| global.merge(tree) }
|
@@ -24,7 +18,7 @@ class Scrawl
|
|
24
18
|
def inspect(namespace = nil)
|
25
19
|
@tree.map do |key, value|
|
26
20
|
unless value.respond_to?(:to_hash)
|
27
|
-
|
21
|
+
label(namespace, key) + KEY_VALUE_DELIMITER + element(value)
|
28
22
|
else
|
29
23
|
Scrawl.new(value).inspect(key)
|
30
24
|
end
|
@@ -35,17 +29,23 @@ class Scrawl
|
|
35
29
|
inspect(namespace)
|
36
30
|
end
|
37
31
|
|
32
|
+
def to_hash
|
33
|
+
tree.to_hash
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_h
|
37
|
+
tree.to_h
|
38
|
+
end
|
39
|
+
|
38
40
|
private def label(namespace, key)
|
39
41
|
[namespace, key].compact.join(NAMESPACE_DELIMITER)
|
40
42
|
end
|
41
43
|
|
42
44
|
private def element(value)
|
43
45
|
case value
|
44
|
-
when Proc then value.call
|
45
|
-
when
|
46
|
-
|
47
|
-
|
48
|
-
else value
|
49
|
-
end.inspect
|
46
|
+
when Proc then element(value.call)
|
47
|
+
when Symbol then element(value.to_s)
|
48
|
+
else value.inspect
|
49
|
+
end
|
50
50
|
end
|
51
51
|
end
|
data/lib/scrawl/version.rb
CHANGED
data/spec/lib/scrawl_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,26 @@
|
|
1
1
|
require "codeclimate-test-reporter"
|
2
|
-
CodeClimate::TestReporter.start
|
3
|
-
|
4
2
|
require "pry"
|
5
3
|
require "rspec"
|
6
4
|
require "scrawl"
|
5
|
+
|
6
|
+
RSpec.configure do |let|
|
7
|
+
let.before("suite") do
|
8
|
+
CodeClimate::TestReporter.start
|
9
|
+
end
|
10
|
+
|
11
|
+
# Exit the spec after the first failure
|
12
|
+
let.fail_fast = true
|
13
|
+
|
14
|
+
# Only run a specific file, using the ENV variable
|
15
|
+
# Example: FILE=spec/blankgem/version_spec.rb bundle exec rake spec
|
16
|
+
let.pattern = ENV["FILE"]
|
17
|
+
|
18
|
+
# Show the slowest examples in the suite
|
19
|
+
let.profile_examples = true
|
20
|
+
|
21
|
+
# Colorize the output
|
22
|
+
let.color = true
|
23
|
+
|
24
|
+
# Output as a document string
|
25
|
+
let.default_formatter = "doc"
|
26
|
+
end
|
metadata
CHANGED
@@ -1,127 +1,127 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scrawl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kurtis Rainbolt-Greene
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.10.5
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 1.10.5
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 3.3.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 3.3.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 10.4.2
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 10.4.2
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: pry
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.10.1
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 0.10.1
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: pry-doc
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 0.8.0
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 0.8.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: codeclimate-test-reporter
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - '='
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 0.4.7
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - '='
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 0.4.7
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: benchmark-ips
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - '='
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 2.3.0
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - '='
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 2.3.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: ruby-prof
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - '='
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: 0.15.8
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - '='
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
124
|
+
version: 0.15.8
|
125
125
|
description: Turn hashes into simple log-ready output
|
126
126
|
email:
|
127
127
|
- me@kurtisrainboltgreene.name
|