1# ==================================================================== 2# Licensed to the Apache Software Foundation (ASF) under one 3# or more contributor license agreements. See the NOTICE file 4# distributed with this work for additional information 5# regarding copyright ownership. The ASF licenses this file 6# to you under the Apache License, Version 2.0 (the 7# "License"); you may not use this file except in compliance 8# with the License. You may obtain a copy of the License at 9# 10# http://www.apache.org/licenses/LICENSE-2.0 11# 12# Unless required by applicable law or agreed to in writing, 13# software distributed under the License is distributed on an 14# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15# KIND, either express or implied. See the License for the 16# specific language governing permissions and limitations 17# under the License. 18# ==================================================================== 19 20module SvnTestUtil 21 class Greek 22 TREE = [ 23 # relative path , contents(nil means directory) 24 ["iota" , "This is the file 'iota'.\n" ], 25 ["A" , nil ], 26 ["A/mu" , "This is the file 'mu'.\n" ], 27 ["A/B" , nil ], 28 ["A/B/lambda" , "This is the file 'lambda'.\n" ], 29 ["A/B/E" , nil ], 30 ["A/B/E/alpha" , "This is the file 'alpha'.\n" ], 31 ["A/B/E/beta" , "This is the file 'beta'.\n" ], 32 ["A/B/F" , nil ], 33 ["A/C" , nil ], 34 ["A/D" , nil ], 35 ["A/D/gamma" , "This is the file 'gamma'.\n" ], 36 ["A/D/G" , nil ], 37 ["A/D/G/pi" , "This is the file 'pi'.\n" ], 38 ["A/D/G/rho" , "This is the file 'rho'.\n" ], 39 ["A/D/G/tau" , "This is the file 'tau'.\n" ], 40 ["A/D/H" , nil ], 41 ["A/D/H/chi" , "This is the file 'chi'.\n" ], 42 ["A/D/H/psi" , "This is the file 'psi'.\n" ], 43 ["A/D/H/omega" , "This is the file 'omega'.\n" ] 44 ] 45 46 TREE.each do |path, contents| 47 const_set(path.split("/").last.upcase, path) 48 end 49 50 def initialize(tmp_path, import_path, wc_path, repos_uri) 51 @tmp_path = tmp_path 52 @import_path = import_path 53 @wc_path = wc_path 54 @repos_uri = repos_uri 55 end 56 57 def setup(context) 58 TREE.each do |path, contents| 59 entry = File.expand_path(File.join(@import_path, path)) 60 if contents 61 File.open(entry, 'w') {|f| f.print(contents)} 62 else 63 FileUtils.mkdir(entry) 64 end 65 end 66 67 context.import(@import_path, @repos_uri) 68 context.update(@wc_path) 69 end 70 71 def path(greek) 72 File.join(@wc_path, resolve(greek)) 73 end 74 75 def uri(greek) 76 "#{@repos_uri}/#{resolve(greek)}" 77 end 78 79 def resolve(greek) 80 self.class.const_get(greek.to_s.upcase) 81 end 82 end 83end 84