Class: Cerberus::SCM::Perforce

Inherits:
Base
  • Object
show all
Defined in:
lib/cerberus/scm/perforce.rb

Constant Summary collapse

CHANGES_LOG_REGEXP =
/^Change (\d+) on (.*) by (.*)\n\n(.*)/m

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, config = {}) ⇒ Perforce

Returns a new instance of Perforce.



8
9
10
11
12
# File 'lib/cerberus/scm/perforce.rb', line 8

def initialize(path, config = {})
  super
  @p4_view = @config[:scm, :view]
  @client_name = Socket.gethostname + ":" + @path.gsub(' ', ':')
end

Instance Attribute Details

#current_revisionObject (readonly)

Returns the value of attribute current_revision.



33
34
35
# File 'lib/cerberus/scm/perforce.rb', line 33

def current_revision
  @current_revision
end

#last_authorObject (readonly)

Returns the value of attribute last_author.



34
35
36
# File 'lib/cerberus/scm/perforce.rb', line 34

def last_author
  @last_author
end

#last_commit_messageObject (readonly)

Returns the value of attribute last_commit_message.



35
36
37
# File 'lib/cerberus/scm/perforce.rb', line 35

def last_commit_message
  @last_commit_message
end

Instance Method Details

#has_changes?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/cerberus/scm/perforce.rb', line 25

def has_changes?
  !@status.include?('file(s) up-to-date.')
end

#installed?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/cerberus/scm/perforce.rb', line 14

def installed?
  exec_successful? "#{@config[:bin_path]}p4 info"
end

#update!Object



18
19
20
21
22
23
# File 'lib/cerberus/scm/perforce.rb', line 18

def update!
  FileUtils.mkpath(@path) unless test(?d,@path)
  create_client

  @status = execute("sync")
end

#urlObject



29
30
31
# File 'lib/cerberus/scm/perforce.rb', line 29

def url
  @view
end