renogen 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +112 -27
- data/lib/renogen/change_log.rb +1 -0
- data/lib/renogen/change_log/item.rb +6 -4
- data/lib/renogen/change_log/model.rb +9 -0
- data/lib/renogen/change_log/validator.rb +61 -0
- data/lib/renogen/change_log/writer.rb +22 -2
- data/lib/renogen/cli.rb +6 -4
- data/lib/renogen/config.rb +15 -15
- data/lib/renogen/exceptions.rb +5 -0
- data/lib/renogen/exceptions/invalid_item_found.rb +32 -0
- data/lib/renogen/exceptions/yaml_file_blank.rb +21 -0
- data/lib/renogen/exceptions/yaml_file_invalid.rb +20 -0
- data/lib/renogen/extraction_stratagies.rb +0 -2
- data/lib/renogen/extraction_stratagies/yaml_file.rb +0 -1
- data/lib/renogen/extraction_stratagies/yaml_file/parser.rb +5 -4
- data/lib/renogen/extraction_stratagies/yaml_file/reader.rb +20 -11
- data/lib/renogen/formatters.rb +2 -0
- data/lib/renogen/formatters/base.rb +14 -4
- data/lib/renogen/formatters/csv.rb +41 -0
- data/lib/renogen/formatters/markdown_table.rb +58 -0
- data/lib/renogen/generator.rb +8 -1
- data/lib/renogen/version.rb +1 -1
- data/lib/renogen/writers/csv.rb +23 -0
- data/spec/lib/renogen/change_log/item_spec.rb +1 -1
- data/spec/lib/renogen/change_log/model_spec.rb +1 -1
- data/spec/lib/renogen/change_log/validator_spec.rb +38 -0
- data/spec/lib/renogen/config_spec.rb +7 -2
- data/spec/lib/renogen/exceptions/invalid_item_found_spec.rb +35 -0
- data/spec/lib/renogen/exceptions/stratagy_not_found_spec.rb +2 -1
- data/spec/lib/renogen/{extraction_stratagies/yaml_file/exceptions → exceptions}/yaml_file_blank_spec.rb +1 -1
- data/spec/lib/renogen/exceptions/yaml_file_invalid_spec.rb +12 -0
- data/spec/lib/renogen/extraction_stratagies/yaml_file/parser_spec.rb +3 -3
- data/spec/lib/renogen/extraction_stratagies/yaml_file/reader_spec.rb +11 -5
- data/spec/lib/renogen/formatters/base_spec.rb +8 -8
- data/spec/lib/renogen/formatters/csv_spec.rb +49 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/support/renogen_helper.rb +9 -0
- metadata +15 -6
- data/lib/renogen/extraction_stratagies/yaml_file/exceptions.rb +0 -12
- data/lib/renogen/extraction_stratagies/yaml_file/exceptions/yaml_file_blank.rb +0 -25
- data/spec/lib/renogen/change_log/writer_spec.rb +0 -8
@@ -1,19 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Renogen::Config do
|
4
|
-
|
5
6
|
subject { described_class.instance }
|
6
7
|
|
7
8
|
describe '#configure' do
|
8
9
|
before :each do
|
9
10
|
described_class.configure do |config|
|
10
11
|
config.single_line_format = 'bar'
|
12
|
+
config.validations = ['test']
|
11
13
|
end
|
12
14
|
end
|
13
15
|
|
14
16
|
it 'can set value' do
|
15
17
|
expect(subject.single_line_format).to eql 'bar'
|
16
18
|
end
|
17
|
-
end
|
18
19
|
|
20
|
+
it 'sets the validations value' do
|
21
|
+
expect(subject.validations).to eql ['test']
|
22
|
+
end
|
23
|
+
end
|
19
24
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Renogen::Exceptions::InvalidItemFound do
|
6
|
+
subject { described_class.new(invalid_items) }
|
7
|
+
|
8
|
+
describe '#message' do
|
9
|
+
context 'valid_values is an array' do
|
10
|
+
let(:invalid_items) do
|
11
|
+
[
|
12
|
+
{ group_name: 'Product', invalid_value: 'Foo', valid_values: %w(Bar Baz) },
|
13
|
+
{ group_name: 'Country', invalid_value: 'LL', valid_values: %w(UK IE) }
|
14
|
+
]
|
15
|
+
end
|
16
|
+
let(:expected_error) do
|
17
|
+
"Invalid items:\nGroup: Product, Content: Foo, Valid Values: [\"Bar\", \"Baz\"]" \
|
18
|
+
"\nGroup: Country, Content: LL, Valid Values: [\"UK\", \"IE\"]"
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'returns a user friendly error message' do
|
22
|
+
expect(subject.message).to eql expected_error
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'valid_values is a RegExp' do
|
27
|
+
let(:invalid_items) { [{ group_name: 'Product', invalid_value: 'Foo', valid_values: /\b(Bar|Baz)\b/ }] }
|
28
|
+
let(:expected_error) { "Invalid items:\nGroup: Product, Content: Foo, Pattern: #{/\b(Bar|Baz)\b/.inspect}" }
|
29
|
+
|
30
|
+
it 'returns a user friendly error message' do
|
31
|
+
expect(subject.message).to eql expected_error
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Renogen::Exceptions::StratagyNotFound do
|
@@ -8,6 +10,5 @@ describe Renogen::Exceptions::StratagyNotFound do
|
|
8
10
|
it 'returns friendly error message' do
|
9
11
|
expect(subject.message).to eql "Error: Stratagy type '#{name}' not found"
|
10
12
|
end
|
11
|
-
|
12
13
|
end
|
13
14
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Renogen::Exceptions::YamlFileInvalid do
|
4
|
+
let(:name) { 'foobar' }
|
5
|
+
subject { described_class.new(name) }
|
6
|
+
|
7
|
+
describe '#message' do
|
8
|
+
it 'returns friendly error message' do
|
9
|
+
expect(subject.message).to eql "Error: File contents invalid '#{name}'"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -6,13 +6,13 @@ describe Renogen::ExtractionStratagies::YamlFile::Parser do
|
|
6
6
|
describe '#parse!' do
|
7
7
|
before :each do
|
8
8
|
yaml_file_reader = double(Renogen::ExtractionStratagies::YamlFile::Reader)
|
9
|
-
allow(yaml_file_reader).to receive(:each_yaml_file).and_yield(file_contents)
|
9
|
+
allow(yaml_file_reader).to receive(:each_yaml_file).and_yield(file_contents, 1)
|
10
10
|
allow(Renogen::ExtractionStratagies::YamlFile::Reader).to receive(:new).and_return(yaml_file_reader)
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'extracts contents from file' do
|
14
|
-
changelog_item = Renogen::ChangeLog::Item.new('Foo', 'Bar')
|
15
|
-
allow(Renogen::ChangeLog::Item).to receive(:new).with('Foo', 'Bar').and_return changelog_item
|
14
|
+
changelog_item = Renogen::ChangeLog::Item.new(1, 'Foo', 'Bar')
|
15
|
+
allow(Renogen::ChangeLog::Item).to receive(:new).with(1, 'Foo', 'Bar').and_return changelog_item
|
16
16
|
|
17
17
|
changelog = subject.parse!
|
18
18
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'json'
|
3
5
|
|
@@ -6,15 +8,19 @@ describe Renogen::ExtractionStratagies::YamlFile::Reader do
|
|
6
8
|
subject { described_class.new(directory_path) }
|
7
9
|
|
8
10
|
describe '#each_yaml_file' do
|
9
|
-
let(:file_contents) { { 'Foo' => '
|
11
|
+
let(:file_contents) { { 'Foo' => 'bar' }.to_json }
|
10
12
|
|
11
|
-
|
12
|
-
allow(Dir).to receive(:glob).with([File.join(directory_path, 'next',
|
13
|
+
it 'yields each yaml file within given directory' do
|
14
|
+
allow(Dir).to receive(:glob).with([File.join(directory_path, 'next', '*.yml')]).and_return(['foo_file'])
|
13
15
|
allow(YAML).to receive(:load_file).with('foo_file').and_return(file_contents)
|
16
|
+
expect { |b| subject.each_yaml_file(&b) }.to yield_with_args(file_contents, 0)
|
14
17
|
end
|
15
18
|
|
16
|
-
it '
|
17
|
-
|
19
|
+
it 'throws invalid yaml file when missing quotes' do
|
20
|
+
allow(subject).to receive(:change_directories).and_return(%w(foo bar))
|
21
|
+
foo = Psych::SyntaxError.new('a', 1, 2, 'd', 'e', 'f')
|
22
|
+
allow(YAML).to receive(:load_file).and_raise(foo)
|
23
|
+
expect { subject.each_yaml_file }.to raise_error(Renogen::Exceptions::YamlFileInvalid)
|
18
24
|
end
|
19
25
|
end
|
20
26
|
end
|
@@ -1,25 +1,25 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Renogen::Formatters::Base do
|
4
|
+
let(:version) { '1.2.34' }
|
5
|
+
let(:date) { Date.today }
|
6
|
+
let(:changelog) { double(Renogen::ChangeLog::Model, version: version, date: date) }
|
7
|
+
|
4
8
|
describe '#header' do
|
5
9
|
subject { described_class.new.header(changelog) }
|
6
10
|
|
7
|
-
let(:version) { '1.2.34' }
|
8
|
-
let(:date) { Date.today }
|
9
|
-
let(:changelog) { double(Renogen::ChangeLog::Model, version: version, date: date) }
|
10
|
-
|
11
11
|
it { is_expected.to eql "#{version} (#{date})" }
|
12
12
|
end
|
13
13
|
|
14
14
|
describe '#write_header' do
|
15
|
-
it '
|
16
|
-
expect
|
15
|
+
it 'does nothing' do
|
16
|
+
expect(subject.write_header(changelog)).to be_nil
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
describe '#write_group' do
|
21
|
-
it '
|
22
|
-
expect
|
21
|
+
it 'does nothing' do
|
22
|
+
expect(subject.write_group(changelog)).to be_nil
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Renogen::Formatters::Csv do
|
6
|
+
describe 'write_methods' do
|
7
|
+
let(:change_1) { renogen_change(1, 'Group 1', 'Change 1') }
|
8
|
+
let(:change_2) { renogen_change(1, 'Group 2', 'Change 2') }
|
9
|
+
let(:change_3) { renogen_change(2, 'Group 1', 'Change 3') }
|
10
|
+
let(:changelog) { Renogen::ChangeLog::Model.new }
|
11
|
+
|
12
|
+
before do
|
13
|
+
[change_1, change_2, change_3].each { |c| changelog.add_change(c) }
|
14
|
+
subject.header(changelog)
|
15
|
+
end
|
16
|
+
|
17
|
+
it { is_expected.to be_table_formatter }
|
18
|
+
describe '#write_header' do
|
19
|
+
it 'returns a comma separated list of group names' do
|
20
|
+
expect(subject.write_header('Group 1,Group 2')).to eq("Group 1,Group 2\n")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#write_change' do
|
25
|
+
let(:ticket) do
|
26
|
+
{
|
27
|
+
'Group 1' => 'This is a Group 1 change',
|
28
|
+
'Group 2' => 'This is a Group 2 change, with a comma'
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'when ticket contains same keys as changelog groups' do
|
33
|
+
it 'outputs all values' do
|
34
|
+
expect(subject.write_change(ticket)).to eq(
|
35
|
+
'This is a Group 1 change,"This is a Group 2 change, with a comma"'
|
36
|
+
)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'when changelog contains keys missing in ticket' do
|
41
|
+
it 'outputs empty values for missing keys' do
|
42
|
+
expect(subject.write_change(ticket)).to eq(
|
43
|
+
'This is a Group 1 change,"This is a Group 2 change, with a comma"'
|
44
|
+
)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'renogen'
|
4
|
+
require_relative 'support/renogen_helper'
|
2
5
|
|
3
6
|
RSpec.configure do |config|
|
4
7
|
config.expect_with :rspec do |expectations|
|
@@ -40,4 +43,6 @@ RSpec.configure do |config|
|
|
40
43
|
# the seed, which is printed after each run.
|
41
44
|
# --seed 1234
|
42
45
|
config.order = :random
|
46
|
+
|
47
|
+
config.include Support::RenogenHelper
|
43
48
|
end
|
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.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Elliott
|
@@ -39,45 +39,54 @@ files:
|
|
39
39
|
- lib/renogen/change_log/group.rb
|
40
40
|
- lib/renogen/change_log/item.rb
|
41
41
|
- lib/renogen/change_log/model.rb
|
42
|
+
- lib/renogen/change_log/validator.rb
|
42
43
|
- lib/renogen/change_log/writer.rb
|
43
44
|
- lib/renogen/cli.rb
|
44
45
|
- lib/renogen/cli/param_parser.rb
|
45
46
|
- lib/renogen/config.rb
|
46
47
|
- lib/renogen/exceptions.rb
|
47
48
|
- lib/renogen/exceptions/base.rb
|
49
|
+
- lib/renogen/exceptions/invalid_item_found.rb
|
48
50
|
- lib/renogen/exceptions/stratagy_not_found.rb
|
51
|
+
- lib/renogen/exceptions/yaml_file_blank.rb
|
52
|
+
- lib/renogen/exceptions/yaml_file_invalid.rb
|
49
53
|
- lib/renogen/extraction_stratagies.rb
|
50
54
|
- lib/renogen/extraction_stratagies/base.rb
|
51
55
|
- lib/renogen/extraction_stratagies/yaml_file.rb
|
52
|
-
- lib/renogen/extraction_stratagies/yaml_file/exceptions.rb
|
53
|
-
- lib/renogen/extraction_stratagies/yaml_file/exceptions/yaml_file_blank.rb
|
54
56
|
- lib/renogen/extraction_stratagies/yaml_file/parser.rb
|
55
57
|
- lib/renogen/extraction_stratagies/yaml_file/provider.rb
|
56
58
|
- lib/renogen/extraction_stratagies/yaml_file/reader.rb
|
57
59
|
- lib/renogen/formatters.rb
|
58
60
|
- lib/renogen/formatters/base.rb
|
61
|
+
- lib/renogen/formatters/csv.rb
|
59
62
|
- lib/renogen/formatters/html.rb
|
60
63
|
- lib/renogen/formatters/markdown.rb
|
64
|
+
- lib/renogen/formatters/markdown_table.rb
|
61
65
|
- lib/renogen/formatters/plain_text.rb
|
62
66
|
- lib/renogen/generator.rb
|
63
67
|
- lib/renogen/version.rb
|
68
|
+
- lib/renogen/writers/csv.rb
|
64
69
|
- spec/lib/renogen/change_log/group_spec.rb
|
65
70
|
- spec/lib/renogen/change_log/item_spec.rb
|
66
71
|
- spec/lib/renogen/change_log/model_spec.rb
|
67
|
-
- spec/lib/renogen/change_log/
|
72
|
+
- spec/lib/renogen/change_log/validator_spec.rb
|
68
73
|
- spec/lib/renogen/config_spec.rb
|
74
|
+
- spec/lib/renogen/exceptions/invalid_item_found_spec.rb
|
69
75
|
- spec/lib/renogen/exceptions/stratagy_not_found_spec.rb
|
76
|
+
- spec/lib/renogen/exceptions/yaml_file_blank_spec.rb
|
77
|
+
- spec/lib/renogen/exceptions/yaml_file_invalid_spec.rb
|
70
78
|
- spec/lib/renogen/extraction_stratagies/base_spec.rb
|
71
|
-
- spec/lib/renogen/extraction_stratagies/yaml_file/exceptions/yaml_file_blank_spec.rb
|
72
79
|
- spec/lib/renogen/extraction_stratagies/yaml_file/parser_spec.rb
|
73
80
|
- spec/lib/renogen/extraction_stratagies/yaml_file/provider_spec.rb
|
74
81
|
- spec/lib/renogen/extraction_stratagies/yaml_file/reader_spec.rb
|
75
82
|
- spec/lib/renogen/formatters/base_spec.rb
|
83
|
+
- spec/lib/renogen/formatters/csv_spec.rb
|
76
84
|
- spec/lib/renogen/formatters/html_spec.rb
|
77
85
|
- spec/lib/renogen/formatters/markdown_spec.rb
|
78
86
|
- spec/lib/renogen/formatters/plain_text_spec.rb
|
79
87
|
- spec/lib/renogen_spec.rb
|
80
88
|
- spec/spec_helper.rb
|
89
|
+
- spec/support/renogen_helper.rb
|
81
90
|
homepage: https://github.com/DDAZZA/renogen
|
82
91
|
licenses:
|
83
92
|
- GPL-3.0
|
@@ -98,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
107
|
version: '0'
|
99
108
|
requirements: []
|
100
109
|
rubyforge_project:
|
101
|
-
rubygems_version: 2.6.
|
110
|
+
rubygems_version: 2.7.6.2
|
102
111
|
signing_key:
|
103
112
|
specification_version: 4
|
104
113
|
summary: Release Notes/changelog Generator
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Renogen
|
2
|
-
module ExtractionStratagies
|
3
|
-
module YamlFile
|
4
|
-
module Exceptions
|
5
|
-
# This is raised when a yaml file change is found but has not contents
|
6
|
-
class YamlFileBlank < Renogen::Exceptions::Base
|
7
|
-
attr_reader :file_path
|
8
|
-
|
9
|
-
def initialize(file_path)
|
10
|
-
@file_path = file_path
|
11
|
-
super
|
12
|
-
end
|
13
|
-
|
14
|
-
# Friendly error message
|
15
|
-
#
|
16
|
-
# @return [String]
|
17
|
-
def message
|
18
|
-
"Error: File contents blank '#{file_path}'"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|