mpatch 2.11.0 → 2.12.0

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: cec135221ac3f2a5c694c8d93fe4a8765e3bca68
4
- data.tar.gz: ac1e24c549d1c98cff57023453529513838a4efd
3
+ metadata.gz: 5b7435616df9a8b359ebd01ae0a345ae13ff4f31
4
+ data.tar.gz: d49da539ef1ac7eb8f1b3bf889a5882e9d1897e5
5
5
  SHA512:
6
- metadata.gz: c2bd6ff235e20003cc427d16a8f3efd475bd2d250ca3921373cad8e90ca421c6ce3c883755f8b5cf138cbcffb08aa0dff68a0f0cd186a301250e06580d8f9e1f
7
- data.tar.gz: 7a5d7383f5ea92faddf35238a180f6b978c29c644766dd39d936b3331695dae9101343ec9179c7a2bce667c05aef25cf35041d7a0ec7098ded7b4bb04024c3c0
6
+ metadata.gz: c1c9c45c6a13f121a24d319630bf4d7d1facb3b711a5931d3e341d48dc73649a05bfd9ddccdebaf4c5bbd283f7516caf3e3879661681282720f066dd957d0aa6
7
+ data.tar.gz: 62f3ab3480556c973381c2a56ff2752aa3897c8ea56b8d041040b178b07f1297ceee5eab9cc37490517f38c285ff4a8f1fadd715407308a5738e933bf4a9fd8a
data/VERSION CHANGED
@@ -1,2 +1,2 @@
1
- 2.11.0
1
+ 2.12.0
2
2
 
data/examples/hash.rb CHANGED
@@ -1,4 +1,5 @@
1
1
 
2
+
2
3
  require "mpatch"
3
4
 
4
5
  x = {}
@@ -14,4 +15,11 @@ var= {hello: "world",no: "yes"}
14
15
  puts var
15
16
 
16
17
  var= [[:hello, "world"],[:no, "yes"]].map_hash{|k,v| {k => v} }
17
- puts var.inspect
18
+ puts var.inspect
19
+
20
+ # require 'debugger'
21
+ # debugger
22
+
23
+ var = { hello: "world",no: 'yes' }.include_hash?( no: 'yes' )
24
+ puts var
25
+
data/lib/mpatch/hash.rb CHANGED
@@ -61,7 +61,7 @@ module MPatch
61
61
  # h2.deep_merge(h1) #=> { :x => {:y => [4, 5, 6]}, :z => [7, 8, 9] }
62
62
  def deep_merge(other_hash)
63
63
  dup.deep_merge!(other_hash)
64
- end unless method_defined? :deep_merge
64
+ end
65
65
 
66
66
  alias :+ :deep_merge
67
67
 
@@ -72,7 +72,7 @@ module MPatch
72
72
  self[k] = tv.is_a?(::Hash) && v.is_a?(::Hash) ? tv.deep_merge(v) : v
73
73
  end
74
74
  self
75
- end unless method_defined? :deep_merge!
75
+ end
76
76
 
77
77
  # return bool that does the sub hash all element include the hash who call this or not
78
78
  def deep_include?(sub_hash)
@@ -83,7 +83,7 @@ module MPatch
83
83
  self[key] == sub_hash[key]
84
84
  end
85
85
  end
86
- end unless method_defined? :deep_include?
86
+ end
87
87
 
88
88
  # map hash will work just alike map but instead of an array it will return a hash obj
89
89
  #
@@ -122,9 +122,14 @@ module MPatch
122
122
  def map_hash! *args,&block
123
123
  self.replace(self.map_hash(*args,&block))
124
124
  end
125
-
126
125
  alias :map2hash! :map_hash!
127
126
 
127
+ # check if every hash pair included in the self hash obj
128
+ def include_hash? hash
129
+ return super unless hash.class <= ::Hash
130
+ return (hash.to_a - self.to_a).empty?
131
+ end
132
+ alias :contain_hash? :include_hash?
128
133
 
129
134
  # Fetch a nested hash value
130
135
  def value_by_keys(*attrs)
@@ -138,6 +143,7 @@ module MPatch
138
143
  end
139
144
  return nil
140
145
  end
146
+ alias :fetch_by_keys :value_by_keys
141
147
 
142
148
  end
143
149
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mpatch
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.11.0
4
+ version: 2.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Luzsi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-08 00:00:00.000000000 Z
11
+ date: 2014-05-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This is a collection of my Ruby monkey patches for making easer to use
14
14
  the basic classes