iteration 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.md +32 -0
- data/LICENSE.txt +23 -0
- data/README.md +73 -0
- data/lib/iteration.rb +6 -7
- metadata +72 -18
- data/COPYING.rdoc +0 -31
- data/HISTORY.rdoc +0 -21
- data/README.rdoc +0 -76
data/HISTORY.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# HISTORY
|
2
|
+
|
3
|
+
## 1.1.1 / 2013-03-10
|
4
|
+
|
5
|
+
This release fixes a bug in #each_with_iteration. When no
|
6
|
+
block was given, the enumerator returned was for `#each_iteration`
|
7
|
+
instead of `#each_with_iteration`.
|
8
|
+
|
9
|
+
Changes:
|
10
|
+
|
11
|
+
* Return corrert enumerator for #each_with_iteration.
|
12
|
+
|
13
|
+
|
14
|
+
## 1.1.0 / 2012-12-31
|
15
|
+
|
16
|
+
This release move the Iteration class to the toplevel
|
17
|
+
namespace.
|
18
|
+
|
19
|
+
Changes:
|
20
|
+
|
21
|
+
* Move Iteration to toplevel.
|
22
|
+
* Modernize build configuration.
|
23
|
+
|
24
|
+
|
25
|
+
## 1.0.0 / 2009-07-18
|
26
|
+
|
27
|
+
This is the initial release of Iteration.
|
28
|
+
|
29
|
+
Changes:
|
30
|
+
|
31
|
+
* Happy Birthday!
|
32
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
(BSD-2-Clause)
|
2
|
+
|
3
|
+
Redistribution and use in source and binary forms, with or without
|
4
|
+
modification, are permitted provided that the following conditions are met:
|
5
|
+
|
6
|
+
1. Redistributions of source code must retain the above copyright notice,
|
7
|
+
this list of conditions and the following disclaimer.
|
8
|
+
|
9
|
+
2. Redistributions in binary form must reproduce the above copyright
|
10
|
+
notice, this list of conditions and the following disclaimer in the
|
11
|
+
documentation and/or other materials provided with the distribution.
|
12
|
+
|
13
|
+
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
14
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
15
|
+
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
16
|
+
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
17
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
18
|
+
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
19
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
20
|
+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
21
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
22
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
23
|
+
|
data/README.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# Iteration
|
2
|
+
|
3
|
+
[Website](http://rubyworks.github.com/iteration) /
|
4
|
+
[Documentation](http://rubydoc.info/gems/iteration) /
|
5
|
+
[Report Issue](http://github.com/rubyworks/iteration/issues) /
|
6
|
+
[Development](http://github.com/rubyworks/iteration)
|
7
|
+
|
8
|
+
[![Build Status](https://secure.travis-ci.org/rubyworks/iteration.png)](http://travis-ci.org/rubyworks/iteration)
|
9
|
+
[![Gem Version](https://badge.fury.io/rb/iteration.png)](http://badge.fury.io/rb/iteration)
|
10
|
+
|
11
|
+
|
12
|
+
## DESCRIPTION
|
13
|
+
|
14
|
+
Have you ever wanted to know if an iteration was the last,
|
15
|
+
or the first, or what iteration results came before the
|
16
|
+
current? Well, now you can! Iteration is a class that encapsulates
|
17
|
+
a step in an each loop. It can be used to query infromation about
|
18
|
+
an iteration easily.
|
19
|
+
|
20
|
+
|
21
|
+
## FEATURES
|
22
|
+
|
23
|
+
* Query sate of each iteration.
|
24
|
+
* Supports look-ahead features on Arrays.
|
25
|
+
|
26
|
+
|
27
|
+
## SYNOPSIS
|
28
|
+
|
29
|
+
Iterate over each element of array using an iteration object.
|
30
|
+
|
31
|
+
[1,2,3].each_iteration do |it|
|
32
|
+
p it.index
|
33
|
+
p it.value
|
34
|
+
p it.first?
|
35
|
+
p it.last?
|
36
|
+
p it.prior
|
37
|
+
p it.after
|
38
|
+
end
|
39
|
+
|
40
|
+
on each successive iteration produces:
|
41
|
+
|
42
|
+
0 1 2
|
43
|
+
1 2 3
|
44
|
+
true false false
|
45
|
+
false false true
|
46
|
+
[] [1] [1,2]
|
47
|
+
[2,3] [3] []
|
48
|
+
|
49
|
+
|
50
|
+
## HOW TO INSTALL
|
51
|
+
|
52
|
+
To install with RubyGems simply open a console and type:
|
53
|
+
|
54
|
+
gem install iteration
|
55
|
+
|
56
|
+
Local installation requires Setup.rb (gem install setup),
|
57
|
+
then download the tarball package and type:
|
58
|
+
|
59
|
+
tar -xvzf iteration-1.0.0.tgz
|
60
|
+
cd iteration-1.0.0.tgz
|
61
|
+
sudo setup.rb all
|
62
|
+
|
63
|
+
Windows users use 'ruby setup.rb all'.
|
64
|
+
|
65
|
+
|
66
|
+
## COPYRIGHTS
|
67
|
+
|
68
|
+
Copyright (c) 2009 Rubyworks
|
69
|
+
|
70
|
+
This program is ditributed unser the terms of the *BSD-2-Clause* license.
|
71
|
+
|
72
|
+
See LICENSE.txt file for details.
|
73
|
+
|
data/lib/iteration.rb
CHANGED
@@ -30,7 +30,7 @@ class Iteration
|
|
30
30
|
|
31
31
|
#private
|
32
32
|
|
33
|
-
# TODO: For Ruby 1.9 make private and use fcall
|
33
|
+
# TODO: For Ruby 1.9 make private and use fcall ?
|
34
34
|
#
|
35
35
|
def __step__(value, &block)
|
36
36
|
@value = value
|
@@ -61,7 +61,7 @@ class Enumerator
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
def with_iteration(&block)
|
64
|
+
def with_iteration(&block) #:yield:
|
65
65
|
it = Iteration.new(self)
|
66
66
|
each do |e|
|
67
67
|
it.__step__(e){ yield(e,it) }
|
@@ -83,7 +83,7 @@ class Array
|
|
83
83
|
# p it.after
|
84
84
|
# end
|
85
85
|
#
|
86
|
-
#
|
86
|
+
# On each successive iteration this produces:
|
87
87
|
#
|
88
88
|
# 0 1 2
|
89
89
|
# 1 2 3
|
@@ -92,8 +92,7 @@ class Array
|
|
92
92
|
# [] [1] [1,2]
|
93
93
|
# [2,3] [3] []
|
94
94
|
#
|
95
|
-
#
|
96
|
-
|
95
|
+
# @return [Enumerator] if no block is given, otherwise nothing.
|
97
96
|
def each_iteration(&block)
|
98
97
|
if block_given?
|
99
98
|
it = Iteration.new(self)
|
@@ -108,6 +107,7 @@ class Array
|
|
108
107
|
# Same as #each_iteration, but provides both the iterated
|
109
108
|
# element and the iteration.
|
110
109
|
#
|
110
|
+
# @return [Enumerator] if no block is given, otherwise nothing.
|
111
111
|
def each_with_iteration(&block)
|
112
112
|
if block_given?
|
113
113
|
it = Iteration.new(self)
|
@@ -115,9 +115,8 @@ class Array
|
|
115
115
|
it.__step__(e){ yield(e, it) }
|
116
116
|
end
|
117
117
|
else
|
118
|
-
Enumerator.new(self, :
|
118
|
+
Enumerator.new(self, :each_with_iteration)
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
122
|
end
|
123
|
-
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iteration
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-03-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: detroit
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,31 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: ergo
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
25
46
|
- !ruby/object:Gem::Dependency
|
26
47
|
name: rubytest
|
27
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
28
49
|
none: false
|
29
50
|
requirements:
|
30
51
|
- - ! '>='
|
@@ -32,10 +53,31 @@ dependencies:
|
|
32
53
|
version: '0'
|
33
54
|
type: :development
|
34
55
|
prerelease: false
|
35
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rubytest-cli
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
36
78
|
- !ruby/object:Gem::Dependency
|
37
79
|
name: microtest
|
38
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
39
81
|
none: false
|
40
82
|
requirements:
|
41
83
|
- - ! '>='
|
@@ -43,10 +85,15 @@ dependencies:
|
|
43
85
|
version: '0'
|
44
86
|
type: :development
|
45
87
|
prerelease: false
|
46
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
47
94
|
- !ruby/object:Gem::Dependency
|
48
95
|
name: ae
|
49
|
-
requirement:
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
50
97
|
none: false
|
51
98
|
requirements:
|
52
99
|
- - ! '>='
|
@@ -54,7 +101,12 @@ dependencies:
|
|
54
101
|
version: '0'
|
55
102
|
type: :development
|
56
103
|
prerelease: false
|
57
|
-
version_requirements:
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
58
110
|
description: ! 'Iteration is class that encapsulate an step in an each loop.
|
59
111
|
|
60
112
|
It can be used to query infromation about an iteration easily.'
|
@@ -63,15 +115,15 @@ email:
|
|
63
115
|
executables: []
|
64
116
|
extensions: []
|
65
117
|
extra_rdoc_files:
|
66
|
-
-
|
67
|
-
-
|
68
|
-
-
|
118
|
+
- LICENSE.txt
|
119
|
+
- HISTORY.md
|
120
|
+
- README.md
|
69
121
|
files:
|
70
122
|
- lib/iteration.rb
|
71
123
|
- test/test_iteration.rb
|
72
|
-
-
|
73
|
-
-
|
74
|
-
-
|
124
|
+
- LICENSE.txt
|
125
|
+
- HISTORY.md
|
126
|
+
- README.md
|
75
127
|
homepage: http://github.com/rubyworks/iteration
|
76
128
|
licenses:
|
77
129
|
- BSD-2-Clause
|
@@ -93,8 +145,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
145
|
version: '0'
|
94
146
|
requirements: []
|
95
147
|
rubyforge_project:
|
96
|
-
rubygems_version: 1.8.
|
148
|
+
rubygems_version: 1.8.24
|
97
149
|
signing_key:
|
98
150
|
specification_version: 3
|
99
151
|
summary: Universal Iteration Object
|
100
|
-
test_files:
|
152
|
+
test_files:
|
153
|
+
- test/test_iteration.rb
|
154
|
+
has_rdoc:
|
data/COPYING.rdoc
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
= COPYRIGHT NOTICES
|
2
|
-
|
3
|
-
== Iteration
|
4
|
-
|
5
|
-
Copyright:: (c) 2007 Rubyworks
|
6
|
-
License:: BSD-2-Clause
|
7
|
-
Website:: http://rubyworks.github.com/iteration
|
8
|
-
|
9
|
-
Copyright 2007 Rubyworks. All rights reserved.
|
10
|
-
|
11
|
-
Redistribution and use in source and binary forms, with or without
|
12
|
-
modification, are permitted provided that the following conditions are met:
|
13
|
-
|
14
|
-
1. Redistributions of source code must retain the above copyright notice,
|
15
|
-
this list of conditions and the following disclaimer.
|
16
|
-
|
17
|
-
2. Redistributions in binary form must reproduce the above copyright
|
18
|
-
notice, this list of conditions and the following disclaimer in the
|
19
|
-
documentation and/or other materials provided with the distribution.
|
20
|
-
|
21
|
-
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
22
|
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
23
|
-
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
24
|
-
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
25
|
-
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
26
|
-
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
27
|
-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
28
|
-
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
29
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
30
|
-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
31
|
-
|
data/HISTORY.rdoc
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
= HISTORY
|
2
|
-
|
3
|
-
== 1.1.0 / 2012-12-31
|
4
|
-
|
5
|
-
This release move the Iteration class to the toplevel
|
6
|
-
namespace.
|
7
|
-
|
8
|
-
Changes:
|
9
|
-
|
10
|
-
* Move Iteration to toplevel.
|
11
|
-
* Modernize build configuration.
|
12
|
-
|
13
|
-
|
14
|
-
== 1.0.0 / 2009-07-18
|
15
|
-
|
16
|
-
This is the initial release of Iteration.
|
17
|
-
|
18
|
-
Changes:
|
19
|
-
|
20
|
-
* Happy Birthday!
|
21
|
-
|
data/README.rdoc
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
= Iteration
|
2
|
-
|
3
|
-
{Website}[http://rubyworks.github.com/iteration] /
|
4
|
-
{Development}[http://github.com/rubyworks/iteration]
|
5
|
-
|
6
|
-
{<img src="https://secure.travis-ci.org/rubyworks/iteration.png" />}[http://travis-ci.org/rubyworks/iteration]
|
7
|
-
|
8
|
-
|
9
|
-
== DESCRIPTION
|
10
|
-
|
11
|
-
Have you ever wanted to know if an iteration was the last,
|
12
|
-
or the first, or what iteration results came before the
|
13
|
-
current? Well, now you can!
|
14
|
-
|
15
|
-
Iteration is a class that encapsulate a step in an each loop.
|
16
|
-
It can be used to query infromation about an iteration easily.
|
17
|
-
|
18
|
-
|
19
|
-
== FEATURES
|
20
|
-
|
21
|
-
* Query sate of each iteration.
|
22
|
-
* Supports look-ahead features on Arrays.
|
23
|
-
|
24
|
-
|
25
|
-
== RELEASE NOTES
|
26
|
-
|
27
|
-
Please see RELEASE file.
|
28
|
-
|
29
|
-
|
30
|
-
== SYNOPSIS
|
31
|
-
|
32
|
-
Iterate over each element of array using an iteration object.
|
33
|
-
|
34
|
-
[1,2,3].each_iteration do |it|
|
35
|
-
p it.index
|
36
|
-
p it.value
|
37
|
-
p it.first?
|
38
|
-
p it.last?
|
39
|
-
p it.prior
|
40
|
-
p it.after
|
41
|
-
end
|
42
|
-
|
43
|
-
on each successive iteration produces:
|
44
|
-
|
45
|
-
0 1 2
|
46
|
-
1 2 3
|
47
|
-
true false false
|
48
|
-
false false true
|
49
|
-
[] [1] [1,2]
|
50
|
-
[2,3] [3] []
|
51
|
-
|
52
|
-
|
53
|
-
== HOW TO INSTALL
|
54
|
-
|
55
|
-
To install with RubyGems simply open a console and type:
|
56
|
-
|
57
|
-
gem install iteration
|
58
|
-
|
59
|
-
Local installation requires Setup.rb (gem install setup),
|
60
|
-
then download the tarball package and type:
|
61
|
-
|
62
|
-
tar -xvzf iteration-1.0.0.tgz
|
63
|
-
cd iteration-1.0.0.tgz
|
64
|
-
sudo setup.rb all
|
65
|
-
|
66
|
-
Windows users use 'ruby setup.rb all'.
|
67
|
-
|
68
|
-
|
69
|
-
== COPYRIGHTS
|
70
|
-
|
71
|
-
Copyright (c) 2009 Rubyworks
|
72
|
-
|
73
|
-
This program is ditributed unser the terms of the *BSD-2-Clause* license.
|
74
|
-
|
75
|
-
See COPYING.rdoc file for details.
|
76
|
-
|