lab42_core 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/lab42/core/fn/iterator_reimpl.rb +22 -18
- data/lib/lab42/core/version.rb +1 -1
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c1c6148c550240fac9cbd4b175be6f44986fd3e
|
4
|
+
data.tar.gz: 630f25d0a92570a4c1c23c46f963520ac7e3f5b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c971f1782da35b2c340b275e0d195b99e7506ed9a85fa240110e847b1a9bcc63f4a081e97514ceb6a3f39e711ffb171447eb4f6d1baa3b94eaf9a411091ecf82
|
7
|
+
data.tar.gz: 242a5a8b5c2f6866b0be0a62698b39a887309a71ce82781bba43e3001c2318ae2ac060408d8162b88d6e38353d8f321ce8a5a26ca01cf57e4acec6044c882908
|
data/README.md
CHANGED
@@ -1,8 +1,20 @@
|
|
1
1
|
module Lab42
|
2
2
|
module Core
|
3
3
|
module IteratorReimpl
|
4
|
+
|
5
|
+
|
6
|
+
def self.decompose_args args, block
|
7
|
+
raise ArgumentError, 'too many arguments' if args.size + ( block ? 1 : 0 ) > 2
|
8
|
+
return [args,block] if block
|
9
|
+
b, a = args.partition{|x| behavior? x}
|
10
|
+
behave = b.pop
|
11
|
+
a = b if a.empty?
|
12
|
+
raise ArgumentError, "No behavior specified" unless behave
|
13
|
+
return [a,behave]
|
14
|
+
end
|
15
|
+
|
4
16
|
def self.included into
|
5
|
-
|
17
|
+
_self = self
|
6
18
|
into.module_eval do
|
7
19
|
alias_method :__lab42_core_iterator_map__, :map
|
8
20
|
def map behavior=nil, &blk
|
@@ -14,29 +26,21 @@ module Lab42
|
|
14
26
|
end
|
15
27
|
alias_method :filter, :select
|
16
28
|
|
17
|
-
alias_method :__lab42_core_iterator_reduce__, :reduce
|
18
|
-
def reduce behavior=nil, &blk
|
19
|
-
if Symbol === behavior
|
20
|
-
__lab42_core_iterator_reduce__ behavior
|
21
|
-
else
|
22
|
-
__lab42_core_iterator_reduce__(&(behavior||blk))
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
29
|
alias_method :__lab42_core_iterator_inject__, :inject
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
if Symbol === behavior
|
31
|
-
__lab42_core_iterator_inject__ value, behavior
|
32
|
-
else
|
33
|
-
__lab42_core_iterator_inject__(value, &(behavior||blk))
|
34
|
-
end
|
30
|
+
define_method :inject do |*args, &blk|
|
31
|
+
args, behavior = _self.decompose_args args, blk
|
32
|
+
__lab42_core_iterator_inject__( *args, &behavior )
|
35
33
|
end
|
34
|
+
alias_method :reduce, :inject
|
36
35
|
|
37
36
|
def filter *args, &blk
|
38
37
|
end
|
39
38
|
end
|
39
|
+
|
40
|
+
private
|
41
|
+
def self.behavior? x
|
42
|
+
Symbol === x || Proc === x || Method === x
|
43
|
+
end
|
40
44
|
end
|
41
45
|
end
|
42
46
|
end # module Core
|
data/lib/lab42/core/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lab42_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Dober
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -44,22 +44,22 @@ executables: []
|
|
44
44
|
extensions: []
|
45
45
|
extra_rdoc_files: []
|
46
46
|
files:
|
47
|
+
- LICENSE
|
48
|
+
- README.md
|
47
49
|
- lib/lab42/core.rb
|
50
|
+
- lib/lab42/core/dir.rb
|
51
|
+
- lib/lab42/core/enumerable.rb
|
52
|
+
- lib/lab42/core/fn.rb
|
48
53
|
- lib/lab42/core/fn/array.rb
|
49
54
|
- lib/lab42/core/fn/basic_object.rb
|
55
|
+
- lib/lab42/core/fn/enumerable.rb
|
50
56
|
- lib/lab42/core/fn/enumerator/lazy.rb
|
51
57
|
- lib/lab42/core/fn/iterator_reimpl.rb
|
52
|
-
- lib/lab42/core/fn/enumerable.rb
|
53
|
-
- lib/lab42/core/dir.rb
|
54
|
-
- lib/lab42/core/module.rb
|
55
|
-
- lib/lab42/core/version.rb
|
56
|
-
- lib/lab42/core/fn.rb
|
57
58
|
- lib/lab42/core/hash.rb
|
58
|
-
- lib/lab42/core/object.rb
|
59
59
|
- lib/lab42/core/kernel.rb
|
60
|
-
- lib/lab42/core/
|
61
|
-
-
|
62
|
-
-
|
60
|
+
- lib/lab42/core/module.rb
|
61
|
+
- lib/lab42/core/object.rb
|
62
|
+
- lib/lab42/core/version.rb
|
63
63
|
homepage: https://github.com/RobertDober/lab42_core
|
64
64
|
licenses:
|
65
65
|
- MIT
|
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
80
|
version: '0'
|
81
81
|
requirements: []
|
82
82
|
rubyforge_project:
|
83
|
-
rubygems_version: 2.
|
83
|
+
rubygems_version: 2.2.0
|
84
84
|
signing_key:
|
85
85
|
specification_version: 4
|
86
86
|
summary: What I am missing in Ruby
|