hash_order_helper 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 07e5129af5fcf29854a8770f7cb19330381cb21c
4
- data.tar.gz: a53ce05d4277f921c3576bd1bd3df0f98a37f889
3
+ metadata.gz: 816648a641f45835c25e16f103cdc7dab96b0649
4
+ data.tar.gz: 7157b16ce4d46d84992d637d6b512733ef06a2cb
5
5
  SHA512:
6
- metadata.gz: 5359868791279063784a0cb07d364baaf8f9dff112653bf3f5dfe4c79112f29fb4b7937fbc1cd43f79f4808db6299ab52ef733691abc8ad2260723eee37f38df
7
- data.tar.gz: 26562ef20322400fb9a7946e92c53ae32f3d7bbeded5e8e509aed929dcc0aad9d8de9fec83f0ece6db8f92760111a2daf0bed7b20980e8a397271719efa49081
6
+ metadata.gz: 189374b3518cc32b0776d0d5d1189433284f58d5c47fb0768f40bc8aed2a909b39687c347a536efcd8a04e11242f07354a8b4a81bdf7a04c74932a2b6175dfc1
7
+ data.tar.gz: 048161554f245df847ddd29890e53f4fff9525d3ad3f33b031178a3513d1909affde523f959af357a260d9776a977c2e64d20a1d6384347af93c5eec86bfb521
data/README.md CHANGED
@@ -45,6 +45,18 @@ The following methods are added:
45
45
  * `last -> Array`
46
46
  * `last(n) -> Array`
47
47
  * `pop -> Array`
48
- * `pop(n) -> Array`
48
+ * `pop(n) -> Array` (alias: `<<`)
49
49
  * `push(hash) -> Hash`
50
50
  * `unshift(hash) -> Hash`
51
+ * `>>(receiver_hash) -> Hash`
52
+
53
+ ### `>>` method
54
+
55
+ ```ruby
56
+ require 'hash_order_helper'
57
+
58
+ hash = {b: 200, a: 100, c: 150}
59
+
60
+ {d: 300} >> hash
61
+ #=> {:d=>300, :b=>200, :a=>100, :c=>150}
62
+ ```
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
  Gem::Specification.new do |spec|
3
3
  spec.name = 'hash_order_helper'
4
- spec.version = '0.1.2'
4
+ spec.version = '0.1.3'
5
5
  spec.authors = ['Genki Sugawara']
6
6
  spec.email = ['sugawara@cookpad.com']
7
7
 
@@ -76,6 +76,7 @@ module HashOrderHelper
76
76
 
77
77
  self.replace(new_hash)
78
78
  end
79
+ alias << push
79
80
 
80
81
  def unshift(unshift_hash)
81
82
  hash_keys = self.keys - unshift_hash.keys
@@ -89,5 +90,13 @@ module HashOrderHelper
89
90
 
90
91
  self.replace(new_hash)
91
92
  end
93
+
94
+ def >>(receiver)
95
+ unless receiver.is_a?(Hash)
96
+ raise TypeError, "no implicit conversion of #{receiver.inspect}:#{receiver.class} into Hash"
97
+ end
98
+
99
+ receiver.unshift(self)
100
+ end
92
101
  end
93
102
  Hash.send(:include, HashOrderHelper)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hash_order_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-19 00:00:00.000000000 Z
11
+ date: 2016-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler