jaz303-repo-man 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/bin/repo-man +94 -0
  2. metadata +53 -0
data/bin/repo-man ADDED
@@ -0,0 +1,94 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ module RepoMan
4
+
5
+ class ApacheConfigGenerator
6
+
7
+ def initialize(path)
8
+ @path = path
9
+ end
10
+
11
+ def roots
12
+ RootDetector.new(@path).roots
13
+ end
14
+
15
+ def to_httpd_conf
16
+ out = ""
17
+ roots.each do |r|
18
+
19
+ out << "<Location #{normalize_location(r)}>\n"
20
+ out << " DAV svn\n"
21
+ out << " SVNParentPath #{r}\n"
22
+
23
+ access_file = File.join(r, 'access')
24
+ if File.exists?(access_file)
25
+ out << " AuthzSVNAccessFile #{access_file}\n"
26
+ end
27
+
28
+ out << " Require valid-user\n"
29
+ out << " Allow from all\n"
30
+ out << " Satisfy all\n"
31
+ out << "</Location>\n\n"
32
+
33
+ end
34
+ out
35
+ end
36
+
37
+ private
38
+
39
+ def normalize_location(r)
40
+ r.gsub(/^#{Regexp.quote(@path)}/, '') + '/'
41
+ end
42
+
43
+ end
44
+
45
+ # Locates all SVN roots under a given path
46
+ # root = directory containing one or more repos
47
+ class RootDetector
48
+ def initialize(path)
49
+ @path = path
50
+ end
51
+
52
+ def roots
53
+ unless @roots
54
+ @roots = []
55
+ find_roots(@path)
56
+ end
57
+ @roots
58
+ end
59
+
60
+ private
61
+
62
+ def find_roots(path)
63
+ try = Dir["#{path}/*"].reject { |f| !File.directory?(f) }
64
+ if try.any? { |f| is_repo?(f) }
65
+ @roots << path
66
+ else
67
+ try.each { |d| find_roots(d) }
68
+ end
69
+ end
70
+
71
+ def is_repo?(path)
72
+ %w(conf dav db hooks locks).all? { |d| File.directory?(File.join(path, d)) }
73
+ end
74
+
75
+ end
76
+ end
77
+
78
+ if $0 == __FILE__
79
+
80
+ if ARGV.length != 1
81
+ puts "Usage: svn-dav-gen path"
82
+ exit
83
+ end
84
+
85
+ path = File.expand_path(ARGV[0])
86
+
87
+ if !File.directory?(path)
88
+ puts "Error: #{path} is not a directory"
89
+ exit 1
90
+ end
91
+
92
+ puts RepoMan::ApacheConfigGenerator.new(path).to_httpd_conf
93
+
94
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jaz303-repo-man
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jason Frame
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-10-27 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: jason@onehackoranother.com
18
+ executables:
19
+ - repo-man
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - bin/repo-man
26
+ has_rdoc: false
27
+ homepage: http://github.com/jaz303/repo-man/
28
+ post_install_message:
29
+ rdoc_options: []
30
+
31
+ require_paths:
32
+ - lib
33
+ required_ruby_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: "0"
38
+ version:
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ requirements: []
46
+
47
+ rubyforge_project:
48
+ rubygems_version: 1.2.0
49
+ signing_key:
50
+ specification_version: 2
51
+ summary: Apache/SVN/DAV config file generator for sites with multiple repository roots
52
+ test_files: []
53
+