expendables 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fe6249e20b26c0b2da19b88a8ef9b05029e6b3aa
4
- data.tar.gz: 2dfad84da1954773a7e3c9c30fed429bb3d44964
3
+ metadata.gz: 35858052c343fb349fbfa85632b85a0000d7c342
4
+ data.tar.gz: 8e213e71cd657362137a8ce8fd69aa1e4e026fd1
5
5
  SHA512:
6
- metadata.gz: 6a29164223e948a133d86c93f457602fab896e882decc3de159d4077eb95038891dcf04c7fe95e553ff114a5713ae9c39733a4cd9980130614422e63342c067d
7
- data.tar.gz: a123c3961e94b83fb1984ba0bddf006e1927a759f3f946723c139ed68394a519f21668bb9014f71ca7b9d3d118c24ac7bc9facb41e2164f904720c6b4a7f566d
6
+ metadata.gz: 66ebd612176ef17ff3a210f5d3cefbcfdc134ae0267cbe25c5068256cd90920693f45ef94dec6a759a3086616966a1abe6001eade2bbafcda8e8710e1378f749
7
+ data.tar.gz: 774ab18aeb7db25417129da84f4b19496814ace3ebe03776f8e6b365c97cf6c07a4d986c1722e646c25ede7d24820e3a672150ef151bfd79c0661ccd7135d61e
@@ -0,0 +1,5 @@
1
+ class NilClass
2
+ def +@
3
+ -> arg { arg }
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ class Proc
2
+ def compose o
3
+ -> *args { (+o).call((+self).call(*args)) }
4
+ end
5
+ alias_method :>>, :compose
6
+
7
+ def +@
8
+ self
9
+ end
10
+ end
@@ -0,0 +1,6 @@
1
+ class Symbol
2
+ def compose o
3
+ -> *args { (+o).call((+self).call(*args)) }
4
+ end
5
+ alias_method :>>, :compose
6
+ end
@@ -1,5 +1,15 @@
1
1
  class Symbol
2
- def to_proc(*args)
3
- -> receiver { receiver.send self, *args }
2
+ def +@
3
+ self.to_proc
4
4
  end
5
+
6
+ def to_proc_with_args(*static_args, &static_block)
7
+ Proc.new do |*proc_args, &proc_block|
8
+ receiver = proc_args.shift
9
+ block = (+static_block >> +proc_block)
10
+ to_proc_without_args.call(receiver, *static_args, *proc_args, &block)
11
+ end
12
+ end
13
+ alias_method :to_proc_without_args, :to_proc
14
+ alias_method :to_proc, :to_proc_with_args
5
15
  end
@@ -1,2 +1,3 @@
1
1
  require "expendables/symbol/to_proc_with_args"
2
2
  require "expendables/symbol/alias_to_proc"
3
+ require "expendables/symbol/compose"
@@ -1,3 +1,3 @@
1
1
  module Expendables
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/expendables.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  require "expendables/version"
2
2
  require "expendables/symbol"
3
- require "expendables/comparable"
4
- require "expendables/kernel"
3
+ require "expendables/proc"
4
+ require "expendables/nil"
@@ -0,0 +1,16 @@
1
+ require "spec_helper"
2
+
3
+ require "expendables"
4
+
5
+ class A
6
+ def b(c, d, e, f)
7
+ c + d + e + f
8
+ end
9
+ end
10
+
11
+ describe Symbol do
12
+ it { :+.to_proc(3).call(4).must_equal 7 }
13
+ it { :b.to_proc(1,2).call(A.new, 3, 4).must_equal 10 }
14
+
15
+ it { :+[3].call(4).must_equal 7 }
16
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: expendables
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eido NABESHIMA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-16 00:00:00.000000000 Z
11
+ date: 2014-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,18 +52,15 @@ files:
52
52
  - Rakefile
53
53
  - expendables.gemspec
54
54
  - lib/expendables.rb
55
- - lib/expendables/comparable.rb
56
- - lib/expendables/comparable/alias_less_more.rb
57
- - lib/expendables/kernel.rb
58
- - lib/expendables/kernel/less_more.rb
55
+ - lib/expendables/nil.rb
56
+ - lib/expendables/proc.rb
59
57
  - lib/expendables/symbol.rb
60
58
  - lib/expendables/symbol/alias_to_proc.rb
59
+ - lib/expendables/symbol/compose.rb
61
60
  - lib/expendables/symbol/to_proc_with_args.rb
62
61
  - lib/expendables/version.rb
63
- - spec/comparable_spec.rb
64
- - spec/kernel_spec.rb
62
+ - spec/expendables_spec.rb
65
63
  - spec/spec_helper.rb
66
- - spec/symbol_spec.rb
67
64
  homepage: ''
68
65
  licenses:
69
66
  - MIT
@@ -89,8 +86,6 @@ signing_key:
89
86
  specification_version: 4
90
87
  summary: Strong power for Ruby.
91
88
  test_files:
92
- - spec/comparable_spec.rb
93
- - spec/kernel_spec.rb
89
+ - spec/expendables_spec.rb
94
90
  - spec/spec_helper.rb
95
- - spec/symbol_spec.rb
96
91
  has_rdoc:
@@ -1,4 +0,0 @@
1
- module Comparable
2
- alias_method :less, :<
3
- alias_method :more, :>
4
- end
@@ -1 +0,0 @@
1
- require "expendables/comparable/alias_less_more"
@@ -1,12 +0,0 @@
1
- require "expendables/symbol"
2
- require "expendables/comparable"
3
-
4
- module Kernel
5
- def less(boundary)
6
- :less[boundary]
7
- end
8
-
9
- def more(boundary)
10
- :more[boundary]
11
- end
12
- end
@@ -1 +0,0 @@
1
- require "expendables/kernel/less_more"
@@ -1,10 +0,0 @@
1
- require "spec_helper"
2
-
3
- require "expendables/comparable"
4
-
5
- describe Numeric do
6
- it { 3.less(4).must_equal true }
7
- it { 4.less(3).must_equal false }
8
- it { 4.more(3).must_equal true }
9
- it { 3.more(4).must_equal false }
10
- end
data/spec/kernel_spec.rb DELETED
@@ -1,10 +0,0 @@
1
- require "spec_helper"
2
-
3
- require "expendables/kernel"
4
-
5
- describe Kernel do
6
- it { less(4).call(3).must_equal true }
7
- it { less(3).call(4).must_equal false }
8
- it { more(3).call(4).must_equal true }
9
- it { more(4).call(3).must_equal false }
10
- end
data/spec/symbol_spec.rb DELETED
@@ -1,8 +0,0 @@
1
- require "spec_helper"
2
-
3
- require "expendables/symbol"
4
-
5
- describe Symbol do
6
- it { :+.to_proc(3).call(4).must_equal 7 }
7
- it { :+[3].call(4).must_equal 7 }
8
- end