renogen 0.0.1 → 0.1.0.pre

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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +62 -3
  3. data/bin/renogen +2 -58
  4. data/lib/renogen.rb +9 -0
  5. data/lib/renogen/change_log.rb +9 -0
  6. data/lib/renogen/change_log/group.rb +21 -0
  7. data/lib/renogen/change_log/item.rb +60 -0
  8. data/lib/renogen/change_log/model.rb +41 -0
  9. data/lib/renogen/change_log/writer.rb +39 -0
  10. data/lib/renogen/cli.rb +60 -0
  11. data/lib/renogen/cli/param_parser.rb +73 -0
  12. data/lib/renogen/config.rb +35 -0
  13. data/lib/renogen/exceptions.rb +8 -0
  14. data/lib/renogen/exceptions/base.rb +7 -0
  15. data/lib/renogen/exceptions/extraction_stratagy_not_found.rb +20 -0
  16. data/lib/renogen/exceptions/formatter_not_found.rb +20 -0
  17. data/lib/renogen/extraction_stratagies.rb +42 -0
  18. data/lib/renogen/extraction_stratagies/base.rb +29 -0
  19. data/lib/renogen/extraction_stratagies/yaml_file.rb +10 -0
  20. data/lib/renogen/extraction_stratagies/yaml_file/parser.rb +39 -0
  21. data/lib/renogen/extraction_stratagies/yaml_file/provider.rb +24 -0
  22. data/lib/renogen/extraction_stratagies/yaml_file/reader.rb +48 -0
  23. data/lib/renogen/formatters.rb +43 -0
  24. data/lib/renogen/formatters/base.rb +54 -0
  25. data/lib/renogen/formatters/html.rb +47 -0
  26. data/lib/renogen/formatters/markdown.rb +33 -0
  27. data/lib/renogen/formatters/plain_text.rb +33 -0
  28. data/lib/renogen/generator.rb +34 -0
  29. data/lib/renogen/version.rb +3 -0
  30. data/spec/lib/renogen/change_log/group_spec.rb +13 -0
  31. data/spec/lib/renogen/change_log/item_spec.rb +51 -0
  32. data/spec/lib/renogen/change_log/model_spec.rb +36 -0
  33. data/spec/lib/renogen/change_log/writer_spec.rb +8 -0
  34. data/spec/lib/renogen/config_spec.rb +19 -0
  35. data/spec/lib/renogen/exceptions/extraction_stratagy_not_found_spec.rb +13 -0
  36. data/spec/lib/renogen/exceptions/formatter_not_found_spec.rb +13 -0
  37. data/spec/lib/renogen/extraction_stratagies/base_spec.rb +10 -0
  38. data/spec/lib/renogen/extraction_stratagies/yaml_file/parser_spec.rb +24 -0
  39. data/spec/lib/renogen/extraction_stratagies/yaml_file/provider_spec.rb +12 -0
  40. data/spec/lib/renogen/extraction_stratagies/yaml_file/reader_spec.rb +20 -0
  41. data/spec/lib/renogen/formatters/base_spec.rb +21 -0
  42. data/spec/lib/renogen/formatters/html_spec.rb +38 -0
  43. data/spec/lib/renogen/formatters/markdown_spec.rb +29 -0
  44. data/spec/lib/renogen/formatters/plain_text_spec.rb +29 -0
  45. data/spec/lib/renogen_spec.rb +11 -0
  46. data/spec/spec_helper.rb +76 -0
  47. metadata +67 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b6ef84185ab75ecceb4964734171fed296586caa
4
- data.tar.gz: 5447620ffba6edc1c577890701139dda06a8ff28
3
+ metadata.gz: 0601d545b81d975fb00732f998a904c07abf2604
4
+ data.tar.gz: d635d1c62edc949f38db2b03a42a48098d48fc8d
5
5
  SHA512:
6
- metadata.gz: da0ae862b3579bdc075a6eb8e1ffc6f7096bd9590e796fda0f43ec2af3b43f6d96b0cc05438177d974cae115083f40ba42565e1c92fa42c341c69c7aa688fde8
7
- data.tar.gz: 804100ae3da88c1f9df7824bbda68504c137ae8da62eef498b172e6c5b592d3300ee427511554f6dcb3c99ce01185bffbafe639683ab442772ae8eff5a6bb998
6
+ metadata.gz: d0c5ece883782914cdb6bc731cfcc368d63bab3c250396cfa36bbbee7e65b774ef253199579e90fe126fb2fe9e3e669d746281f0e4e0e0b2f6423857d2dd8c0f
7
+ data.tar.gz: 8c2f2eb12331c3dd664066202aafe1e60545b37945e7a2ba7130a30109ad0832246f206ebebc3445f194858089e7dc1fecb8c8e27ce4386bf5f52cbf340923d5
data/README.md CHANGED
@@ -1,12 +1,71 @@
1
- # ReNoGen
1
+ # Renogen
2
2
 
3
- Re(lease) No(tes) Gen(ortor) is a tool designed to compile RELEASE_NOTES or
4
- a CHANGELOG from a chosen source into a chosen format
3
+ Renogen or Re(lease) No(tes) Gen(erator) is a tool to separate feature notes from product versions.
5
4
 
6
5
  ### Installation
7
6
 
7
+ To install Renogen, use the following command:
8
+
9
+ `$ gem install renogen`
10
+
11
+ or add the following to your Gemfile
12
+
13
+ `gem 'renogen', :require => false, :group => :development`
14
+
15
+ `$ renogen init # optional creates directory for notes`
16
+ `$ renogen --help # list available command options
17
+
8
18
  ### Usage
9
19
 
20
+ To generate your notes run the following command
21
+
22
+ `$ renogen <VERSION> # e.g v1.2.1`
23
+
24
+ Unfortunatly renogen cant write documentation for your change.
25
+ By default renogen uses the yaml file stratagy to extract your notes
26
+
27
+ #### Adding YAML feature notes
28
+
29
+ Create a file within the next version folder(default:'change_log/next/')
30
+
31
+ Example feature note
32
+ ```
33
+ # change_log/next/example.yml
34
+ MyFormattedSingleLine:
35
+ identifier: bug_1
36
+ link: example.com/bug_1
37
+ summary: fixes all issues
38
+
39
+ MyMultiLineNote: |
40
+ Title
41
+
42
+ description
43
+
44
+ Example of usage
45
+ $ foo bar baz
46
+ MyList:
47
+ - e.g. run this command
48
+ - e.g. run this as well
49
+ ```
50
+
51
+ #### Examples
52
+
53
+ Prepend your notes to a changelog file(TODO make command simple)
54
+ `$ renogen --format markdown v1.2.1 > CHANGELOG.md | cat - CHANGELOG > CHANGELOG.tmp && mv CHANGELOG.tmp CHANGELOG`
55
+
56
+ Writes notes to html file
57
+ `$ renogen --format html v1.2.1 > v1_2_1.html
58
+
59
+ Print all notes since v1.0.0 as text
60
+ `$ renogen --format text -l v1.0.0 v1.2.1
61
+
62
+ ### Configuration
63
+
64
+ TODO
65
+ `.renogen` file
66
+ single line format
67
+ change log directory
68
+
10
69
  ### License
11
70
 
12
71
  Renogen is a programming tool to generate a log of source code changes
@@ -1,61 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'renogen'
4
- require 'optparse'
3
+ require 'renogen/cli'
5
4
 
6
- class Parser
7
- def self.parse(options)
8
- args = Hash.new
9
-
10
- opt_parser = OptionParser.new do |opts|
11
-
12
- opts.banner = "Usage: renogen [options] VERSION"
13
-
14
- opts.separator ""
15
- opts.separator "Required:"
16
- opts.separator " VERSION this is the version that is currently being required:"
17
-
18
- opts.separator ""
19
- opts.separator "Optional:"
20
-
21
- opts.on("-fFORMAT", "--format=FORMAT", "Output format to be generated") do |n|
22
- args['format'] = n
23
- end
24
-
25
- opts.on("-sSOURCE", "--source=SOURCE", "Type of source that changes will be extracted from") do |n|
26
- args['source'] = n
27
- end
28
-
29
- opts.on_tail("-h", "--help", "Show this message") do
30
- puts opts
31
- exit
32
- end
33
-
34
- opts.on_tail("--version", "Show renogen version") do
35
- puts Renogen::VERSION
36
- exit
37
- end
38
- end
39
-
40
- opt_parser.parse!(options)
41
-
42
- args['new_version'] = options.shift
43
- if args['new_version'].nil?
44
- puts "Missing argument: VERSION"
45
- puts
46
- puts opt_parser
47
- exit 1
48
- elsif options.count > 0
49
- puts "Unknown arguments: #{options}"
50
- puts
51
- puts opt_parser
52
- exit 1
53
- end
54
-
55
- return args
56
- end
57
- end
58
-
59
- options = Parser.parse(ARGV)
60
-
61
- Renogen.generate(options)
5
+ Renogen::Cli.run(ARGV)
@@ -0,0 +1,9 @@
1
+ module Renogen
2
+ require 'renogen/version'
3
+ require 'renogen/exceptions'
4
+ require 'renogen/formatters'
5
+ require 'renogen/extraction_stratagies'
6
+ require 'renogen/change_log'
7
+ require 'renogen/generator'
8
+ require 'renogen/config'
9
+ end
@@ -0,0 +1,9 @@
1
+ module Renogen
2
+ # Components to represent a change log
3
+ module ChangeLog
4
+ require 'renogen/change_log/item'
5
+ require 'renogen/change_log/group'
6
+ require 'renogen/change_log/writer'
7
+ require 'renogen/change_log/model'
8
+ end
9
+ end
@@ -0,0 +1,21 @@
1
+ module Renogen
2
+ module ChangeLog
3
+ # Object to represent a group of changes
4
+ class Group
5
+ attr_reader :name, :changes
6
+
7
+ def initialize(group_name, options={})
8
+ @name = group_name
9
+ @changes ||= []
10
+ end
11
+
12
+ # Add change to the groups change list
13
+ #
14
+ # @param new_change [ChangeLog::Item]
15
+ def add(new_change)
16
+ @changes << new_change
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,60 @@
1
+ module Renogen
2
+ module ChangeLog
3
+ # Object to represent single change item
4
+ class Item
5
+ attr_accessor :change
6
+ attr_reader :group_name
7
+
8
+ def initialize(group_name, change, options={})
9
+ @group_name = group_name
10
+ @change = change
11
+ end
12
+
13
+ # @return [String]
14
+ def to_s
15
+ case change.class.to_s
16
+ when String.to_s
17
+ format_multiline(change)
18
+ when Hash.to_s
19
+ format_oneline(change)
20
+ when Array.to_s
21
+ # TODO should return a string
22
+ change
23
+ else
24
+ raise TypeError
25
+ end
26
+ end
27
+
28
+ # @return [Boolean] true if change is of type array
29
+ def list?
30
+ change.is_a? Array
31
+ end
32
+
33
+ def each
34
+ change.each do |item|
35
+ yield item.to_s
36
+ end
37
+ end
38
+
39
+ private
40
+
41
+ def format_multiline(change)
42
+ change.gsub('\n', '\n \n ') + "\n"
43
+ end
44
+
45
+ def format_oneline(change)
46
+ # TODO Refactor
47
+ string = config.single_line_format.downcase.gsub('\n', '\n ')
48
+ config.supported_keys.each do |key|
49
+ string = string.gsub(key, '#{change[\'' + key + '\']}')
50
+ end
51
+ ss = "\"#{string}\""
52
+ eval(ss)
53
+ end
54
+
55
+ def config
56
+ Config.instance
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,41 @@
1
+ require 'date'
2
+
3
+ module Renogen
4
+ module ChangeLog
5
+ # Object to represent a Changelog/release notes
6
+ class Model
7
+ attr_reader :items
8
+ attr_accessor :version
9
+
10
+ def initialize(options={})
11
+ @version = options[:version]
12
+ @items = []
13
+ end
14
+
15
+ # The title for the change log output
16
+ #
17
+ # @return [String]
18
+ def header
19
+ "#{version} (#{Date.today})"
20
+ end
21
+
22
+ # @return [Hash<group_name: change>]
23
+ def groups
24
+ items.inject({}) do |hash, change|
25
+ hash[change.group_name] ||= []
26
+ hash[change.group_name] << change
27
+ hash
28
+ end
29
+ end
30
+
31
+ # Adds a change to the changelog
32
+ #
33
+ # @param change [Renogen::ChangeLog::Item]
34
+ # @return [Array] All changes
35
+ def add_change(change)
36
+ raise TypeError unless change.is_a?(Renogen::ChangeLog::Item)
37
+ items << change
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,39 @@
1
+ module Renogen
2
+ module ChangeLog
3
+ # Writes out the change log
4
+ class Writer
5
+ def initialize(formatter)
6
+ @formatter = formatter
7
+ end
8
+
9
+ # Writes out the change log
10
+ #
11
+ # @param changelog [ChangeLog::Model]
12
+ def write!(changelog)
13
+ puts formatter.write_header(changelog.header)
14
+ output_groups(changelog.groups)
15
+ puts formatter.write_footer(changelog)
16
+ end
17
+
18
+ protected
19
+
20
+ attr_reader :formatter
21
+
22
+ def output_change(change)
23
+ if change.list?
24
+ change.each { |item| puts formatter.write_change(item) }
25
+ else
26
+ puts formatter.write_change(change.to_s)
27
+ end
28
+ end
29
+
30
+ def output_groups(groups)
31
+ groups.each do |group, changes|
32
+ puts formatter.write_group(group)
33
+ changes.each { |change| output_change(change) }
34
+ puts formatter.write_group_end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,60 @@
1
+ require 'renogen'
2
+
3
+ module Renogen
4
+ # Command line interface helpers
5
+ module Cli
6
+ require 'renogen/cli/param_parser'
7
+
8
+ # Execute the program via command line
9
+ # Renogen exceptions will be rescued and printed
10
+ # @param args [Array]
11
+ def self.run(args)
12
+ return init if args.first == 'init'
13
+ param_parser = ParamParser.new(args)
14
+ version, options = param_parser.parse
15
+
16
+ format = options['format'] || Config.instance.output_format
17
+ source = options['source'] || Config.instance.input_source
18
+ options['changelog_path'] ||= Config.instance.changelog_path
19
+ options['old_version'] ||= Config.instance.changelog_path
20
+
21
+ begin
22
+ generator = Renogen::Generator.new(version, source, format, options)
23
+ generator.generate!
24
+ rescue Renogen::Exceptions::Base => e
25
+ puts e.message
26
+ end
27
+ end
28
+
29
+ # Initialize the current working directory with example change
30
+ def self.init
31
+ Dir.mkdir('./change_log')
32
+ puts "Created './change_log/'"
33
+
34
+ Dir.mkdir('./change_log/next')
35
+ puts "Created './change_log/next/'"
36
+
37
+ File.open("./change_log/next/added_renogen_gem.yml", 'w') do |f|
38
+ f.write("Summary:\n")
39
+ f.write(" identifier: renogen\n")
40
+ f.write(" link: https://github.com/DDAZZA/renogen\n")
41
+ f.write(" summary: Added ReNoGen gem\n")
42
+ f.write("\n")
43
+ f.write("Detailed: |\n")
44
+ f.write(" Added ReNoGen gem\n")
45
+ f.write("\n")
46
+ f.write(" Allows release notes to be generated\n")
47
+ f.write("\n")
48
+ f.write("Tasks:\n")
49
+ f.write(" - $ renogen vX.Y.Z > release_vX_Y_Z.md\n")
50
+ end
51
+
52
+ puts "Created './change_log/next/added_renogen_gem.yml'"
53
+
54
+ File.open(".renogen", 'w') do |f|
55
+ f.write("changelog_path: './change_log/'\n")
56
+ end
57
+ puts "Created '.renogen'"
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,73 @@
1
+ require 'optparse'
2
+
3
+ module Renogen
4
+ module Cli
5
+ # Extracts options and version from argument list
6
+ class ParamParser
7
+ attr_accessor :options
8
+
9
+ def initialize(options)
10
+ @options = options
11
+ end
12
+
13
+ # Extracts options and version from argument list
14
+ #
15
+ # @return [Hash] options
16
+ def parse
17
+ args = Hash.new
18
+
19
+ opt_parser = OptionParser.new do |opts|
20
+ opts.banner = "Usage: renogen [options] VERSION"
21
+ opts.separator ""
22
+ opts.separator "Required:"
23
+ opts.separator " VERSION this is the version that is currently being required:"
24
+ opts.separator ""
25
+ opts.separator "Options:"
26
+
27
+ opts.on("-fFORMAT", "--format=FORMAT", "Output format to be generated") do |n|
28
+ args['format'] = n
29
+ end
30
+
31
+ opts.on("-sSOURCE", "--source=SOURCE", "Type of source that changes will be extracted from") do |n|
32
+ args['source'] = n
33
+ end
34
+
35
+ opts.on("-pPATH", "--path=PATH", "Path to changelog files") do |n|
36
+ args['changelog_path'] = n
37
+ end
38
+
39
+ opts.on("-lVERSION", "--legacy=VERSION", "Used to collate all changes since") do |n|
40
+ args['legacy_version'] = n
41
+ end
42
+
43
+ opts.on_tail("-h", "--help", "Show this message") do
44
+ puts opts
45
+ exit
46
+ end
47
+
48
+ opts.on_tail("--version", "Show renogen version") do
49
+ puts Renogen::VERSION
50
+ exit
51
+ end
52
+ end
53
+
54
+ opt_parser.parse!(options)
55
+
56
+ new_version = options.shift
57
+ if new_version.nil?
58
+ puts "Missing argument: VERSION"
59
+ puts
60
+ puts opt_parser
61
+ exit 1
62
+ elsif options.count > 0
63
+ puts "Unknown arguments: #{options}"
64
+ puts
65
+ puts opt_parser
66
+ exit 1
67
+ end
68
+
69
+ return new_version, args
70
+ end
71
+ end
72
+ end
73
+ end