Class: RSCM::Perforce::P4Daemon
- Inherits:
-
Object
- Object
- RSCM::Perforce::P4Daemon
- Includes:
- FileUtils
- Defined in:
- lib/rscm/perforce/perforce.rb
Instance Method Summary collapse
- #assert_running ⇒ Object
-
#initialize(depotpath) ⇒ P4Daemon
constructor
A new instance of P4Daemon.
- #launch ⇒ Object
- #running? ⇒ Boolean
- #shutdown ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(depotpath) ⇒ P4Daemon
Returns a new instance of P4Daemon.
127 128 129 |
# File 'lib/rscm/perforce/perforce.rb', line 127 def initialize(depotpath) @depotpath = depotpath end |
Instance Method Details
#assert_running ⇒ Object
137 138 139 |
# File 'lib/rscm/perforce/perforce.rb', line 137 def assert_running raise "p4d did not start properly" if timeout(10) { running? } end |
#launch ⇒ Object
141 142 143 144 145 146 147 148 149 |
# File 'lib/rscm/perforce/perforce.rb', line 141 def launch fork do mkdir_p(@depotpath) cd(@depotpath) debug "starting p4 server" exec("p4d") end at_exit { shutdown } end |
#running? ⇒ Boolean
155 156 157 |
# File 'lib/rscm/perforce/perforce.rb', line 155 def running? !`p4 -p 1666 info`.empty? end |
#shutdown ⇒ Object
151 152 153 |
# File 'lib/rscm/perforce/perforce.rb', line 151 def shutdown `p4 -p 1666 admin stop` end |
#start ⇒ Object
131 132 133 134 135 |
# File 'lib/rscm/perforce/perforce.rb', line 131 def start shutdown if running? launch assert_running end |