nty_change_log 0.1.1 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 17c7ebce87d812e8a150345feb4205d3ea06ff00
4
- data.tar.gz: af990a911b83496628fea21070d5e2a5799e8dcf
3
+ metadata.gz: 432466756e753d5fe6fb2f79de97b6fe68abe329
4
+ data.tar.gz: e9b23bb87f5a3146b0af417e614e473e9e14af5a
5
5
  SHA512:
6
- metadata.gz: 49819598e7d6c33a293254e01b63ad4f0a76d3aa6076b8a75d7654b1319c5db552da3e5bf42deeaaf6fb11421bdf553952383e6645eed2cc5b0703a4110eb853
7
- data.tar.gz: e7839b6ac4f95629b7e0304d24d26ca3fe4613eaa2db87e5296a9b33e5c760a97be2d2cd198ae03b0087b46f89407c351d7dda3d483618ac546522679d9ea8e2
6
+ metadata.gz: df31a8a69f6151d24d6583f499c9a502a9883a74ecb76e5c1158520dee0216bb0bfaf461e5bcca43f5d93891707b97ac192d7292d75db4838ab4a52000952273
7
+ data.tar.gz: 4bd4e6a990d0087712313443993704fe7a91b49e987f7b35de8e580a60b514e6285825dceb0a71b2e2fd9eb49dd04a7954ca1b3eb04ff90937e409e009c20b67
data/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ # Change Log
2
+
3
+ ## 0.2.0
4
+
5
+ ### Change
6
+ * Stoping grouping by issues and add issues notation to each changes.
7
+
8
+ ## 0.1.1
9
+
10
+ ### Fix
11
+ * Fix failure to parse versions including characters like "x.y.z".
data/README.md CHANGED
@@ -5,26 +5,18 @@
5
5
 
6
6
  ## 1.0.1
7
7
 
8
- ### [#3](https://github.com/naoty/nty_change_log/pull/3)
8
+ ### Change
9
+ * Change the name of this rubygem. [#3](https://github.com/naoty/nty_change_log/pull/3)
10
+ * Divide a large methods into some small methods. [#3](https://github.com/naoty/nty_change_log/pull/3)
9
11
 
10
- #### Change
11
- * Change the name of this rubygem.
12
- * Divide a large methods into some small methods.
13
-
14
- #### Fix
15
- * Fix some bugs.
12
+ ### Fix
13
+ * Fix some bugs. [#3](https://github.com/naoty/nty_change_log/pull/3)
16
14
 
17
15
  ## 1.0.0
18
16
 
19
- ### [#2](https://github.com/naoty/nty_change_log/pull/2)
20
-
21
- #### Add
22
- * Parse change groups.
23
-
24
- ### [#1](https://github.com/naoty/nty_change_log/pull/1)
25
-
26
- #### Add
27
- * Parse change logs in my style.
17
+ ### Add
18
+ * Parse change groups. [#2](https://github.com/naoty/nty_change_log/pull/2)
19
+ * Parse change logs in my style. [#1](https://github.com/naoty/nty_change_log/pull/1)
28
20
  ```
29
21
 
30
22
  ## Usage
@@ -34,9 +26,19 @@ require "nty_change_log"
34
26
 
35
27
  text = File.read("./CHANGELOG.md")
36
28
  change_log = NTYChangeLog::Parser.new.parse(text)
29
+
30
+ version = change_log.versions.first
31
+ version.number #=> "1.0.1"
32
+
33
+ change_group = version.change_groups.first
34
+ change_group.label #=> "Change"
35
+
36
+ change = change_group.changes.first
37
+ change.description #=> "Change the name of this rubygem."
38
+ change.issue.number #=> 3
39
+ change.issue.url #=> "https://github.com/naoty/nty_change_log/pull/3"
37
40
  ```
38
41
 
39
42
  ## License
40
43
 
41
44
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
42
-
@@ -1,14 +1,18 @@
1
1
  module NTYChangeLog
2
2
  class Change
3
- attr_reader :description
3
+ attr_reader :description, :issue
4
4
 
5
- def initialize(description)
5
+ def initialize(description, issue)
6
6
  @description = description
7
+ @issue = issue
7
8
  end
8
9
 
9
10
  def to_s
10
- "* #{description}"
11
+ if issue == nil
12
+ "* #{description}"
13
+ else
14
+ "* #{description} #{issue}"
15
+ end
11
16
  end
12
17
  end
13
18
  end
14
-
@@ -8,8 +8,7 @@ module NTYChangeLog
8
8
  end
9
9
 
10
10
  def to_s
11
- (["#### #{name}"] + changes).join("\n")
11
+ (["### #{name}"] + changes).join("\n")
12
12
  end
13
13
  end
14
14
  end
15
-
@@ -1,15 +1,14 @@
1
1
  module NTYChangeLog
2
2
  class Issue
3
- attr_reader :name, :change_groups
3
+ attr_reader :number, :url
4
4
 
5
- def initialize(name, change_groups)
6
- @name = name
7
- @change_groups = change_groups
5
+ def initialize(number, url)
6
+ @number = number
7
+ @url = url
8
8
  end
9
9
 
10
10
  def to_s
11
- (["### #{name}"] + change_groups.map(&:to_s)).join("\n\n")
11
+ "[##{number}](#{url})"
12
12
  end
13
13
  end
14
14
  end
15
-
@@ -7,22 +7,14 @@ module NTYChangeLog
7
7
 
8
8
  def parse_versions(text)
9
9
  result = text.split(/^## (\w+\.\w+\.\w+)$/)[1..-1].map(&:strip)
10
- Hash[*result].map do |number, issue_texts|
11
- issues = parse_issues(issue_texts)
12
- Version.new(number, issues)
13
- end
14
- end
15
-
16
- def parse_issues(text)
17
- result = text.split(/^### (.+)$/)[1..-1].map(&:strip)
18
- Hash[*result].map do |name, change_group_texts|
10
+ Hash[*result].map do |number, change_group_texts|
19
11
  change_groups = parse_change_groups(change_group_texts)
20
- Issue.new(name, change_groups)
12
+ Version.new(number, change_groups)
21
13
  end
22
14
  end
23
15
 
24
16
  def parse_change_groups(text)
25
- result = text.split(/^#### (.+)$/)[1..-1].map(&:strip)
17
+ result = text.split(/^### (.+)$/)[1..-1].map(&:strip)
26
18
  Hash[*result].map do |name, change_texts|
27
19
  changes = parse_changes(change_texts)
28
20
  ChangeGroup.new(name, changes)
@@ -30,9 +22,15 @@ module NTYChangeLog
30
22
  end
31
23
 
32
24
  def parse_changes(text)
33
- result = text.split(/^\*\s*(.+)$/).map(&:strip).reject(&:empty?)
34
- result.map do |description|
35
- Change.new(description)
25
+ rows = text.split("\n").map(&:strip)
26
+ rows.map do |row|
27
+ match = row.match(/\*\s+(?<description>\S+)(\s+\[#(?<number>\d+)\]\((?<url>.+)\))?$/)
28
+ if match[:number] == nil
29
+ Change.new(match[:description], nil)
30
+ else
31
+ issue = Issue.new(match[:number].to_i, match[:url])
32
+ Change.new(match[:description], issue)
33
+ end
36
34
  end
37
35
  end
38
36
  end
@@ -1,31 +1,14 @@
1
1
  module NTYChangeLog
2
2
  class Version
3
- attr_reader :number, :issues
3
+ attr_reader :number, :change_groups
4
4
 
5
- def initialize(number, issues)
5
+ def initialize(number, change_groups)
6
6
  @number = number
7
- @issues = issues
7
+ @change_groups = change_groups
8
8
  end
9
9
 
10
10
  def to_s
11
- (["## #{number}"] + issues.map(&:to_s)).join("\n\n")
12
- end
13
-
14
- def summary
15
- change_groups = {}
16
-
17
- issues.each do |issue|
18
- issue.change_groups.each do |change_group|
19
- change_groups[change_group.name] ||= []
20
- change_groups[change_group.name] += change_group.changes
21
- end
22
- end
23
-
24
- change_group_texts = change_groups.map do |change_group_name, changes|
25
- (["#### #{change_group_name}"] + changes.map(&:to_s)).join("\n")
26
- end
27
-
28
- (["## #{number}"] + change_group_texts).join("\n\n")
11
+ (["## #{number}"] + change_groups.map(&:to_s)).join("\n\n")
29
12
  end
30
13
  end
31
14
  end
@@ -1,11 +1,6 @@
1
- # coding: utf-8
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "nty_change_log/version"
5
-
6
1
  Gem::Specification.new do |spec|
7
2
  spec.name = "nty_change_log"
8
- spec.version = "0.1.1"
3
+ spec.version = "0.2.0"
9
4
  spec.authors = ["Naoto Kaneko"]
10
5
  spec.email = ["naoty.k@gmail.com"]
11
6
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nty_change_log
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naoto Kaneko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-20 00:00:00.000000000 Z
11
+ date: 2017-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -74,6 +74,7 @@ extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
76
  - ".gitignore"
77
+ - CHANGELOG.md
77
78
  - CODE_OF_CONDUCT.md
78
79
  - Gemfile
79
80
  - LICENSE.txt
@@ -109,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
110
  version: '0'
110
111
  requirements: []
111
112
  rubyforge_project:
112
- rubygems_version: 2.5.1
113
+ rubygems_version: 2.5.2
113
114
  signing_key:
114
115
  specification_version: 4
115
116
  summary: A rubygem to parse CHANGELOGs in my style