Class: External
Instance Attribute Summary collapse
-
#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
- .externals_of(parent, prop = `svn propget svn:externals #{parent}`) ⇒ Object
- .from_property_line(parent, property_line) ⇒ Object
Instance Method Summary collapse
- #==(other) ⇒ Object
- #checkout ⇒ Object
-
#initialize(parent, name, url, revision = nil) ⇒ External
constructor
A new instance of External.
- #revision_actual ⇒ Object
- #should_update? ⇒ Boolean
- #to_s ⇒ Object
-
#update ⇒ Object
todo: test? (indirectly tested via root.rb).
Methods included from Sys::Client
#run, #say, #svn, #sys, #verbosity, #verbosity=
Constructor Details
#initialize(parent, name, url, revision = nil) ⇒ External
Returns a new instance of External.
24 25 26 27 28 29 |
# File 'lib/sub/external.rb', line 24 def initialize(parent, name, url, revision = nil) @name = name @revision = revision @url = url @path = "#{parent}/#{@name}" end |
Instance Attribute Details
#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_of(parent, prop = `svn propget svn:externals #{parent}`) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/sub/external.rb', line 4 def self.externals_of(parent, prop = `svn propget svn:externals #{parent}`) exts = [] prop.split("\n").each do |prop_line| next if prop_line.strip.empty? exts << External.from_property_line(parent, prop_line) end exts end |
.from_property_line(parent, property_line) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/sub/external.rb', line 15 def self.from_property_line(parent, property_line) match = /^(\S+)\s+(-r\s*\d*\s+)?(\S+)\s*$/.match(property_line) name = match[1] revision = match[2] ? match[2].gsub(/\D/,'').to_i : nil url = match[3] raise "no url found for '#{property_line}'" if url.nil? new(parent, name, url, revision) end |
Instance Method Details
#==(other) ⇒ Object
31 32 33 |
# File 'lib/sub/external.rb', line 31 def ==(other) (path == other.path and url == other.url) end |
#checkout ⇒ Object
59 60 61 62 63 |
# File 'lib/sub/external.rb', line 59 def checkout say "Checking out external #{path}" rev = revision.nil? ? '' : "-r#{revision}" svn("co #{rev} #{url} #{path}") end |
#revision_actual ⇒ Object
41 42 43 44 |
# File 'lib/sub/external.rb', line 41 def revision_actual info = `svn info #{@path}` info.grep(/^Revision:/).first.gsub(/Revision: /, '').to_i end |
#should_update? ⇒ Boolean
46 47 48 |
# File 'lib/sub/external.rb', line 46 def should_update? revision == nil || revision_actual != revision end |
#to_s ⇒ Object
35 36 37 38 39 |
# File 'lib/sub/external.rb', line 35 def to_s "#{name} " + (revision ? "-r #{revision} " : "") + url end |
#update ⇒ Object
todo: test? (indirectly tested via root.rb)
51 52 53 54 55 56 57 |
# File 'lib/sub/external.rb', line 51 def update raise "path is nil" if path.nil? say "Updating external #{path}" run("svn cleanup #{path}") rev = revision.nil? ? '' : "-r#{revision}" svn("up #{rev} #{path}", true) end |