Class: Vlad::Perforce
- Inherits:
-
Object
- Object
- Vlad::Perforce
- Defined in:
- lib/vlad/perforce.rb
Constant Summary collapse
- VERSION =
'2.0.1'
Instance Method Summary collapse
-
#checkout(revision, destination) ⇒ Object
Returns the p4 command that will checkout
revision
into the directorydestination
. -
#export(revision_or_source, destination) ⇒ Object
Returns the p4 command that will export
revision
into the directorydirectory
. -
#rev_no(revision) ⇒ Object
Maps revision
revision
into a Perforce revision. -
#revision(revision) ⇒ Object
Returns a command that maps human-friendly revision identifier
revision
into a Perforce revision specification.
Instance Method Details
#checkout(revision, destination) ⇒ Object
Returns the p4 command that will checkout revision
into the directory destination
.
11 12 13 |
# File 'lib/vlad/perforce.rb', line 11 def checkout(revision, destination) "#{p4_cmd} sync ...#{rev_no(revision)}" end |
#export(revision_or_source, destination) ⇒ Object
Returns the p4 command that will export revision
into the directory directory
.
19 20 21 22 23 24 25 |
# File 'lib/vlad/perforce.rb', line 19 def export(revision_or_source, destination) if revision_or_source =~ /^(\d+|head)$/i then "(cd #{destination} && #{p4_cmd} sync ...#{rev_no(revision_or_source)})" else "cp -r #{revision_or_source} #{destination}" end end |
#rev_no(revision) ⇒ Object
Maps revision revision
into a Perforce revision.
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/vlad/perforce.rb', line 38 def rev_no(revision) case revision.to_s when /head/i then "#head" when /^\d+$/ then "@#{revision}" else revision end end |
#revision(revision) ⇒ Object
Returns a command that maps human-friendly revision identifier revision
into a Perforce revision specification.
31 32 33 |
# File 'lib/vlad/perforce.rb', line 31 def revision(revision) "`#{p4_cmd} changes -s submitted -m 1 ...#{rev_no(revision)} | cut -f 2 -d\\ `" end |