Class: SVNUtils
- Inherits:
-
Object
- Object
- SVNUtils
- Defined in:
- lib/svnutils.rb
Overview
use the svn Id Keyword expansion to report svn file information revision, developer, filename, date and time of last revision.
Defined Under Namespace
Classes: FileNotFound
Constant Summary collapse
- @@files =
Hash.new
Class Method Summary collapse
-
.date(target_file) ⇒ Object
get the date the last revision was made to the file.
-
.developer(target_file) ⇒ Object
get the last developer who checked in the file.
-
.filename(target_file) ⇒ Object
get the svn filename of the file.
-
.parse_file(target_file) ⇒ Object
parse the file, so we can get its values.
-
.revision(target_file) ⇒ Object
get the svn version of a file.
-
.time(target_file) ⇒ Object
get the time the last revision was made to the file.
Class Method Details
.date(target_file) ⇒ Object
get the date the last revision was made to the file
39 40 41 42 43 44 |
# File 'lib/svnutils.rb', line 39 def SVNUtils.date(target_file) if not @@files[target_file] parse_file(target_file) end return @@files[target_file].date end |
.developer(target_file) ⇒ Object
get the last developer who checked in the file
23 24 25 26 27 28 |
# File 'lib/svnutils.rb', line 23 def SVNUtils.developer(target_file) if not @@files[target_file] parse_file(target_file) end return @@files[target_file].developer end |
.filename(target_file) ⇒ Object
get the svn filename of the file
31 32 33 34 35 36 |
# File 'lib/svnutils.rb', line 31 def SVNUtils.filename(target_file) if not @@files[target_file] parse_file(target_file) end return @@files[target_file].filename end |
.parse_file(target_file) ⇒ Object
parse the file, so we can get its values
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/svnutils.rb', line 56 def SVNUtils.parse_file(target_file) if not File.exist?(target_file) raise SVNUtils::FileNotFound, target_file end # get first id from the file File.readlines(target_file).each do |line| match = [] match = line.scan(/\$Id:(.+)\$/) if not match[0].nil? matchset = match[0][0].strip.split(" ") @@files[target_file] = OpenStruct.new m = @@files[target_file] m.filename, m.revision, m.date, m.time, m.developer = matchset break end end # what if there is no Id tag in the given file? if @@files[target_file].nil? @@files[target_file] = OpenStruct.new @@files[target_file].filename = "No ID tag found" @@files[target_file].revision = "No ID tag found" @@files[target_file].date = "No ID tag found" @@files[target_file].time = "No ID tag found" @@files[target_file].developer = "No ID tag found" end end |
.revision(target_file) ⇒ Object
get the svn version of a file
15 16 17 18 19 20 |
# File 'lib/svnutils.rb', line 15 def SVNUtils.revision(target_file) if not @@files[target_file] parse_file(target_file) end return @@files[target_file].revision end |
.time(target_file) ⇒ Object
get the time the last revision was made to the file
47 48 49 50 51 52 |
# File 'lib/svnutils.rb', line 47 def SVNUtils.time(target_file) if not @@files[target_file] parse_file(target_file) end return @@files[target_file].time end |