its-it 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +42 -0
- data/LICENSE.txt +21 -0
- data/README.rdoc +44 -0
- data/Rakefile +62 -0
- data/VERSION +1 -0
- data/its-it.gemspec +131 -0
- data/lib/its-it/it.rb +41 -0
- data/lib/its-it/kernel.rb +7 -0
- data/lib/its-it/version.rb +10 -0
- data/lib/its-it.rb +8 -0
- data/spec/it_spec.rb +56 -0
- data/spec/rspec_compatibility_spec.rb +20 -0
- data/spec/spec_helper.rb +18 -0
- metadata +322 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
its-it (1.0.0)
|
5
|
+
blankslate
|
6
|
+
its-it
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
blankslate (2.1.2.4)
|
12
|
+
diff-lcs (1.1.2)
|
13
|
+
git (1.2.5)
|
14
|
+
jeweler (1.5.2)
|
15
|
+
bundler (~> 1.0.0)
|
16
|
+
git (>= 1.2.5)
|
17
|
+
rake
|
18
|
+
rake (0.8.7)
|
19
|
+
rspec (2.3.0)
|
20
|
+
rspec-core (~> 2.3.0)
|
21
|
+
rspec-expectations (~> 2.3.0)
|
22
|
+
rspec-mocks (~> 2.3.0)
|
23
|
+
rspec-core (2.3.1)
|
24
|
+
rspec-expectations (2.3.0)
|
25
|
+
diff-lcs (~> 1.1.2)
|
26
|
+
rspec-mocks (2.3.0)
|
27
|
+
simplecov (0.4.2)
|
28
|
+
simplecov-html (~> 0.4.4)
|
29
|
+
simplecov-gem-adapter (1.0.1)
|
30
|
+
simplecov
|
31
|
+
simplecov-html (0.4.4)
|
32
|
+
|
33
|
+
PLATFORMS
|
34
|
+
ruby
|
35
|
+
|
36
|
+
DEPENDENCIES
|
37
|
+
bundler (~> 1.0.0)
|
38
|
+
its-it!
|
39
|
+
jeweler (~> 1.5.2)
|
40
|
+
rspec (~> 2.3.0)
|
41
|
+
simplecov
|
42
|
+
simplecov-gem-adapter
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Original code Copyright (c) 2007 Jay Phillips
|
2
|
+
Updates Copyright (c) 2011 Ronen Barzel
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
= its-it
|
2
|
+
|
3
|
+
== Overview
|
4
|
+
|
5
|
+
This gem defines kernel methods <code>its</code> and <code>it</code> that extend the Symbol#to_proc idiom to support chaining multiple methods.
|
6
|
+
|
7
|
+
The pure Ruby way to chain methods when enumerating a list would be:
|
8
|
+
|
9
|
+
users.collect{|user| user.contact}.collect{|contact| contact.last_name}.collect{|name| name.capitalize}
|
10
|
+
|
11
|
+
Using <code>Symbol#to_proc</code>, this becomes simpler:
|
12
|
+
|
13
|
+
users.collect(&:contact).collect(&:last_name).collect(&:capitalize)
|
14
|
+
|
15
|
+
And using <code>its</code>, this becomes becomes simpler still:
|
16
|
+
|
17
|
+
users.collect(&its.contact.last_name.capitalize)
|
18
|
+
|
19
|
+
<code>it</code> is an alias for <code>its</code>, to use with methods that
|
20
|
+
describe actions rather than posessives. For example:
|
21
|
+
|
22
|
+
items.collect(&it.to_s.capitalize)
|
23
|
+
|
24
|
+
== Installation
|
25
|
+
|
26
|
+
Install from http://rubygems.org via
|
27
|
+
|
28
|
+
$ gem install "its-it"
|
29
|
+
|
30
|
+
or in a Gemfile
|
31
|
+
|
32
|
+
gem "its-it"
|
33
|
+
|
34
|
+
== Compatibility
|
35
|
+
|
36
|
+
Tested with <b>ruby 1.8.7</b> and <b>ruby 1.9.2</b>
|
37
|
+
|
38
|
+
== History
|
39
|
+
|
40
|
+
This gem is a clone of Jay Philips'
|
41
|
+
methodphitamine[https://github.com/jicksta/methodphitamine] gem, updated to
|
42
|
+
be compatible with ruby 1.9.2 and gemspec, renamed its-it, and installed on
|
43
|
+
rubygems.org[http://rubygems.org]. Unlike methodphitamine, this gem includes only
|
44
|
+
<code>its</code> and <code>it</code>, not the "maybe" monad.
|
data/Rakefile
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'rake'
|
11
|
+
|
12
|
+
require 'jeweler'
|
13
|
+
require './lib/its-it/version'
|
14
|
+
Jeweler::Tasks.new do |gem|
|
15
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
16
|
+
gem.name = "its-it"
|
17
|
+
gem.homepage = "http://github.com/ronen/its-it"
|
18
|
+
gem.license = "MIT"
|
19
|
+
gem.summary = %Q{Defines its() and it() method-chain proc proxies.}
|
20
|
+
gem.description = %Q{
|
21
|
+
This gem defines the Kernel method "it", which extends the Symbol#to_proc
|
22
|
+
idiom to support chaining multiple methods. For example,
|
23
|
+
items.collect(&it.to_s.capitalize). The method is also aliased as "its",
|
24
|
+
for methods that describe possessives rather than actions, such as
|
25
|
+
items.collect(&its.name.capitalize)
|
26
|
+
|
27
|
+
[This gem is clone of Jay Philips' "methodphitamine" gem, updated for ruby 1.9 and gemspec compatibility.]
|
28
|
+
}
|
29
|
+
gem.email = "ronen@barzel.org"
|
30
|
+
gem.authors = ["Ronen Barzel"]
|
31
|
+
gem.version = ItsIt::Version::STRING
|
32
|
+
gem.add_runtime_dependency 'blankslate'
|
33
|
+
gem.add_development_dependency "rspec", "~> 2.3.0"
|
34
|
+
gem.add_development_dependency "bundler", "~> 1.0.0"
|
35
|
+
gem.add_development_dependency "jeweler", "~> 1.5.2"
|
36
|
+
gem.add_development_dependency "simplecov"
|
37
|
+
gem.add_development_dependency "simplecov-gem-adapter"
|
38
|
+
end
|
39
|
+
Jeweler::RubygemsDotOrgTasks.new
|
40
|
+
|
41
|
+
require 'rspec/core'
|
42
|
+
require 'rspec/core/rake_task'
|
43
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
44
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
45
|
+
end
|
46
|
+
|
47
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
48
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
49
|
+
spec.rcov = true
|
50
|
+
end
|
51
|
+
|
52
|
+
task :default => :spec
|
53
|
+
|
54
|
+
require 'rake/rdoctask'
|
55
|
+
Rake::RDocTask.new do |rdoc|
|
56
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
57
|
+
|
58
|
+
rdoc.rdoc_dir = 'rdoc'
|
59
|
+
rdoc.title = "its-it #{version}"
|
60
|
+
rdoc.rdoc_files.include('README*')
|
61
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
62
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.1.0
|
data/its-it.gemspec
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{its-it}
|
8
|
+
s.version = "1.0.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Ronen Barzel"]
|
12
|
+
s.date = %q{2011-04-23}
|
13
|
+
s.description = %q{
|
14
|
+
This gem defines the Kernel method "it", which extends the Symbol#to_proc
|
15
|
+
idiom to support chaining multiple methods. For example,
|
16
|
+
items.collect(&it.to_s.capitalize). The method is also aliased as "its",
|
17
|
+
for methods that describe possessives rather than actions, such as
|
18
|
+
items.collect(&its.name.capitalize)
|
19
|
+
|
20
|
+
[This gem is clone of Jay Philips' "methodphitamine" gem, updated for ruby 1.9 and gemspec compatibility.]
|
21
|
+
}
|
22
|
+
s.email = %q{ronen@barzel.org}
|
23
|
+
s.extra_rdoc_files = [
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README.rdoc"
|
26
|
+
]
|
27
|
+
s.files = [
|
28
|
+
".document",
|
29
|
+
".rspec",
|
30
|
+
"Gemfile",
|
31
|
+
"Gemfile.lock",
|
32
|
+
"LICENSE.txt",
|
33
|
+
"README.rdoc",
|
34
|
+
"Rakefile",
|
35
|
+
"VERSION",
|
36
|
+
"its-it.gemspec",
|
37
|
+
"lib/its-it.rb",
|
38
|
+
"lib/its-it/it.rb",
|
39
|
+
"lib/its-it/kernel.rb",
|
40
|
+
"lib/its-it/version.rb",
|
41
|
+
"spec/it_spec.rb",
|
42
|
+
"spec/rspec_compatibility_spec.rb",
|
43
|
+
"spec/spec_helper.rb"
|
44
|
+
]
|
45
|
+
s.homepage = %q{http://github.com/ronen/its-it}
|
46
|
+
s.licenses = ["MIT"]
|
47
|
+
s.require_paths = ["lib"]
|
48
|
+
s.rubygems_version = %q{1.7.2}
|
49
|
+
s.summary = %q{Defines its() and it() method-chain proc proxies.}
|
50
|
+
s.test_files = [
|
51
|
+
"spec/it_spec.rb",
|
52
|
+
"spec/rspec_compatibility_spec.rb",
|
53
|
+
"spec/spec_helper.rb"
|
54
|
+
]
|
55
|
+
|
56
|
+
if s.respond_to? :specification_version then
|
57
|
+
s.specification_version = 3
|
58
|
+
|
59
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
60
|
+
s.add_runtime_dependency(%q<its-it>, [">= 0"])
|
61
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
|
62
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
63
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
64
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
65
|
+
s.add_development_dependency(%q<simplecov-gem-adapter>, [">= 0"])
|
66
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
|
67
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
68
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
69
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
70
|
+
s.add_development_dependency(%q<simplecov-gem-adapter>, [">= 0"])
|
71
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
|
72
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
73
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
74
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
75
|
+
s.add_development_dependency(%q<simplecov-gem-adapter>, [">= 0"])
|
76
|
+
s.add_runtime_dependency(%q<blankslate>, [">= 0"])
|
77
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
|
78
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
79
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
80
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
81
|
+
s.add_development_dependency(%q<simplecov-gem-adapter>, [">= 0"])
|
82
|
+
else
|
83
|
+
s.add_dependency(%q<its-it>, [">= 0"])
|
84
|
+
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
85
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
86
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
87
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
88
|
+
s.add_dependency(%q<simplecov-gem-adapter>, [">= 0"])
|
89
|
+
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
90
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
91
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
92
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
93
|
+
s.add_dependency(%q<simplecov-gem-adapter>, [">= 0"])
|
94
|
+
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
95
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
96
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
97
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
98
|
+
s.add_dependency(%q<simplecov-gem-adapter>, [">= 0"])
|
99
|
+
s.add_dependency(%q<blankslate>, [">= 0"])
|
100
|
+
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
101
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
102
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
103
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
104
|
+
s.add_dependency(%q<simplecov-gem-adapter>, [">= 0"])
|
105
|
+
end
|
106
|
+
else
|
107
|
+
s.add_dependency(%q<its-it>, [">= 0"])
|
108
|
+
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
109
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
110
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
111
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
112
|
+
s.add_dependency(%q<simplecov-gem-adapter>, [">= 0"])
|
113
|
+
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
114
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
115
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
116
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
117
|
+
s.add_dependency(%q<simplecov-gem-adapter>, [">= 0"])
|
118
|
+
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
119
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
120
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
121
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
122
|
+
s.add_dependency(%q<simplecov-gem-adapter>, [">= 0"])
|
123
|
+
s.add_dependency(%q<blankslate>, [">= 0"])
|
124
|
+
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
125
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
126
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
127
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
128
|
+
s.add_dependency(%q<simplecov-gem-adapter>, [">= 0"])
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
data/lib/its-it/it.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'blankslate'
|
2
|
+
|
3
|
+
# This module contains an It class which queues any methods called on it
|
4
|
+
# and can be converted into a Proc. The Proc it generates executes the queued
|
5
|
+
# methods in the order received on the argument passed to the block, allowing
|
6
|
+
# something like the following:
|
7
|
+
#
|
8
|
+
# (1..10).select &it % 2 == 0
|
9
|
+
#
|
10
|
+
module ItsIt
|
11
|
+
|
12
|
+
# The class instantiated by the <code>it</code> and <code>its</code> kernel methods.
|
13
|
+
class It < BlankSlate
|
14
|
+
|
15
|
+
def initialize #:nodoc:
|
16
|
+
@methods = []
|
17
|
+
end
|
18
|
+
|
19
|
+
def method_missing(*args, &block)
|
20
|
+
@methods << [args, block] unless args == [:respond_to?, :to_proc]
|
21
|
+
self
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_proc
|
25
|
+
lambda do |obj|
|
26
|
+
@methods.inject(obj) do |current,(args,block)|
|
27
|
+
current.send(*args, &block)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Used for testing. This method is hidden but can be revealed using
|
33
|
+
# ItsIt::It.reveal(:method_queue)
|
34
|
+
def method_queue
|
35
|
+
@methods
|
36
|
+
end
|
37
|
+
hide(:method_queue)
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
data/lib/its-it.rb
ADDED
data/spec/it_spec.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/spec_helper"
|
2
|
+
|
3
|
+
describe "An It instance" do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
ItsIt::It.reveal(:method_queue)
|
7
|
+
end
|
8
|
+
|
9
|
+
before:each do
|
10
|
+
@it = ItsIt::It.new
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should queue a single simple method" do
|
14
|
+
@it.foo
|
15
|
+
queue = @it.method_queue
|
16
|
+
queue.size.should == 1
|
17
|
+
queue.first.size.should == 2
|
18
|
+
queue.first.last.should be_nil # No block, ergo nil
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should store arguments" do
|
22
|
+
@it.bar(:qaz, :qwerty)
|
23
|
+
@it.method_queue.first.should == [[:bar, :qaz, :qwerty], nil]
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should store a block" do
|
27
|
+
@it.map { }
|
28
|
+
@it.method_queue.first.last.should be_kind_of(Proc)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should allow chaining blocks" do
|
32
|
+
@it.map {}.inject {}.select {}.sexypants {}
|
33
|
+
blocks = @it.method_queue.map { |x| x.last }
|
34
|
+
blocks.size.should == 4
|
35
|
+
blocks.each do |block|
|
36
|
+
block.should be_kind_of(Proc)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should queue many methods in the right order" do
|
41
|
+
@it.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z
|
42
|
+
queue = @it.method_queue
|
43
|
+
queue.size.should == 26
|
44
|
+
queue.map { |x| x.first.first.to_s }.should == ('a'..'z').to_a
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should respond to to_proc()" do
|
48
|
+
@it.should respond_to(:to_proc)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should not queue the method respond_to? when given :to_proc as an arg" do
|
52
|
+
@it.respond_to? :to_proc
|
53
|
+
@it.method_queue.should be_empty
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/spec_helper"
|
2
|
+
|
3
|
+
describe "The ItsIt's RSpec compatibility" do
|
4
|
+
|
5
|
+
# Surprisingly, RSpec's it() method isn't even defined within the context
|
6
|
+
# of each expectation block. Man, that's some crazy voodoo.
|
7
|
+
|
8
|
+
it "should make available the it and its methods" do
|
9
|
+
should respond_to(:it)
|
10
|
+
should respond_to(:its)
|
11
|
+
method(:it).should == method(:its) # Ensure it's not RSpec's it() method
|
12
|
+
lambda do
|
13
|
+
it.should be_kind_of(ItsIt::It)
|
14
|
+
end.should_not raise_error
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should work with RSpec's assertion methods" do
|
18
|
+
[1,2,3].each &it.should(be_kind_of(Fixnum))
|
19
|
+
end
|
20
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
if RUBY_VERSION > "1.9"
|
2
|
+
require 'simplecov'
|
3
|
+
require 'simplecov-gem-adapter'
|
4
|
+
SimpleCov.start 'gem'
|
5
|
+
end
|
6
|
+
|
7
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
8
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
9
|
+
require 'rspec'
|
10
|
+
require 'its-it'
|
11
|
+
|
12
|
+
# Requires supporting files with custom matchers and macros, etc,
|
13
|
+
# in ./support/ and its subdirectories.
|
14
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
15
|
+
|
16
|
+
RSpec.configure do |config|
|
17
|
+
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,322 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: its-it
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 1.0.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ronen Barzel
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-04-23 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: its-it
|
17
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: rspec
|
28
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.3.0
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *id002
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: bundler
|
39
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 1.0.0
|
45
|
+
type: :development
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *id003
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: jeweler
|
50
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ~>
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 1.5.2
|
56
|
+
type: :development
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: *id004
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: simplecov
|
61
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: "0"
|
67
|
+
type: :development
|
68
|
+
prerelease: false
|
69
|
+
version_requirements: *id005
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: simplecov-gem-adapter
|
72
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: "0"
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: *id006
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: rspec
|
83
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ~>
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 2.3.0
|
89
|
+
type: :development
|
90
|
+
prerelease: false
|
91
|
+
version_requirements: *id007
|
92
|
+
- !ruby/object:Gem::Dependency
|
93
|
+
name: bundler
|
94
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - ~>
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: 1.0.0
|
100
|
+
type: :development
|
101
|
+
prerelease: false
|
102
|
+
version_requirements: *id008
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: jeweler
|
105
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.5.2
|
111
|
+
type: :development
|
112
|
+
prerelease: false
|
113
|
+
version_requirements: *id009
|
114
|
+
- !ruby/object:Gem::Dependency
|
115
|
+
name: simplecov
|
116
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
117
|
+
none: false
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: "0"
|
122
|
+
type: :development
|
123
|
+
prerelease: false
|
124
|
+
version_requirements: *id010
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: simplecov-gem-adapter
|
127
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
128
|
+
none: false
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: "0"
|
133
|
+
type: :development
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: *id011
|
136
|
+
- !ruby/object:Gem::Dependency
|
137
|
+
name: rspec
|
138
|
+
requirement: &id012 !ruby/object:Gem::Requirement
|
139
|
+
none: false
|
140
|
+
requirements:
|
141
|
+
- - ~>
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: 2.3.0
|
144
|
+
type: :development
|
145
|
+
prerelease: false
|
146
|
+
version_requirements: *id012
|
147
|
+
- !ruby/object:Gem::Dependency
|
148
|
+
name: bundler
|
149
|
+
requirement: &id013 !ruby/object:Gem::Requirement
|
150
|
+
none: false
|
151
|
+
requirements:
|
152
|
+
- - ~>
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: 1.0.0
|
155
|
+
type: :development
|
156
|
+
prerelease: false
|
157
|
+
version_requirements: *id013
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
name: jeweler
|
160
|
+
requirement: &id014 !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - ~>
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: 1.5.2
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: *id014
|
169
|
+
- !ruby/object:Gem::Dependency
|
170
|
+
name: simplecov
|
171
|
+
requirement: &id015 !ruby/object:Gem::Requirement
|
172
|
+
none: false
|
173
|
+
requirements:
|
174
|
+
- - ">="
|
175
|
+
- !ruby/object:Gem::Version
|
176
|
+
version: "0"
|
177
|
+
type: :development
|
178
|
+
prerelease: false
|
179
|
+
version_requirements: *id015
|
180
|
+
- !ruby/object:Gem::Dependency
|
181
|
+
name: simplecov-gem-adapter
|
182
|
+
requirement: &id016 !ruby/object:Gem::Requirement
|
183
|
+
none: false
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: "0"
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: *id016
|
191
|
+
- !ruby/object:Gem::Dependency
|
192
|
+
name: blankslate
|
193
|
+
requirement: &id017 !ruby/object:Gem::Requirement
|
194
|
+
none: false
|
195
|
+
requirements:
|
196
|
+
- - ">="
|
197
|
+
- !ruby/object:Gem::Version
|
198
|
+
version: "0"
|
199
|
+
type: :runtime
|
200
|
+
prerelease: false
|
201
|
+
version_requirements: *id017
|
202
|
+
- !ruby/object:Gem::Dependency
|
203
|
+
name: rspec
|
204
|
+
requirement: &id018 !ruby/object:Gem::Requirement
|
205
|
+
none: false
|
206
|
+
requirements:
|
207
|
+
- - ~>
|
208
|
+
- !ruby/object:Gem::Version
|
209
|
+
version: 2.3.0
|
210
|
+
type: :development
|
211
|
+
prerelease: false
|
212
|
+
version_requirements: *id018
|
213
|
+
- !ruby/object:Gem::Dependency
|
214
|
+
name: bundler
|
215
|
+
requirement: &id019 !ruby/object:Gem::Requirement
|
216
|
+
none: false
|
217
|
+
requirements:
|
218
|
+
- - ~>
|
219
|
+
- !ruby/object:Gem::Version
|
220
|
+
version: 1.0.0
|
221
|
+
type: :development
|
222
|
+
prerelease: false
|
223
|
+
version_requirements: *id019
|
224
|
+
- !ruby/object:Gem::Dependency
|
225
|
+
name: jeweler
|
226
|
+
requirement: &id020 !ruby/object:Gem::Requirement
|
227
|
+
none: false
|
228
|
+
requirements:
|
229
|
+
- - ~>
|
230
|
+
- !ruby/object:Gem::Version
|
231
|
+
version: 1.5.2
|
232
|
+
type: :development
|
233
|
+
prerelease: false
|
234
|
+
version_requirements: *id020
|
235
|
+
- !ruby/object:Gem::Dependency
|
236
|
+
name: simplecov
|
237
|
+
requirement: &id021 !ruby/object:Gem::Requirement
|
238
|
+
none: false
|
239
|
+
requirements:
|
240
|
+
- - ">="
|
241
|
+
- !ruby/object:Gem::Version
|
242
|
+
version: "0"
|
243
|
+
type: :development
|
244
|
+
prerelease: false
|
245
|
+
version_requirements: *id021
|
246
|
+
- !ruby/object:Gem::Dependency
|
247
|
+
name: simplecov-gem-adapter
|
248
|
+
requirement: &id022 !ruby/object:Gem::Requirement
|
249
|
+
none: false
|
250
|
+
requirements:
|
251
|
+
- - ">="
|
252
|
+
- !ruby/object:Gem::Version
|
253
|
+
version: "0"
|
254
|
+
type: :development
|
255
|
+
prerelease: false
|
256
|
+
version_requirements: *id022
|
257
|
+
description: "\n\
|
258
|
+
This gem defines the Kernel method \"it\", which extends the Symbol#to_proc\n\
|
259
|
+
idiom to support chaining multiple methods. For example,\n\
|
260
|
+
items.collect(&it.to_s.capitalize). The method is also aliased as \"its\",\n\
|
261
|
+
for methods that describe possessives rather than actions, such as\n\
|
262
|
+
items.collect(&its.name.capitalize)\n\n\
|
263
|
+
[This gem is clone of Jay Philips' \"methodphitamine\" gem, updated for ruby 1.9 and gemspec compatibility.]\n"
|
264
|
+
email: ronen@barzel.org
|
265
|
+
executables: []
|
266
|
+
|
267
|
+
extensions: []
|
268
|
+
|
269
|
+
extra_rdoc_files:
|
270
|
+
- LICENSE.txt
|
271
|
+
- README.rdoc
|
272
|
+
files:
|
273
|
+
- .document
|
274
|
+
- .rspec
|
275
|
+
- Gemfile
|
276
|
+
- Gemfile.lock
|
277
|
+
- LICENSE.txt
|
278
|
+
- README.rdoc
|
279
|
+
- Rakefile
|
280
|
+
- VERSION
|
281
|
+
- its-it.gemspec
|
282
|
+
- lib/its-it.rb
|
283
|
+
- lib/its-it/it.rb
|
284
|
+
- lib/its-it/kernel.rb
|
285
|
+
- lib/its-it/version.rb
|
286
|
+
- spec/it_spec.rb
|
287
|
+
- spec/rspec_compatibility_spec.rb
|
288
|
+
- spec/spec_helper.rb
|
289
|
+
homepage: http://github.com/ronen/its-it
|
290
|
+
licenses:
|
291
|
+
- MIT
|
292
|
+
post_install_message:
|
293
|
+
rdoc_options: []
|
294
|
+
|
295
|
+
require_paths:
|
296
|
+
- lib
|
297
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
298
|
+
none: false
|
299
|
+
requirements:
|
300
|
+
- - ">="
|
301
|
+
- !ruby/object:Gem::Version
|
302
|
+
hash: -58219903
|
303
|
+
segments:
|
304
|
+
- 0
|
305
|
+
version: "0"
|
306
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
307
|
+
none: false
|
308
|
+
requirements:
|
309
|
+
- - ">="
|
310
|
+
- !ruby/object:Gem::Version
|
311
|
+
version: "0"
|
312
|
+
requirements: []
|
313
|
+
|
314
|
+
rubyforge_project:
|
315
|
+
rubygems_version: 1.7.2
|
316
|
+
signing_key:
|
317
|
+
specification_version: 3
|
318
|
+
summary: Defines its() and it() method-chain proc proxies.
|
319
|
+
test_files:
|
320
|
+
- spec/it_spec.rb
|
321
|
+
- spec/rspec_compatibility_spec.rb
|
322
|
+
- spec/spec_helper.rb
|