subtrigger 0.2.7 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/README.md +158 -0
- data/Rakefile +3 -9
- data/VERSION +1 -1
- data/lib/subtrigger.rb +83 -118
- data/lib/subtrigger/dsl.rb +42 -0
- data/lib/subtrigger/path.rb +82 -0
- data/lib/subtrigger/revision.rb +95 -0
- data/lib/subtrigger/rule.rb +165 -0
- data/lib/subtrigger/template.rb +96 -0
- data/subtrigger.gemspec +24 -24
- data/test/test_helper.rb +3 -0
- data/test/test_path.rb +50 -0
- data/test/test_revision.rb +43 -0
- data/test/test_rule.rb +66 -0
- data/test/test_template.rb +42 -0
- metadata +48 -26
- data/LICENSE +0 -20
- data/README.rdoc +0 -56
- data/bin/subtrigger +0 -9
- data/lib/subtrigger/email.rb +0 -56
- data/lib/subtrigger/repository.rb +0 -140
- data/lib/subtrigger/trigger.rb +0 -60
- data/test/helper.rb +0 -11
- data/test/test_email.rb +0 -44
- data/test/test_repository.rb +0 -75
- data/test/test_subtrigger.rb +0 -44
- data/test/test_trigger.rb +0 -37
data/test/test_helper.rb
ADDED
data/test/test_path.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
+
|
3
|
+
class TestPath < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@path = Subtrigger::Path.new
|
6
|
+
end
|
7
|
+
|
8
|
+
def stub_system
|
9
|
+
@path.class.send(:define_method, :system) do |command|
|
10
|
+
yield command
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_should_find_program_in_default_path
|
15
|
+
stub_system { |c| c =~ /usr\/bin/ }
|
16
|
+
assert_equal('/usr/bin', @path.to('foo'))
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_should_find_first_match
|
20
|
+
stub_system { true }
|
21
|
+
assert_equal('/opt/subversion/bin', @path.to('foo'))
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_should_raise_exception_when_not_found
|
25
|
+
stub_system { false }
|
26
|
+
assert_raise(Subtrigger::Path::NotFound) { @path.to('foo') }
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_should_add_path_to_stack
|
30
|
+
stub_system { true }
|
31
|
+
@path << '/bar'
|
32
|
+
assert_equal('/bar', @path.to('baz'))
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_should_memoize_lookup
|
36
|
+
i = 0
|
37
|
+
stub_system { |c| i += 1; c = /usr\/bin/ }
|
38
|
+
@path.to('foo')
|
39
|
+
@path.to('foo')
|
40
|
+
assert_equal(1, i)
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_should_memoize_lookup_per_argument
|
44
|
+
i = 0
|
45
|
+
stub_system { |c| i += 1; c = /usr\/bin/ }
|
46
|
+
@path.to('foo')
|
47
|
+
@path.to('bar')
|
48
|
+
assert_equal(2, i)
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
+
|
3
|
+
class TestRevision < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@valid_arguments = [
|
6
|
+
'6000',
|
7
|
+
"john\n2010-07-05 17:00:00 +0200 (Mon, 01 Jan 2010)\n215\nDescription of log\n",
|
8
|
+
'/foo/trunk'
|
9
|
+
]
|
10
|
+
@revision = Subtrigger::Revision.new(*@valid_arguments)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_should_require_string_arguments
|
14
|
+
assert_raise(ArgumentError) { Subtrigger::Revision.new }
|
15
|
+
assert_raise(ArgumentError) { Subtrigger::Revision.new('foo') }
|
16
|
+
assert_raise(ArgumentError) { Subtrigger::Revision.new('foo', 'bar') }
|
17
|
+
assert_nothing_raised(ArgumentError) { Subtrigger::Revision.new(*@valid_arguments) }
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_should_return_author
|
21
|
+
assert_equal('john', @revision.author)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_should_return_revision_number
|
25
|
+
assert_equal(6000, @revision.number)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_should_return_date
|
29
|
+
assert_equal(Time.parse('2010-07-05 17:00:00 +0200 (Mon, 01 Jan 2010)'), @revision.date)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_should_return_message
|
33
|
+
assert_equal('Description of log', @revision.message)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_should_raise_when_unparsable
|
37
|
+
assert_raise(ArgumentError) { Subtrigger::Revision.new('6000', "invalid info", '') }
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_should_return_modified_projects
|
41
|
+
assert_equal(['/foo'], @revision.projects)
|
42
|
+
end
|
43
|
+
end
|
data/test/test_rule.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
+
|
3
|
+
class CustomMatcher
|
4
|
+
def initialize
|
5
|
+
@matched = false
|
6
|
+
end
|
7
|
+
|
8
|
+
def ===(other)
|
9
|
+
@matched = (other.number == 6000)
|
10
|
+
end
|
11
|
+
|
12
|
+
def matched?
|
13
|
+
@matched
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class TestRule < Test::Unit::TestCase
|
18
|
+
def setup
|
19
|
+
Subtrigger::Rule.reset
|
20
|
+
@rule1 = Subtrigger::Rule.new(/foo/) { }
|
21
|
+
@rule2 = Subtrigger::Rule.new(/bar/) { }
|
22
|
+
|
23
|
+
# Set up dummy Revision
|
24
|
+
Struct.new('Revision', :message, :number)
|
25
|
+
@revision = Struct::Revision.new('foo', 6000)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_should_keep_track_of_created_classes
|
29
|
+
assert_equal(2, Subtrigger::Rule.rules.size)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_should_return_all_matching_classes
|
33
|
+
assert_equal(1, Subtrigger::Rule.matching(@revision).size)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_should_return_empty_array_when_none_match
|
37
|
+
assert_instance_of(Array, Subtrigger::Rule.matching(Struct::Revision.new('bar', 6000)))
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_should_raise_without_block
|
41
|
+
assert_raise(ArgumentError) { Subtrigger::Rule.new(/foo/) }
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_should_match_object
|
45
|
+
assert @rule1.matches?(@revision)
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_should_call_block_with_revision_on_run
|
49
|
+
Subtrigger::Rule.new(/foo/) { |r, m|
|
50
|
+
assert_equal(@revision, r)
|
51
|
+
}.run(@revision)
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_should_pass_on_all_captures_to_block
|
55
|
+
Subtrigger::Rule.new(/fo(o)?/) { |r, m|
|
56
|
+
assert_equal({:message => ['o']}, m)
|
57
|
+
}.run(@revision)
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_should_use_custom_matcher_for_revision
|
61
|
+
matcher = CustomMatcher.new
|
62
|
+
Subtrigger::Rule.new(:all => matcher) { }
|
63
|
+
Subtrigger::Rule.matching(@revision)
|
64
|
+
assert matcher.matched?
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
+
|
3
|
+
class TestTemplate < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@templates = <<-EOS
|
6
|
+
@@ one
|
7
|
+
foo
|
8
|
+
@@ two
|
9
|
+
bar %s
|
10
|
+
EOS
|
11
|
+
Subtrigger::Template.parse(@templates)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_should_parse_format
|
15
|
+
assert_not_nil(Subtrigger::Template.find('one'))
|
16
|
+
assert_not_nil(Subtrigger::Template.find('two'))
|
17
|
+
assert_nil(Subtrigger::Template.find('three'))
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_should_raise_when_unparseable
|
21
|
+
assert_raise(Subtrigger::Template::Unparseable) { Subtrigger::Template.parse('foo') }
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_should_keep_track_of_created_templates
|
25
|
+
assert_instance_of(Subtrigger::Template, Subtrigger::Template.find('one'))
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_should_find_template_by_name
|
29
|
+
assert_equal('foo', Subtrigger::Template.find('one').string)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_should_convert_to_string
|
33
|
+
t = Subtrigger::Template.find('one')
|
34
|
+
assert_equal(t.string, t.to_s)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_should_format_template
|
38
|
+
t = Subtrigger::Template.find('two')
|
39
|
+
assert_equal('bar %s', t.to_s)
|
40
|
+
assert_equal('bar baz', t.format('baz'))
|
41
|
+
end
|
42
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: subtrigger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 19
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Arjan van der Gaag
|
@@ -14,16 +15,18 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
-
default_executable:
|
18
|
+
date: 2010-07-16 00:00:00 +02:00
|
19
|
+
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: thoughtbot-shoulda
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
27
30
|
segments:
|
28
31
|
- 0
|
29
32
|
version: "0"
|
@@ -33,41 +36,56 @@ dependencies:
|
|
33
36
|
name: mocha
|
34
37
|
prerelease: false
|
35
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
36
40
|
requirements:
|
37
41
|
- - ">="
|
38
42
|
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
39
44
|
segments:
|
40
45
|
- 0
|
41
46
|
version: "0"
|
42
47
|
type: :development
|
43
48
|
version_requirements: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: pony
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
type: :runtime
|
62
|
+
version_requirements: *id003
|
44
63
|
description: This gem allows you to create simple Ruby triggers for Subversion commit messages, responding to keywords in your log messages to send e-mails, deploy sites or do whatever you need.
|
45
64
|
email: arjan@arjanvandergaag.nl
|
46
|
-
executables:
|
47
|
-
|
65
|
+
executables: []
|
66
|
+
|
48
67
|
extensions: []
|
49
68
|
|
50
69
|
extra_rdoc_files:
|
51
|
-
-
|
52
|
-
- README.rdoc
|
70
|
+
- README.md
|
53
71
|
files:
|
54
72
|
- .document
|
55
73
|
- .gitignore
|
56
|
-
-
|
57
|
-
- README.rdoc
|
74
|
+
- README.md
|
58
75
|
- Rakefile
|
59
76
|
- VERSION
|
60
|
-
- bin/subtrigger
|
61
77
|
- lib/subtrigger.rb
|
62
|
-
- lib/subtrigger/
|
63
|
-
- lib/subtrigger/
|
64
|
-
- lib/subtrigger/
|
78
|
+
- lib/subtrigger/dsl.rb
|
79
|
+
- lib/subtrigger/path.rb
|
80
|
+
- lib/subtrigger/revision.rb
|
81
|
+
- lib/subtrigger/rule.rb
|
82
|
+
- lib/subtrigger/template.rb
|
65
83
|
- subtrigger.gemspec
|
66
|
-
- test/
|
67
|
-
- test/
|
68
|
-
- test/
|
69
|
-
- test/
|
70
|
-
- test/
|
84
|
+
- test/test_helper.rb
|
85
|
+
- test/test_path.rb
|
86
|
+
- test/test_revision.rb
|
87
|
+
- test/test_rule.rb
|
88
|
+
- test/test_template.rb
|
71
89
|
has_rdoc: true
|
72
90
|
homepage: http://github.com/avdgaag/subtrigger
|
73
91
|
licenses: []
|
@@ -78,29 +96,33 @@ rdoc_options:
|
|
78
96
|
require_paths:
|
79
97
|
- lib
|
80
98
|
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
81
100
|
requirements:
|
82
101
|
- - ">="
|
83
102
|
- !ruby/object:Gem::Version
|
103
|
+
hash: 3
|
84
104
|
segments:
|
85
105
|
- 0
|
86
106
|
version: "0"
|
87
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
88
109
|
requirements:
|
89
110
|
- - ">="
|
90
111
|
- !ruby/object:Gem::Version
|
112
|
+
hash: 3
|
91
113
|
segments:
|
92
114
|
- 0
|
93
115
|
version: "0"
|
94
116
|
requirements: []
|
95
117
|
|
96
118
|
rubyforge_project:
|
97
|
-
rubygems_version: 1.3.
|
119
|
+
rubygems_version: 1.3.7
|
98
120
|
signing_key:
|
99
121
|
specification_version: 3
|
100
122
|
summary: Create post-commit triggers for Subversion commit messages
|
101
123
|
test_files:
|
102
|
-
- test/
|
103
|
-
- test/
|
104
|
-
- test/
|
105
|
-
- test/
|
106
|
-
- test/
|
124
|
+
- test/test_helper.rb
|
125
|
+
- test/test_path.rb
|
126
|
+
- test/test_revision.rb
|
127
|
+
- test/test_rule.rb
|
128
|
+
- test/test_template.rb
|
data/LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2010 Arjan van der Gaag
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
= subtrigger
|
2
|
-
|
3
|
-
Subtrigger is a tiny tool for firing callback methods based on triggers in subversion log messages. This allows you to send out e-mail notifications after a commit, or take some other action based on keywords in Subversion's log messages.
|
4
|
-
|
5
|
-
Here's a quick example:
|
6
|
-
|
7
|
-
# use as post-commit hook in /path/to/repo/hooks
|
8
|
-
require 'subtrigger'
|
9
|
-
Subtrigger.on(/log: (\w+)/) { |matches, repo|
|
10
|
-
puts "#{repo.author} committed #{matches[0]} in revision #{repo.revision}"
|
11
|
-
}.run(*ARGV)
|
12
|
-
|
13
|
-
== Documentation
|
14
|
-
|
15
|
-
See the inline API documentation for descriptions and usage examples.
|
16
|
-
|
17
|
-
== Credits
|
18
|
-
|
19
|
-
Author:: Arjan van der Gaag
|
20
|
-
E-mail:: arjan@arjanvandergaag.nl
|
21
|
-
URL:: http://arjanvandergaag.nl
|
22
|
-
Source:: http://github.com/avdgaag/subtrigger
|
23
|
-
|
24
|
-
== Note on Patches/Pull Requests
|
25
|
-
|
26
|
-
* Fork the project.
|
27
|
-
* Make your feature addition or bug fix.
|
28
|
-
* Add tests for it. This is important so I don't break it in a
|
29
|
-
future version unintentionally.
|
30
|
-
* Commit, do not mess with rakefile, version, or history.
|
31
|
-
(if you want to have your own version, that is fine but bump version in a
|
32
|
-
commit by itself I can ignore when I pull)
|
33
|
-
* Send me a pull request. Bonus points for topic branches.
|
34
|
-
|
35
|
-
== Copyright
|
36
|
-
|
37
|
-
Copyright (c) 2010 Arjan van der Gaag
|
38
|
-
|
39
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
40
|
-
a copy of this software and associated documentation files (the
|
41
|
-
"Software"), to deal in the Software without restriction, including
|
42
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
43
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
44
|
-
permit persons to whom the Software is furnished to do so, subject to
|
45
|
-
the following conditions:
|
46
|
-
|
47
|
-
The above copyright notice and this permission notice shall be
|
48
|
-
included in all copies or substantial portions of the Software.
|
49
|
-
|
50
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
51
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
52
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
53
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
54
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
55
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
56
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|