modalsupport 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.0
1
+ 0.7.0
@@ -1,4 +1,5 @@
1
1
  class Array
2
+
2
3
  # backport of Ruby 1.9.2 Array#rotate
3
4
  unless [].respond_to?(:rotate)
4
5
  def rotate(n=1)
@@ -11,4 +12,19 @@ class Array
11
12
  self.replace(self.rotate(n))
12
13
  end
13
14
  end
15
+
16
+ # backport of Ruby 1.8.7 Array#index(){...}
17
+ if_ruby_version :<, '1.8.7' do
18
+ unless [].respond_to?(:index_without_block)
19
+ alias index_without_block index
20
+ def index(*args, &blk)
21
+ if args.empty?
22
+ index_without_block(find(&blk))
23
+ else
24
+ index_without_block(*args, &blk)
25
+ end
26
+ end
27
+ end
28
+ end
29
+
14
30
  end
data/modalsupport.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{modalsupport}
8
- s.version = "0.6.0"
8
+ s.version = "0.7.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Javier Goizueta"]
@@ -37,6 +37,7 @@ Gem::Specification.new do |s|
37
37
  "lib/modalsupport/string.rb",
38
38
  "modalsupport.gemspec",
39
39
  "test/helper.rb",
40
+ "test/test_array_index.rb",
40
41
  "test/test_bracket_constructor.rb",
41
42
  "test/test_cross_each.rb",
42
43
  "test/test_grep.rb",
@@ -57,6 +58,7 @@ Gem::Specification.new do |s|
57
58
  s.summary = %q{simple extensions to core classes}
58
59
  s.test_files = [
59
60
  "test/helper.rb",
61
+ "test/test_array_index.rb",
60
62
  "test/test_bracket_constructor.rb",
61
63
  "test/test_cross_each.rb",
62
64
  "test/test_grep.rb",
@@ -0,0 +1,19 @@
1
+ require 'helper'
2
+
3
+ class TestArrayIndex < Test::Unit::TestCase
4
+
5
+ context "Arrays" do
6
+
7
+ should "have an index method with no parameters accepting a block" do
8
+ assert_equal 3, [1,2,3,4,5,6,7].index{|x| x>3}
9
+ assert_equal nil, [1,2,3,4,5,6,7].index{|x| x>7}
10
+ end
11
+
12
+ should "also have an index method with parameters" do
13
+ assert_equal 3, [1,2,3,4,5,6,7].index(4)
14
+ assert_equal nil, [1,2,3,4,5,6,7].index(8)
15
+ end
16
+
17
+ end
18
+
19
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modalsupport
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 3
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 6
8
+ - 7
9
9
  - 0
10
- version: 0.6.0
10
+ version: 0.7.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Javier Goizueta
@@ -62,6 +62,7 @@ files:
62
62
  - lib/modalsupport/string.rb
63
63
  - modalsupport.gemspec
64
64
  - test/helper.rb
65
+ - test/test_array_index.rb
65
66
  - test/test_bracket_constructor.rb
66
67
  - test/test_cross_each.rb
67
68
  - test/test_grep.rb
@@ -111,6 +112,7 @@ specification_version: 3
111
112
  summary: simple extensions to core classes
112
113
  test_files:
113
114
  - test/helper.rb
115
+ - test/test_array_index.rb
114
116
  - test/test_bracket_constructor.rb
115
117
  - test/test_cross_each.rb
116
118
  - test/test_grep.rb