lxa_core_extensions 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +4 -0
- data/lib/lxa_core_extensions/array.rb +1 -2
- data/lib/lxa_core_extensions/enumerable.rb +4 -0
- data/lib/lxa_core_extensions/version.rb +1 -1
- data/test/helper.rb +0 -1
- data/test/test_enumerable.rb +9 -1
- metadata +12 -24
- data/hash_spec.rb +0 -33
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 433e6a868a245c0743c8263917c7b3a9be1523be
|
4
|
+
data.tar.gz: 56767bb2416b5b0d96dc914383abee66b825f1bc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9f51836a3565bb3265f8de38c59e93738e1f023401572486b5209b6fe7ce516ce595e83b9678b8f355063a6b8bdaf2d9401d88270810f6edce317e5bfb196b19
|
7
|
+
data.tar.gz: fea7d4729de89474b39d97bc76c2ccbd2cf27db0a1aa0850db528c2bdd0eaea9d757d4d66e3ca453cab90b24805ff2e28e96c33dbe09b24f805d751fe3bbf83b
|
data/README.md
CHANGED
@@ -16,6 +16,10 @@ simple core extensions for ruby:
|
|
16
16
|
[[1,2],[3,4],[5,6]].build_hash #=> {1=>2, 3=>4, 5=>6}
|
17
17
|
[[1,2],[3,4],[5,6]].build_hash(:last) #=> {2=>[1,2], 4=>[3,4], 6=>[5,6]}
|
18
18
|
|
19
|
+
### Enumerable#tally
|
20
|
+
|
21
|
+
[4,4,4,4,"3","3","3","one"].tally => [[4,4], [3,"3"], [1,"one"]]
|
22
|
+
|
19
23
|
### Hash#compact
|
20
24
|
|
21
25
|
{ 4=>35, 9=>nil, 10=>false }.compact #=> {4=>35, 10=>false}
|
data/test/helper.rb
CHANGED
data/test/test_enumerable.rb
CHANGED
@@ -5,7 +5,7 @@ describe "Enumerable#build_hash" do
|
|
5
5
|
assert_equal({1=>2, 3=>4, 5=>6},
|
6
6
|
[[1,2],[3,4],[5,6]].build_hash)
|
7
7
|
|
8
|
-
assert_equal(
|
8
|
+
assert_equal({2=>[1,2], 4=>[3,4],6=>[5,6]},
|
9
9
|
[[1,2],[3,4],[5,6]].build_hash(:last))
|
10
10
|
|
11
11
|
assert_equal({1=>1, 2=>2, 3=>3},
|
@@ -19,3 +19,11 @@ describe "Enumerable#build_hash" do
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
describe "Enumerable#tally" do
|
23
|
+
it "should count items" do
|
24
|
+
assert_equal([[4,4], [3,"3"], [1,"one"]],
|
25
|
+
[4,4,4,4,"3","3","3","one"].tally)
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
metadata
CHANGED
@@ -1,46 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lxa_core_extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Levin Alexander
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-07-24 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: minitest
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
description: simple core extensions
|
@@ -55,7 +50,6 @@ files:
|
|
55
50
|
- LICENSE.txt
|
56
51
|
- README.md
|
57
52
|
- Rakefile
|
58
|
-
- hash_spec.rb
|
59
53
|
- lib/lxa_core_extensions.rb
|
60
54
|
- lib/lxa_core_extensions/array.rb
|
61
55
|
- lib/lxa_core_extensions/constants.rb
|
@@ -70,33 +64,26 @@ files:
|
|
70
64
|
- test/test_hash.rb
|
71
65
|
homepage: ''
|
72
66
|
licenses: []
|
67
|
+
metadata: {}
|
73
68
|
post_install_message:
|
74
69
|
rdoc_options: []
|
75
70
|
require_paths:
|
76
71
|
- lib
|
77
72
|
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
-
none: false
|
79
73
|
requirements:
|
80
|
-
- -
|
74
|
+
- - '>='
|
81
75
|
- !ruby/object:Gem::Version
|
82
76
|
version: '0'
|
83
|
-
segments:
|
84
|
-
- 0
|
85
|
-
hash: -2106405039464562958
|
86
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
-
none: false
|
88
78
|
requirements:
|
89
|
-
- -
|
79
|
+
- - '>='
|
90
80
|
- !ruby/object:Gem::Version
|
91
81
|
version: '0'
|
92
|
-
segments:
|
93
|
-
- 0
|
94
|
-
hash: -2106405039464562958
|
95
82
|
requirements: []
|
96
83
|
rubyforge_project:
|
97
|
-
rubygems_version:
|
84
|
+
rubygems_version: 2.0.0
|
98
85
|
signing_key:
|
99
|
-
specification_version:
|
86
|
+
specification_version: 4
|
100
87
|
summary: simple utility methods like Hash#compact and Enumerable#build_hash
|
101
88
|
test_files:
|
102
89
|
- test/helper.rb
|
@@ -104,3 +91,4 @@ test_files:
|
|
104
91
|
- test/test_constants.rb
|
105
92
|
- test/test_enumerable.rb
|
106
93
|
- test/test_hash.rb
|
94
|
+
has_rdoc:
|
data/hash_spec.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Hash#flip" do
|
4
|
-
it "should work" do
|
5
|
-
{1=>2, 3=>4, 5=>6, 6=>2, 7=>4}.flip.should == {2=>[1, 6], 4=>[3, 7], 6=>[5]}
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
|
10
|
-
describe "Hash#compact" do
|
11
|
-
it "should compact without block" do
|
12
|
-
{ 4=>35, 9=>nil, 10=>false }.compact.should == {4=>35, 10=>false}
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should compact with block" do
|
16
|
-
{ 4=>35, 9=>nil, 10=>false }.compact(&:blank?).should == {4=>35}
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "Hash#rekey" do
|
21
|
-
it "should work" do
|
22
|
-
{1=>2, 3=>4, 5=>{6=>7, 8=>9}}.rekey(&:to_s).should == {"1"=>2,"3"=>4, "5"=>{"6"=>7, "8"=>9}}
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
|
27
|
-
describe "Hash#nested_keys" do
|
28
|
-
it "should work" do
|
29
|
-
{1=>2, 3=>4, 5=>{6=>7, 8=> {9=>10}}}.nested_keys.to_a.should == [1,3,5,6,8,9]
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
|