vclog 1.1 → 1.2

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/lib/vclog/command.rb DELETED
@@ -1,168 +0,0 @@
1
- module VCLog
2
-
3
- require 'vclog/vcs'
4
- require 'optparse'
5
-
6
- # = vclog Command
7
- #
8
- # == SYNOPSIS
9
- #
10
- # VCLog provides cross-vcs ChangeLogs. It works by
11
- # parsing the native changelog a VCS system produces
12
- # into a common model, which then can be used to
13
- # produce Changelogs in a variety of formats.
14
- #
15
- # VCLog currently support SVN and Git. CVS, Darcs and
16
- # Mercurial/Hg are in the works.
17
- #
18
- # == EXAMPLES
19
- #
20
- # To produce a GNU-like changelog:
21
- #
22
- # $ vclog
23
- #
24
- # For XML format:
25
- #
26
- # $ vclog --xml
27
- #
28
- # Or for a micorformat-ish HTML:
29
- #
30
- # $ vclog --html
31
- #
32
- # To use the library programmatically, please see the API documentation.
33
-
34
- def self.run
35
- begin
36
- vclog
37
- rescue => err
38
- if $DEBUG
39
- raise err
40
- else
41
- puts err.message
42
- exit -1
43
- end
44
- end
45
- end
46
-
47
- #
48
- def self.vclog
49
- format = :gnu
50
- typed = false
51
- rev = false
52
- vers = nil
53
- style = nil
54
- output = nil
55
-
56
- optparse = OptionParser.new do |opt|
57
- opt.separator("FORMAT (choose one):")
58
-
59
- opt.on('--gnu', "GNU standard format") do
60
- format = :gnu
61
- end
62
-
63
- opt.on('--xml [XSL]', "XML format") do |file|
64
- format = :xml
65
- style = file
66
- end
67
-
68
- opt.on('--yaml', "YAML format") do
69
- format = :yaml
70
- end
71
-
72
- opt.on('--json', "JSON format") do
73
- format = :json
74
- end
75
-
76
- opt.on('--html [CSS]', "HTML micro-like format") do |file|
77
- format = :html
78
- style = file
79
- end
80
-
81
- opt.on('--rel <VER>', "release format") do |version|
82
- format = :rel
83
- vers = version
84
- end
85
-
86
- opt.on('--rev <VER>', "release format w/ revison ids") do |version|
87
- format = :rev
88
- vers = version
89
- end
90
-
91
- opt.separator("OTHER OPTIONS:")
92
-
93
- opt.on('--typed', "catagorize by commit type") do
94
- typed = true
95
- end
96
-
97
- #opt.on('--style [FILE]', "provide a stylesheet (css or xsl)") do |val|
98
- # style = val
99
- #end
100
-
101
- opt.on('--output', '-o [FILE]', "send output to a file instead of stdout") do |out|
102
- output = out
103
- end
104
-
105
- opt.separator("STANDARD OPTIONS:")
106
-
107
- opt.on('--debug', "show debugging infromation") do
108
- $DEBUG = true
109
- end
110
-
111
- opt.on_tail('--help' , '-h', 'display this help information') do
112
- puts opt
113
- exit
114
- end
115
- end
116
-
117
- optparse.parse!(ARGV)
118
-
119
- vcs = VCLog::VCS.new
120
-
121
- changelog = vcs.changelog
122
-
123
- if typed
124
- changelog = changelog.typed
125
- end
126
-
127
- case format
128
- when :xml
129
- log = changelog.format_xml(style) # xsl stylesheet url
130
- when :html
131
- log = changelog.format_html(style) # css stylesheet url
132
- when :yaml
133
- log = changelog.format_yaml
134
- when :json
135
- log = changelog.format_json
136
- when :rel
137
- file = changelog_file(output)
138
- raise "no previous log to go by" unless file
139
- log = changelog.format_rel(file, vers, nil, false)
140
- when :rev
141
- file = changelog_file(output)
142
- raise "no previous log to go by" unless file
143
- log = changelog.format_rel(file, vers, nil, true)
144
- else #:gnu
145
- log = changelog.to_s
146
- end
147
-
148
- if output
149
- File.open(output, 'w') do |f|
150
- f << log
151
- end
152
- else
153
- puts log
154
- end
155
- end
156
-
157
- def self.changelog_file(file)
158
- if file && File.file?(file)
159
- file
160
- else
161
- Dir.glob('{history,changes,changelog}{,.*}', File::FNM_CASEFOLD).first
162
- end
163
- end
164
-
165
- end
166
-
167
- # VCLog Copyright (c) 2008 Thomas Sawyer
168
-