sixarm_ruby_array_slice 2.1.2 → 2.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +78 -0
- data/VERSION +1 -1
- data/lib/sixarm_ruby_array_slice.rb +1 -1
- data/test/sixarm_ruby_array_slice_test.rb +100 -98
- data.tar.gz.sig +1 -1
- metadata +4 -7
- metadata.gz.sig +3 -1
- data/CHANGELOG.txt +0 -4
- data/INSTALL.txt +0 -32
- data/LICENSE.txt +0 -25
- data/README.rdoc +0 -15
data/README.md
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# SixArm.com » Ruby » <br> Array slice methods by size and share
|
2
|
+
|
3
|
+
* Docs: <http://sixarm.com/sixarm_ruby_array_slice/doc>
|
4
|
+
* Repo: <http://github.com/sixarm/sixarm_ruby_array_slice>
|
5
|
+
* Email: Joel Parker Henderson, <joel@sixarm.com>
|
6
|
+
|
7
|
+
|
8
|
+
## Introduction
|
9
|
+
|
10
|
+
Array slice methods:
|
11
|
+
|
12
|
+
* #slice_by_share: divides an array into a given number of slices
|
13
|
+
* #slice_by_size: divides an array into a slices of a given size
|
14
|
+
|
15
|
+
For docs go to <http://sixarm.com/sixarm_ruby_array_slice/doc>
|
16
|
+
|
17
|
+
Want to help? We're happy to get pull requests.
|
18
|
+
|
19
|
+
|
20
|
+
## Quickstart
|
21
|
+
|
22
|
+
Install:
|
23
|
+
|
24
|
+
gem install sixarm_ruby_array_slice
|
25
|
+
|
26
|
+
Bundler:
|
27
|
+
|
28
|
+
gem "sixarm_ruby_array_slice", "=2.1.4"
|
29
|
+
|
30
|
+
Require:
|
31
|
+
|
32
|
+
require "sixarm_ruby_array_slice"
|
33
|
+
|
34
|
+
|
35
|
+
## Example
|
36
|
+
|
37
|
+
Example of both ways to slice:
|
38
|
+
|
39
|
+
[1,2,3,4,5,6,7,8].slice_by_size(2)
|
40
|
+
=> [[1,2],[3,4],[5,6],[7,8]]
|
41
|
+
|
42
|
+
[1,2,3,4,5,6,7,8].slice_by_share(2)
|
43
|
+
=> [[1,2,3,4],[5,6,7,8]]
|
44
|
+
|
45
|
+
|
46
|
+
## Changes
|
47
|
+
|
48
|
+
* 2012-03-16 2.1.4 1.9.3; minitest/spec; update docs, tests.
|
49
|
+
* 2012-02-01 1.0.0 Publish.
|
50
|
+
|
51
|
+
|
52
|
+
## License
|
53
|
+
|
54
|
+
You may choose any of these open source licenses:
|
55
|
+
|
56
|
+
* Apache License
|
57
|
+
* BSD License
|
58
|
+
* CreativeCommons License, Non-commercial Share Alike
|
59
|
+
* GNU General Public License Version 2 (GPL 2)
|
60
|
+
* GNU Lesser General Public License (LGPL)
|
61
|
+
* MIT License
|
62
|
+
* Perl Artistic License
|
63
|
+
* Ruby License
|
64
|
+
|
65
|
+
The software is provided "as is", without warranty of any kind,
|
66
|
+
express or implied, including but not limited to the warranties of
|
67
|
+
merchantability, fitness for a particular purpose and noninfringement.
|
68
|
+
|
69
|
+
In no event shall the authors or copyright holders be liable for any
|
70
|
+
claim, damages or other liability, whether in an action of contract,
|
71
|
+
tort or otherwise, arising from, out of or in connection with the
|
72
|
+
software or the use or other dealings in the software.
|
73
|
+
|
74
|
+
This license is for the included software that is created by SixArm;
|
75
|
+
some of the included software may have its own licenses, copyrights,
|
76
|
+
authors, etc. and these do take precedence over the SixArm license.
|
77
|
+
|
78
|
+
Copyright (c) 2005-2013 Joel Parker Henderson
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.
|
1
|
+
2.1.4
|
@@ -1,105 +1,107 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
require '
|
2
|
+
require 'minitest/autorun'
|
3
3
|
require 'simplecov'
|
4
4
|
SimpleCov.start
|
5
5
|
require 'sixarm_ruby_array_slice'
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
7
|
+
describe Array do
|
8
|
+
|
9
|
+
before do
|
10
|
+
A ||= [1,2,3,4,5,6,7,8]
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#slice_by_size" do
|
14
|
+
|
15
|
+
it "with 1 count" do
|
16
|
+
A.slice_by_size(1).must_equal [[1],[2],[3],[4],[5],[6],[7],[8]]
|
17
|
+
end
|
18
|
+
|
19
|
+
it "with balanced results" do
|
20
|
+
A.slice_by_size(2).must_equal [[1,2],[3,4],[5,6],[7,8]]
|
21
|
+
A.slice_by_size(4).must_equal [[1,2,3,4],[5,6,7,8]]
|
22
|
+
end
|
23
|
+
|
24
|
+
it "with unbalanced results" do
|
25
|
+
A.slice_by_size(3).must_equal [[1,2,3],[4,5,6],[7,8]]
|
26
|
+
end
|
27
|
+
|
28
|
+
it "with very unbalanced results" do
|
29
|
+
A.slice_by_size(7).must_equal [[1,2,3,4,5,6,7],[8]]
|
30
|
+
end
|
31
|
+
|
32
|
+
it "with empty input" do
|
33
|
+
[].slice_by_size(1).must_equal []
|
34
|
+
end
|
35
|
+
|
36
|
+
it "with 0 count" do
|
37
|
+
assert_raise ArgumentError do
|
38
|
+
A.slice_by_size(0)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
it "with negative count" do
|
43
|
+
assert_raise ArgumentError do
|
44
|
+
A.slice_by_size(-1)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
it "with float count" do
|
49
|
+
assert_raise ArgumentError do
|
50
|
+
A.slice_by_size(1.234)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
it "with non numeric count" do
|
55
|
+
assert_raise ArgumentError do
|
56
|
+
A.slice_by_size(1.234)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "#slice_by_share" do
|
63
|
+
|
64
|
+
it "with 1 count" do
|
65
|
+
A.slice_by_share(1).must_equal [[1,2,3,4,5,6,7,8]]
|
66
|
+
end
|
67
|
+
|
68
|
+
it "with balanced results" do
|
69
|
+
A.slice_by_share(2).must_equal [[1,2,3,4],[5,6,7,8]]
|
70
|
+
A.slice_by_share(4).must_equal [[1,2],[3,4],[5,6],[7,8]]
|
71
|
+
end
|
72
|
+
|
73
|
+
it "with unbalanced results" do
|
74
|
+
A.slice_by_share(3).must_equal [[1,2,3],[4,5,6],[7,8]]
|
75
|
+
end
|
76
|
+
|
77
|
+
it "with very unbalanced results" do
|
78
|
+
A.slice_by_share(7).must_equal [[1,2],[3,4],[5,6],[7,8],[],[],[]]
|
79
|
+
end
|
80
|
+
|
81
|
+
it "with zero count" do
|
82
|
+
assert_raise ArgumentError do
|
83
|
+
A.slice_by_share(0)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
it "with negative count" do
|
88
|
+
assert_raise ArgumentError do
|
89
|
+
A.slice_by_share(-1)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
it "with float count" do
|
94
|
+
assert_raise ArgumentError do
|
95
|
+
A.slice_by_share(1.234)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
it "with non numeric count" do
|
100
|
+
assert_raise ArgumentError do
|
101
|
+
A.slice_by_share("")
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
104
106
|
|
105
107
|
end
|
data.tar.gz.sig
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
uB��xh���4�ہ19��j䖤x6cl��{��n����p� �HDq��w�;�+�x-�g�*g3n���9��Y �x!���0��n�����i���P��<)^C�o/��h�!�|D7I����U���"G
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sixarm_ruby_array_slice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
L2RORkllUkVIekVSClpEUlFZTXFydTlURU1uYTZIRDl6cGNzdEY3dndUaEdv
|
36
36
|
dmxPUSszWTZwbFE0bk16aXBYY1o5VEhxczY1UElMMHEKZWFid3BDYkFvcG89
|
37
37
|
Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
|
38
|
-
date: 2012-
|
38
|
+
date: 2012-03-16 00:00:00.000000000 Z
|
39
39
|
dependencies: []
|
40
40
|
description:
|
41
41
|
email: sixarm@sixarm.com
|
@@ -44,11 +44,8 @@ extensions: []
|
|
44
44
|
extra_rdoc_files: []
|
45
45
|
files:
|
46
46
|
- .gemtest
|
47
|
-
- CHANGELOG.txt
|
48
|
-
- INSTALL.txt
|
49
|
-
- LICENSE.txt
|
50
47
|
- Rakefile
|
51
|
-
- README.
|
48
|
+
- README.md
|
52
49
|
- VERSION
|
53
50
|
- lib/sixarm_ruby_array_slice.rb
|
54
51
|
- test/sixarm_ruby_array_slice_test.rb
|
@@ -72,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
69
|
version: '0'
|
73
70
|
requirements: []
|
74
71
|
rubyforge_project:
|
75
|
-
rubygems_version: 1.8.
|
72
|
+
rubygems_version: 1.8.11
|
76
73
|
signing_key:
|
77
74
|
specification_version: 3
|
78
75
|
summary: SixArm.com » Ruby » Array slice methods
|
metadata.gz.sig
CHANGED
data/CHANGELOG.txt
DELETED
data/INSTALL.txt
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
|
2
|
-
= SixArm.com Ruby Gem Install
|
3
|
-
|
4
|
-
|
5
|
-
First-time users: add our gem certificate and source.
|
6
|
-
When you do this once, it works for all our gems.
|
7
|
-
|
8
|
-
sudo wget http://sixarm.com/sixarm.pem
|
9
|
-
sudo gem cert --add sixarm.pem
|
10
|
-
sudo gem sources --add http://sixarm.com
|
11
|
-
|
12
|
-
Install the gem with advanced options.
|
13
|
-
|
14
|
-
sudo gem install sixarm_ruby_array_slice --test --trust-policy HighSecurity
|
15
|
-
|
16
|
-
|
17
|
-
== Notes
|
18
|
-
|
19
|
-
Do you have any questions, comments, suggestions, or feedback?
|
20
|
-
Let us know, we're happy to help. Our email is sixarm@sixarm.com
|
21
|
-
|
22
|
-
Do you want to create your own high security gems?
|
23
|
-
Learn how at http://www.rubygems.org/read/chapter/21
|
24
|
-
|
25
|
-
To see your current gem certificate list:
|
26
|
-
|
27
|
-
sudo gem cert --list
|
28
|
-
|
29
|
-
Our cert looks like this:
|
30
|
-
|
31
|
-
/C=US/ST=California/L=San Francisco/O=SixArm/CN=sixarm.com
|
32
|
-
|
data/LICENSE.txt
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
LICENSE
|
2
|
-
|
3
|
-
You may choose any of these open source licenses:
|
4
|
-
|
5
|
-
- Apache License
|
6
|
-
- BSD License
|
7
|
-
- CreativeCommons License, Non-commercial Share Alike
|
8
|
-
- GNU General Public License Version 2 (GPL 2)
|
9
|
-
- GNU Lesser General Public License (LGPL)
|
10
|
-
- MIT License
|
11
|
-
- Perl Artistic License
|
12
|
-
- Ruby License
|
13
|
-
|
14
|
-
The software is provided "as is", without warranty of any kind,
|
15
|
-
express or implied, including but not limited to the warranties of
|
16
|
-
merchantability, fitness for a particular purpose and noninfringement.
|
17
|
-
|
18
|
-
In no event shall the authors or copyright holders be liable for any
|
19
|
-
claim, damages or other liability, whether in an action of contract,
|
20
|
-
tort or otherwise, arising from, out of or in connection with the
|
21
|
-
software or the use or other dealings in the software.
|
22
|
-
|
23
|
-
This license is for the included software that is created by SixArm;
|
24
|
-
some of the included software may have its own licenses, copyrights,
|
25
|
-
authors, etc. and these do take precedence over the SixArm license.
|
data/README.rdoc
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
= SixArm.com » Ruby » Array slices by size and count
|
2
|
-
|
3
|
-
Author:: Joel Parker Henderson, joel@joelparkerhenderson.com
|
4
|
-
Copyright:: Copyright (c) 2006-2012 Joel Parker Henderson
|
5
|
-
License:: See LICENSE.txt file
|
6
|
-
|
7
|
-
Array slice methods:
|
8
|
-
|
9
|
-
* #slice_by_share: divides an array into a given number of slices
|
10
|
-
* #slice_by_size: divides an array into a slices of a given size
|
11
|
-
|
12
|
-
These methods are extraced from the sixarm_ruby_ramp gem.
|
13
|
-
|
14
|
-
|
15
|
-
|