Module: Subtrigger

Extended by:
Subtrigger
Included in:
Subtrigger
Defined in:
lib/subtrigger.rb,
lib/subtrigger/dsl.rb,
lib/subtrigger/path.rb,
lib/subtrigger/rule.rb,
lib/subtrigger/revision.rb,
lib/subtrigger/template.rb

Defined Under Namespace

Modules: Dsl Classes: Path, Revision, Rule, Template

Constant Summary collapse

Exception =

Standard exception for all Subtrigger exceptions

Class.new(Exception)

Instance Method Summary collapse

Instance Method Details

#pathPath

Returns The ‘global’ Path object.

Returns:

  • (Path)

    The ‘global’ Path object

See Also:



71
72
73
# File 'lib/subtrigger.rb', line 71

def path
  @path ||= Path.new
end

#run(repository_path, revision_number) ⇒ Object

Run the current file of rules.

This method is called after all the rules have been defined. It takes the command line arguments that come from subversion.

Parameters:

  • repository_path (String)

    is the path to the repository to query

  • revision_number (String)

    is the revision number that triggered the hook.

Returns:

  • nil



36
37
38
39
40
41
42
43
44
# File 'lib/subtrigger.rb', line 36

def run(repository_path, revision_number)
  Template.parse(DATA.read)
  rev = Revision.new(
    revision_number,
    svnlook('info', repository_path),
    svnlook('dirs-changed', repository_path)
  )
  Rule.matching(rev).each { |r| r.run(rev) }
end

#svn(*args) ⇒ String

Make a system call to svn with the given arguments. The executable that used is the first found by Subtrigger::Path#to.

Examples:

Using multiple arguments

svn 'update', 'foo', '--ignore-externals'
# => '/usr/bin/svn update foo --ignore-externals'

Returns:

  • (String)

    output from the command



53
54
55
# File 'lib/subtrigger.rb', line 53

def svn(*args)
  `svn #{[*args].join(' ')}`
end

#svnlook(*args) ⇒ String

Make a system call to svnlook with the given arguments. The executable # that used is the first found in POSSIBLE_PATHS.

Examples:

Using multiple arguments

svnlook 'youngest', '/path/to/repo'
# => '/usr/bin/svnlook youngest /path/to/repo

Returns:

  • (String)

    output from the command



65
66
67
# File 'lib/subtrigger.rb', line 65

def svnlook(*args)
  `svnlook #{[*args].join(' ')}`
end

#versionString

Return the current version number as defined in ./VERSION

Returns:

  • (String)

    version number (e.g. ‘0.3.1’)



23
24
25
# File 'lib/subtrigger.rb', line 23

def version
  File.read(File.join(File.dirname(__FILE__), '..', 'VERSION'))
end