Class: Script::Mercurial

Inherits:
Object
  • Object
show all
Defined in:
lib/plugins/mercurial.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(toplevel, repository, &block) ⇒ Mercurial

Returns a new instance of Mercurial.



9
10
11
12
13
14
15
# File 'lib/plugins/mercurial.rb', line 9

def initialize(toplevel, repository, &block)
  @toplevel = toplevel
  @repository = repository
  @m = 0
  @interval = 5
  instance_eval(&block)
end

Instance Attribute Details

#actiontagObject (readonly)

Returns the value of attribute actiontag.



17
18
19
# File 'lib/plugins/mercurial.rb', line 17

def actiontag
  @actiontag
end

#groupnameObject (readonly)

Returns the value of attribute groupname.



17
18
19
# File 'lib/plugins/mercurial.rb', line 17

def groupname
  @groupname
end

#repositoryObject (readonly)

Returns the value of attribute repository.



17
18
19
# File 'lib/plugins/mercurial.rb', line 17

def repository
  @repository
end

#usernameObject (readonly)

Returns the value of attribute username.



17
18
19
# File 'lib/plugins/mercurial.rb', line 17

def username
  @username
end

Instance Method Details

#action(tag) ⇒ Object



61
62
63
# File 'lib/plugins/mercurial.rb', line 61

def action(tag)
  @actiontag = tag
end

#doitObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/plugins/mercurial.rb', line 19

def doit
  @m += 1
  if @interval <= @m
    Dir.chdir(repository) do 
      Bash.new(@toplevel, self) do
        user injection.username
        group injection.groupname
        code "          hg incoming\n        EOC\n        success(injection) do\n          bash(injection) do\n            log \"hg: pull --update \#{injection.repository}\"\n            user injection.username\n            group injection.groupname\n            echo true\n            code <<-EOC\n              HGENCODING=utf-8 hg pull --update\n            EOC\n          end\n          run injection.actiontag\n        end\n      end.doit\n    end\n    @m = 0\n  end\nend\n"

#group(groupname) ⇒ Object



57
58
59
# File 'lib/plugins/mercurial.rb', line 57

def group(groupname)
  @groupname = groupname
end

#interval(n) ⇒ Object


DSL



49
50
51
# File 'lib/plugins/mercurial.rb', line 49

def interval(n)
  @interval = n
end

#user(username) ⇒ Object



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

def user(username)
  @username = username
end