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.
176 177 178 179 180 |
# File 'lib/Wiki2Go/Install/make_repository.rb', line 176 def initialize(dir,logger=nil) @dir = dir @logger = logger || Logger.new(STDERR) RSCM::Better.use_logger @logger end |
Class Method Details
.addwiki(args) ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/Wiki2Go/Install/make_repository.rb', line 120 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
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/Wiki2Go/Install/make_repository.rb', line 91 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
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/Wiki2Go/Install/make_repository.rb', line 150 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
198 199 200 201 202 203 204 205 |
# File 'lib/Wiki2Go/Install/make_repository.rb', line 198 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
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 269 270 271 272 273 |
# File 'lib/Wiki2Go/Install/make_repository.rb', line 223 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
275 276 277 278 279 |
# File 'lib/Wiki2Go/Install/make_repository.rb', line 275 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
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/Wiki2Go/Install/make_repository.rb', line 182 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
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/Wiki2Go/Install/make_repository.rb', line 207 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 |