curry_for_ruby18 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/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .rvmrc
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/.travis.yml ADDED
@@ -0,0 +1,2 @@
1
+ rvm:
2
+ 1.8.7
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in curry_for_ruby18.gemspec
4
+ gemspec
data/MIT-LICENCE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2011 by Dmitriy Kiriyenko.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # Curry.
2
+ In mathematics and computer science, currying is the technique
3
+ of transforming a function that takes multiple arguments (or an n-tuple
4
+ of arguments) in such a way that it can be called as a chain of
5
+ functions each with a single argument (partial application).
6
+ [More](http://en.wikipedia.org/wiki/Currying)
7
+
8
+ # For Ruby.
9
+ Ruby 1.9.x has currying already. For 1.8.7 use this gem. It
10
+ adds Proc#curry that does just its stuff. Warning - it does not affect arity.
11
+ [More](http://www.khelll.com/blog/ruby/ruby-currying/)
12
+
13
+ # Installation.
14
+
15
+ In Gemfile:
16
+
17
+ ```ruby
18
+ gem 'curry_for_ruby18', :platforms => [:ruby18]
19
+ ```
20
+
21
+ # Usage
22
+
23
+ ```ruby
24
+ a = lambda {|x, y, z| x + y + z}
25
+
26
+ a.call(1, 2, 3) # => 6
27
+ a.curry(1).call(2, 3) # => 6
28
+ ```
29
+
30
+ # Credits
31
+
32
+ * Thank you very much, [khell](http://www.khelll.com/blog/ruby/ruby-currying/).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ require 'bundler/gem_tasks'
5
+ require 'rspec/core/rake_task'
6
+
7
+ task :default => :spec
8
+
9
+ RSpec::Core::RakeTask.new(:spec) do |t|
10
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "curry_for_ruby18/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "curry_for_ruby18"
7
+ s.version = CurryForRuby18::VERSION
8
+ s.authors = ["Dmitriy Kiriyenko"]
9
+ s.email = ["dmitriy.kiriyenko@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{Just a Proc#curry for ruby 1.8.x}
12
+ s.description = %q{Just a Proc#curry for ruby 1.8.x. For more info about currying: http://en.wikipedia.org/wiki/Currying.
13
+ For more information about currying in Ruby: http://www.khelll.com/blog/ruby/ruby-currying/}
14
+
15
+ s.rubyforge_project = "curry_for_ruby18"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ s.add_development_dependency "rake"
23
+ s.add_development_dependency "rspec"
24
+ end
@@ -0,0 +1,2 @@
1
+ require "curry_for_ruby18/version"
2
+ require 'curry_for_ruby18/curry'
@@ -0,0 +1,5 @@
1
+ class Proc
2
+ def curry(*p, &block)
3
+ lambda {|*args| self.call(*(p+args), &block)}
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module CurryForRuby18
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Proc#curry" do
4
+ context "for a regular proc" do
5
+ subject { Proc.new {|a, b, c| a + b + c}}
6
+
7
+ it "should return proc" do
8
+ subject.curry(1).should be_a(Proc)
9
+ end
10
+
11
+ it "should curry" do
12
+ subject.curry(1).call(2, 3).should == 6
13
+ end
14
+
15
+ it "should curry with varargs" do
16
+ subject.curry(1, 2).call(3).should == 6
17
+ end
18
+
19
+ it "should curry with no args" do
20
+ subject.curry.call(1, 2, 3).should == 6
21
+ end
22
+ end
23
+
24
+ context "for a proc with varargs" do
25
+ subject { Proc.new {|*args| args.inject(0) {|acc, i| acc + i}}}
26
+
27
+ it "should curry" do
28
+ subject.curry(1, 2).call(3, 4).should == 10
29
+ end
30
+ end
31
+
32
+ context "for a proc with both args and varargs" do
33
+ subject { Proc.new {|a, b, *args| a + b + args.inject(0) {|acc, i| acc + i}}}
34
+
35
+ it "should curry" do
36
+ subject.curry(1, 2, 3, 4).call(5, 6).should == 21
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,12 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ Bundler.require(:default, :development)
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir[File.join(File.dirname(__FILE__), "support", "**", "*.rb")].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+ # some (optional) config here
12
+ end
File without changes
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: curry_for_ruby18
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Dmitriy Kiriyenko
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-12-30 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ type: :development
22
+ prerelease: false
23
+ name: rake
24
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ requirement: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ type: :development
36
+ prerelease: false
37
+ name: rspec
38
+ version_requirements: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ requirement: *id002
48
+ description: |-
49
+ Just a Proc#curry for ruby 1.8.x. For more info about currying: http://en.wikipedia.org/wiki/Currying.
50
+ For more information about currying in Ruby: http://www.khelll.com/blog/ruby/ruby-currying/
51
+ email:
52
+ - dmitriy.kiriyenko@gmail.com
53
+ executables: []
54
+
55
+ extensions: []
56
+
57
+ extra_rdoc_files: []
58
+
59
+ files:
60
+ - .gitignore
61
+ - .rspec
62
+ - .travis.yml
63
+ - Gemfile
64
+ - MIT-LICENCE
65
+ - README.md
66
+ - Rakefile
67
+ - curry_for_ruby18.gemspec
68
+ - lib/curry_for_ruby18.rb
69
+ - lib/curry_for_ruby18/curry.rb
70
+ - lib/curry_for_ruby18/version.rb
71
+ - spec/lib/curry_spec.rb
72
+ - spec/spec_helper.rb
73
+ - spec/support/.gitkeep
74
+ homepage: ""
75
+ licenses: []
76
+
77
+ post_install_message:
78
+ rdoc_options: []
79
+
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ hash: 3
88
+ segments:
89
+ - 0
90
+ version: "0"
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ hash: 3
97
+ segments:
98
+ - 0
99
+ version: "0"
100
+ requirements: []
101
+
102
+ rubyforge_project: curry_for_ruby18
103
+ rubygems_version: 1.8.6
104
+ signing_key:
105
+ specification_version: 3
106
+ summary: Just a Proc#curry for ruby 1.8.x
107
+ test_files:
108
+ - spec/lib/curry_spec.rb
109
+ - spec/spec_helper.rb
110
+ - spec/support/.gitkeep