hash-utils 2.1.1 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +7 -0
- data/Gemfile.lock +13 -13
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/VERSION +1 -1
- data/hash-utils.gemspec +2 -2
- data/lib/hash-utils/hash.rb +28 -0
- data/spec/modules/hash_spec.rb +8 -0
- metadata +17 -17
data/CHANGES.txt
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,26 +1,26 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
diff-lcs (1.
|
4
|
+
diff-lcs (1.2.4)
|
5
5
|
git (1.2.5)
|
6
6
|
jeweler (1.8.4)
|
7
7
|
bundler (~> 1.0)
|
8
8
|
git (>= 1.2.5)
|
9
9
|
rake
|
10
10
|
rdoc
|
11
|
-
json (1.
|
12
|
-
multi_json (1.4
|
13
|
-
rake (10.0.
|
14
|
-
rdoc (
|
11
|
+
json (1.8.0)
|
12
|
+
multi_json (1.7.4)
|
13
|
+
rake (10.0.4)
|
14
|
+
rdoc (4.0.1)
|
15
15
|
json (~> 1.4)
|
16
|
-
rspec (2.
|
17
|
-
rspec-core (~> 2.
|
18
|
-
rspec-expectations (~> 2.
|
19
|
-
rspec-mocks (~> 2.
|
20
|
-
rspec-core (2.
|
21
|
-
rspec-expectations (2.
|
22
|
-
diff-lcs (
|
23
|
-
rspec-mocks (2.
|
16
|
+
rspec (2.13.0)
|
17
|
+
rspec-core (~> 2.13.0)
|
18
|
+
rspec-expectations (~> 2.13.0)
|
19
|
+
rspec-mocks (~> 2.13.0)
|
20
|
+
rspec-core (2.13.1)
|
21
|
+
rspec-expectations (2.13.0)
|
22
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
23
|
+
rspec-mocks (2.13.1)
|
24
24
|
ruby-version (0.4.3)
|
25
25
|
simplecov (0.7.1)
|
26
26
|
multi_json (~> 1.0)
|
data/LICENSE.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2011-
|
1
|
+
Copyright (c) 2011-2013 Martin Kozák (martinkozak@martinkozak.net)
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
a copy of this software and associated documentation files (the
|
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` – 46 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.2
|
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.2"
|
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 = "2013-
|
12
|
+
s.date = "2013-06-07"
|
13
13
|
s.email = "martinkozak@martinkozak.net"
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE.txt",
|
data/lib/hash-utils/hash.rb
CHANGED
@@ -911,5 +911,33 @@ class Hash
|
|
911
911
|
if not self.__hash_utils_instance_respond_to? :<<
|
912
912
|
alias :<< :merge!
|
913
913
|
end
|
914
|
+
|
915
|
+
##
|
916
|
+
# Returns first key of the hash.
|
917
|
+
#
|
918
|
+
# @return [Object]
|
919
|
+
# @since 2.1.2
|
920
|
+
#
|
921
|
+
|
922
|
+
if not self.__hash_utils_instance_respond_to? :first_key
|
923
|
+
def first_key
|
924
|
+
first = self.first
|
925
|
+
first ? first.first : nil
|
926
|
+
end
|
927
|
+
end
|
928
|
+
|
929
|
+
##
|
930
|
+
# Returns first value in the hash.
|
931
|
+
#
|
932
|
+
# @return [Object]
|
933
|
+
# @since 2.1.2
|
934
|
+
#
|
914
935
|
|
936
|
+
if not self.__hash_utils_instance_respond_to? :first_value
|
937
|
+
def first_value
|
938
|
+
first = self.first
|
939
|
+
first ? first.second : nil
|
940
|
+
end
|
941
|
+
end
|
942
|
+
|
915
943
|
end
|
data/spec/modules/hash_spec.rb
CHANGED
@@ -69,6 +69,14 @@ describe "Hash" do
|
|
69
69
|
t1.default.should eq(:default)
|
70
70
|
t2.default_proc.should eq(proc)
|
71
71
|
end
|
72
|
+
specify("#first_key") do
|
73
|
+
{:a => :b}.first_key.should eq(:a)
|
74
|
+
{ }.first_key.should be_nil
|
75
|
+
end
|
76
|
+
specify("#first_value") do
|
77
|
+
{:a => :b}.first_value.should eq(:b)
|
78
|
+
{ }.first_key.should be_nil
|
79
|
+
end
|
72
80
|
specify("#flip") do
|
73
81
|
t = { :a => 1, :b => 2, :c => 2 }
|
74
82
|
result = t.flip
|
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.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,14 +9,14 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-06-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ruby-version
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: 0.4.0
|
22
22
|
type: :runtime
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 0.4.0
|
30
30
|
- !ruby/object:Gem::Dependency
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
35
|
-
- -
|
35
|
+
- - '>='
|
36
36
|
- !ruby/object:Gem::Version
|
37
37
|
version: '0'
|
38
38
|
type: :development
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
|
-
- -
|
43
|
+
- - '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
46
|
- !ruby/object:Gem::Dependency
|
@@ -48,7 +48,7 @@ dependencies:
|
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
49
49
|
none: false
|
50
50
|
requirements:
|
51
|
-
- -
|
51
|
+
- - '>='
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '0'
|
54
54
|
type: :development
|
@@ -56,7 +56,7 @@ dependencies:
|
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
- !ruby/object:Gem::Dependency
|
@@ -64,7 +64,7 @@ dependencies:
|
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
65
65
|
none: false
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - '>='
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
70
|
type: :development
|
@@ -72,7 +72,7 @@ dependencies:
|
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
|
-
- -
|
75
|
+
- - '>='
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
78
|
- !ruby/object:Gem::Dependency
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|
81
81
|
none: false
|
82
82
|
requirements:
|
83
|
-
- -
|
83
|
+
- - '>='
|
84
84
|
- !ruby/object:Gem::Version
|
85
85
|
version: '0'
|
86
86
|
type: :development
|
@@ -88,7 +88,7 @@ dependencies:
|
|
88
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
89
|
none: false
|
90
90
|
requirements:
|
91
|
-
- -
|
91
|
+
- - '>='
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
94
|
- !ruby/object:Gem::Dependency
|
@@ -96,7 +96,7 @@ dependencies:
|
|
96
96
|
requirement: !ruby/object:Gem::Requirement
|
97
97
|
none: false
|
98
98
|
requirements:
|
99
|
-
- -
|
99
|
+
- - '>='
|
100
100
|
- !ruby/object:Gem::Version
|
101
101
|
version: '0'
|
102
102
|
type: :development
|
@@ -104,7 +104,7 @@ dependencies:
|
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
|
-
- -
|
107
|
+
- - '>='
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
110
|
description:
|
@@ -165,16 +165,16 @@ require_paths:
|
|
165
165
|
required_ruby_version: !ruby/object:Gem::Requirement
|
166
166
|
none: false
|
167
167
|
requirements:
|
168
|
-
- -
|
168
|
+
- - '>='
|
169
169
|
- !ruby/object:Gem::Version
|
170
170
|
version: '0'
|
171
171
|
segments:
|
172
172
|
- 0
|
173
|
-
hash:
|
173
|
+
hash: 814178071789703873
|
174
174
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
175
|
none: false
|
176
176
|
requirements:
|
177
|
-
- -
|
177
|
+
- - '>='
|
178
178
|
- !ruby/object:Gem::Version
|
179
179
|
version: '0'
|
180
180
|
requirements: []
|