subtrigger 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -17,6 +17,7 @@ module Subtrigger
17
17
  # TODO: Use a hash of options rather than plain arguments.
18
18
  class Email
19
19
  attr_accessor :from, :to, :subject, :body, :development
20
+ attr_reader :sendmail
20
21
 
21
22
  # Sets up a new message and tries to find +sendmail+ on your system.
22
23
  def initialize(options = {})
@@ -25,7 +26,7 @@ module Subtrigger
25
26
  @subject = options[:subject]
26
27
  @body = options[:body]
27
28
  @development = options[:development] || false
28
- @sendmail = `which sendmail`.strip
29
+ @sendmail = Subtrigger.sendmail || `which sendmail`.strip
29
30
  raise 'Could not find sendmail; aborting.' if @sendmail.nil?
30
31
  end
31
32
 
@@ -33,7 +34,7 @@ module Subtrigger
33
34
  def send
34
35
  message = header + "\n" + body
35
36
  unless development
36
- fd = open("|#{@sendmail} #{@to}", "w")
37
+ fd = open("|#{sendmail} #{to}", "w")
37
38
  fd.print(message)
38
39
  fd.close
39
40
  end
@@ -32,7 +32,7 @@ module Subtrigger
32
32
  raise "Invalid revision number '#{revision}'" unless revision.to_i > 0
33
33
  @path = path
34
34
  @revision = revision.to_i
35
- @svn_path = `which svn`.strip
35
+ @svn_path = Subtrigger.svn || `which svn`.strip
36
36
  raise 'Could not locate svn' if @svn_path.nil?
37
37
  end
38
38
 
@@ -97,7 +97,7 @@ module Subtrigger
97
97
 
98
98
  # Runs an arbitrary +svn+ command and returns its results.
99
99
  def exec(command)
100
- command = "#{@svn_path} #{command}"
100
+ command = "#{@svn_path} #{command} #{Subtrigger.svn_args}"
101
101
  `#{command}`
102
102
  end
103
103
 
@@ -105,7 +105,7 @@ module Subtrigger
105
105
 
106
106
  # Execute a +svnlook+ command for the current repository and revision.
107
107
  def look_at(subcommand)
108
- `#{File.join(File.dirname(@svn_path), 'svnlook')} #{subcommand} #{@path} -r #{@revision}`
108
+ `#{File.join(File.dirname(@svn_path), 'svnlook')} #{subcommand} #{@path} -r #{@revision} #{Subtrigger.svn_args}`
109
109
  end
110
110
 
111
111
  # Get the contents of a line from the <tt>svnlook info</tt> output, which
data/lib/subtrigger.rb CHANGED
@@ -54,8 +54,10 @@ $:.unshift File.dirname(__FILE__)
54
54
  # that Subversion runs its hooks in an empty environment, with no PATH set,
55
55
  # and you will also see no output.
56
56
  module Subtrigger
57
+ attr_accessor :svn, :sendmail, :svn_args
58
+
57
59
  # Output the version number for this gem by reading /VERSION
58
- def self.version
60
+ def version
59
61
  File.read(File.join(File.dirname(__FILE__), *%w{.. VERSION}))
60
62
  end
61
63
 
@@ -65,7 +67,7 @@ module Subtrigger
65
67
  # number.
66
68
  #
67
69
  # If an exception occurs, the program will quit with its error message.
68
- def self.run(*args)
70
+ def run(*args)
69
71
  Trigger.run(Repository.new(*args))
70
72
  rescue Exception => e
71
73
  puts "Error: #{e}" and exit(1)
@@ -74,10 +76,11 @@ module Subtrigger
74
76
  # Define a new +Trigger+ object -- shortcut method to
75
77
  # <tt>Trigger#define</tt>. To enable method chaining this method returns
76
78
  # itself.
77
- def self.on(pattern, &block)
79
+ def on(pattern, &block)
78
80
  Trigger.define(pattern, &block)
79
81
  self
80
82
  end
83
+ extend self
81
84
  end
82
85
 
83
86
  require 'subtrigger/email'
data/subtrigger.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{subtrigger}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
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"]
data/test/test_email.rb CHANGED
@@ -13,6 +13,11 @@ class TestEmail < Test::Unit::TestCase
13
13
  @message = @email.send
14
14
  end
15
15
 
16
+ should 'use custom sendmail location' do
17
+ Subtrigger.sendmail = 'foo'
18
+ assert_equal('foo', Subtrigger::Email.new.sendmail)
19
+ end
20
+
16
21
  should 'set all e-mail attributes' do
17
22
  assert_equal('from@from.com', @email.from)
18
23
  assert_equal('to@to.com', @email.to)
@@ -24,6 +24,16 @@ class TestRepository < Test::Unit::TestCase
24
24
  assert_equal('Foo', @r.author)
25
25
  end
26
26
 
27
+ should 'use custom configuration' do
28
+ Subtrigger::Repository.any_instance.expects(:`).with('/usr/foo/svn info --non-interactive').once
29
+ Subtrigger::Repository.any_instance.expects(:`).with('/usr/foo/svnlook info path/to/repo -r 1 --non-interactive').once.returns('')
30
+ Subtrigger.svn = '/usr/foo/svn'
31
+ Subtrigger.svn_args = '--non-interactive'
32
+ @r = Subtrigger::Repository.new('path/to/repo', 1)
33
+ @r.exec('info')
34
+ @r.author
35
+ end
36
+
27
37
  should 'yield changed directories' do
28
38
  @r.expects(:look_at).with('dirs-changed').returns("www.project1.com/trunk\nsub/www.project2.com/tags/v1")
29
39
  yieldings = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: subtrigger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arjan van der Gaag