Class: External
- Inherits:
-
Object
- Object
- External
- Defined in:
- lib/sub/external.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#revision ⇒ Object
readonly
Returns the value of attribute revision.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #checkout ⇒ Object
-
#initialize(parent, property, app = nil) ⇒ External
constructor
A new instance of External.
- #revision_actual ⇒ Object
- #run(cmd, return_output = false) ⇒ Object
- #say(msg) ⇒ Object
- #should_update? ⇒ Boolean
- #svn(cmd) ⇒ Object
- #to_s ⇒ Object
-
#update ⇒ Object
todo: test? (indirectly tested via root.rb).
Constructor Details
#initialize(parent, property, app = nil) ⇒ External
Returns a new instance of External.
15 16 17 18 19 20 21 22 |
# File 'lib/sub/external.rb', line 15 def initialize(parent, property, app = nil) match = /^(\S+)\s+(-r\s*\d*\s+)?(\S+)\s*$/.match(property) @name = match[1] @revision = match[2] ? match[2].gsub(/\D/,'').to_i : nil @url = match[3] @path = "#{parent}/#{@name}" @app = app end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
13 14 15 |
# File 'lib/sub/external.rb', line 13 def app @app end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
13 14 15 |
# File 'lib/sub/external.rb', line 13 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
13 14 15 |
# File 'lib/sub/external.rb', line 13 def path @path end |
#revision ⇒ Object (readonly)
Returns the value of attribute revision.
13 14 15 |
# File 'lib/sub/external.rb', line 13 def revision @revision end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
13 14 15 |
# File 'lib/sub/external.rb', line 13 def url @url end |
Class Method Details
.externals_in_directory(parent, app) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/sub/external.rb', line 3 def self.externals_in_directory(parent, app) exts = [] prop = `svn propget svn:externals #{parent}` prop.split("\n").each do |prop_line| next if prop_line.strip.empty? exts << External.new(parent, prop_line, app) end exts end |
Instance Method Details
#==(other) ⇒ Object
36 37 38 |
# File 'lib/sub/external.rb', line 36 def ==(other) (path == other.path and url == other.url) end |
#checkout ⇒ Object
61 62 63 64 65 |
# File 'lib/sub/external.rb', line 61 def checkout say "Checking out external #{path}" rev = revision.nil? ? '' : "-r#{revision}" svn("co #{rev} #{url} #{path}") end |
#revision_actual ⇒ Object
44 45 46 47 |
# File 'lib/sub/external.rb', line 44 def revision_actual info = `svn info #{@path}` info.grep(/^Revision:/).first.gsub(/Revision: /, '').to_i end |
#run(cmd, return_output = false) ⇒ Object
32 33 34 |
# File 'lib/sub/external.rb', line 32 def run(cmd, return_output = false) app.run(cmd, return_output) end |
#say(msg) ⇒ Object
24 25 26 |
# File 'lib/sub/external.rb', line 24 def say(msg) app.say(msg) end |
#should_update? ⇒ Boolean
49 50 51 |
# File 'lib/sub/external.rb', line 49 def should_update? revision == nil || revision_actual != revision end |
#svn(cmd) ⇒ Object
28 29 30 |
# File 'lib/sub/external.rb', line 28 def svn(cmd) app.svn(cmd) end |
#to_s ⇒ Object
40 41 42 |
# File 'lib/sub/external.rb', line 40 def to_s "External[name=#{name}, path=#{path}, url=#{url}, revision=#{revision}]" end |
#update ⇒ Object
todo: test? (indirectly tested via root.rb)
54 55 56 57 58 59 |
# File 'lib/sub/external.rb', line 54 def update say "Updating external #{path}" run("svn cleanup #{path}") rev = revision.nil? ? '' : "-r#{revision}" svn("up #{rev} #{path} | grep -v 'At revision'") end |