translated_collection 0.1.0

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.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NjhmNGQyNDhlNjIyZTc2YWE3NWJiZTI2ZDFiMjY3Yzg1M2U0OTk2Ng==
5
+ data.tar.gz: !binary |-
6
+ NmE3NDg1YTJkNTE5MDhmODE4NGFjZjdiNmI2NjU4ZWUxMTk2ZjYwNA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ OWZlOGJhYzBhNWU2NzQ4ZDYyMzI0MWU5MjQ3ZmQ3ZmM0Yzg5YzM3MmQ5NmE2
10
+ YzkzMDBkNTk2Y2Y3M2I2NmJjNDhjNTRiOWYzYzVkNjI2YTU4MWFhYTgzYTBk
11
+ NTY4YWM3MTMyMjQ0YzU3Y2ZmNWI2NTcyMDQyOGRiOThkZDcxMzY=
12
+ data.tar.gz: !binary |-
13
+ MDU1YWY1MjFiNDgxOTBlNDZlOTk0NmU0YWQyNGQ3MWJiMTliNGYyODEwMTQ0
14
+ MWQwMjQ4MTg3MmRlNDJhM2ZlNDA4YWJhOTIxMzcxMTAxOWFjYjM2M2QyNDAy
15
+ ZjBhN2UzMTBkM2NjMjMyMGY1ZmM4YzRhNjZkOTMzODE5NjhmM2I=
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ /vendor
2
+ /coverage
3
+ /gemfiles/.bundle
4
+ /pkg
5
+ /tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --drb
data/.travis.yml ADDED
@@ -0,0 +1,15 @@
1
+ # .travis.yml
2
+ rvm:
3
+ - 1.9.3-p547
4
+ - 2.0.0-p598
5
+ - 2.1.5
6
+ - 2.2.0
7
+ gemfile:
8
+ - gemfiles/rails40.gemfile
9
+ - gemfiles/rails41.gemfile
10
+ - gemfiles/rails42.gemfile
11
+ #matrix:
12
+ # exclude:
13
+ # - rbenv: 2.0.0
14
+ # gemfile: gemfiles/rails2.gemfile
15
+ script: "bundle exec rake spec"
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'pry'
4
+ gem 'activerecord', '~> 4.0.13'
5
+
6
+ # Specify your gem's dependencies in pg_funcall.gemspec
7
+ gemspec :path=>"."
data/Gemfile.lock ADDED
@@ -0,0 +1,69 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ translated_collection (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ activemodel (4.0.13)
10
+ activesupport (= 4.0.13)
11
+ builder (~> 3.1.0)
12
+ activerecord (4.0.13)
13
+ activemodel (= 4.0.13)
14
+ activerecord-deprecated_finders (~> 1.0.2)
15
+ activesupport (= 4.0.13)
16
+ arel (~> 4.0.0)
17
+ activerecord-deprecated_finders (1.0.3)
18
+ activesupport (4.0.13)
19
+ i18n (~> 0.6, >= 0.6.9)
20
+ minitest (~> 4.2)
21
+ multi_json (~> 1.3)
22
+ thread_safe (~> 0.1)
23
+ tzinfo (~> 0.3.37)
24
+ arel (4.0.2)
25
+ builder (3.1.4)
26
+ coderay (1.1.0)
27
+ diff-lcs (1.2.5)
28
+ docile (1.1.5)
29
+ i18n (0.7.0)
30
+ method_source (0.8.2)
31
+ minitest (4.7.5)
32
+ multi_json (1.10.1)
33
+ pg (0.18.1)
34
+ pry (0.10.1)
35
+ coderay (~> 1.1.0)
36
+ method_source (~> 0.8.1)
37
+ slop (~> 3.4)
38
+ rake (10.4.2)
39
+ rspec (2.14.1)
40
+ rspec-core (~> 2.14.0)
41
+ rspec-expectations (~> 2.14.0)
42
+ rspec-mocks (~> 2.14.0)
43
+ rspec-core (2.14.8)
44
+ rspec-expectations (2.14.5)
45
+ diff-lcs (>= 1.1.3, < 2.0)
46
+ rspec-mocks (2.14.6)
47
+ simplecov (0.9.1)
48
+ docile (~> 1.1.0)
49
+ multi_json (~> 1.0)
50
+ simplecov-html (~> 0.8.0)
51
+ simplecov-html (0.8.0)
52
+ slop (3.6.0)
53
+ thread_safe (0.3.4)
54
+ tzinfo (0.3.42)
55
+ wwtd (0.7.0)
56
+
57
+ PLATFORMS
58
+ ruby
59
+
60
+ DEPENDENCIES
61
+ activerecord (~> 4.0.13)
62
+ bundler (~> 1.7)
63
+ pg (~> 0.17, >= 0.17.1)
64
+ pry
65
+ rake (~> 10.0)
66
+ rspec (~> 2.14)
67
+ simplecov (~> 0.9)
68
+ translated_collection!
69
+ wwtd (~> 0.7)
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Robert Sanders
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # TranslatedCollection
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'translated_collection'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install translated_collection
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/translated_collection/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'bundler/setup'
3
+ require 'wwtd/tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec) do |config|
7
+ #config.rcov = true
8
+ end
9
+
10
+ task :default => :wwtd
@@ -0,0 +1,37 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ development:
7
+ adapter: postgresql
8
+ database: pg_experiments
9
+ pool: 20
10
+ encoding: UTF8
11
+ min_messages: notice
12
+ host: localhost
13
+ username: <%= `whoami`.chomp %>
14
+ timeout: 5000
15
+
16
+ # Warning: The database defined as "test" will be erased and
17
+ # re-generated from your development database when you run "rake".
18
+ # Do not set this db to the same as development or production.
19
+ test:
20
+ adapter: postgresql
21
+ database: pg_experiments_test
22
+ pool: 20
23
+ encoding: UTF8
24
+ min_messages: notice
25
+ host: localhost
26
+ username: <%= `whoami`.chomp %>
27
+ timeout: 5000
28
+
29
+ production:
30
+ adapter: postgresql
31
+ database: pg_experiments_prod
32
+ pool: 20
33
+ encoding: UTF8
34
+ min_messages: notice
35
+ host: localhost
36
+ username: <%= `whoami`.chomp %>
37
+ timeout: 5000
@@ -0,0 +1,17 @@
1
+ test:
2
+ adapter: postgresql
3
+ encoding: UTF8
4
+ database: pg_funcall_test
5
+ username: pgfuncallgem
6
+ password: pgfuncallgem
7
+ min_messages: warning
8
+ host: localhost
9
+
10
+ development:
11
+ adapter: postgresql
12
+ encoding: UTF8
13
+ database: pg_funcall_dev
14
+ username: pgfuncallgem
15
+ password: pgfuncallgem
16
+ min_messages: warning
17
+ host: localhost
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'pry'
4
+ gem 'activerecord', '~> 4.0.13'
5
+ gem 'pg', '~> 0.17.1'
6
+
7
+ # Specify your gem's dependencies in pg_funcall.gemspec
8
+ gemspec :path=>"../"
@@ -0,0 +1,69 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ translated_collection (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ activemodel (4.0.13)
10
+ activesupport (= 4.0.13)
11
+ builder (~> 3.1.0)
12
+ activerecord (4.0.13)
13
+ activemodel (= 4.0.13)
14
+ activerecord-deprecated_finders (~> 1.0.2)
15
+ activesupport (= 4.0.13)
16
+ arel (~> 4.0.0)
17
+ activerecord-deprecated_finders (1.0.3)
18
+ activesupport (4.0.13)
19
+ i18n (~> 0.6, >= 0.6.9)
20
+ minitest (~> 4.2)
21
+ multi_json (~> 1.3)
22
+ thread_safe (~> 0.1)
23
+ tzinfo (~> 0.3.37)
24
+ arel (4.0.2)
25
+ builder (3.1.4)
26
+ coderay (1.1.0)
27
+ diff-lcs (1.2.5)
28
+ docile (1.1.5)
29
+ i18n (0.7.0)
30
+ method_source (0.8.2)
31
+ minitest (4.7.5)
32
+ multi_json (1.10.1)
33
+ pg (0.17.1)
34
+ pry (0.10.1)
35
+ coderay (~> 1.1.0)
36
+ method_source (~> 0.8.1)
37
+ slop (~> 3.4)
38
+ rake (10.4.2)
39
+ rspec (2.14.1)
40
+ rspec-core (~> 2.14.0)
41
+ rspec-expectations (~> 2.14.0)
42
+ rspec-mocks (~> 2.14.0)
43
+ rspec-core (2.14.8)
44
+ rspec-expectations (2.14.5)
45
+ diff-lcs (>= 1.1.3, < 2.0)
46
+ rspec-mocks (2.14.6)
47
+ simplecov (0.9.1)
48
+ docile (~> 1.1.0)
49
+ multi_json (~> 1.0)
50
+ simplecov-html (~> 0.8.0)
51
+ simplecov-html (0.8.0)
52
+ slop (3.6.0)
53
+ thread_safe (0.3.4)
54
+ tzinfo (0.3.42)
55
+ wwtd (0.7.0)
56
+
57
+ PLATFORMS
58
+ ruby
59
+
60
+ DEPENDENCIES
61
+ activerecord (~> 4.0.13)
62
+ bundler (~> 1.7)
63
+ pg (~> 0.17.1)
64
+ pry
65
+ rake (~> 10.0)
66
+ rspec (~> 2.14)
67
+ simplecov (~> 0.9)
68
+ translated_collection!
69
+ wwtd (~> 0.7)
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'pry'
4
+ gem 'activerecord', '~> 4.1.9'
5
+
6
+ # Specify your gem's dependencies in pg_funcall.gemspec
7
+ gemspec :path=>"../"
@@ -0,0 +1,69 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ translated_collection (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ activemodel (4.1.9)
10
+ activesupport (= 4.1.9)
11
+ builder (~> 3.1)
12
+ activerecord (4.1.9)
13
+ activemodel (= 4.1.9)
14
+ activesupport (= 4.1.9)
15
+ arel (~> 5.0.0)
16
+ activesupport (4.1.9)
17
+ i18n (~> 0.6, >= 0.6.9)
18
+ json (~> 1.7, >= 1.7.7)
19
+ minitest (~> 5.1)
20
+ thread_safe (~> 0.1)
21
+ tzinfo (~> 1.1)
22
+ arel (5.0.1.20140414130214)
23
+ builder (3.2.2)
24
+ coderay (1.1.0)
25
+ diff-lcs (1.2.5)
26
+ docile (1.1.5)
27
+ i18n (0.7.0)
28
+ json (1.8.2)
29
+ method_source (0.8.2)
30
+ minitest (5.5.1)
31
+ multi_json (1.10.1)
32
+ pg (0.18.1)
33
+ pry (0.10.1)
34
+ coderay (~> 1.1.0)
35
+ method_source (~> 0.8.1)
36
+ slop (~> 3.4)
37
+ rake (10.4.2)
38
+ rspec (2.14.1)
39
+ rspec-core (~> 2.14.0)
40
+ rspec-expectations (~> 2.14.0)
41
+ rspec-mocks (~> 2.14.0)
42
+ rspec-core (2.14.8)
43
+ rspec-expectations (2.14.5)
44
+ diff-lcs (>= 1.1.3, < 2.0)
45
+ rspec-mocks (2.14.6)
46
+ simplecov (0.9.1)
47
+ docile (~> 1.1.0)
48
+ multi_json (~> 1.0)
49
+ simplecov-html (~> 0.8.0)
50
+ simplecov-html (0.8.0)
51
+ slop (3.6.0)
52
+ thread_safe (0.3.4)
53
+ tzinfo (1.2.2)
54
+ thread_safe (~> 0.1)
55
+ wwtd (0.7.0)
56
+
57
+ PLATFORMS
58
+ ruby
59
+
60
+ DEPENDENCIES
61
+ activerecord (~> 4.1.9)
62
+ bundler (~> 1.7)
63
+ pg (~> 0.17, >= 0.17.1)
64
+ pry
65
+ rake (~> 10.0)
66
+ rspec (~> 2.14)
67
+ simplecov (~> 0.9)
68
+ translated_collection!
69
+ wwtd (~> 0.7)
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'pry'
4
+ gem 'activerecord', '~> 4.2.0'
5
+
6
+ # Specify your gem's dependencies in pg_funcall.gemspec
7
+ gemspec :path=>"../"
@@ -0,0 +1,69 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ translated_collection (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ activemodel (4.2.0)
10
+ activesupport (= 4.2.0)
11
+ builder (~> 3.1)
12
+ activerecord (4.2.0)
13
+ activemodel (= 4.2.0)
14
+ activesupport (= 4.2.0)
15
+ arel (~> 6.0)
16
+ activesupport (4.2.0)
17
+ i18n (~> 0.7)
18
+ json (~> 1.7, >= 1.7.7)
19
+ minitest (~> 5.1)
20
+ thread_safe (~> 0.3, >= 0.3.4)
21
+ tzinfo (~> 1.1)
22
+ arel (6.0.0)
23
+ builder (3.2.2)
24
+ coderay (1.1.0)
25
+ diff-lcs (1.2.5)
26
+ docile (1.1.5)
27
+ i18n (0.7.0)
28
+ json (1.8.2)
29
+ method_source (0.8.2)
30
+ minitest (5.5.1)
31
+ multi_json (1.10.1)
32
+ pg (0.18.1)
33
+ pry (0.10.1)
34
+ coderay (~> 1.1.0)
35
+ method_source (~> 0.8.1)
36
+ slop (~> 3.4)
37
+ rake (10.4.2)
38
+ rspec (2.14.1)
39
+ rspec-core (~> 2.14.0)
40
+ rspec-expectations (~> 2.14.0)
41
+ rspec-mocks (~> 2.14.0)
42
+ rspec-core (2.14.8)
43
+ rspec-expectations (2.14.5)
44
+ diff-lcs (>= 1.1.3, < 2.0)
45
+ rspec-mocks (2.14.6)
46
+ simplecov (0.9.1)
47
+ docile (~> 1.1.0)
48
+ multi_json (~> 1.0)
49
+ simplecov-html (~> 0.8.0)
50
+ simplecov-html (0.8.0)
51
+ slop (3.6.0)
52
+ thread_safe (0.3.4)
53
+ tzinfo (1.2.2)
54
+ thread_safe (~> 0.1)
55
+ wwtd (0.7.0)
56
+
57
+ PLATFORMS
58
+ ruby
59
+
60
+ DEPENDENCIES
61
+ activerecord (~> 4.2.0)
62
+ bundler (~> 1.7)
63
+ pg (~> 0.17, >= 0.17.1)
64
+ pry
65
+ rake (~> 10.0)
66
+ rspec (~> 2.14)
67
+ simplecov (~> 0.9)
68
+ translated_collection!
69
+ wwtd (~> 0.7)
@@ -0,0 +1,3 @@
1
+ module TranslatedCollection
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,206 @@
1
+ require 'observer'
2
+
3
+ module TranslatedCollection
4
+ class Wrapper
5
+ include Enumerable
6
+ include Observable
7
+
8
+ attr_reader :collection
9
+ attr_accessor :wrap_results
10
+
11
+ def initialize(collection, wrapfunc_in, wrapfunc_out, check = false)
12
+ @collection = collection
13
+ @wrapfunc_in = wrapfunc_in
14
+ @wrapfunc_out = wrapfunc_out
15
+
16
+ @wrap_results = true
17
+
18
+ raise ArgumentError, "Non-conforming array provided" if
19
+ check && !collection.empty? && !_conforming?
20
+ end
21
+
22
+ def each
23
+ @collection.each do |elt|
24
+ yield @wrapfunc_out.call(elt)
25
+ end
26
+ end
27
+
28
+ def [](key)
29
+ @wrapfunc_out.call(@collection[key])
30
+ end
31
+
32
+ SENTINEL = Object.new
33
+
34
+ def fetch(*args, &blk)
35
+ @wrapfunc_out.call(@collection.__send__(:fetch, *args, &blk))
36
+ end
37
+
38
+ def []=(key, value)
39
+ @collection[key] = @wrapfunc_in.call(value).tap do |xlated|
40
+ changed
41
+ notify_observers(self, :set, key, xlated)
42
+ end
43
+ end
44
+
45
+ def <<(value)
46
+ @collection << @wrapfunc_in.call(value).tap do |xlated|
47
+ changed
48
+ notify_observers(self, :push, xlated)
49
+ end
50
+ end
51
+
52
+ alias :push :<<
53
+
54
+ def pop(count=nil)
55
+ if @collection.count > 0
56
+ if count == nil
57
+ value = @wrapfunc_out.call(@collection.pop)
58
+ else
59
+ value = @collection.pop(count).map(&@wrapfunc_out)
60
+ end
61
+ changed
62
+ notify_observers(self, :pop)
63
+ else
64
+ value = nil
65
+ end
66
+
67
+ value
68
+ end
69
+
70
+ def delete(elt)
71
+ @collection.delete(@wrapfunc_in.call(elt)).tap do |removed|
72
+ if removed
73
+ changed
74
+ notify_observers(self, :delete, removed)
75
+ end
76
+ end
77
+ end
78
+
79
+ def delete_at(pos)
80
+ @collection.delete_at(pos).tap do |removed|
81
+ if removed
82
+ changed
83
+ notify_observers(self, :delete, removed) if removed
84
+ end
85
+ end
86
+ end
87
+
88
+ def clear
89
+ @collection.clear.tap do
90
+ changed
91
+ notify_observers(self, :clear)
92
+ end
93
+ self
94
+ end
95
+
96
+ def self.copy_clone_states(from,to)
97
+ to.taint if from.tainted? && ! to.tainted?
98
+ to.freeze if from.frozen? && ! to.frozen?
99
+ to
100
+ end
101
+
102
+ def clone
103
+ dup.tap do |newobj|
104
+ newobj.instance_variable_set("@collection", self.class.copy_clone_states(@collection, @collection.dup))
105
+ self.class.copy_clone_states(self, newobj)
106
+ end
107
+ end
108
+
109
+ def dup
110
+ super.tap do |newobj|
111
+ newobj.instance_variable_set("@collection", @collection.dup)
112
+ end
113
+ end
114
+
115
+ def freeze
116
+ @collection.freeze
117
+ super
118
+ end
119
+
120
+ #
121
+ # Are all the elements of this collection unchanged when the "in" wrapper is
122
+ # applied to them?
123
+ #
124
+ def _conforming?
125
+ @collection.each do |elt|
126
+ return false if @wrapfunc_in.call(elt) != elt
127
+ end
128
+ true
129
+ end
130
+
131
+ def _make_conforming!
132
+ return if _conforming?
133
+
134
+ xlated = @collection.map {|elt| @wrapfunc_in.call(elt) }
135
+ @collection.clear
136
+ xlated.each {|elt| @collection << elt }
137
+ changed
138
+ notify_observers(self, :misc)
139
+ self
140
+ end
141
+
142
+ def is_a?(clazz)
143
+ super(clazz) || @collection.is_a?(clazz)
144
+ end
145
+
146
+ alias :kind_of? :is_a?
147
+
148
+ #
149
+ # Used to wrap results from various Enumerable methods that are defined
150
+ # to return an array
151
+ #
152
+ def _rewrap_array(result)
153
+ if @wrap_results
154
+ newcoll = @collection.class.new(result)
155
+ self.class.new(newcoll, @wrapfunc_in, @wrapfunc_out)
156
+ else
157
+ @collection.class.new(result.map(&@wrapfunc_out))
158
+ end
159
+ end
160
+
161
+ def _wrap_enumerator(enumerator)
162
+ Enumerator.new do |y|
163
+ loop do
164
+ changed
165
+ notify_observers(self, :misc)
166
+ y << @wrapfunc_out.call(enumerator.next)
167
+ end
168
+ end
169
+ end
170
+
171
+ # methods that take a block that accepts one or more elements
172
+ # and return an array
173
+ %w[sort].each do |meth|
174
+ define_method(meth) do |*args, &blk|
175
+ unless blk
176
+ blk = Proc.new {|a,b| @wrapfunc_out.call(a) <=> @wrapfunc_out.call(b) }
177
+ end
178
+
179
+ blk2 = Proc.new {|a,b| blk.call(@wrapfunc_out.call(a), @wrapfunc_out.call(b)) }
180
+ _rewrap_array(@collection.__send__(meth, *args, &blk2))
181
+ end
182
+ end
183
+
184
+ # methods that take a block which accepts a single element of the collection,
185
+ # and return an array, or if no block, return an enumerator
186
+ %w[collect collect_concat drop_while find_all
187
+ flat_map map select take_while sort_by].each do |meth|
188
+ define_method(meth) do |*args, &blk|
189
+ if blk
190
+ blk2 = Proc.new {|elt| blk.call(@wrapfunc_out.call(elt)) }
191
+ _rewrap_array(@collection.__send__(meth, *args, &blk2))
192
+ else
193
+ _wrap_enumerator(@collection.__send__(meth, *args))
194
+ end
195
+ end
196
+ end
197
+
198
+ def reject!(&blk)
199
+ if blk
200
+ @collection.reject! {|x| blk.call(@wrapfunc_out.call(x)) } && self
201
+ else
202
+ _wrap_enumerator(@collection.reject!)
203
+ end
204
+ end
205
+ end
206
+ end
@@ -0,0 +1,7 @@
1
+ require "translated_collection/version"
2
+ require "translated_collection/wrapper"
3
+
4
+ module TranslatedCollection
5
+ # Your code goes here...
6
+ end
7
+