to_lambda 0.0.1

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.
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # ToLambda #
2
+
3
+ http://rubygems.org/gems/to_lambda
4
+
5
+ # Description #
6
+
7
+ Provides :to_lambda for Proc instances.
8
+
9
+ # Summary #
10
+
11
+ This is a bullshit solution to a simple problem of converting proc to lambda, since a good solution doesn't seem to exist.
12
+
13
+ # Install #
14
+
15
+ * sudo gem install to_lambda
16
+
17
+ # Usage #
18
+
19
+ ```ruby
20
+ proc = Proc.new do
21
+ puts 'something'
22
+ end
23
+
24
+ lambda = proc.to_lambda
25
+
26
+ lambda.is_lambda?
27
+ # => true
28
+ ```
29
+
30
+ # License #
31
+
32
+ (The MIT License)
33
+
34
+ Copyright (c) 2012 Asher
35
+
36
+ Permission is hereby granted, free of charge, to any person obtaining
37
+ a copy of this software and associated documentation files (the
38
+ 'Software'), to deal in the Software without restriction, including
39
+ without limitation the rights to use, copy, modify, merge, publish,
40
+ distribute, sublicense, and/or sell copies of the Software, and to
41
+ permit persons to whom the Software is furnished to do so, subject to
42
+ the following conditions:
43
+
44
+ The above copyright notice and this permission notice shall be
45
+ included in all copies or substantial portions of the Software.
46
+
47
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
48
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
49
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
50
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
51
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
52
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
53
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
File without changes
data/lib/to_lambda.rb ADDED
@@ -0,0 +1,13 @@
1
+
2
+ module ::ToLambda
3
+ module Proc
4
+ end
5
+ end
6
+
7
+ require_relative 'to_lambda/ToLambda/Proc.rb'
8
+
9
+ class ::Proc
10
+
11
+ include ::ToLambda::Proc
12
+
13
+ end
@@ -0,0 +1,21 @@
1
+
2
+ module ::ToLambda::Proc
3
+
4
+ ###############
5
+ # to_lambda #
6
+ ###############
7
+
8
+ def to_lambda
9
+
10
+ # This is a bullshit solution to a simple problem of converting proc to lambda.
11
+ # This is a stupid hack, so anyone with a better way please let me know.
12
+
13
+ # Why would we want to do this?
14
+ # Primarily to utilize the "return" keyword in a DSL block.
15
+ # Surely there are also other reasons - after all, the distinction was created for a reason, no?
16
+
17
+ return define_singleton_method( :proc_to_lambda_junk_method, & self ).to_proc
18
+
19
+ end
20
+
21
+ end
@@ -0,0 +1,18 @@
1
+
2
+ require_relative '../../lib/to_lambda.rb'
3
+
4
+ describe ::ToLambda::Proc do
5
+
6
+ ###############
7
+ # to_lambda #
8
+ ###############
9
+
10
+ it 'can return a lambda from a proc' do
11
+ proc = Proc.new do
12
+ puts 'something'
13
+ end
14
+ proc.lambda?.should == false
15
+ proc.to_lambda.lambda?.should == true
16
+ end
17
+
18
+ end
metadata ADDED
@@ -0,0 +1,50 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: to_lambda
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Asher
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-13 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: This is a bullshit solution to a simple problem of converting proc to
15
+ lambda, since a good solution doesn't seem to exist.
16
+ email: asher@ridiculouspower.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - lib/to_lambda/ToLambda/Proc.rb
22
+ - lib/to_lambda.rb
23
+ - spec/ToLambda/Proc_spec.rb
24
+ - README.md
25
+ - README.rdoc
26
+ homepage: http://rubygems.org/gems/to_lambda
27
+ licenses: []
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ required_rubygems_version: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubyforge_project: to_lambda
46
+ rubygems_version: 1.8.11
47
+ signing_key:
48
+ specification_version: 3
49
+ summary: Provides :to_lambda for Proc instances.
50
+ test_files: []