vclog 1.9.1 → 1.9.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,6 +8,7 @@ module VCLog
8
8
  #
9
9
  class Heuristics
10
10
 
11
+ #
11
12
  # Load heuristics from a designated file.
12
13
  #
13
14
  # @param [String] file
@@ -18,7 +19,19 @@ module VCLog
18
19
  new{ instance_eval(File.read(file), file) }
19
20
  end
20
21
 
21
- # Setup new heurtistics set.
22
+ #
23
+ # Load heuristics given a script.
24
+ #
25
+ # @param [String] script
26
+ # Configuration script.
27
+ #
28
+ def self.eval(script, file='(eval)', line=0)
29
+ new{ instance_eval(text, file, line) }
30
+ end
31
+
32
+ #
33
+ # Initialize new heurtistics set.
34
+ #
22
35
  def initialize(&block)
23
36
  @rules = []
24
37
 
@@ -34,6 +47,7 @@ module VCLog
34
47
  end
35
48
  end
36
49
 
50
+ #
37
51
  # Apply heuristics to a commit.
38
52
  #
39
53
  # @param [Change] commit
@@ -57,13 +71,17 @@ module VCLog
57
71
  commit.color = color
58
72
  end
59
73
 
74
+ #
60
75
  # Define a new rule.
76
+ #
61
77
  def on(pattern=nil, &block)
62
78
  @rules << Rule.new(pattern, &block)
63
79
  end
64
80
 
81
+ #
65
82
  # Convenience method for setting-up commit types, which can
66
83
  # be easily assigned, setting both label and level in one go.
84
+ #
67
85
  def type(type, level, label)
68
86
  @types[type.to_sym] = Type.new(type, level, label)
69
87
  end
@@ -71,6 +89,7 @@ module VCLog
71
89
  # @deprecated
72
90
  alias_method :set, :type
73
91
 
92
+ #
74
93
  # Access to defined types.
75
94
  #
76
95
  # @example
@@ -78,6 +97,7 @@ module VCLog
78
97
  #
79
98
  attr :types
80
99
 
100
+ #
81
101
  # Set color list. The center element cooresponds to `level=0`.
82
102
  # Elements before the center are incrementally higher levels
83
103
  # and those after are lower.
@@ -89,7 +109,17 @@ module VCLog
89
109
  @colors = list
90
110
  end
91
111
 
112
+ #
113
+ # Set default level.
114
+ #
115
+ def level(integer=nil)
116
+ @level = integer.to_i is integer
117
+ @level
118
+ end
119
+
120
+ #
92
121
  # Default settings.
122
+ #
93
123
  def default
94
124
  type :major, 3, "Major Enhancements"
95
125
  type :minor, 2, "Minor Enhancements"
@@ -122,7 +152,9 @@ module VCLog
122
152
  end
123
153
  end
124
154
 
155
+ #
125
156
  # Work on next-gen default heuristics.
157
+ #
126
158
  def default2
127
159
  type :major, 3, "Major Enhancements"
128
160
  type :minor, 2, "Minor Enhancements"
@@ -59,6 +59,11 @@ module VCLog
59
59
  end
60
60
  end
61
61
 
62
+ #
63
+ def news
64
+ tags.first.message
65
+ end
66
+
62
67
  end
63
68
 
64
69
  end
@@ -1,7 +1,6 @@
1
- require 'confection'
2
-
3
1
  require 'vclog/core_ext'
4
2
  require 'vclog/adapters'
3
+ require 'vclog/config'
5
4
  require 'vclog/heuristics'
6
5
  require 'vclog/history_file'
7
6
  require 'vclog/changelog'
@@ -11,13 +10,14 @@ require 'vclog/report'
11
10
 
12
11
  module VCLog
13
12
 
13
+ # Encapsulate representaiton of the repository.
14
14
  #
15
15
  class Repo
16
16
 
17
17
  #
18
18
  # File glob used to find project root directory.
19
19
  #
20
- ROOT_GLOB = '{.git/,.hg/,_darcs/,.svn/}'
20
+ ROOT_GLOB = '{.ruby,.map/,.git/,.hg/,_darcs/,.svn/}'
21
21
 
22
22
  #
23
23
  # Project's root directory.
@@ -33,10 +33,12 @@ module VCLog
33
33
  # Setup new Repo instance.
34
34
  #
35
35
  def initialize(root, options={})
36
- @root = root || lookup_root
36
+ options[:root] = root if root
37
+
38
+ @config = Config.new(options)
37
39
  @options = options
38
40
 
39
- vcs_type = read_vcs_type
41
+ vcs_type = @config.vcs_type
40
42
 
41
43
  raise ArgumentError, "Not a recognized version control system." unless vcs_type
42
44
 
@@ -51,53 +53,31 @@ module VCLog
51
53
  end
52
54
 
53
55
  #
54
- # Check force option.
56
+ # Configuration.
55
57
  #
56
- def force?
57
- options[:force]
58
+ def config
59
+ @config
58
60
  end
59
61
 
60
62
  #
63
+ # Project root directory.
61
64
  #
62
- #
63
- def read_vcs_type
64
- dir = nil
65
- Dir.chdir(root) do
66
- dir = Dir.glob("{.git,.hg,.svn,_darcs}").first
67
- end
68
- dir[1..-1] if dir
65
+ def root
66
+ config.root
69
67
  end
70
68
 
71
69
  #
72
- # Find project root. This searches up from the current working
73
- # directory for a Confection configuration file or source control
74
- # manager directory.
75
- #
76
- # .co
77
- # .git/
78
- # .hg/
79
- # .svn/
80
- # _darcs/
81
- #
82
- # If all else fails the current directory is returned.
70
+ # Load heuristics script.
83
71
  #
84
- def lookup_root
85
- root = nil
86
- Dir.ascend(Dir.pwd) do |path|
87
- check = Dir[ROOT_GLOB].first
88
- if check
89
- root = path
90
- break
91
- end
92
- end
93
- root || Dir.pwd
72
+ def heuristics
73
+ config.heuristics
94
74
  end
95
75
 
96
76
  #
97
- # Load heuristics script.
77
+ # Check force option.
98
78
  #
99
- def heuristics
100
- @heuristics ||= Heuristics.new(&Confection[:vclog])
79
+ def force?
80
+ config.force?
101
81
  end
102
82
 
103
83
  #
@@ -169,7 +149,7 @@ module VCLog
169
149
 
170
150
  #ver = repo.bump(version)
171
151
 
172
- name = options[:version] || 'HEAD'
152
+ name = config.version || 'HEAD'
173
153
  user = adapter.user
174
154
  date = ::Time.now + (3600 * 24) # one day ahead
175
155
 
@@ -1,6 +1,6 @@
1
1
  require 'ostruct'
2
- #require 'ansi'
3
2
  require 'erb'
3
+ #require 'ansi'
4
4
 
5
5
  module VCLog
6
6
 
@@ -32,12 +32,11 @@ module VCLog
32
32
  #
33
33
  def initialize(repo, options)
34
34
  @repo = repo
35
- @options = case options
36
- when Hash
37
- OpenStruct.new(options)
38
- else
39
- options
40
- end
35
+
36
+ options[:type] ||= 'changelog'
37
+ options[:format] ||= 'ansi'
38
+
39
+ @options = OpenStruct.new(options)
41
40
 
42
41
  @options.level ||= 0
43
42
  end
@@ -57,6 +56,20 @@ module VCLog
57
56
  repo.releases(changelog.changes)
58
57
  end
59
58
 
59
+ #
60
+ # Report type.
61
+ #
62
+ def type
63
+ options.type
64
+ end
65
+
66
+ #
67
+ # Report format.
68
+ #
69
+ def format
70
+ options.format
71
+ end
72
+
60
73
  #
61
74
  # User as given by the command line or from the repo.
62
75
  #
@@ -99,7 +112,7 @@ module VCLog
99
112
  #
100
113
  def title
101
114
  return options.title if options.title
102
- case options.type
115
+ case type
103
116
  when :history
104
117
  "RELEASE HISTORY"
105
118
  else
@@ -114,23 +127,23 @@ module VCLog
114
127
  # Print report.
115
128
  #
116
129
  def print
117
- options.type ||= 'changelog'
118
- options.format ||= 'ansi'
130
+ require_formatter(format)
119
131
 
120
- require_formatter(options.format)
132
+ tmpl_glob = File.join(DIR, 'templates', "#{type}.#{format}.{erb,rb}")
133
+ tmpl_file = Dir[tmpl_glob].first
121
134
 
122
- tmp_file = Dir[File.join(DIR, 'templates', "#{options.type}.#{options.format}.{erb,rb}")].first
135
+ raise "could not find template -- #{tmp_glob}" unless tmpl_file
123
136
 
124
- tmp = File.read(tmp_file)
137
+ tmpl = File.read(tmpl_file)
125
138
 
126
- case File.extname(tmp_file)
139
+ case File.extname(tmpl_file)
127
140
  when '.rb'
128
- eval(tmp, binding, tmp_file)
141
+ eval(tmpl, binding, tmpl_file)
129
142
  when '.erb'
130
- erb = ERB.new(tmp, nil, '<>')
143
+ erb = ERB.new(tmpl, nil, '<>')
131
144
  erb.result(binding)
132
145
  else
133
- raise "unrecognized template - #{tmp_file}"
146
+ raise "unrecognized template type -- #{tmpl_file}"
134
147
  end
135
148
  end
136
149
 
@@ -3,6 +3,7 @@ vclog(1) vclog.1.ronn
3
3
  vclog-changelog(1) vclog-changelog.1.ronn
4
4
  vclog-history(1) vclog-history.1.ronn
5
5
  vclog-version(1) vclog-version.1.ronn
6
+ vclog-news(1) vclog-news.1.ronn
6
7
  vclog-bump(1) vclog-bump.1.ronn
7
8
  vclog-autotag(1) vclog-autotag.1.ronn
8
9
 
@@ -64,7 +64,7 @@
64
64
  <a href="#DESCRIPTION">DESCRIPTION</a>
65
65
  <a href="#OPTIONS">OPTIONS</a>
66
66
  <a href="#SEE-ALSO">SEE ALSO</a>
67
- </div>
67
+ </div>
68
68
 
69
69
  <ol class='man-decor man-head man head'>
70
70
  <li class='tl'>vclog-autotag(1)</li>
@@ -103,7 +103,7 @@ convention of <code>HISTORY.*</code>.</p></li>
103
103
 
104
104
  <h2 id="SEE-ALSO">SEE ALSO</h2>
105
105
 
106
- <p><a href="vclog.1.html" class="man-ref">vclog<span class="s">(1)</span></a></p>
106
+ <p><a class="man-ref" href="vclog.1.html">vclog<span class="s">(1)</span></a></p>
107
107
 
108
108
 
109
109
  <ol class='man-decor man-foot man foot'>
@@ -64,7 +64,7 @@
64
64
  <a href="#DESCRIPTION">DESCRIPTION</a>
65
65
  <a href="#OPTIONS">OPTIONS</a>
66
66
  <a href="#SEE-ALSO">SEE ALSO</a>
67
- </div>
67
+ </div>
68
68
 
69
69
  <ol class='man-decor man-head man head'>
70
70
  <li class='tl'>vclog-bump(1)</li>
@@ -97,7 +97,7 @@ Assume this version number is current.</li>
97
97
 
98
98
  <h2 id="SEE-ALSO">SEE ALSO</h2>
99
99
 
100
- <p><a href="vclog.1.html" class="man-ref">vclog<span class="s">(1)</span></a></p>
100
+ <p><a class="man-ref" href="vclog.1.html">vclog<span class="s">(1)</span></a></p>
101
101
 
102
102
 
103
103
  <ol class='man-decor man-foot man foot'>
@@ -0,0 +1,25 @@
1
+ .\" generated with Ronn/v0.7.3
2
+ .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
+ .
4
+ .TH "VCLOG\-NEWS" "1" "March 2012" "RubyWorks" "VCLog"
5
+ .
6
+ .SH "NAME"
7
+ \fBvclog\-news\fR \- output latest release notice
8
+ .
9
+ .SH "SYNOPSIS"
10
+ \fBvclog news\fR
11
+ .
12
+ .SH "DESCRIPTION"
13
+ Display the most recent entry in a project\'s history file\. This command does NOT show the latest tag message, rather it is useful for making a new tag\. For instnace:
14
+ .
15
+ .P
16
+ \fBvclog news | git tag \-a \-F \- v1\.0\.0\fR
17
+ .
18
+ .P
19
+ This command will create a new git tag using the most recent message in the history file\.
20
+ .
21
+ .SH "OPTIONS"
22
+ No options yet\.
23
+ .
24
+ .SH "SEE ALSO"
25
+ vclog(1)
@@ -0,0 +1,112 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv='content-type' value='text/html;charset=utf8'>
5
+ <meta name='generator' value='Ronn/v0.7.3 (http://github.com/rtomayko/ronn/tree/0.7.3)'>
6
+ <title>vclog-news(1) - output latest release notice</title>
7
+ <style type='text/css' media='all'>
8
+ /* style: man */
9
+ body#manpage {margin:0}
10
+ .mp {max-width:100ex;padding:0 9ex 1ex 4ex}
11
+ .mp p,.mp pre,.mp ul,.mp ol,.mp dl {margin:0 0 20px 0}
12
+ .mp h2 {margin:10px 0 0 0}
13
+ .mp > p,.mp > pre,.mp > ul,.mp > ol,.mp > dl {margin-left:8ex}
14
+ .mp h3 {margin:0 0 0 4ex}
15
+ .mp dt {margin:0;clear:left}
16
+ .mp dt.flush {float:left;width:8ex}
17
+ .mp dd {margin:0 0 0 9ex}
18
+ .mp h1,.mp h2,.mp h3,.mp h4 {clear:left}
19
+ .mp pre {margin-bottom:20px}
20
+ .mp pre+h2,.mp pre+h3 {margin-top:22px}
21
+ .mp h2+pre,.mp h3+pre {margin-top:5px}
22
+ .mp img {display:block;margin:auto}
23
+ .mp h1.man-title {display:none}
24
+ .mp,.mp code,.mp pre,.mp tt,.mp kbd,.mp samp,.mp h3,.mp h4 {font-family:monospace;font-size:14px;line-height:1.42857142857143}
25
+ .mp h2 {font-size:16px;line-height:1.25}
26
+ .mp h1 {font-size:20px;line-height:2}
27
+ .mp {text-align:justify;background:#fff}
28
+ .mp,.mp code,.mp pre,.mp pre code,.mp tt,.mp kbd,.mp samp {color:#131211}
29
+ .mp h1,.mp h2,.mp h3,.mp h4 {color:#030201}
30
+ .mp u {text-decoration:underline}
31
+ .mp code,.mp strong,.mp b {font-weight:bold;color:#131211}
32
+ .mp em,.mp var {font-style:italic;color:#232221;text-decoration:none}
33
+ .mp a,.mp a:link,.mp a:hover,.mp a code,.mp a pre,.mp a tt,.mp a kbd,.mp a samp {color:#0000ff}
34
+ .mp b.man-ref {font-weight:normal;color:#434241}
35
+ .mp pre {padding:0 4ex}
36
+ .mp pre code {font-weight:normal;color:#434241}
37
+ .mp h2+pre,h3+pre {padding-left:0}
38
+ ol.man-decor,ol.man-decor li {margin:3px 0 10px 0;padding:0;float:left;width:33%;list-style-type:none;text-transform:uppercase;color:#999;letter-spacing:1px}
39
+ ol.man-decor {width:100%}
40
+ ol.man-decor li.tl {text-align:left}
41
+ ol.man-decor li.tc {text-align:center;letter-spacing:4px}
42
+ ol.man-decor li.tr {text-align:right;float:right}
43
+ </style>
44
+ <style type='text/css' media='all'>
45
+ /* style: toc */
46
+ .man-navigation {display:block !important;position:fixed;top:0;left:113ex;height:100%;width:100%;padding:48px 0 0 0;border-left:1px solid #dbdbdb;background:#eee}
47
+ .man-navigation a,.man-navigation a:hover,.man-navigation a:link,.man-navigation a:visited {display:block;margin:0;padding:5px 2px 5px 30px;color:#999;text-decoration:none}
48
+ .man-navigation a:hover {color:#111;text-decoration:underline}
49
+ </style>
50
+ </head>
51
+ <!--
52
+ The following styles are deprecated and will be removed at some point:
53
+ div#man, div#man ol.man, div#man ol.head, div#man ol.man.
54
+
55
+ The .man-page, .man-decor, .man-head, .man-foot, .man-title, and
56
+ .man-navigation should be used instead.
57
+ -->
58
+ <body id='manpage'>
59
+ <div class='mp' id='man'>
60
+
61
+ <div class='man-navigation' style='display:none'>
62
+ <a href="#NAME">NAME</a>
63
+ <a href="#SYNOPSIS">SYNOPSIS</a>
64
+ <a href="#DESCRIPTION">DESCRIPTION</a>
65
+ <a href="#OPTIONS">OPTIONS</a>
66
+ <a href="#SEE-ALSO">SEE ALSO</a>
67
+ </div>
68
+
69
+ <ol class='man-decor man-head man head'>
70
+ <li class='tl'>vclog-news(1)</li>
71
+ <li class='tc'>VCLog</li>
72
+ <li class='tr'>vclog-news(1)</li>
73
+ </ol>
74
+
75
+ <h2 id="NAME">NAME</h2>
76
+ <p class="man-name">
77
+ <code>vclog-news</code> - <span class="man-whatis">output latest release notice</span>
78
+ </p>
79
+
80
+ <h2 id="SYNOPSIS">SYNOPSIS</h2>
81
+
82
+ <p><code>vclog news</code></p>
83
+
84
+ <h2 id="DESCRIPTION">DESCRIPTION</h2>
85
+
86
+ <p>Display the most recent entry in a project's history file. This command
87
+ does NOT show the latest tag message, rather it is useful for making
88
+ a new tag. For instnace:</p>
89
+
90
+ <p> <code>vclog news | git tag -a -F - v1.0.0</code></p>
91
+
92
+ <p>This command will create a new git tag using the most recent message in
93
+ the history file.</p>
94
+
95
+ <h2 id="OPTIONS">OPTIONS</h2>
96
+
97
+ <p>No options yet.</p>
98
+
99
+ <h2 id="SEE-ALSO">SEE ALSO</h2>
100
+
101
+ <p><a class="man-ref" href="vclog.1.html">vclog<span class="s">(1)</span></a></p>
102
+
103
+
104
+ <ol class='man-decor man-foot man foot'>
105
+ <li class='tl'>RubyWorks</li>
106
+ <li class='tc'>March 2012</li>
107
+ <li class='tr'>vclog-news(1)</li>
108
+ </ol>
109
+
110
+ </div>
111
+ </body>
112
+ </html>