relevance-github_hook 0.5.0
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/History.txt +3 -0
- data/Manifest +15 -0
- data/README.txt +46 -0
- data/github_hook.gemspec +45 -0
- data/lib/github_hook.rb +20 -0
- data/spec/github_hook_spec.rb +47 -0
- data/spec/helper.rb +4 -0
- data/spec/payload.rb +35 -0
- data/spec/vendor/bacon-0.9.0/COPYING +18 -0
- data/spec/vendor/bacon-0.9.0/RDOX +35 -0
- data/spec/vendor/bacon-0.9.0/README +227 -0
- data/spec/vendor/bacon-0.9.0/Rakefile +133 -0
- data/spec/vendor/bacon-0.9.0/bin/bacon +110 -0
- data/spec/vendor/bacon-0.9.0/lib/bacon.rb +298 -0
- data/spec/vendor/bacon-0.9.0/test/spec_bacon.rb +310 -0
- metadata +74 -0
data/History.txt
ADDED
data/Manifest
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
github_hook.gemspec
|
2
|
+
History.txt
|
3
|
+
lib/github_hook.rb
|
4
|
+
Manifest
|
5
|
+
README.txt
|
6
|
+
spec/github_hook_spec.rb
|
7
|
+
spec/helper.rb
|
8
|
+
spec/payload.rb
|
9
|
+
spec/vendor/bacon-0.9.0/bin/bacon
|
10
|
+
spec/vendor/bacon-0.9.0/COPYING
|
11
|
+
spec/vendor/bacon-0.9.0/lib/bacon.rb
|
12
|
+
spec/vendor/bacon-0.9.0/Rakefile
|
13
|
+
spec/vendor/bacon-0.9.0/RDOX
|
14
|
+
spec/vendor/bacon-0.9.0/README
|
15
|
+
spec/vendor/bacon-0.9.0/test/spec_bacon.rb
|
data/README.txt
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
= GithubHook
|
2
|
+
|
3
|
+
== DESCRIPTION:
|
4
|
+
|
5
|
+
* Simple object wrapper around the Github post receive JSON payload.
|
6
|
+
|
7
|
+
== FEATURES/PROBLEMS:
|
8
|
+
|
9
|
+
* Provides a simple object wrapper around the post recieve hook that Github provides. For more details on Github's post recieve hooks, see http://github.com/guides/post-receive-hooks.
|
10
|
+
|
11
|
+
== SYNOPSIS:
|
12
|
+
|
13
|
+
FIX (code sample of usage)
|
14
|
+
|
15
|
+
== REQUIREMENTS:
|
16
|
+
|
17
|
+
* json rubygem
|
18
|
+
|
19
|
+
== INSTALL:
|
20
|
+
|
21
|
+
* sudo gem install github_hook
|
22
|
+
|
23
|
+
== LICENSE:
|
24
|
+
|
25
|
+
(The MIT License)
|
26
|
+
|
27
|
+
Copyright (c) 2008 Rob Sanheim
|
28
|
+
|
29
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
30
|
+
a copy of this software and associated documentation files (the
|
31
|
+
'Software'), to deal in the Software without restriction, including
|
32
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
33
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
34
|
+
permit persons to whom the Software is furnished to do so, subject to
|
35
|
+
the following conditions:
|
36
|
+
|
37
|
+
The above copyright notice and this permission notice shall be
|
38
|
+
included in all copies or substantial portions of the Software.
|
39
|
+
|
40
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
41
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
42
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
43
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
44
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
45
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
46
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/github_hook.gemspec
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
|
2
|
+
# Gem::Specification for Github_hook-0.5.0
|
3
|
+
# Originally generated by Echoe
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = %q{github_hook}
|
7
|
+
s.version = "0.5.0"
|
8
|
+
|
9
|
+
s.specification_version = 2 if s.respond_to? :specification_version=
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.authors = ["Rob Sanheim"]
|
13
|
+
s.date = %q{2008-05-09}
|
14
|
+
s.description = %q{Wrapper around the github post receive JSON payload.}
|
15
|
+
s.email = %q{opensource@thinkrelevance.com}
|
16
|
+
s.extra_rdoc_files = ["History.txt", "lib/github_hook.rb", "README.txt"]
|
17
|
+
s.files = ["History.txt", "lib/github_hook.rb", "Manifest", "README.txt", "spec/github_hook_spec.rb", "spec/helper.rb", "spec/payload.rb", "spec/vendor/bacon-0.9.0/bin/bacon", "spec/vendor/bacon-0.9.0/COPYING", "spec/vendor/bacon-0.9.0/lib/bacon.rb", "spec/vendor/bacon-0.9.0/Rakefile", "spec/vendor/bacon-0.9.0/RDOX", "spec/vendor/bacon-0.9.0/README", "spec/vendor/bacon-0.9.0/test/spec_bacon.rb", "github_hook.gemspec"]
|
18
|
+
s.has_rdoc = true
|
19
|
+
s.homepage = %q{http://opensource.thinkrelevance.com/wiki/github_hook}
|
20
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Github_hook", "--main", "README.txt"]
|
21
|
+
s.require_paths = ["lib"]
|
22
|
+
s.rubyforge_project = %q{thinkrelevance}
|
23
|
+
s.rubygems_version = %q{1.1.1}
|
24
|
+
s.summary = %q{Wrapper around the github post receive JSON payload.}
|
25
|
+
s.test_files = ["spec/github_hook_spec.rb"]
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
# # Original Rakefile source (requires the Echoe gem):
|
30
|
+
#
|
31
|
+
# require 'rubygems'
|
32
|
+
# require 'echoe'
|
33
|
+
# require './lib/github_hook.rb'
|
34
|
+
#
|
35
|
+
# Echoe.new('github_hook', GithubHook::VERSION) do |p|
|
36
|
+
# p.rubyforge_name = 'thinkrelevance'
|
37
|
+
# p.author = 'Rob Sanheim'
|
38
|
+
# p.email = 'opensource@thinkrelevance.com'
|
39
|
+
# p.summary = "Wrapper around the github post receive JSON payload."
|
40
|
+
# p.url = "http://opensource.thinkrelevance.com/wiki/github_hook"
|
41
|
+
# p.rdoc_pattern = /^(lib|bin|ext)|txt|rdoc|CHANGELOG|MIT-LICENSE$/
|
42
|
+
# rdoc_template = `allison --path`.strip << ".rb"
|
43
|
+
# p.rdoc_template = rdoc_template
|
44
|
+
# p.test_pattern = 'spec/**/*_spec.rb'
|
45
|
+
# end
|
data/lib/github_hook.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
class GithubHook
|
5
|
+
VERSION = '0.5.0'
|
6
|
+
attr_reader :before, :after, :ref, :repository, :owner, :commits
|
7
|
+
|
8
|
+
def initialize(json)
|
9
|
+
payload = JSON.parse(json)
|
10
|
+
@before, @after, @ref = payload["before"], payload["after"], payload["ref"]
|
11
|
+
@repository = OpenStruct.new(payload["repository"])
|
12
|
+
@owner = OpenStruct.new(payload["repository"]["owner"])
|
13
|
+
@commits = {}
|
14
|
+
payload["commits"].each do |sha1, commit|
|
15
|
+
commit = OpenStruct.new(commit)
|
16
|
+
commit.author = OpenStruct.new(commit.author)
|
17
|
+
commits[sha1] = commit
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), *%w[helper])
|
2
|
+
|
3
|
+
describe GithubHook do
|
4
|
+
before { @pc = GithubHook.new(Payload)}
|
5
|
+
|
6
|
+
it "should have repo" do
|
7
|
+
repository = @pc.repository
|
8
|
+
repository.url.should == "http://github.com/defunkt/github"
|
9
|
+
repository.name.should == "github"
|
10
|
+
end
|
11
|
+
|
12
|
+
it "has reference to branch" do
|
13
|
+
@pc.ref.should == "refs/heads/master"
|
14
|
+
end
|
15
|
+
|
16
|
+
it "has before and after tag" do
|
17
|
+
@pc.before.should == "5aef35982fb2d34e9d9d4502f6ede1072793222d"
|
18
|
+
@pc.after.should == "de8251ff97ee194a289832576287d6f8ad74e3d0"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "has owner" do
|
22
|
+
owner = @pc.owner
|
23
|
+
owner.email.should == "chris@ozmm.org"
|
24
|
+
owner.name.should == "defunkt"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "has a hash for commits keyed on sha1" do
|
28
|
+
commits = @pc.commits
|
29
|
+
commits.keys[0].should == "de8251ff97ee194a289832576287d6f8ad74e3d0"
|
30
|
+
commits.keys[1].should == "41a212ee83ca127e3c8cf465891ab7216a705f59"
|
31
|
+
end
|
32
|
+
|
33
|
+
it "has commit values" do
|
34
|
+
commit = @pc.commits["de8251ff97ee194a289832576287d6f8ad74e3d0"]
|
35
|
+
commit.url.should == "http://github.com/defunkt/github/commit/de8251ff97ee194a289832576287d6f8ad74e3d0"
|
36
|
+
commit.message.should == "update pricing a tad"
|
37
|
+
commit.timestamp.should == "2008-02-15T14:36:34-08:00"
|
38
|
+
end
|
39
|
+
|
40
|
+
it "has commit author" do
|
41
|
+
author = @pc.commits["de8251ff97ee194a289832576287d6f8ad74e3d0"].author
|
42
|
+
author.name.should == "Chris Wanstrath"
|
43
|
+
author.email.should == "chris@ozmm.org"
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
data/spec/helper.rb
ADDED
data/spec/payload.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
Payload = <<-EOL
|
2
|
+
{
|
3
|
+
"before": "5aef35982fb2d34e9d9d4502f6ede1072793222d",
|
4
|
+
"repository": {
|
5
|
+
"url": "http://github.com/defunkt/github",
|
6
|
+
"name": "github",
|
7
|
+
"owner": {
|
8
|
+
"email": "chris@ozmm.org",
|
9
|
+
"name": "defunkt"
|
10
|
+
}
|
11
|
+
},
|
12
|
+
"commits": {
|
13
|
+
"41a212ee83ca127e3c8cf465891ab7216a705f59": {
|
14
|
+
"url": "http://github.com/defunkt/github/commit/41a212ee83ca127e3c8cf465891ab7216a705f59",
|
15
|
+
"author": {
|
16
|
+
"email": "chris@ozmm.org",
|
17
|
+
"name": "Chris Wanstrath"
|
18
|
+
},
|
19
|
+
"message": "okay i give in",
|
20
|
+
"timestamp": "2008-02-15T14:57:17-08:00"
|
21
|
+
},
|
22
|
+
"de8251ff97ee194a289832576287d6f8ad74e3d0": {
|
23
|
+
"url": "http://github.com/defunkt/github/commit/de8251ff97ee194a289832576287d6f8ad74e3d0",
|
24
|
+
"author": {
|
25
|
+
"email": "chris@ozmm.org",
|
26
|
+
"name": "Chris Wanstrath"
|
27
|
+
},
|
28
|
+
"message": "update pricing a tad",
|
29
|
+
"timestamp": "2008-02-15T14:36:34-08:00"
|
30
|
+
}
|
31
|
+
},
|
32
|
+
"after": "de8251ff97ee194a289832576287d6f8ad74e3d0",
|
33
|
+
"ref": "refs/heads/master"
|
34
|
+
}
|
35
|
+
EOL
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Copyright (c) 2007, 2008 Christian Neukirchen <purl.org/net/chneukirchen>
|
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
|
5
|
+
deal in the Software without restriction, including without limitation the
|
6
|
+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
7
|
+
sell 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
|
16
|
+
THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
17
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
18
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,35 @@
|
|
1
|
+
Bacon
|
2
|
+
- should have should.satisfy
|
3
|
+
- should have should.equal
|
4
|
+
- should have should.raise
|
5
|
+
- should have should.raise with a block
|
6
|
+
- should have a should.raise should return the exception
|
7
|
+
- should have should.be.an.instance_of
|
8
|
+
- should have should.be.nil
|
9
|
+
- should have should.include
|
10
|
+
- should have should.be.a.kind_of
|
11
|
+
- should have should.match
|
12
|
+
- should have should.not.raise
|
13
|
+
- should have should.throw
|
14
|
+
- should have should.not.satisfy
|
15
|
+
- should have should.not.equal
|
16
|
+
- should have should.not.match
|
17
|
+
- should have should.be.identical_to/same_as
|
18
|
+
- should have should.respond_to
|
19
|
+
- should have should.be.close
|
20
|
+
- should support multiple negation
|
21
|
+
- should have should.<predicate>
|
22
|
+
- should have should <operator> (>, >=, <, <=, ===)
|
23
|
+
- should allow for custom shoulds
|
24
|
+
- should have should.flunk
|
25
|
+
|
26
|
+
before/after
|
27
|
+
- should run in the right order
|
28
|
+
|
29
|
+
shared/behaves_like
|
30
|
+
- gets called where it is included
|
31
|
+
- raises NameError when the context is not found
|
32
|
+
- gets called where it is included
|
33
|
+
- can access data
|
34
|
+
|
35
|
+
28 specifications (288 requirements), 0 failures, 0 errors
|
@@ -0,0 +1,227 @@
|
|
1
|
+
= Bacon -- small RSpec clone.
|
2
|
+
|
3
|
+
"Truth will sooner come out from error than from confusion."
|
4
|
+
---Francis Bacon
|
5
|
+
|
6
|
+
Bacon is a small RSpec clone weighing less than 300 LoC but
|
7
|
+
nevertheless providing all essential features.
|
8
|
+
|
9
|
+
== Whirl-wind tour
|
10
|
+
|
11
|
+
require 'bacon'
|
12
|
+
|
13
|
+
describe 'A new array' do
|
14
|
+
before do
|
15
|
+
@ary = Array.new
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should be empty' do
|
19
|
+
@ary.should.be.empty
|
20
|
+
@ary.should.not.include 1
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should have zero size' do
|
24
|
+
@ary.size.should.equal 0
|
25
|
+
@ary.size.should.be.close 0.1, 0.5
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should raise on trying fetch any index' do
|
29
|
+
lambda { @ary.fetch 0 }.
|
30
|
+
should.raise(IndexError).
|
31
|
+
message.should.match(/out of array/)
|
32
|
+
|
33
|
+
# Alternatively:
|
34
|
+
should.raise(IndexError) { @ary.fetch 0 }
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should have an object identity' do
|
38
|
+
@ary.should.not.be.same_as Array.new
|
39
|
+
end
|
40
|
+
|
41
|
+
# Custom assertions are trivial to do, they are lambdas returning a
|
42
|
+
# boolean vale:
|
43
|
+
palindrome = lambda { |obj| obj == obj.reverse }
|
44
|
+
it 'should be a palindrome' do
|
45
|
+
@ary.should.be.a palindrome
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should have super powers' do
|
49
|
+
should.flunk "no super powers found"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
Now run it:
|
54
|
+
|
55
|
+
$ bacon whirlwind.rb
|
56
|
+
A new array
|
57
|
+
- should be empty
|
58
|
+
- should have zero size
|
59
|
+
- should raise on trying fetch any index
|
60
|
+
- should have an object identity
|
61
|
+
- should be a palindrome
|
62
|
+
- should have super powers [FAILED]
|
63
|
+
|
64
|
+
Bacon::Error: no super powers found
|
65
|
+
./whirlwind.rb:39: A new array - should have super powers
|
66
|
+
./whirlwind.rb:38
|
67
|
+
./whirlwind.rb:3
|
68
|
+
|
69
|
+
6 specifications (9 requirements), 1 failures, 0 errors
|
70
|
+
|
71
|
+
If you want shorter output, use the Test::Unit format:
|
72
|
+
|
73
|
+
$ bacon -q whirlwind.rb
|
74
|
+
.....F
|
75
|
+
Bacon::Error: no super powers found
|
76
|
+
./whirlwind.rb:39: A new array - should have super powers
|
77
|
+
./whirlwind.rb:38
|
78
|
+
./whirlwind.rb:3
|
79
|
+
|
80
|
+
6 tests, 9 assertions, 1 failures, 0 errors
|
81
|
+
|
82
|
+
It also supports TAP:
|
83
|
+
|
84
|
+
$ bacon -p whirlwind.rb
|
85
|
+
ok 1 - should be empty
|
86
|
+
ok 2 - should have zero size
|
87
|
+
ok 3 - should raise on trying fetch any index
|
88
|
+
ok 4 - should have an object identity
|
89
|
+
ok 5 - should be a palindrome
|
90
|
+
not ok 6 - should have super powers: FAILED
|
91
|
+
# Bacon::Error: no super powers found
|
92
|
+
# ./whirlwind.rb:39: A new array - should have super powers
|
93
|
+
# ./whirlwind.rb:38
|
94
|
+
# ./whirlwind.rb:3
|
95
|
+
1..6
|
96
|
+
# 6 tests, 9 assertions, 1 failures, 0 errors
|
97
|
+
|
98
|
+
$ bacon -p whirlwind.rb | taptap -q
|
99
|
+
Tests took 0.00 seconds.
|
100
|
+
FAILED tests 6
|
101
|
+
6) should have super powers: FAILED
|
102
|
+
|
103
|
+
Failed 1/6 tests, 83.33% okay.
|
104
|
+
|
105
|
+
(taptap is available from http://chneukirchen.org/repos/taptap/)
|
106
|
+
|
107
|
+
|
108
|
+
== Implemented assertions
|
109
|
+
|
110
|
+
* should.<predicate> and should.be.<predicate>
|
111
|
+
* should.equal
|
112
|
+
* should.match
|
113
|
+
* should.be.identical_to / should.be.same_as
|
114
|
+
* should.raise(*exceptions) { }
|
115
|
+
* should.change { }
|
116
|
+
* should.throw(symbol) { }
|
117
|
+
* should.satisfy { |object| }
|
118
|
+
|
119
|
+
|
120
|
+
== Added core predicates
|
121
|
+
|
122
|
+
* Object#true?
|
123
|
+
* Object#false?
|
124
|
+
* Proc#change?
|
125
|
+
* Proc#raise?
|
126
|
+
* Proc#throw?
|
127
|
+
* Numeric#close?
|
128
|
+
|
129
|
+
|
130
|
+
== before/after
|
131
|
+
|
132
|
+
before and after need to be defined before the first specification in
|
133
|
+
a context and are run before and after each specification.
|
134
|
+
|
135
|
+
|
136
|
+
== Shared contexts
|
137
|
+
|
138
|
+
You can define shared contexts in Bacon like this:
|
139
|
+
|
140
|
+
shared "an empty container" do
|
141
|
+
it "should have size zero" do
|
142
|
+
end
|
143
|
+
|
144
|
+
it "should be empty" do
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
context "A new array" do
|
149
|
+
behaves_like "an empty container"
|
150
|
+
end
|
151
|
+
|
152
|
+
These contexts are not executed on their own, but can be included with
|
153
|
+
behaves_like in other contexts. You can use shared contexts to
|
154
|
+
structure suites with many recurring specifications.
|
155
|
+
|
156
|
+
|
157
|
+
== Matchers
|
158
|
+
|
159
|
+
Custom matchers are simply lambdas returning a boolean value, for
|
160
|
+
example:
|
161
|
+
|
162
|
+
def shorter_than(max_size)
|
163
|
+
lambda { |obj| obj.size < max_size }
|
164
|
+
end
|
165
|
+
|
166
|
+
[1,2,3].should.be shorter_than(5)
|
167
|
+
|
168
|
+
You can use modules and extend to group matchers for use in multiple
|
169
|
+
contexts.
|
170
|
+
|
171
|
+
|
172
|
+
== bacon standalone runner
|
173
|
+
|
174
|
+
-s, --specdox do AgileDox-like output (default)
|
175
|
+
-q, --quiet do Test::Unit-like non-verbose output
|
176
|
+
-p, --tap do TAP (Test Anything Protocol) output
|
177
|
+
-o, --output FORMAT do FORMAT (SpecDox/TestUnit/Tap) output
|
178
|
+
-a, --automatic gather tests from ./test/, include ./lib/
|
179
|
+
-n, --name NAME runs tests matching regexp NAME
|
180
|
+
-t, --testcase TESTCASE runs tests in TestCases matching regexp TESTCASE
|
181
|
+
|
182
|
+
If you don't want to use the standalone runner, run
|
183
|
+
Bacon.summary_on_exit to install an exit handler showing the summary.
|
184
|
+
|
185
|
+
|
186
|
+
== Object#should
|
187
|
+
|
188
|
+
You can use Object#should outside of contexts, where the result of
|
189
|
+
assertion will be returned as a boolean. This is nice for
|
190
|
+
demonstrations, quick checks and doctest tests.
|
191
|
+
|
192
|
+
>> require 'bacon'
|
193
|
+
>> (1 + 1).should.equal 2
|
194
|
+
=> true
|
195
|
+
>> (6*9).should.equal 42
|
196
|
+
=> false
|
197
|
+
|
198
|
+
|
199
|
+
== Thanks to
|
200
|
+
|
201
|
+
* Michael Fellinger, for fixing Bacon for 1.9 and various improvements.
|
202
|
+
|
203
|
+
|
204
|
+
== Contact
|
205
|
+
|
206
|
+
Please mail bugs, suggestions and patches to
|
207
|
+
<mailto:chneukirchen@gmail.com>.
|
208
|
+
|
209
|
+
Darcs repository ("darcs send" is welcome for patches):
|
210
|
+
http://chneukirchen.org/repos/bacon
|
211
|
+
|
212
|
+
|
213
|
+
== Copying
|
214
|
+
|
215
|
+
Copyright (C) 2007, 2008 Christian Neukirchen <purl.org/net/chneukirchen>
|
216
|
+
|
217
|
+
Bacon is freely distributable under the terms of an MIT-style license.
|
218
|
+
See COPYING or http://www.opensource.org/licenses/mit-license.php.
|
219
|
+
|
220
|
+
|
221
|
+
== Links
|
222
|
+
|
223
|
+
Behavior-Driven Development:: <http://behaviour-driven.org/>
|
224
|
+
RSpec:: <http://rspec.rubyforge.org/>
|
225
|
+
test/spec:: <http://test-spec.rubyforge.org/>
|
226
|
+
|
227
|
+
Christian Neukirchen:: <http://chneukirchen.org/>
|
@@ -0,0 +1,133 @@
|
|
1
|
+
# Rakefile for Bacon. -*-ruby-*-
|
2
|
+
require 'rake/rdoctask'
|
3
|
+
require 'rake/testtask'
|
4
|
+
|
5
|
+
|
6
|
+
desc "Run all the tests"
|
7
|
+
task :default => [:test]
|
8
|
+
|
9
|
+
desc "Do predistribution stuff"
|
10
|
+
task :predist => [:chmod, :changelog, :rdoc]
|
11
|
+
|
12
|
+
|
13
|
+
desc "Make an archive as .tar.gz"
|
14
|
+
task :dist => :test do
|
15
|
+
sh "export DARCS_REPO=#{File.expand_path "."}; " +
|
16
|
+
"darcs dist -d bacon-#{get_darcs_tree_version}"
|
17
|
+
end
|
18
|
+
|
19
|
+
# Helper to retrieve the "revision number" of the darcs tree.
|
20
|
+
def get_darcs_tree_version
|
21
|
+
unless File.directory? "_darcs"
|
22
|
+
$: << "lib"
|
23
|
+
require 'bacon'
|
24
|
+
return Bacon::VERSION
|
25
|
+
end
|
26
|
+
|
27
|
+
changes = `darcs changes`
|
28
|
+
count = 0
|
29
|
+
tag = "0.0"
|
30
|
+
|
31
|
+
changes.each("\n\n") { |change|
|
32
|
+
head, title, desc = change.split("\n", 3)
|
33
|
+
|
34
|
+
if title =~ /^ \*/
|
35
|
+
# Normal change.
|
36
|
+
count += 1
|
37
|
+
elsif title =~ /tagged (.*)/
|
38
|
+
# Tag. We look for these.
|
39
|
+
tag = $1
|
40
|
+
break
|
41
|
+
else
|
42
|
+
warn "Unparsable change: #{change}"
|
43
|
+
end
|
44
|
+
}
|
45
|
+
|
46
|
+
tag + "." + count.to_s
|
47
|
+
end
|
48
|
+
|
49
|
+
def manifest
|
50
|
+
`darcs query manifest 2>/dev/null`.split("\n").map { |f| f.gsub(/\A\.\//, '') }
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
desc "Make binaries executable"
|
55
|
+
task :chmod do
|
56
|
+
Dir["bin/*"].each { |binary| File.chmod(0775, binary) }
|
57
|
+
end
|
58
|
+
|
59
|
+
desc "Generate a ChangeLog"
|
60
|
+
task :changelog do
|
61
|
+
sh "darcs changes --repo=#{ENV["DARCS_REPO"] || "."} >ChangeLog"
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
desc "Generate RDox"
|
66
|
+
task "RDOX" do
|
67
|
+
sh "bin/bacon -Ilib --automatic --specdox >RDOX"
|
68
|
+
end
|
69
|
+
|
70
|
+
desc "Run all the fast tests"
|
71
|
+
task :test do
|
72
|
+
ruby "bin/bacon -Ilib --automatic --quiet"
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
begin
|
77
|
+
$" << "sources" if defined? FromSrc
|
78
|
+
require 'rubygems'
|
79
|
+
|
80
|
+
require 'rake'
|
81
|
+
require 'rake/clean'
|
82
|
+
require 'rake/packagetask'
|
83
|
+
require 'rake/gempackagetask'
|
84
|
+
require 'fileutils'
|
85
|
+
rescue LoadError
|
86
|
+
# Too bad.
|
87
|
+
else
|
88
|
+
spec = Gem::Specification.new do |s|
|
89
|
+
s.name = "bacon"
|
90
|
+
s.version = get_darcs_tree_version
|
91
|
+
s.platform = Gem::Platform::RUBY
|
92
|
+
s.summary = "a small RSpec clone"
|
93
|
+
|
94
|
+
s.description = <<-EOF
|
95
|
+
Bacon is a small RSpec clone weighing less than 300 LoC but
|
96
|
+
nevertheless providing all essential features.
|
97
|
+
|
98
|
+
http://chneukirchen.org/repos/bacon
|
99
|
+
EOF
|
100
|
+
|
101
|
+
s.files = manifest + %w(RDOX)
|
102
|
+
s.bindir = 'bin'
|
103
|
+
s.executables << 'bacon'
|
104
|
+
s.require_path = 'lib'
|
105
|
+
s.has_rdoc = true
|
106
|
+
s.extra_rdoc_files = ['README', 'RDOX']
|
107
|
+
s.test_files = []
|
108
|
+
|
109
|
+
s.author = 'Christian Neukirchen'
|
110
|
+
s.email = 'chneukirchen@gmail.com'
|
111
|
+
s.homepage = 'http://chneukirchen.org/repos/bacon'
|
112
|
+
end
|
113
|
+
|
114
|
+
Rake::GemPackageTask.new(spec) do |p|
|
115
|
+
p.gem_spec = spec
|
116
|
+
p.need_tar = false
|
117
|
+
p.need_zip = false
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
desc "Generate RDoc documentation"
|
122
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
123
|
+
rdoc.options << '--line-numbers' << '--inline-source' <<
|
124
|
+
'--main' << 'README' <<
|
125
|
+
'--title' << 'Bacon Documentation' <<
|
126
|
+
'--charset' << 'utf-8'
|
127
|
+
rdoc.rdoc_dir = "doc"
|
128
|
+
rdoc.rdoc_files.include 'README'
|
129
|
+
rdoc.rdoc_files.include 'COPYING'
|
130
|
+
rdoc.rdoc_files.include 'RDOX'
|
131
|
+
rdoc.rdoc_files.include('lib/bacon.rb')
|
132
|
+
end
|
133
|
+
task :rdoc => ["RDOX"]
|