ribbon 0.4.7 → 0.5.0

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.
@@ -1,10 +1,20 @@
1
1
  # Ribbon
2
2
 
3
- RuBy Object Notation
3
+ Ruby Object Notation
4
4
 
5
5
  Inspired by JSON and OpenStruct.
6
6
 
7
- ## Quick Start
7
+ # Installation
8
+
9
+ Latest version:
10
+
11
+ gem install ribbon
12
+
13
+ From source:
14
+
15
+ git clone git://github.com/matheusmoreira/ribbon.git
16
+
17
+ # Introduction
8
18
 
9
19
  A Ribbon is a simple but powerful associative data structure designed to be easy
10
20
  and natural to use. It allows the dynamic definition of arbitrary attributes,
@@ -46,7 +56,7 @@ If the block takes no arguments (arity of zero), it will be evaluated in the
46
56
  context of the value instance. The above example could be rewritten as:
47
57
 
48
58
  > Ribbon.new do
49
- config.music do
59
+ music do
50
60
  file do
51
61
  extensions %w(flac mp3 ogg wma)
52
62
  end
@@ -205,7 +205,7 @@ class Ribbon < BasicObject
205
205
  # in any other case.
206
206
  def extract_hash_from(ribbon)
207
207
  case ribbon
208
- when Ribbon::Wrapper then ribbon.hash
208
+ when Ribbon::Wrapper then ribbon.internal_hash
209
209
  when Ribbon then ribbon.__hash__
210
210
  when Hash then ribbon
211
211
  else nil
@@ -218,10 +218,10 @@ class Ribbon < BasicObject
218
218
  Ribbon.new YAML.load(string)
219
219
  end
220
220
 
221
- # Wraps a ribbon instance in a Ribbon::Wrapper.
221
+ # Creates a new instance.
222
222
  #
223
- # Ribbon[ribbon].keys
224
- alias [] wrap
223
+ # Ribbon[a: :a, b: :b, c: :c]
224
+ alias [] new
225
225
 
226
226
  private
227
227
 
@@ -11,12 +11,12 @@ class Ribbon < BasicObject
11
11
  # Minor version.
12
12
  #
13
13
  # Increments denote backward-compatible changes and additions.
14
- MINOR = 4
14
+ MINOR = 5
15
15
 
16
16
  # Patch version.
17
17
  #
18
18
  # Increments denote changes in implementation.
19
- PATCH = 7
19
+ PATCH = 0
20
20
 
21
21
  # Build version.
22
22
  #
@@ -64,14 +64,14 @@ class Ribbon < BasicObject
64
64
  end
65
65
 
66
66
  # Returns the hash of the wrapped ribbon.
67
- def hash
67
+ def internal_hash
68
68
  ribbon.__hash__
69
69
  end
70
70
 
71
71
  # Forwards the method, arguments and block to the wrapped Ribbon's hash, if
72
72
  # it responds to the method, or to the ribbon itself otherwise.
73
73
  def method_missing(method, *args, &block)
74
- if hash.respond_to? method then hash
74
+ if (hash = internal_hash).respond_to? method then hash
75
75
  else ribbon end.__send__ method, *args, &block
76
76
  end
77
77
 
@@ -151,8 +151,8 @@ class Ribbon < BasicObject
151
151
  # Recursively wraps all ribbons inside. This implementation avoids the
152
152
  # creation of additional ribbon or wrapper objects.
153
153
  def wrap_all_recursive!(wrapper = self)
154
- wrapper.hash.each do |key, value|
155
- wrapper.hash[key] = case value
154
+ wrapper.internal_hash.each do |key, value|
155
+ wrapper.internal_hash[key] = case value
156
156
  when Ribbon then wrap_all_recursive! Ribbon::Wrapper[value]
157
157
  else value
158
158
  end
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.4.7
4
+ version: 0.5.0
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-16 00:00:00.000000000 Z
12
+ date: 2012-01-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rookie
16
- requirement: &15079400 !ruby/object:Gem::Requirement
16
+ requirement: &16830660 !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: *15079400
24
+ version_requirements: *16830660
25
25
  description: Ruby Object Notation. Inspired by JSON and OpenStruct.
26
26
  email: matheus.a.m.moreira@gmail.com
27
27
  executables: []
@@ -55,7 +55,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
55
55
  version: '0'
56
56
  segments:
57
57
  - 0
58
- hash: -3941054121051003876
58
+ hash: 3672326478508748876
59
59
  required_rubygems_version: !ruby/object:Gem::Requirement
60
60
  none: false
61
61
  requirements:
@@ -64,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  version: '0'
65
65
  segments:
66
66
  - 0
67
- hash: -3941054121051003876
67
+ hash: 3672326478508748876
68
68
  requirements: []
69
69
  rubyforge_project:
70
70
  rubygems_version: 1.8.10