array_floe 1.1.0 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,40 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ # rcov generated
6
+ coverage
7
+
8
+ # rdoc generated
9
+ rdoc
10
+
11
+ # yard generated
12
+ doc
13
+ .yardoc
14
+
15
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
16
+ #
17
+ # * Create a file at ~/.gitignore
18
+ # * Include files you want ignored
19
+ # * Run: git config --global core.excludesfile ~/.gitignore
20
+ #
21
+ # After doing this, these files will be ignored in all your git projects,
22
+ # saving you from having to 'pollute' every project you touch with them
23
+ #
24
+ # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
25
+ #
26
+ # For MacOS:
27
+ #
28
+ #.DS_Store
29
+ #
30
+ # For TextMate
31
+ #*.tmproj
32
+ #tmtags
33
+ #
34
+ # For emacs:
35
+ #*~
36
+ #\#*
37
+ #.\#*
38
+ #
39
+ # For vim:
40
+ #*.swp
data/Gemfile CHANGED
@@ -1,13 +1,4 @@
1
1
  source "http://rubygems.org"
2
- # Add dependencies required to use your gem here.
3
- # Example:
4
- # gem "activesupport", ">= 2.3.5"
5
2
 
6
- # Add dependencies to develop your gem here.
7
- # Include everything needed to run rake, tests, features, etc.
8
- group :development do
9
- gem "rspec", "~> 2.3.0"
10
- gem "bundler", "~> 1.0.0"
11
- gem "jeweler", "~> 1.5.2"
12
- gem "rcov", ">= 0"
13
- end
3
+ # Specify your gem's dependencies in array_floe.gemspec
4
+ gemspec
data/README.rdoc CHANGED
@@ -34,7 +34,7 @@ in the array:
34
34
  assert_equal(i == 0, floe.first?)
35
35
  assert_equal(i == ary.last, floe.last?)
36
36
  assert_equal(i % 2 == 1, float.odd?)
37
- assert_equal(i % 2 == 1, float.even?)
37
+ assert_equal(i % 2 == 0, float.even?)
38
38
  end
39
39
 
40
40
  If no block is given, an enumerator is returned instead.
data/Rakefile CHANGED
@@ -1,7 +1,13 @@
1
1
  require 'rubygems'
2
- require 'bundler'
2
+
3
3
  begin
4
- Bundler.setup(:default, :development)
4
+ require 'bundler'
5
+ rescue LoadError
6
+ $stderr.puts "You must install bundler - run `gem install bundler`"
7
+ end
8
+
9
+ begin
10
+ Bundler.setup
5
11
  rescue Bundler::BundlerError => e
6
12
  $stderr.puts e.message
7
13
  $stderr.puts "Run `bundle install` to install missing gems"
@@ -9,37 +15,16 @@ rescue Bundler::BundlerError => e
9
15
  end
10
16
  require 'rake'
11
17
 
12
- require 'jeweler'
13
- Jeweler::Tasks.new do |gem|
14
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
- gem.name = "array_floe"
16
- gem.homepage = "http://github.com/ronen/array_floe"
17
- gem.license = "MIT"
18
- gem.summary = %Q{Provides iterators Array#each_with_floe and Array#each_with_index_floe}
19
- gem.description = %Q{
20
- This small extension to ruby's Array class provides two additional
21
- iterators, Array#each_with_floe and Array#each_with_index_floe, that
22
- simplify the reasonably-common need to specially handle "floe"--i.e.,
23
- first, last, odd, even--when iterating through the elements of an array.
24
- It's particularly handy for generating CSS classes.
25
- }
26
- gem.email = "ronen@barzel.org"
27
- gem.authors = ["ronen barzel"]
28
- # Include your dependencies below. Runtime dependencies are required when using your gem,
29
- # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
30
- # gem.add_runtime_dependency 'jabber4r', '> 0.1'
31
- # gem.add_development_dependency 'rspec', '> 1.2.3'
32
- end
33
- Jeweler::RubygemsDotOrgTasks.new
18
+ require 'bueller'
19
+ Bueller::Tasks.new
34
20
 
35
- require 'rspec/core'
36
21
  require 'rspec/core/rake_task'
37
22
  RSpec::Core::RakeTask.new(:spec) do |spec|
38
- spec.pattern = FileList['spec/**/*_spec.rb']
23
+ spec.rspec_opts = '-Ispec'
39
24
  end
40
25
 
41
26
  RSpec::Core::RakeTask.new(:rcov) do |spec|
42
- spec.pattern = 'spec/**/*_spec.rb'
27
+ spec.rspec_opts = '-Ispec'
43
28
  spec.rcov = true
44
29
  end
45
30
 
@@ -49,6 +34,7 @@ require 'rake/rdoctask'
49
34
  Rake::RDocTask.new do |rdoc|
50
35
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
51
36
 
37
+ rdoc.main = 'README.rdoc'
52
38
  rdoc.rdoc_dir = 'rdoc'
53
39
  rdoc.title = "array_floe #{version}"
54
40
  rdoc.rdoc_files.include('README*')
data/array_floe.gemspec CHANGED
@@ -1,15 +1,15 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+ require 'array_floe/version'
5
3
 
6
4
  Gem::Specification.new do |s|
7
- s.name = %q{array_floe}
8
- s.version = "1.1.0"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
5
+ s.name = 'array_floe'
6
+ s.version = ArrayFloe::VERSION
7
+ s.platform = Gem::Platform::RUBY
8
+ s.date = "2011-04-23"
11
9
  s.authors = ["ronen barzel"]
12
- s.date = %q{2011-04-09}
10
+ s.email = 'ronen@barzel.org'
11
+ s.homepage = %q{http://github.com/ronen/array_floe}
12
+ s.summary = %q{Provides iterators Array#each_with_floe and Array#each_with_index_floe}
13
13
  s.description = %q{
14
14
  This small extension to ruby's Array class provides two additional
15
15
  iterators, Array#each_with_floe and Array#each_with_index_floe, that
@@ -17,54 +17,24 @@ simplify the reasonably-common need to specially handle "floe"--i.e.,
17
17
  first, last, odd, even--when iterating through the elements of an array.
18
18
  It's particularly handy for generating CSS classes.
19
19
  }
20
- s.email = %q{ronen@barzel.org}
21
20
  s.extra_rdoc_files = [
22
21
  "LICENSE.txt",
23
22
  "README.rdoc"
24
23
  ]
25
- s.files = [
26
- ".document",
27
- ".rspec",
28
- "Gemfile",
29
- "Gemfile.lock",
30
- "LICENSE.txt",
31
- "README.rdoc",
32
- "Rakefile",
33
- "VERSION",
34
- "array_floe.gemspec",
35
- "lib/array_floe.rb",
36
- "spec/array_floe_spec.rb",
37
- "spec/spec_helper.rb"
38
- ]
39
- s.homepage = %q{http://github.com/ronen/array_floe}
40
- s.licenses = ["MIT"]
41
- s.require_paths = ["lib"]
42
- s.rubygems_version = %q{1.5.0}
43
- s.summary = %q{Provides iterators Array#each_with_floe and Array#each_with_index_floe}
44
- s.test_files = [
45
- "spec/array_floe_spec.rb",
46
- "spec/spec_helper.rb"
47
- ]
48
24
 
49
- if s.respond_to? :specification_version then
50
- s.specification_version = 3
25
+ s.required_rubygems_version = Gem::Requirement.new('>= 1.3.7')
26
+ s.rubygems_version = '1.3.7'
27
+ s.specification_version = 3
28
+
29
+ s.files = `git ls-files`.split("\n")
30
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
31
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
32
+ s.require_paths = ['lib']
51
33
 
52
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
53
- s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
54
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
55
- s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
56
- s.add_development_dependency(%q<rcov>, [">= 0"])
57
- else
58
- s.add_dependency(%q<rspec>, ["~> 2.3.0"])
59
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
60
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
61
- s.add_dependency(%q<rcov>, [">= 0"])
62
- end
63
- else
64
- s.add_dependency(%q<rspec>, ["~> 2.3.0"])
65
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
66
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
67
- s.add_dependency(%q<rcov>, [">= 0"])
68
- end
34
+ s.add_development_dependency 'rspec'
35
+ s.add_development_dependency 'bundler'
36
+ s.add_development_dependency 'bueller'
37
+ s.add_development_dependency 'simplecov'
38
+ s.add_development_dependency 'simplecov-gem-adapter'
69
39
  end
70
40
 
data/lib/array_floe.rb CHANGED
@@ -1,90 +1,4 @@
1
- require 'enumerator' unless defined?(Enumerator)
1
+ require 'array_floe/array'
2
+ require 'array_floe/floe'
2
3
 
3
- class Array
4
-
5
- # The class for the "floe" object that constructed by
6
- # Array#each_with_floe and Array#each_with_index_floe
7
- class FirstLastOddEven
8
- def initialize(i, size) # :nodoc:
9
- @first = i == 0
10
- @last = i == size -1
11
- @odd = i.odd?
12
- end
13
-
14
- # Returns true for the first element
15
- def first?
16
- @first
17
- end
18
-
19
- # Returns true for the last element
20
- def last?
21
- @last
22
- end
23
-
24
- # Returns true for odd-numbered elements
25
- def odd?
26
- @odd
27
- end
28
-
29
- # Returns true for even-numbered elements
30
- def even?
31
- !@odd
32
- end
33
-
34
- # Returns a space-separated list of "first", "last", "odd", and "even"
35
- # as appropriate for the current element.
36
- def to_s
37
- @str ||= [@first && "first", @last && "last", @odd ? "odd" : "even"].select{|x| x}.join(' ')
38
- end
39
- end
40
-
41
- # For each element in the array, calls the block with two arguments: the
42
- # element and a "floe" object.
43
- #
44
- # ary.each_with_floe do |element, floe|
45
- # if floe.first?
46
- # puts "#{element} is the first element"
47
- # end
48
- # if floe.last?
49
- # puts "#{element} is the last element"
50
- # end
51
- # if floe.odd?
52
- # puts "#{element} is an odd-numbered element"
53
- # end
54
- # if floe.even?
55
- # puts "#{element} is an even-numbered element"
56
- # end
57
- # end
58
- #
59
- # If no block is given, an enumerator is returned instead.
60
- def each_with_floe() # :yields: element, floe
61
- if block_given?
62
- each_with_index do |element, i|
63
- yield(element, FirstLastOddEven.new(i, size))
64
- end
65
- else
66
- to_enum(:each_with_floe)
67
- end
68
- end
69
-
70
- # For each element in the array, calls the block with three arguments: the
71
- # element, its index, and a "floe" object.
72
- #
73
- # ary.each_with_index_floe do |element, i, floe|
74
- # assert_equal(i == 0, floe.first?)
75
- # assert_equal(i == ary.last, floe.last?)
76
- # assert_equal(i % 2 == 1, float.odd?)
77
- # assert_equal(i % 2 == 1, float.even?)
78
- # end
79
- #
80
- # If no block is given, an enumerator is returned instead.
81
- def each_with_index_floe() # :yields: element, i, floe
82
- if block_given?
83
- each_with_index do |element, i|
84
- yield(element, i, FirstLastOddEven.new(i, size))
85
- end
86
- else
87
- to_enum(:each_with_index_floe)
88
- end
89
- end
90
- end
4
+ Array.send :include, ArrayFloe::Array
@@ -0,0 +1,57 @@
1
+ require 'enumerator' unless defined?(Enumerator)
2
+
3
+ module ArrayFloe
4
+ module Array
5
+
6
+ # For each element in the array, calls the block with two arguments: the
7
+ # element and a "floe" object.
8
+ #
9
+ # ary.each_with_floe do |element, floe|
10
+ # if floe.first?
11
+ # puts "#{element} is the first element"
12
+ # end
13
+ # if floe.last?
14
+ # puts "#{element} is the last element"
15
+ # end
16
+ # if floe.odd?
17
+ # puts "#{element} is an odd-numbered element"
18
+ # end
19
+ # if floe.even?
20
+ # puts "#{element} is an even-numbered element"
21
+ # end
22
+ # end
23
+ #
24
+ # If no block is given, an enumerator is returned instead.
25
+ def each_with_floe() # :yields: element, floe
26
+ if block_given?
27
+ each_with_index do |element, i|
28
+ yield(element, Floe.new(i, size))
29
+ end
30
+ else
31
+ to_enum(:each_with_floe)
32
+ end
33
+ end
34
+
35
+ # For each element in the array, calls the block with three arguments: the
36
+ # element, its index, and a "floe" object.
37
+ #
38
+ # ary.each_with_index_floe do |element, i, floe|
39
+ # assert_equal(i == 0, floe.first?)
40
+ # assert_equal(i == ary.last, floe.last?)
41
+ # assert_equal(i % 2 == 1, float.odd?)
42
+ # assert_equal(i % 2 == 1, float.even?)
43
+ # end
44
+ #
45
+ # If no block is given, an enumerator is returned instead.
46
+ def each_with_index_floe() # :yields: element, i, floe
47
+ if block_given?
48
+ each_with_index do |element, i|
49
+ yield(element, i, Floe.new(i, size))
50
+ end
51
+ else
52
+ to_enum(:each_with_index_floe)
53
+ end
54
+ end
55
+ end
56
+ end
57
+
@@ -0,0 +1,38 @@
1
+ module ArrayFloe
2
+
3
+ # The class for the "floe" object constructed by
4
+ # Array#each_with_floe and Array#each_with_index_floe
5
+ class Floe
6
+ def initialize(i, size) # :nodoc:
7
+ @first = i == 0
8
+ @last = i == size -1
9
+ @odd = i.odd?
10
+ end
11
+
12
+ # Returns true for the first element
13
+ def first?
14
+ @first
15
+ end
16
+
17
+ # Returns true for the last element
18
+ def last?
19
+ @last
20
+ end
21
+
22
+ # Returns true for odd-numbered elements
23
+ def odd?
24
+ @odd
25
+ end
26
+
27
+ # Returns true for even-numbered elements
28
+ def even?
29
+ !@odd
30
+ end
31
+
32
+ # Returns a space-separated list of "first", "last", "odd", and "even"
33
+ # as appropriate for the current element.
34
+ def to_s
35
+ @str ||= [@first && "first", @last && "last", @odd ? "odd" : "even"].select{|x| x}.join(' ')
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,3 @@
1
+ module ArrayFloe
2
+ VERSION = "1.1.2"
3
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,9 @@
1
+ if RUBY_VERSION > "1.9"
2
+ require 'simplecov'
3
+ require 'simplecov-gem-adapter'
4
+ SimpleCov.start "gem"
5
+ end
6
+
1
7
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
8
  $LOAD_PATH.unshift(File.dirname(__FILE__))
3
9
  require 'rspec'
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: array_floe
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
5
4
  prerelease:
6
- segments:
7
- - 1
8
- - 1
9
- - 0
10
- version: 1.1.0
5
+ version: 1.1.2
11
6
  platform: ruby
12
7
  authors:
13
8
  - ronen barzel
@@ -15,71 +10,63 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2011-04-09 00:00:00 -07:00
19
- default_executable:
13
+ date: 2011-04-23 00:00:00 Z
20
14
  dependencies:
21
15
  - !ruby/object:Gem::Dependency
22
- prerelease: false
23
- type: :development
16
+ name: rspec
24
17
  requirement: &id001 !ruby/object:Gem::Requirement
25
18
  none: false
26
19
  requirements:
27
- - - ~>
20
+ - - ">="
28
21
  - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 2
32
- - 3
33
- - 0
34
- version: 2.3.0
35
- name: rspec
22
+ version: "0"
23
+ type: :development
24
+ prerelease: false
36
25
  version_requirements: *id001
37
26
  - !ruby/object:Gem::Dependency
38
- prerelease: false
39
- type: :development
27
+ name: bundler
40
28
  requirement: &id002 !ruby/object:Gem::Requirement
41
29
  none: false
42
30
  requirements:
43
- - - ~>
31
+ - - ">="
44
32
  - !ruby/object:Gem::Version
45
- hash: 23
46
- segments:
47
- - 1
48
- - 0
49
- - 0
50
- version: 1.0.0
51
- name: bundler
33
+ version: "0"
34
+ type: :development
35
+ prerelease: false
52
36
  version_requirements: *id002
53
37
  - !ruby/object:Gem::Dependency
54
- prerelease: false
55
- type: :development
38
+ name: bueller
56
39
  requirement: &id003 !ruby/object:Gem::Requirement
57
40
  none: false
58
41
  requirements:
59
- - - ~>
42
+ - - ">="
60
43
  - !ruby/object:Gem::Version
61
- hash: 7
62
- segments:
63
- - 1
64
- - 5
65
- - 2
66
- version: 1.5.2
67
- name: jeweler
44
+ version: "0"
45
+ type: :development
46
+ prerelease: false
68
47
  version_requirements: *id003
69
48
  - !ruby/object:Gem::Dependency
70
- prerelease: false
71
- type: :development
49
+ name: simplecov
72
50
  requirement: &id004 !ruby/object:Gem::Requirement
73
51
  none: false
74
52
  requirements:
75
53
  - - ">="
76
54
  - !ruby/object:Gem::Version
77
- hash: 3
78
- segments:
79
- - 0
80
55
  version: "0"
81
- name: rcov
56
+ type: :development
57
+ prerelease: false
82
58
  version_requirements: *id004
59
+ - !ruby/object:Gem::Dependency
60
+ name: simplecov-gem-adapter
61
+ requirement: &id005 !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ type: :development
68
+ prerelease: false
69
+ version_requirements: *id005
83
70
  description: "\n\
84
71
  This small extension to ruby's Array class provides two additional\n\
85
72
  iterators, Array#each_with_floe and Array#each_with_index_floe, that\n\
@@ -96,21 +83,22 @@ extra_rdoc_files:
96
83
  - README.rdoc
97
84
  files:
98
85
  - .document
86
+ - .gitignore
99
87
  - .rspec
100
88
  - Gemfile
101
- - Gemfile.lock
102
89
  - LICENSE.txt
103
90
  - README.rdoc
104
91
  - Rakefile
105
- - VERSION
106
92
  - array_floe.gemspec
107
93
  - lib/array_floe.rb
94
+ - lib/array_floe/array.rb
95
+ - lib/array_floe/floe.rb
96
+ - lib/array_floe/version.rb
108
97
  - spec/array_floe_spec.rb
109
98
  - spec/spec_helper.rb
110
- has_rdoc: true
111
99
  homepage: http://github.com/ronen/array_floe
112
- licenses:
113
- - MIT
100
+ licenses: []
101
+
114
102
  post_install_message:
115
103
  rdoc_options: []
116
104
 
@@ -121,7 +109,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
121
109
  requirements:
122
110
  - - ">="
123
111
  - !ruby/object:Gem::Version
124
- hash: 3
112
+ hash: 970771791
125
113
  segments:
126
114
  - 0
127
115
  version: "0"
@@ -130,14 +118,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
118
  requirements:
131
119
  - - ">="
132
120
  - !ruby/object:Gem::Version
133
- hash: 3
134
- segments:
135
- - 0
136
- version: "0"
121
+ version: 1.3.7
137
122
  requirements: []
138
123
 
139
124
  rubyforge_project:
140
- rubygems_version: 1.5.0
125
+ rubygems_version: 1.7.2
141
126
  signing_key:
142
127
  specification_version: 3
143
128
  summary: Provides iterators Array#each_with_floe and Array#each_with_index_floe
data/Gemfile.lock DELETED
@@ -1,28 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- diff-lcs (1.1.2)
5
- git (1.2.5)
6
- jeweler (1.5.2)
7
- bundler (~> 1.0.0)
8
- git (>= 1.2.5)
9
- rake
10
- rake (0.8.7)
11
- rcov (0.9.9)
12
- rspec (2.3.0)
13
- rspec-core (~> 2.3.0)
14
- rspec-expectations (~> 2.3.0)
15
- rspec-mocks (~> 2.3.0)
16
- rspec-core (2.3.1)
17
- rspec-expectations (2.3.0)
18
- diff-lcs (~> 1.1.2)
19
- rspec-mocks (2.3.0)
20
-
21
- PLATFORMS
22
- ruby
23
-
24
- DEPENDENCIES
25
- bundler (~> 1.0.0)
26
- jeweler (~> 1.5.2)
27
- rcov
28
- rspec (~> 2.3.0)
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.1.0