crank 1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/crank +136 -0
- metadata +51 -0
data/bin/crank
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
begin
|
3
|
+
require "rubygems"
|
4
|
+
require "rscm"
|
5
|
+
rescue LoadError => le
|
6
|
+
STDOUT.puts "RubyGEMS and the RSCM gem is required"
|
7
|
+
end
|
8
|
+
require 'erb'
|
9
|
+
require 'optparse'
|
10
|
+
require "yaml"
|
11
|
+
|
12
|
+
module RSCM
|
13
|
+
class Revisions
|
14
|
+
#add some sort options to RSCM
|
15
|
+
def sort_desc
|
16
|
+
@revisions.sort!{|r1,r2| r2.time<=>r1.time}
|
17
|
+
end
|
18
|
+
def sort_asc
|
19
|
+
@revisions.sort!{|r1,r2| r1.time<=>r2.time}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
OPTIONS = {}
|
25
|
+
OPTIONS[:revision] = 0
|
26
|
+
OPTIONS[:run] = true
|
27
|
+
|
28
|
+
opts = OptionParser.new do |opts|
|
29
|
+
opts.on("-s", "--scm=svn", "Which SCM to use (svn,cvs,starteam,perforce).") do |s|
|
30
|
+
OPTIONS[:scm] = s if s != nil
|
31
|
+
end
|
32
|
+
|
33
|
+
opts.on("-l","--url=somerepourl", "The repository URL. (svn://, http://, file:///)") do |l|
|
34
|
+
OPTIONS[:repo] = l if l != nil
|
35
|
+
end
|
36
|
+
|
37
|
+
opts.on("-x", "--path=/trunk/core","An internal path to the repository.") do |x|
|
38
|
+
OPTIONS[:path] = x if x != nil
|
39
|
+
end
|
40
|
+
|
41
|
+
opts.on("-u", "--username=developername","Username for the repository.") do |t|
|
42
|
+
OPTIONS[:username] = t if t != nil
|
43
|
+
end
|
44
|
+
|
45
|
+
opts.on("-p", "--password=asd82kd92", "Password for the repository.") do |p|
|
46
|
+
OPTIONS[:password] = p if p != nil
|
47
|
+
end
|
48
|
+
|
49
|
+
opts.on("-r", "--revision=400", "A revision to start from.") do |w|
|
50
|
+
if w == "HEAD" || w == "PREV" || w == "BASE"
|
51
|
+
OPTIONS[:revision] = w
|
52
|
+
else
|
53
|
+
OPTIONS[:revision] = Number(w) if w != nil
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
opts.on("-d", "--diff", "Show a diff for each file.") do |d|
|
58
|
+
OPTIONS[:diff] = true if d != nil
|
59
|
+
end
|
60
|
+
|
61
|
+
opts.on("-t","--template=mytemplate.*","An ERB template file to parse.") do |t|
|
62
|
+
OPTIONS[:template_file] = t if t != nil
|
63
|
+
end
|
64
|
+
|
65
|
+
opts.on("-o", "--out=myfile.*", "Output file (html,xhtml,htm,rss,feed,xml,atom).") do |f|
|
66
|
+
type = f.split('.').last
|
67
|
+
OPTIONS[:type] = type
|
68
|
+
OPTIONS[:output_file] = f if f != nil
|
69
|
+
end
|
70
|
+
|
71
|
+
#help, toggle server starting
|
72
|
+
opts.on_tail("-h", "--help", "Show this usage statement.") do |h|
|
73
|
+
puts opts
|
74
|
+
OPTIONS[:run] = false
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
begin
|
79
|
+
opts.parse!(ARGV)
|
80
|
+
rescue Exception => e
|
81
|
+
puts e, "", opts
|
82
|
+
exit
|
83
|
+
end
|
84
|
+
|
85
|
+
begin
|
86
|
+
if OPTIONS[:run]
|
87
|
+
|
88
|
+
#check required args
|
89
|
+
if !OPTIONS[:repo] || !OPTIONS[:scm] || !OPTIONS[:template_file] || !OPTIONS[:output_file]
|
90
|
+
STDOUT.puts "You must supply --url,--scm,--template and --out. Run 'crank -h' for help"
|
91
|
+
exit(0)
|
92
|
+
end
|
93
|
+
|
94
|
+
case OPTIONS[:scm].downcase
|
95
|
+
when "svn":
|
96
|
+
repo = RSCM::Subversion.new(OPTIONS[:repo])
|
97
|
+
when "cvs"
|
98
|
+
repo = RSCM::CVS.new(OPTIONS[:repo])
|
99
|
+
when "starteam"
|
100
|
+
repo = RSCM::StarTeam.new(OPTIONS[:repo])
|
101
|
+
when "perforce"
|
102
|
+
repo = RSCM::Perforce.new(OPTIONS[:repo])
|
103
|
+
end
|
104
|
+
|
105
|
+
if !OPTIONS[:username].nil? then repo.username = OPTIONS[:username] end
|
106
|
+
if !OPTIONS[:password].nil? then repo.password = OPTIONS[:password] end
|
107
|
+
if !OPTIONS[:path].nil? then repo.path = OPTIONS[:path] end
|
108
|
+
|
109
|
+
revisions = repo.revisions(Time.now, {:from_identifier => OPTIONS[:revision]})
|
110
|
+
revisions.sort_desc #sort descending
|
111
|
+
options = OPTIONS
|
112
|
+
|
113
|
+
#get template content
|
114
|
+
template_content = ''
|
115
|
+
File.open(OPTIONS[:template_file], "r") do |f|
|
116
|
+
while line = f.gets
|
117
|
+
template_content << line
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
#ERB the template
|
122
|
+
#available vars in the ERB template::
|
123
|
+
# options
|
124
|
+
# repo
|
125
|
+
# revisions
|
126
|
+
e = ERB.new(template_content, 0, "%<>")
|
127
|
+
result = e.result(self.send("binding"))
|
128
|
+
|
129
|
+
#write output
|
130
|
+
File.open(OPTIONS[:output_file],"w") do |f|
|
131
|
+
f.puts result
|
132
|
+
end
|
133
|
+
end
|
134
|
+
rescue Exception => e
|
135
|
+
STDOUT.puts e.message
|
136
|
+
end
|
metadata
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.0
|
3
|
+
specification_version: 1
|
4
|
+
name: crank
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: "1.2"
|
7
|
+
date: 2007-07-22 00:00:00 -04:00
|
8
|
+
summary: "RSS, HTML and Email output from SVN repository logs with Ruby"
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: aaron@rubyamf.org
|
12
|
+
homepage: http://www.rubysvn2rss.com
|
13
|
+
rubyforge_project:
|
14
|
+
description:
|
15
|
+
autorequire:
|
16
|
+
default_executable: crank
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: false
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
-
|
22
|
+
- ">"
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 0.0.0
|
25
|
+
version:
|
26
|
+
platform: ruby
|
27
|
+
signing_key:
|
28
|
+
cert_chain:
|
29
|
+
post_install_message:
|
30
|
+
authors:
|
31
|
+
- Aaron Smith
|
32
|
+
files:
|
33
|
+
- bin/crank
|
34
|
+
test_files: []
|
35
|
+
rdoc_options: []
|
36
|
+
extra_rdoc_files: []
|
37
|
+
executables:
|
38
|
+
- crank
|
39
|
+
extensions: []
|
40
|
+
requirements: []
|
41
|
+
dependencies:
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rscm
|
44
|
+
version_requirement:
|
45
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
46
|
+
requirements:
|
47
|
+
-
|
48
|
+
- ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: "0.5"
|
51
|
+
version:
|