Class: Wiki2Go::RepositoryMaker
- Inherits:
-
Object
- Object
- Wiki2Go::RepositoryMaker
- Defined in:
- lib/Wiki2Go/Install/make_repository.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_module(modulename, user, group) ⇒ Object
- #add_wiki(wikidir, modulename, comment = 'No Comment') ⇒ Object
-
#initialize(dir, logger = nil) ⇒ RepositoryMaker
constructor
A new instance of RepositoryMaker.
- #is_local?(wikidir, modulename) ⇒ Boolean
- #make_empty_repository(user, group) ⇒ Object
- #update(wikidir, modulename) ⇒ Object
Constructor Details
#initialize(dir, logger = nil) ⇒ RepositoryMaker
Returns a new instance of RepositoryMaker.
171 172 173 174 175 |
# File 'lib/Wiki2Go/Install/make_repository.rb', line 171 def initialize(dir,logger=nil) @dir = dir @logger = logger || Logger.new(STDERR) RSCM::Better.use_logger @logger end |
Class Method Details
.addwiki(args) ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/Wiki2Go/Install/make_repository.rb', line 115 def RepositoryMaker.addwiki(args) opts = OptionParser.new directory = '' wikidir = '' modulename = '' comment = 'Store wiki' opts.on("-d",'--directory dir',String) { |val| directory = (val) } opts.on("-w",'--wikidirectory dir',String) { |val| wikidir = File.(val) } opts.on("-m",'--module name',String) { |val| modulename = val } opts.on("-c",'--comment string',String) { |val| comment = val } opts.on_tail("-h", "--help", "Show this message") do puts opts exit end opts.parse(args) if directory.empty? || wikidir.empty? || modulename.empty? then puts opts return [] else puts "Adding wiki #{wikidir} as module '#{modulename}' in CVS #{directory}" oldmask = File.umask(02) cvs = RepositoryMaker.new(directory) added = cvs.add_wiki(wikidir,modulename,comment) File.umask(oldmask) return added end end |
.create(args) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/Wiki2Go/Install/make_repository.rb', line 86 def RepositoryMaker.create(args) opts = OptionParser.new directory = '' user = '' group = '' modulename = '' opts.on("-d",'--directory dir',String) { |val| directory = (val) } opts.on("-u",'--user username',String) { |val| user = val } opts.on("-g",'--group groupname',String) { |val| group = val } opts.on("-m",'--module name ',String) { |val| modulename = val } opts.on_tail("-h", "--help", "Show this message") do puts opts exit end opts.parse(args) if directory.empty? then puts opts else puts "Creating CVS in directory #{directory}" oldmask = File.umask(02) cvs = RepositoryMaker.new(directory) cvs.make_empty_repository(user,group) cvs.add_module(modulename,user,group) File.umask(oldmask) end end |
.updatewiki(args) ⇒ Object
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/Wiki2Go/Install/make_repository.rb', line 145 def RepositoryMaker.updatewiki(args) opts = OptionParser.new wikidir = '' directory = '' modulename = '' opts.on("-d",'--directory dir',String) { |val| directory = (val) } opts.on("-w",'--wikidirectory dir',String) { |val| wikidir = File.(val) } opts.on("-m",'--module name ',String) { |val| modulename = val } opts.on_tail("-h", "--help", "Show this message") do puts opts exit end opts.parse(args) if wikidir.empty? then puts opts else puts "Updating wiki #{wikidir}" oldmask = File.umask(02) cvs = RepositoryMaker.new(directory) cvs.update(wikidir,modulename) File.umask(oldmask) end end |
Instance Method Details
#add_module(modulename, user, group) ⇒ Object
193 194 195 196 197 198 199 200 |
# File 'lib/Wiki2Go/Install/make_repository.rb', line 193 def add_module(modulename,user,group) if !modulename.nil? && !modulename.empty? then moduledir = File.join(@dir,modulename) FileUtils::mkdir_p moduledir set_owner(moduledir,user,group) end end |
#add_wiki(wikidir, modulename, comment = 'No Comment') ⇒ Object
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/Wiki2Go/Install/make_repository.rb', line 218 def add_wiki(wikidir,modulename,comment='No Comment') repository = RSCM::Cvs.new(@dir,modulename) repository.checkout_dir = wikidir repository.checkout unless repository.checked_out? output = [] added_files = [] added_files += add_contents_of(modulename,wikidir,'texts') { |dir,name| checkin = ((name =~ /^\./) ? false : true) # output << "Add #{name.inspect} in #{dir} ? => #{checkin}" checkin } added_files += add_contents_of(modulename,wikidir,'templates') { |dir,name| checkin = ((name =~ /^\./) ? false : true) # output << "Add #{name} in #{dir} ? => #{checkin}" checkin } sitedir = File.join(wikidir,'site') if File.exists?(sitedir) then add_directory modulename,wikidir,'site' scriptdir = File.join(sitedir,'scripts') if File.exists?(scriptdir) then add_directory modulename,sitedir,'scripts' added_files += add_files modulename,scriptdir,[ 'CgiOptions.rb'] end end added_files += add_contents_of(modulename,File.join(wikidir,'site'),'html') { |dir,name| checkin = ((name == 'rss.xml' || (name =~ /^\./)) ? false : true) # output << "Add #{name} in #{dir} ? => #{checkin}" checkin } added_files += add_contents_of(modulename,wikidir,'config') { |dir,name| checkin = ((name == 'chonqed_blacklist.txt' || (name =~ /^\./)) ? false : true) # output << "Add #{name} in #{dir} ? => #{checkin}" checkin } begin repository.commit comment do |line| output << line end rescue Exception => e output << e.to_s end output end |
#is_local?(wikidir, modulename) ⇒ Boolean
270 271 272 273 274 |
# File 'lib/Wiki2Go/Install/make_repository.rb', line 270 def is_local?(wikidir,modulename) repository = RSCM::Cvs.new(@dir,modulename) repository.checkout_dir = wikidir repository.can_create_central? end |
#make_empty_repository(user, group) ⇒ Object
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/Wiki2Go/Install/make_repository.rb', line 177 def make_empty_repository(user,group) if !File.exists?(File.join(@dir,'CVSROOT')) then repository = RSCM::Cvs.new(@dir) FileUtils::mkdir_p @dir repository.create_central lockdir = File.join(@dir,'locks') FileUtils::mkdir_p lockdir set_owner(@dir,user,group) end update_configuration end |
#update(wikidir, modulename) ⇒ Object
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/Wiki2Go/Install/make_repository.rb', line 202 def update(wikidir,modulename) repository = RSCM::Cvs.new(@dir,modulename) repository.checkout_dir = wikidir updated = [] clashed = [] begin repository.checkout do |event,path| updated << path if event == 'U' || event == 'P' clashed << path if event == 'C' end rescue Exception => e clashed = [ e.to_s ] end return updated,clashed end |