technomancy-gitjour 6.3.0 → 6.4.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.
- data/History.txt +13 -0
- data/Manifest.txt +1 -18
- data/README.txt +64 -5
- data/Rakefile +15 -4
- data/bin/gitjour +0 -0
- data/lib/gitjour.rb +188 -1
- metadata +21 -33
- data/License.txt +0 -20
- data/config/hoe.rb +0 -71
- data/config/requirements.rb +0 -17
- data/lib/gitjour/application.rb +0 -183
- data/lib/gitjour/version.rb +0 -9
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/script/txt2html +0 -74
- data/setup.rb +0 -1585
- data/tasks/deployment.rake +0 -34
- data/tasks/environment.rake +0 -7
- data/tasks/website.rake +0 -17
- data/website/index.html +0 -11
- data/website/index.txt +0 -39
- data/website/javascripts/rounded_corners_lite.inc.js +0 -285
- data/website/stylesheets/screen.css +0 -138
- data/website/template.rhtml +0 -48
data/lib/gitjour/application.rb
DELETED
@@ -1,183 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'dnssd'
|
3
|
-
require 'set'
|
4
|
-
require 'gitjour/version'
|
5
|
-
|
6
|
-
Thread.abort_on_exception = true
|
7
|
-
|
8
|
-
module Gitjour
|
9
|
-
GitService = Struct.new(:name, :host, :port, :description)
|
10
|
-
|
11
|
-
class Application
|
12
|
-
|
13
|
-
class << self
|
14
|
-
def run(*args)
|
15
|
-
case args.shift
|
16
|
-
when "list"
|
17
|
-
list
|
18
|
-
when "clone"
|
19
|
-
clone(*args)
|
20
|
-
when "serve"
|
21
|
-
serve(*args)
|
22
|
-
when "remote"
|
23
|
-
remote(*args)
|
24
|
-
else
|
25
|
-
help
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
def list
|
31
|
-
service_list.each do |service|
|
32
|
-
puts "=== #{service.name} on #{service.host}:#{service.port} ==="
|
33
|
-
puts " gitjour clone #{service.name}"
|
34
|
-
if service.description != '' && service.description !~ /^Unnamed repository/
|
35
|
-
puts " #{service.description}"
|
36
|
-
end
|
37
|
-
puts
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def clone(repository_name, *rest)
|
42
|
-
dir = rest.shift || repository_name
|
43
|
-
if File.exists?(dir)
|
44
|
-
exit_with! "ERROR: Clone directory '#{dir}' already exists."
|
45
|
-
end
|
46
|
-
|
47
|
-
puts "Cloning '#{repository_name}' into directory '#{dir}'..."
|
48
|
-
|
49
|
-
unless service = locate_repo(repository_name)
|
50
|
-
exit_with! "ERROR: Unable to find project named '#{repository_name}'"
|
51
|
-
end
|
52
|
-
|
53
|
-
puts "Connecting to #{service.host}:#{service.port}"
|
54
|
-
|
55
|
-
system "git clone git://#{service.host}:#{service.port}/ #{dir}"
|
56
|
-
end
|
57
|
-
|
58
|
-
def remote(repository_name, *rest)
|
59
|
-
dir = rest.shift || repository_name
|
60
|
-
service = locate_repo repository_name
|
61
|
-
system "git remote add #{dir} git://#{service.host}:#{service.port}/"
|
62
|
-
end
|
63
|
-
|
64
|
-
def serve(path=Dir.pwd, *rest)
|
65
|
-
path = File.expand_path(path)
|
66
|
-
name = rest.shift || File.basename(path)
|
67
|
-
port = rest.shift || 9418
|
68
|
-
|
69
|
-
# If the name starts with ^, then don't apply the prefix
|
70
|
-
if name[0] == ?^
|
71
|
-
name = name[1..-1]
|
72
|
-
else
|
73
|
-
prefix = `git config --get gitjour.prefix`.chomp
|
74
|
-
prefix = ENV["USER"] if prefix.empty?
|
75
|
-
name = [prefix, name].compact.join("-")
|
76
|
-
end
|
77
|
-
|
78
|
-
if File.exists?("#{path}/.git")
|
79
|
-
announce_repo(path, name, port.to_i)
|
80
|
-
else
|
81
|
-
Dir["#{path}/*"].each do |dir|
|
82
|
-
if File.directory?(dir)
|
83
|
-
name = File.basename(dir)
|
84
|
-
announce_repo(dir, name, 9418)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
`git-daemon --verbose --export-all --port=#{port} --base-path=#{path} --base-path-relaxed`
|
90
|
-
end
|
91
|
-
|
92
|
-
def help
|
93
|
-
puts "Gitjour #{Gitjour::VERSION::STRING}"
|
94
|
-
puts "Serve up and use git repositories via Bonjour/DNSSD."
|
95
|
-
puts "\nUsage: gitjour <command> [args]"
|
96
|
-
puts
|
97
|
-
puts " list"
|
98
|
-
puts " Lists available repositories."
|
99
|
-
puts
|
100
|
-
puts " clone <project> [<directory>]"
|
101
|
-
puts " Clone a gitjour served repository."
|
102
|
-
puts
|
103
|
-
puts " serve <path_to_project> [<name_of_project>] [<port>] or"
|
104
|
-
puts " <path_to_projects>"
|
105
|
-
puts " Serve up the current directory or projects via gitjour."
|
106
|
-
puts
|
107
|
-
puts " The name of your project is automatically prefixed with"
|
108
|
-
puts " `git config --get gitjour.prefix` or your username (preference"
|
109
|
-
puts " in that order). If you don't want a prefix, put a ^ on the front"
|
110
|
-
puts " of the name_of_project (the ^ is removed before announcing)."
|
111
|
-
puts
|
112
|
-
puts " remote <project> [<name>]"
|
113
|
-
puts " Add a Bonjour remote into your current repository."
|
114
|
-
puts " Optionally pass name to not use pwd."
|
115
|
-
puts
|
116
|
-
end
|
117
|
-
|
118
|
-
def exit_with!(message)
|
119
|
-
STDERR.puts message
|
120
|
-
exit!
|
121
|
-
end
|
122
|
-
|
123
|
-
class Done < RuntimeError; end
|
124
|
-
|
125
|
-
def discover(timeout=5)
|
126
|
-
waiting_thread = Thread.current
|
127
|
-
|
128
|
-
dns = DNSSD.browse "_git._tcp" do |reply|
|
129
|
-
DNSSD.resolve reply.name, reply.type, reply.domain do |resolve_reply|
|
130
|
-
service = GitService.new(reply.name,
|
131
|
-
resolve_reply.target,
|
132
|
-
resolve_reply.port,
|
133
|
-
resolve_reply.text_record['description'].to_s)
|
134
|
-
begin
|
135
|
-
yield service
|
136
|
-
rescue Done
|
137
|
-
waiting_thread.run
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
puts "Gathering for up to #{timeout} seconds..."
|
143
|
-
sleep timeout
|
144
|
-
dns.stop
|
145
|
-
end
|
146
|
-
|
147
|
-
def locate_repo(name)
|
148
|
-
found = nil
|
149
|
-
|
150
|
-
discover do |obj|
|
151
|
-
if obj.name == name
|
152
|
-
found = obj
|
153
|
-
raise Done
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
return found
|
158
|
-
end
|
159
|
-
|
160
|
-
def service_list
|
161
|
-
list = Set.new
|
162
|
-
discover { |obj| list << obj }
|
163
|
-
|
164
|
-
return list
|
165
|
-
end
|
166
|
-
|
167
|
-
def announce_repo(path, name, port)
|
168
|
-
return unless File.exists?("#{path}/.git")
|
169
|
-
|
170
|
-
tr = DNSSD::TextRecord.new
|
171
|
-
tr['description'] = File.read("#{path}/.git/description") rescue "a git project"
|
172
|
-
|
173
|
-
DNSSD.register(name, "_git._tcp", 'local', port, tr.encode) do |rr|
|
174
|
-
puts "Registered #{name} on port #{port}. Starting service."
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
end
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
|
183
|
-
|
data/lib/gitjour/version.rb
DELETED
data/script/destroy
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'rubigen'
|
6
|
-
rescue LoadError
|
7
|
-
require 'rubygems'
|
8
|
-
require 'rubigen'
|
9
|
-
end
|
10
|
-
require 'rubigen/scripts/destroy'
|
11
|
-
|
12
|
-
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
-
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
-
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'rubigen'
|
6
|
-
rescue LoadError
|
7
|
-
require 'rubygems'
|
8
|
-
require 'rubigen'
|
9
|
-
end
|
10
|
-
require 'rubigen/scripts/generate'
|
11
|
-
|
12
|
-
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
-
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
-
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/script/txt2html
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
begin
|
5
|
-
require 'newgem'
|
6
|
-
rescue LoadError
|
7
|
-
puts "\n\nGenerating the website requires the newgem RubyGem"
|
8
|
-
puts "Install: gem install newgem\n\n"
|
9
|
-
exit(1)
|
10
|
-
end
|
11
|
-
require 'redcloth'
|
12
|
-
require 'syntax/convertors/html'
|
13
|
-
require 'erb'
|
14
|
-
require File.dirname(__FILE__) + '/../lib/gitjour/version.rb'
|
15
|
-
|
16
|
-
version = Gitjour::VERSION::STRING
|
17
|
-
download = 'http://rubyforge.org/projects/gitjour'
|
18
|
-
|
19
|
-
class Fixnum
|
20
|
-
def ordinal
|
21
|
-
# teens
|
22
|
-
return 'th' if (10..19).include?(self % 100)
|
23
|
-
# others
|
24
|
-
case self % 10
|
25
|
-
when 1: return 'st'
|
26
|
-
when 2: return 'nd'
|
27
|
-
when 3: return 'rd'
|
28
|
-
else return 'th'
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
class Time
|
34
|
-
def pretty
|
35
|
-
return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def convert_syntax(syntax, source)
|
40
|
-
return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
|
41
|
-
end
|
42
|
-
|
43
|
-
if ARGV.length >= 1
|
44
|
-
src, template = ARGV
|
45
|
-
template ||= File.join(File.dirname(__FILE__), '/../website/template.rhtml')
|
46
|
-
|
47
|
-
else
|
48
|
-
puts("Usage: #{File.split($0).last} source.txt [template.rhtml] > output.html")
|
49
|
-
exit!
|
50
|
-
end
|
51
|
-
|
52
|
-
template = ERB.new(File.open(template).read)
|
53
|
-
|
54
|
-
title = nil
|
55
|
-
body = nil
|
56
|
-
File.open(src) do |fsrc|
|
57
|
-
title_text = fsrc.readline
|
58
|
-
body_text = fsrc.read
|
59
|
-
syntax_items = []
|
60
|
-
body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
|
61
|
-
ident = syntax_items.length
|
62
|
-
element, syntax, source = $1, $2, $3
|
63
|
-
syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
|
64
|
-
"syntax-temp-#{ident}"
|
65
|
-
}
|
66
|
-
title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
|
67
|
-
body = RedCloth.new(body_text).to_html
|
68
|
-
body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
|
69
|
-
end
|
70
|
-
stat = File.stat(src)
|
71
|
-
created = stat.ctime
|
72
|
-
modified = stat.mtime
|
73
|
-
|
74
|
-
$stdout << template.result(binding)
|