ribbon 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/lib/ribbon.rb +6 -0
- data/lib/ribbon/core_ext.rb +8 -0
- data/lib/ribbon/core_ext/hash.rb +22 -0
- data/lib/ribbon/object.rb +2 -0
- data/lib/ribbon/version.rb +1 -1
- metadata +5 -3
data/.gitignore
CHANGED
data/lib/ribbon.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'ribbon/object'
|
2
|
+
|
3
|
+
module Ribbon
|
4
|
+
module CoreExt
|
5
|
+
|
6
|
+
# Includes a method to convert hashes to ribbons.
|
7
|
+
module Hash
|
8
|
+
|
9
|
+
# Converts this hash to a Ribbon::Object.
|
10
|
+
def to_ribbon
|
11
|
+
::Ribbon::Object.new self
|
12
|
+
end
|
13
|
+
|
14
|
+
# Same as #to_ribbon.
|
15
|
+
alias to_rbon to_ribbon
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
::Hash.send :include, ::Ribbon::CoreExt::Hash
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
data/lib/ribbon/object.rb
CHANGED
@@ -49,11 +49,13 @@ module Ribbon
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
+
# Computes a simple key:value string for easy visualization.
|
52
53
|
def to_s
|
53
54
|
values = __hash__.map { |k, v| "#{k}:#{v}" }
|
54
55
|
"<Ribbon #{values.join}>"
|
55
56
|
end
|
56
57
|
|
58
|
+
# Same as #to_s.
|
57
59
|
alias :inspect :to_s
|
58
60
|
|
59
61
|
# If <tt>object</tt> is a Hash, converts it to a Ribbon::Object. If it is
|
data/lib/ribbon/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ribbon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-12-27 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rookie
|
16
|
-
requirement: &
|
16
|
+
requirement: &11036900 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *11036900
|
25
25
|
description: Ruby Object Notation. Inspired by JSON and OpenStruct.
|
26
26
|
email: matheus.a.m.moreira@gmail.com
|
27
27
|
executables: []
|
@@ -35,6 +35,8 @@ files:
|
|
35
35
|
- README.markdown
|
36
36
|
- Rakefile
|
37
37
|
- lib/ribbon.rb
|
38
|
+
- lib/ribbon/core_ext.rb
|
39
|
+
- lib/ribbon/core_ext/hash.rb
|
38
40
|
- lib/ribbon/object.rb
|
39
41
|
- lib/ribbon/version.rb
|
40
42
|
- ribbon.gemspec
|