renogen 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 441ccac5869c9d78abc7c3d163a851c4341d29b2
4
- data.tar.gz: 78e083dde9bba0f04c01c9ce4fe37ac6a3c862b6
3
+ metadata.gz: 9c597a603a1ff6629766e2fca60f6970a75bb1e3
4
+ data.tar.gz: 70ff70d1bcd0fe5fba73dcb6a7a04b3a70652630
5
5
  SHA512:
6
- metadata.gz: c5851785f48aed5505e8b1506c9f5752b6c49c24dca5488110f9a28fdc0d02b33b90c399c3db571beb65d77d908892fdb30f6e8f335bd8b701ec9744f3eb7979
7
- data.tar.gz: 96f6024f0e7decc226d44ce9b55d9f746aa3e2a272a0033b82d219558f1396e65207daae4330f40001b23484bc72a0182cdc48b77b237d92595798e8e9a03d25
6
+ metadata.gz: 22e630d7505723cf02a2c6c66853c74ae1f98633e0d102cde31061b7dcc8ab1d6bdca9cb22c438f6cb746a8b1ecc5cf295b4fabfa9dff1c49b43e0b7421014ea
7
+ data.tar.gz: c94d1ae2b66072bbfcdf8d4960fa3f29caf58a0aaabb76a32d4f164e6eae73bff06a0f6040f64aaaab99b685cc82a92909d11f8a40841e1ec642768f60539c72
data/README.md CHANGED
@@ -79,6 +79,43 @@ TODO
79
79
  * How to set configuration with `.renogen` file
80
80
  * How to change formatted single line
81
81
 
82
+ ### Custom formatter
83
+
84
+ You can use your own formatter quite easily.
85
+
86
+ For example, put this in `lib/my_project/renogen_formatter.rb`:
87
+ ```ruby
88
+ require 'renogen/formatters'
89
+
90
+ class MyProject::RenogenFormatter < Renogen::Formatters::Base
91
+ register :xml
92
+
93
+ def write_header(header)
94
+ "<release><header>#{header}</header>"
95
+ end
96
+
97
+ def write_group(group)
98
+ "<group><title>#{group}</title>"
99
+ end
100
+
101
+ def write_group_end
102
+ "</group>"
103
+ end
104
+
105
+ def write_change(change)
106
+ "<change>#{change}</change>"
107
+ end
108
+
109
+ def write_footer(*)
110
+ "</release>"
111
+ end
112
+ end
113
+ ```
114
+
115
+ You have to include that file when running renogen:
116
+
117
+ `$ renogen -I. -Rlib/my_project/renogen_formatter 1.2.3`
118
+
82
119
  ### Why does renogen not use renogen?
83
120
  The amount of activity and contributes for this project is small and so it is more practical to use a text file.
84
121
 
@@ -5,20 +5,14 @@ module Renogen
5
5
  # Object to represent a Changelog/release notes
6
6
  class Model
7
7
  attr_reader :items
8
- attr_accessor :version
8
+ attr_accessor :version, :date
9
9
 
10
10
  def initialize(options={})
11
11
  @version = options[:version]
12
+ @date = options[:date] || Date.today
12
13
  @items = []
13
14
  end
14
15
 
15
- # The title for the change log output
16
- #
17
- # @return [String]
18
- def header
19
- "#{version} (#{Date.today})"
20
- end
21
-
22
16
  # @return [Hash<group_name: change>]
23
17
  def groups
24
18
  items.inject({}) do |hash, change|
@@ -10,7 +10,7 @@ module Renogen
10
10
  #
11
11
  # @param changelog [ChangeLog::Model]
12
12
  def write!(changelog)
13
- puts formatter.write_header(changelog.header)
13
+ puts formatter.write_header(formatter.header(changelog))
14
14
  output_groups(changelog.groups)
15
15
  puts formatter.write_footer(changelog)
16
16
  end
@@ -20,6 +20,7 @@ module Renogen
20
20
  source = options['source'] || config_instance.input_source
21
21
  options['changelog_path'] ||= config_instance.changelog_path
22
22
  options['old_version'] ||= config_instance.changelog_path
23
+ options['release_date'] ||= Date.today
23
24
 
24
25
  begin
25
26
  generator = Renogen::Generator.new(version, source, format, options)
@@ -44,6 +44,18 @@ module Renogen
44
44
  args['legacy_version'] = n
45
45
  end
46
46
 
47
+ opts.on("-rDATE", "--release-date=DATE", "Release date") do |n|
48
+ args['release_date'] = n
49
+ end
50
+
51
+ opts.on("-IPATH", "--include=PATH", "Add a path to the load path") do |n|
52
+ $LOAD_PATH << n
53
+ end
54
+
55
+ opts.on("-RFILE", "--require=FILE", "Require a file from the load path") do |n|
56
+ require n
57
+ end
58
+
47
59
  opts.on_tail("-h", "--help", "Show this message") do
48
60
  puts opts
49
61
  exit
@@ -13,18 +13,31 @@ module Renogen
13
13
  Renogen::Formatters.add(identifier.to_sym, self)
14
14
  end
15
15
 
16
+ # Generate a header for a given changelog
17
+ #
18
+ # @param changelog [Renogen::ChangeLog::Model]
19
+ #
20
+ # return [String]
21
+ def header(changelog)
22
+ "#{changelog.version} (#{changelog.date})"
23
+ end
24
+
16
25
  # Outputs a line or block of text appearing at the top of the change log.
17
26
  #
27
+ # @abstract
28
+ #
18
29
  # @param header [String]
19
- # @return [NotImplementedError]
30
+ # @raise NotImplementedError
20
31
  def write_header(header)
21
32
  raise NotImplementedError
22
33
  end
23
34
 
24
35
  # Outputs a line or block as a header for a group.
25
36
  #
37
+ # @abstract
38
+ #
26
39
  # @param group [String]
27
- # @return [NotImplementedError]
40
+ # @raise NotImplementedError
28
41
  def write_group(group)
29
42
  raise NotImplementedError
30
43
  end
@@ -37,8 +50,10 @@ module Renogen
37
50
 
38
51
  # Outputs a line or block as the body for a change.
39
52
  #
53
+ # @abstract
54
+ #
40
55
  # @param change [String]
41
- # @return [NotImplementedError]
56
+ # @raise NotImplementedError
42
57
  def write_change(change)
43
58
  raise NotImplementedError
44
59
  end
@@ -14,6 +14,7 @@ module Renogen
14
14
  def generate!
15
15
  changelog = extraction_stratagy.extract
16
16
  changelog.version = version
17
+ changelog.date = options['release_date']
17
18
 
18
19
  writer.write!(changelog)
19
20
  end
@@ -1,3 +1,3 @@
1
1
  module Renogen
2
- VERSION='1.1.1'.freeze # :nodoc:
2
+ VERSION='1.2.0'.freeze # :nodoc:
3
3
  end
@@ -14,13 +14,6 @@ describe Renogen::ChangeLog::Model do
14
14
  end
15
15
  end
16
16
 
17
- describe '#header' do
18
- it 'returns version and date' do
19
- subject.version = '123'
20
- expect(subject.header).to eql "123 (#{Date.today})"
21
- end
22
- end
23
-
24
17
  describe '#add_change' do
25
18
  it 'adds change to changes store' do
26
19
  subject.add_change(change_item)
@@ -33,4 +26,25 @@ describe Renogen::ChangeLog::Model do
33
26
  end
34
27
  end
35
28
 
29
+ describe '#date' do
30
+ it 'defaults to Date.today' do
31
+ expect(subject.date).to eql Date.today
32
+ end
33
+
34
+ it 'can be set using an option' do
35
+ date = Date.parse('2015-12-25')
36
+ model_instance = described_class.new(date: date)
37
+
38
+ expect(model_instance.date).to eql date
39
+ end
40
+
41
+ it 'has a setter' do
42
+ date = Date.parse('1981-03-20')
43
+
44
+ subject.date = date
45
+
46
+ expect(subject.date).to eql date
47
+ end
48
+ end
49
+
36
50
  end
@@ -1,6 +1,16 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Renogen::Formatters::Base do
4
+ describe '#header' do
5
+ subject { described_class.new.header(changelog) }
6
+
7
+ let(:version) { '1.2.34' }
8
+ let(:date) { Date.today }
9
+ let(:changelog) { double(Renogen::ChangeLog::Model, version: version, date: date) }
10
+
11
+ it { is_expected.to eql "#{version} (#{date})" }
12
+ end
13
+
4
14
  describe '#write_header' do
5
15
  it 'raises an NotImplementedError' do
6
16
  expect{subject.write_header('header')}.to raise_error NotImplementedError
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: renogen
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Elliott
@@ -98,9 +98,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  version: '0'
99
99
  requirements: []
100
100
  rubyforge_project:
101
- rubygems_version: 2.6.2
101
+ rubygems_version: 2.6.3
102
102
  signing_key:
103
103
  specification_version: 4
104
104
  summary: Release Notes/changelog Generator
105
105
  test_files: []
106
- has_rdoc: