hash-utils 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/VERSION +1 -1
- data/hash-utils.gemspec +3 -3
- data/lib/hash-utils/hash.rb +28 -1
- data/lib/hash-utils/symbol.rb +7 -3
- data/spec/modules/symbol_spec.rb +6 -0
- metadata +4 -4
data/README.md
CHANGED
@@ -11,7 +11,7 @@ non-atomic and organized by better way.
|
|
11
11
|
- `FalseClass` – 3 methods,
|
12
12
|
- `File` – 2 methods,
|
13
13
|
- `Gem` – 2 methods,
|
14
|
-
- `Hash` –
|
14
|
+
- `Hash` – 44 methods,
|
15
15
|
- `IO` – 1 method,
|
16
16
|
- `Module` – 1 method,
|
17
17
|
- `NilClass` – 1 method,
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.
|
1
|
+
2.1.1
|
data/hash-utils.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "hash-utils"
|
8
|
-
s.version = "2.1.
|
8
|
+
s.version = "2.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Martin Koz\u{e1}k"]
|
12
|
-
s.date = "
|
12
|
+
s.date = "2013-02-12"
|
13
13
|
s.email = "martinkozak@martinkozak.net"
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE.txt",
|
@@ -60,7 +60,7 @@ Gem::Specification.new do |s|
|
|
60
60
|
s.homepage = "http://github.com/martinkozak/hash-utils"
|
61
61
|
s.licenses = ["MIT"]
|
62
62
|
s.require_paths = ["lib"]
|
63
|
-
s.rubygems_version = "1.8.
|
63
|
+
s.rubygems_version = "1.8.25"
|
64
64
|
s.summary = "Adds more than 155 useful and frequently rather fundamental methods which are missing in Ruby programming language, to Array, File, Hash, Module, Object, String and Symbol classes. It tries to be similar project to Ruby Facets on principle, but less complex, more practical, non-atomic and organized by better way. Thanks to defensive and careful patching it should be compatible with all other libraries."
|
65
65
|
|
66
66
|
if s.respond_to? :specification_version then
|
data/lib/hash-utils/hash.rb
CHANGED
@@ -853,6 +853,7 @@ class Hash
|
|
853
853
|
# @return [Boolean] +true+ if yes, +false+ in otherwise
|
854
854
|
# @since 0.17.0
|
855
855
|
#
|
856
|
+
|
856
857
|
if not self.__hash_utils_instance_respond_to? :hash?
|
857
858
|
def hash?
|
858
859
|
true
|
@@ -866,6 +867,7 @@ class Hash
|
|
866
867
|
# @see http://www.php.net/array_flip
|
867
868
|
# @since 2.0.1
|
868
869
|
#
|
870
|
+
|
869
871
|
if not self.__hash_utils_instance_respond_to? :flip
|
870
872
|
def flip
|
871
873
|
self.map_pairs { |k, v| [v, k] }
|
@@ -879,10 +881,35 @@ class Hash
|
|
879
881
|
# @see http://www.php.net/array_flip
|
880
882
|
# @since 2.0.1
|
881
883
|
#
|
884
|
+
|
882
885
|
if not self.__hash_utils_instance_respond_to? :flip!
|
883
886
|
def flip!
|
884
887
|
self.map_pairs! { |k, v| [v, k] }
|
885
888
|
end
|
886
889
|
end
|
887
|
-
|
890
|
+
|
891
|
+
##
|
892
|
+
# Sums hashes by merging.
|
893
|
+
#
|
894
|
+
# @param [Hash] hash merged item
|
895
|
+
# @return [Hash] new hash
|
896
|
+
# @since 2.1.1
|
897
|
+
#
|
898
|
+
|
899
|
+
if not self.__hash_utils_instance_respond_to? :+
|
900
|
+
alias :+ :merge
|
901
|
+
end
|
902
|
+
|
903
|
+
##
|
904
|
+
# Sums hashes by merging in place.
|
905
|
+
#
|
906
|
+
# @param [Hash] hash merged item
|
907
|
+
# @return [Hash]
|
908
|
+
# @since 2.1.1
|
909
|
+
#
|
910
|
+
|
911
|
+
if not self.__hash_utils_instance_respond_to? :<<
|
912
|
+
alias :<< :merge!
|
913
|
+
end
|
914
|
+
|
888
915
|
end
|
data/lib/hash-utils/symbol.rb
CHANGED
@@ -64,27 +64,31 @@ class Symbol
|
|
64
64
|
##
|
65
65
|
# Returns true if +Symbol+ starts with a prefix given.
|
66
66
|
#
|
67
|
-
# @param [String
|
67
|
+
# @param [Symbol, String] *prefix prefixes for check
|
68
68
|
# @return [Boolean] +true+ if yes, +false+ in otherwise
|
69
69
|
# @since 0.12.0
|
70
|
+
# @since 2.1.1 receives also +Symbol+
|
70
71
|
#
|
71
72
|
|
72
73
|
if not self.__hash_utils_instance_respond_to? :start_with?
|
73
74
|
def start_with?(*prefix)
|
75
|
+
prefix.map! { |i| i.to_s }
|
74
76
|
self.to_s.start_with?(*prefix)
|
75
77
|
end
|
76
78
|
end
|
77
79
|
|
78
80
|
##
|
79
|
-
# Returns true if +Symbol+ ends with a
|
81
|
+
# Returns true if +Symbol+ ends with a suffix given.
|
80
82
|
#
|
81
|
-
# @param [String
|
83
|
+
# @param [Symbol, String] *suffix suffixes for check
|
82
84
|
# @return [Boolean] +true+ if yes, +false+ in otherwise
|
83
85
|
# @since 0.12.0
|
86
|
+
# @since 2.1.1 receives also +Symbol+
|
84
87
|
#
|
85
88
|
|
86
89
|
if not self.__hash_utils_instance_respond_to? :end_with?
|
87
90
|
def end_with?(*suffix)
|
91
|
+
suffix.map! { |i| i.to_s }
|
88
92
|
self.to_s.end_with?(*suffix)
|
89
93
|
end
|
90
94
|
end
|
data/spec/modules/symbol_spec.rb
CHANGED
@@ -24,6 +24,9 @@ describe "Symbol" do
|
|
24
24
|
end
|
25
25
|
specify("#end_with?") do
|
26
26
|
:abcde.end_with?("ghi", "cde").should be_true
|
27
|
+
:abcde.end_with?(:ghi, :cde).should be_true
|
28
|
+
:abcde.end_with?("ghi").should be_false
|
29
|
+
:abcde.end_with?(:ghi).should be_false
|
27
30
|
end
|
28
31
|
specify("#prepend") do
|
29
32
|
:abcd.prepend("012").should eq(:"012abcd")
|
@@ -33,6 +36,9 @@ describe "Symbol" do
|
|
33
36
|
end
|
34
37
|
specify("#start_with?") do
|
35
38
|
:abcde.start_with?("ghi", "abc").should be_true
|
39
|
+
:abcde.start_with?(:ghi, :abc).should be_true
|
40
|
+
:abcde.start_with?("ghi").should be_false
|
41
|
+
:abcde.start_with?(:ghi).should be_false
|
36
42
|
end
|
37
43
|
specify("#strip") do
|
38
44
|
:" a ".strip.should eq(:a)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hash-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ruby-version
|
@@ -170,7 +170,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
170
170
|
version: '0'
|
171
171
|
segments:
|
172
172
|
- 0
|
173
|
-
hash:
|
173
|
+
hash: -1342609353394313918
|
174
174
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
175
|
none: false
|
176
176
|
requirements:
|
@@ -179,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
179
179
|
version: '0'
|
180
180
|
requirements: []
|
181
181
|
rubyforge_project:
|
182
|
-
rubygems_version: 1.8.
|
182
|
+
rubygems_version: 1.8.25
|
183
183
|
signing_key:
|
184
184
|
specification_version: 3
|
185
185
|
summary: Adds more than 155 useful and frequently rather fundamental methods which
|