octothorpe 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/.hgignore +2 -1
  3. data/lib/octothorpe.rb +15 -13
  4. metadata +3 -4
  5. data/.ruby-version +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bc534ef4336a77b76543f3516e116638fa32689c
4
- data.tar.gz: bea9afa7dbf04641ad087876739b196bb144eae5
3
+ metadata.gz: 04716672658edfc3209de1cf393dd97f6bc8704a
4
+ data.tar.gz: 87efb8325fbe599b1ee0c17ac3dd854a2190a601
5
5
  SHA512:
6
- metadata.gz: f0aefe4fe287dde92571b523f81d556c66140e44cab5c0b5287d789400c08eec22d01eff403f858692a20fcd40dbc1ddec8ea7f5de5c44018b3c7c10bb23500f
7
- data.tar.gz: e873feb328edecb076cd126c92861d0f7032d2fc4bca4b21ef732c8a7c75d3c8be1a46a84e37008559a8b9f2069721e4da01309bcc1b43eeccef1525f5521d25
6
+ metadata.gz: 95250990bf652fef1126436b8f86cfebc049cac2074f59355a819847b9f5fde15d85cf151930df174d48fb095be3b8fd8293c8cf6f6f60329fd40f5ca286a35f
7
+ data.tar.gz: 931b5b36ee0e1976831ee8f9d6ee8a7d3df86a7557407229c0010fc9ab3469700089496ddd505b6a42a243db1d4cc1945eedab7bcc5ce82bbdcfcd986d668712
data/.hgignore CHANGED
@@ -10,4 +10,5 @@ tmp/
10
10
  *.o
11
11
  *.a
12
12
  mkmf.log
13
- .rbenv-gemsets
13
+ .ruby*
14
+ .rbenv*
@@ -14,7 +14,7 @@ require 'forwardable'
14
14
  # Meant to facilitate message-passing between classes.
15
15
  #
16
16
  # Simple example:
17
- # ot = Octotghorpe.new(one: 1, "two" => 2, "weird key" => 3)
17
+ # ot = Octothorpe.new(one: 1, "two" => 2, "weird key" => 3)
18
18
  # ot.>>.one # -> 1
19
19
  # ot.>>.two # -> 2
20
20
  # ot.get("weird key") # -> 3
@@ -41,7 +41,7 @@ class Octothorpe
41
41
  def_delegators :@inner_hash, :select, :map, :reject, :inject
42
42
 
43
43
  # Gem version number
44
- VERSION = '0.1.1'
44
+ VERSION = '0.1.2'
45
45
 
46
46
 
47
47
  # Generic Octothorpe error class
@@ -59,15 +59,15 @@ class Octothorpe
59
59
  # names. Not exposed to Octothorpe's caller.
60
60
  #
61
61
  class Storage
62
- attr_reader :store
62
+ attr_reader :octothorpe_store
63
63
 
64
64
  def initialize(hash)
65
- @store = hash
65
+ @octothorpe_store = hash
66
66
  end
67
67
 
68
68
  def method_missing(method, *attrs)
69
69
  super if (block_given? || !attrs.empty?)
70
- @store[method.to_sym]
70
+ @octothorpe_store[method.to_sym]
71
71
  end
72
72
 
73
73
  end
@@ -88,7 +88,7 @@ class Octothorpe
88
88
  #
89
89
  def initialize(hash=nil)
90
90
  @store = Storage.new( symbol_hash(hash || {}) )
91
- @inner_hash = @store.store
91
+ @inner_hash = @store.octothorpe_store
92
92
  end
93
93
 
94
94
 
@@ -112,13 +112,14 @@ class Octothorpe
112
112
  # :call-seq:
113
113
  # ot.get(key)
114
114
  # ot.send(key)
115
+ # ot[key]
115
116
  #
116
117
  # You can use get to access member object values instead of the >> syntax.
117
118
  #
118
119
  # Unlike >>, this works for keys with spaces, or keys that have the same name
119
120
  # as methods on Object.
120
121
  #
121
- def get(key); @store.store[key.to_sym]; end
122
+ def get(key); @store.octothorpe_store[key.to_sym]; end
122
123
 
123
124
  alias send get
124
125
  alias [] get
@@ -127,7 +128,7 @@ class Octothorpe
127
128
  ##
128
129
  # Returns a hash of the object.
129
130
  #
130
- def to_h; @store.store; end
131
+ def to_h; @store.octothorpe_store; end
131
132
 
132
133
 
133
134
  ##
@@ -146,7 +147,7 @@ class Octothorpe
146
147
  #
147
148
  def guard(klass, *keys)
148
149
  raise Frozen if self.frozen?
149
- keys.map(&:to_sym).each{|k| @store.store[k] ||= klass.new }
150
+ keys.map(&:to_sym).each{|k| @store.octothorpe_store[k] ||= klass.new }
150
151
  self
151
152
  end
152
153
 
@@ -156,22 +157,23 @@ class Octothorpe
156
157
  # ot.merge(other) -> new_ot
157
158
  # ot.merge(other){|key, oldval, newval| block} -> new_ot
158
159
  #
159
- # Exactly has _Hash.merge_, but returns a new Octothorpe object.
160
+ # Exactly as _Hash.merge_, but returns a new Octothorpe object.
160
161
  #
161
162
  # You may pass a hash or an octothorpe. Raises Octothorpe::BadHash
162
163
  # if it is anything else.
163
164
  #
164
165
  def merge(other)
166
+ thisHash = @store.octothorpe_store
165
167
  otherHash = symbol_hash(other)
166
168
 
167
169
  merged =
168
170
  if block_given?
169
- @store.store.merge(otherHash) {|key,old,new| yield key, old, new }
171
+ thisHash.merge(otherHash) {|key,old,new| yield key, old, new }
170
172
  else
171
- @store.store.merge(otherHash)
173
+ thisHash.merge(otherHash)
172
174
  end
173
175
 
174
- return Octothorpe.new(merged)
176
+ Octothorpe.new(merged)
175
177
  end
176
178
 
177
179
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octothorpe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Jones
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-05 00:00:00.000000000 Z
11
+ date: 2016-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -95,7 +95,6 @@ extra_rdoc_files: []
95
95
  files:
96
96
  - ".hgignore"
97
97
  - ".rspec"
98
- - ".ruby-version"
99
98
  - Gemfile
100
99
  - LICENSE.txt
101
100
  - README.md
@@ -125,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
124
  version: '0'
126
125
  requirements: []
127
126
  rubyforge_project:
128
- rubygems_version: 2.4.5
127
+ rubygems_version: 2.5.1
129
128
  signing_key:
130
129
  specification_version: 4
131
130
  summary: Like a Hash. Better for message passing between classes, I hope.
@@ -1 +0,0 @@
1
- 2.2.2