Class: Reap::Subversion
- Inherits:
-
Object
- Object
- Reap::Subversion
- Includes:
- Utilities
- Defined in:
- lib/reap/systems/subversion.rb
Instance Attribute Summary collapse
-
#branchpath ⇒ Object
Directory to store branches.
-
#dryrun ⇒ Object
Operate in dryrun mode.
-
#message ⇒ Object
Optional commit message.
-
#prefix ⇒ Object
Prefix to use on tag folder.
-
#project ⇒ Object
Project name (for repository).
-
#protocol ⇒ Object
The URL protocol to use.
-
#repository ⇒ Object
Developers URL to repository.
-
#tagpath ⇒ Object
Directory to store tags.
-
#username ⇒ Object
Username.
-
#version ⇒ Object
Current version of project.
Attributes included from Utilities
Instance Method Summary collapse
-
#branch(options = {}) ⇒ Object
Branch current version.
-
#developer_domain ⇒ Object
Developer domain is “username@repository”.
-
#initialize(options = {}) ⇒ Subversion
constructor
New Subversion object.
-
#log(file = nil) ⇒ Object
Create a change log.
- #log_xml(file) ⇒ Object
-
#tag(options = {}) ⇒ Object
Tag current version.
Methods included from Utilities
#ask, #bin?, #cd, #command_paths, #dir!, #dir?, directory!, directory?, #dryrun?, #email, exist!, exist?, #exists!, #exists?, #file!, #file?, #fileutils, #force?, #glob, #multiglob, #multiglob_r, #out_of_date?, #password, path!, path?, #read, #rm_r, #safe?, #sh, #stage, #stage_manifest, #status, #tar_bzip, #tgz, #trace?, #verbose?, #write, #zip, #ziputils
Constructor Details
#initialize(options = {}) ⇒ Subversion
New Subversion object.
TODO: Perhaps format prefix, like:
prefix = prefix + '_' if prefix && prefix !~ /[_-]$/
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/reap/systems/subversion.rb', line 54 def initialize(={}) .each do |k,v| send("#{k}=", v) if respond_to?("#{k}=") end # defaults are for rubyforge @repository ||= "rubyforge.org/var/svn/#{project}" @username ||= ENV['RUBYFORGE_USERNAME'] @protocol ||= "svn+ssh" @tagpath ||= "tags" @branchpath ||= "branches" if i = @repository.index('//') @repository = @repository[i+2..-1] end end |
Instance Attribute Details
#branchpath ⇒ Object
Directory to store branches. Defaults to branches/.
43 44 45 |
# File 'lib/reap/systems/subversion.rb', line 43 def branchpath @branchpath end |
#dryrun ⇒ Object
Operate in dryrun mode.
47 48 49 |
# File 'lib/reap/systems/subversion.rb', line 47 def dryrun @dryrun end |
#message ⇒ Object
Optional commit message. This is intended for commandline usage. (Use -m for shorthand).
35 36 37 |
# File 'lib/reap/systems/subversion.rb', line 35 def @message end |
#prefix ⇒ Object
Prefix to use on tag folder. Default is no prefix.
30 31 32 |
# File 'lib/reap/systems/subversion.rb', line 30 def prefix @prefix end |
#project ⇒ Object
Project name (for repository).
10 11 12 |
# File 'lib/reap/systems/subversion.rb', line 10 def project @project end |
#protocol ⇒ Object
The URL protocol to use. Defaults to “svn+ssh”.
26 27 28 |
# File 'lib/reap/systems/subversion.rb', line 26 def protocol @protocol end |
#repository ⇒ Object
Developers URL to repository. Defaults to Rubyforge address.
18 19 20 |
# File 'lib/reap/systems/subversion.rb', line 18 def repository @repository end |
#tagpath ⇒ Object
Directory to store tags. Defaults to tags/.
39 40 41 |
# File 'lib/reap/systems/subversion.rb', line 39 def tagpath @tagpath end |
#username ⇒ Object
Username. Defaults to ENV.
22 23 24 |
# File 'lib/reap/systems/subversion.rb', line 22 def username @username end |
#version ⇒ Object
Current version of project.
14 15 16 |
# File 'lib/reap/systems/subversion.rb', line 14 def version @version end |
Instance Method Details
#branch(options = {}) ⇒ Object
Branch current version.
message Optional commit message. This is intended for commandline
usage. (Use -m for shorthand).
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/reap/systems/subversion.rb', line 82 def branch(={}) msg = ['message'] || ['m'] name = "#{prefix}#{version}" path = branchpath.to_s if path == '.' or path.empty? url = "#{protocol}://" + File.join(developer_domain, name) else url = "#{protocol}://" + File.join(developer_domain, path, name) end if dryrun? puts "svn copy . #{url}" else case ask("Branch: #{url} ? [yN]").strip.downcase when 'y', 'yes' #sh "svn copy #{protocol}://#{username}@#{repository}/trunk #{url}" sh "svn copy . #{url}" end end end |
#developer_domain ⇒ Object
Developer domain is “username@repository”.
73 74 75 |
# File 'lib/reap/systems/subversion.rb', line 73 def developer_domain "#{username}@#{repository}" end |
#log(file = nil) ⇒ Object
Create a change log.
change File name to store rdoc formated changelog. Default is 'changelog.txt'.
output Path to store rdoc formated changelog. Default is 'log'.
xmlchange File name to store XML formated changelog. Default is 'changelog.xml'.
This also creates a file, if needed, by the same name but with .xsl extension.
xmloutput Path to store XML-formated changelog. Default is 'doc/log'.
If change or xmlchange contain a path separator (‘/’, not ‘'), then it is assumed they provide their own path and the output fields will not be used. This allows you to set change
to “./CHANGES” for instance, without effecting the location of other logs. You can also set change or xmlchange to ’false’ to supress creation altogether.
TODO: Allow for a way to dump the text-based Changelog to standard out. “$stdout” as the filename? TODO: How to apply naming policy from here?
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/reap/systems/subversion.rb', line 150 def log(file=nil) #txtlog = file #options['change'] || 'changelog.txt' #txtdir = options['output'] || 'log' #xmllog = options['xmlchange'] || 'changelog.xml' #xmldir = options['xmloutput'] || 'doc/log' #txtlog = File.join(txtdir, txtlog) unless xmllog.include?('/') #xmllog = File.join(xmldir, xmllog) unless xmllog.include?('/') text = changelog_text if dryrun? puts "svn log > #{file}" elsif file mkdir_p(File.dirname(file)) File.open(file, 'w'){|f| f << text } puts "Updated #{file}" else puts text end end |
#log_xml(file) ⇒ Object
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/reap/systems/subversion.rb', line 171 def log_xml(file) #xmldir = options['xmloutput'] || 'doc/log' xslfile = file.chomp(File.extname(file)) + '.xsl' log_xsl(xslfile) text = changelog_xml i = text.index("?>\n") text.insert(i+2, "\n" + %[<?xml-stylesheet href="#{xslfile}" type="text/xsl" ?>]) if dryrun? puts "svn log --xml > #{file}" elsif file mkdir_p(File.dirname(file)) File.open(file, 'w'){ |f| f << text } puts "Updated #{file}" else puts text end end |
#tag(options = {}) ⇒ Object
Tag current version.
message Optional commit message. This is intended for commandline
usage. (Use -m for shorthand).
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/reap/systems/subversion.rb', line 109 def tag(={}) msg = ['message'] || ['m'] name = "#{prefix}#{version}" path = tagpath.to_s if path == '.' or path.empty? url = "#{protocol}://" + File.join(developer_domain, name) else url = "#{protocol}://" + File.join(developer_domain, path, name) end if dryrun? puts "svn copy . #{url}" else case ask("Tag: #{url} ? [yN]").strip.downcase when 'y', 'yes' #sh "svn copy #{protocol}://#{username}@#{repository}/trunk #{url}" sh "svn copy . #{url}" end end end |