methodize 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -81,4 +81,19 @@ module MethodizedArray
81
81
  def last(*args)
82
82
  ::Methodize.__normalize__(super(*args))
83
83
  end
84
+
85
+ def each(*args, &block)
86
+ unless defined?(@methodized)
87
+ @methodized = true
88
+ super(*args) do |*args2|
89
+ ::Methodize.__normalize__(args2.first) if args2.any?
90
+ end
91
+ end
92
+ super(*args, &block)
93
+ end
94
+
95
+ def map(*args, &block)
96
+ each(*args) unless defined?(@methodized)
97
+ super(*args, &block)
98
+ end
84
99
  end
@@ -60,4 +60,27 @@ class MethodizeHashTest < Test::Unit::TestCase
60
60
  assert_equal "Article 3", @hash.methodize!.article.last.title
61
61
  end
62
62
 
63
+ def test_iteration_of_array_using_method__each
64
+ map = []
65
+ @hash.article.each do |article|
66
+ map << article.kind_of?(MethodizedHash)
67
+ end
68
+ assert_equal [true, true, true], map
69
+ end
70
+
71
+ def test_iteration_of_array_using_method__each_with_index
72
+ map = []
73
+ @hash.article.each_with_index do |article, index|
74
+ map << [article.kind_of?(MethodizedHash), index]
75
+ end
76
+ assert_equal [[true, 0], [true, 1], [true, 2]], map
77
+ end
78
+
79
+ def test_iteration_of_array_using_method__map
80
+ map = @hash.article.map do |article|
81
+ article.kind_of?(MethodizedHash)
82
+ end
83
+ assert_equal [true, true, true], map
84
+ end
85
+
63
86
  end
@@ -2,6 +2,7 @@ require 'test/unit'
2
2
  require 'methodize'
3
3
 
4
4
  require 'rubygems'
5
+ require 'stringio'
5
6
 
6
7
  class MethodizeTest < Test::Unit::TestCase
7
8
 
@@ -61,7 +62,7 @@ class MethodizeTest < Test::Unit::TestCase
61
62
  def test_should_be_able_to_call_previously_freed_methods
62
63
  assert_equal 4, @hash.__size__
63
64
  begin
64
- $stderr = StringIO.new
65
+ $stderr = ::StringIO.new
65
66
  assert_equal Hash, @hash.__class__
66
67
  $stderr.rewind
67
68
  ensure
metadata CHANGED
@@ -1,70 +1,50 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: methodize
3
- version: !ruby/object:Gem::Version
4
- hash: 21
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.2
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 2
9
- - 1
10
- version: 0.2.1
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Luis Cipriani
14
9
  - Marcelo Manzan
15
10
  autorequire:
16
11
  bindir: bin
17
12
  cert_chain: []
18
-
19
- date: 2012-02-10 00:00:00 Z
13
+ date: 2012-05-15 00:00:00.000000000Z
20
14
  dependencies: []
21
-
22
15
  description:
23
16
  email: lfcipriani@gmail.com
24
17
  executables: []
25
-
26
18
  extensions: []
27
-
28
19
  extra_rdoc_files: []
29
-
30
- files:
20
+ files:
31
21
  - README.md
32
22
  - lib/methodize.rb
33
23
  - lib/methodize/hash.rb
34
24
  - test/methodize_test.rb
35
25
  - test/hash_test.rb
36
- homepage: http://blog.talleye.com
26
+ homepage: http://talleye.com
37
27
  licenses: []
38
-
39
28
  post_install_message:
40
29
  rdoc_options: []
41
-
42
- require_paths:
30
+ require_paths:
43
31
  - lib
44
- required_ruby_version: !ruby/object:Gem::Requirement
32
+ required_ruby_version: !ruby/object:Gem::Requirement
45
33
  none: false
46
- requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- hash: 3
50
- segments:
51
- - 0
52
- version: "0"
53
- required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
39
  none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- hash: 3
59
- segments:
60
- - 0
61
- version: "0"
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
62
44
  requirements: []
63
-
64
45
  rubyforge_project:
65
46
  rubygems_version: 1.8.15
66
47
  signing_key:
67
48
  specification_version: 3
68
49
  summary: Module to read from and write to the keys of a ruby Hash using methods
69
50
  test_files: []
70
-