subtrigger 0.2.5 → 0.2.6

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.5
1
+ 0.2.6
@@ -13,8 +13,6 @@ module Subtrigger
13
13
  # :body => 'Your post-commit hook has just fired').send
14
14
  #
15
15
  # If +sendmail+ can not be found on your system an exception will be raised.
16
- #--
17
- # TODO: Use a hash of options rather than plain arguments.
18
16
  class Email
19
17
  attr_accessor :from, :to, :subject, :body, :development
20
18
  attr_reader :sendmail
@@ -31,6 +29,7 @@ module Subtrigger
31
29
  end
32
30
 
33
31
  # Tries to use +sendmail+ to send the message.
32
+ # The message sent is returned for inspecting purposes.
34
33
  def send
35
34
  message = header + "\n" + body
36
35
  unless development
@@ -69,7 +69,10 @@ module Subtrigger
69
69
  #
70
70
  # Then committing to <tt>group1/project3/trunk</tt> will yield both
71
71
  # <tt>group1/project3/trunk</tt> and <tt>project3</tt>.
72
+ #
73
+ # The list of changed project names is returned as an array.
72
74
  def changed_projects #:yields: full_path, project_path
75
+ projects = []
73
76
  (@dirs_changed ||= look_at('dirs-changed')).split("\n").each do |dir|
74
77
  if dir =~ /([\w\-\.]+)\/(trunk|branches|tags)/
75
78
  project_name = $1
@@ -77,9 +80,11 @@ module Subtrigger
77
80
  when /^(.*\/trunk)/: $1
78
81
  when /^(.*\/(?:tags|branches)\/\w+)/: $1
79
82
  end
80
- yield top_level_dir, project_name
83
+ projects << project_name
84
+ yield top_level_dir, project_name if block_given?
81
85
  end
82
86
  end
87
+ projects
83
88
  end
84
89
 
85
90
  # Returns the HEAD revision number (<tt>svnlook youngest</tt>)
data/lib/subtrigger.rb CHANGED
@@ -44,7 +44,9 @@ $:.unshift File.dirname(__FILE__)
44
44
  # #!/usr/local/bin/ruby
45
45
  # require 'rubygems'
46
46
  # require 'subtrigger'
47
- # Subtrigger.on(/foo/) { |matches, repo|
47
+ # Subtrigger.configure { |c|
48
+ # c.svn = '/usr/bin/svn'
49
+ # }.on(/foo/) { |matches, repo|
48
50
  # puts "#{repo.author} comitted foo!"
49
51
  # }.on(/bar/) { |matches, repo|
50
52
  # puts "#{repo.author} comitted bar!"
@@ -68,6 +70,14 @@ $:.unshift File.dirname(__FILE__)
68
70
  # Subtrigger.sendmail = '/path/to/sendmail'
69
71
  # Subtrigger.svn_args = ''
70
72
  #
73
+ # You can alternatively use a block:
74
+ #
75
+ # Subtrigger.configure do |c|
76
+ # c.svn = '/path/to/svn'
77
+ # end
78
+ #
79
+ # This will return Subtrigger itself, so you can chain further commands.
80
+ #
71
81
  # The <tt>svn_args</tt> setting is a string appended to every +svn+ command.
72
82
  # This allows you to, for example, set a custom username and password. You
73
83
  # might also want to apply the <tt>--non-interactive</tt> argument. For
@@ -81,6 +91,16 @@ $:.unshift File.dirname(__FILE__)
81
91
  module Subtrigger
82
92
  attr_accessor :svn, :sendmail, :svn_args
83
93
 
94
+ def reset
95
+ self.svn = nil
96
+ self.sendmail = nil
97
+ self.svn_args = nil
98
+ end
99
+
100
+ def configure(&block)
101
+ yield self and return self
102
+ end
103
+
84
104
  # Output the version number for this gem by reading /VERSION
85
105
  def version
86
106
  File.read(File.join(File.dirname(__FILE__), *%w{.. VERSION}))
data/subtrigger.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{subtrigger}
8
- s.version = "0.2.5"
8
+ s.version = "0.2.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Arjan van der Gaag"]
12
- s.date = %q{2010-03-04}
12
+ s.date = %q{2010-04-23}
13
13
  s.default_executable = %q{subtrigger}
14
14
  s.description = %q{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.}
15
15
  s.email = %q{arjan@arjanvandergaag.nl}
@@ -39,6 +39,17 @@ class TestRepository < Test::Unit::TestCase
39
39
  @r.author
40
40
  end
41
41
 
42
+ should 'return changed project names' do
43
+ lines = <<-EOS
44
+ www.project1.com/trunk
45
+ www.project2.com/trunk/inc
46
+ sub/www.project2.com/tags/v1
47
+ sub/www.project2.com/tags/v1/test
48
+ EOS
49
+ @r.expects(:look_at).with('dirs-changed').returns(lines)
50
+ assert_equal(['www.project1.com', 'www.project2.com', 'www.project2.com', 'www.project2.com'], @r.changed_projects)
51
+ end
52
+
42
53
  should 'yield changed directories' do
43
54
  lines = <<-EOS
44
55
  www.project1.com/trunk
@@ -3,6 +3,7 @@ require 'helper'
3
3
  class TestSubtrigger < Test::Unit::TestCase
4
4
  context 'with a clean slate' do
5
5
  setup do
6
+ Subtrigger.reset
6
7
  Subtrigger::Trigger.reset
7
8
  end
8
9
 
@@ -10,6 +11,15 @@ class TestSubtrigger < Test::Unit::TestCase
10
11
  assert_match(/\d+\.\d+\.\d+/, Subtrigger.version)
11
12
  end
12
13
 
14
+ should 'configure with a block' do
15
+ assert_nil Subtrigger.svn
16
+ output = Subtrigger.configure do |c|
17
+ c.svn = 'foo'
18
+ end
19
+ assert_equal('foo', Subtrigger.svn)
20
+ assert_equal(Subtrigger, output)
21
+ end
22
+
13
23
  should 'Create new Repository object' do
14
24
  Subtrigger::Repository.expects(:new).with('foo', '1')
15
25
  Subtrigger.run('foo', '1')
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 5
9
- version: 0.2.5
8
+ - 6
9
+ version: 0.2.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Arjan van der Gaag
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-04 00:00:00 +01:00
17
+ date: 2010-04-23 00:00:00 +02:00
18
18
  default_executable: subtrigger
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency