structured_changelog 0.4.0 → 0.5.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: 71d85da1fe01d03fce4a37f8217be7eb23171232
4
- data.tar.gz: 7f90cc3e3253bb41b44970789154df852a69937e
3
+ metadata.gz: 0278b9063784473fbb20ccbf450c0b88df4c5295
4
+ data.tar.gz: 048479b8e751253f690a60d325ec50c15aba2062
5
5
  SHA512:
6
- metadata.gz: be77a461dea2b7ed531b1bbac9b34960e3a032761dc92c4c922ac199d6dff34f8b099c93f6b1964d8c87be131a2ef13d7cc748b5664532e180e2010402bf3602
7
- data.tar.gz: 0f7cb255f3b8b31d2a975aeea479e207063b337e49065597fb135efa22c1140636ecced8d609443dcf5e70014cf8b7eda3c6b361b76ee51e7ba19a3ff5a0ee3f
6
+ metadata.gz: cc9651df70ac1ead474b14ece1ebac6f8a612da52dc6c72a68e0844915a27f0799a042473c975b33a9e98dba9af34e5c2235968901215c8e8c36501b73ced105
7
+ data.tar.gz: baf20d1048c3742f2330ce418e1dc73c07606999ea5f148e6289fb4a64d475d849ccd3351ae14bc3061d094ab1783cc711cba63d6d3bf1f29481e818bc1293ea
data/CHANGELOG.md CHANGED
@@ -3,10 +3,17 @@
3
3
  * validate that each line starts with BREAKING:/FEATURE:/FIX:
4
4
  * validate that each release has the appropriate version
5
5
  * validate that release numbers increase monotonically
6
- * have a README
7
6
  * support variant versions (rc1, pre, alpha, etc..)
8
7
  * centralize the version regex (if possible)
9
8
 
9
+ ## RELEASE 0.5.0
10
+
11
+ * FEATURE: a `rake changelog:version` to display the current version
12
+
13
+ ## RELEASE 0.4.1
14
+
15
+ * FIX: with no query, `rake changelog:notes` outputs the notes of the current version (instead of all versions)
16
+
10
17
  ## RELEASE 0.4.0
11
18
 
12
19
  * FEATURE: view the release notes for a version (or range of versions) with "rake changelog:notes"
data/README.md CHANGED
@@ -2,16 +2,12 @@
2
2
 
3
3
  You have a changelog in your repo, right? Great! Then what do you need with a `VERSION` constant?
4
4
 
5
- To parse your gem's current version right off your changelog, put this in `yourproject.gemspec`:
5
+ To parse your gem's current version from your changelog, put this in `lib/myproject/version.rb`:
6
6
 
7
7
  ```ruby
8
8
  require 'structured_changelog'
9
9
 
10
- Gem::Specification.new do |spec|
11
- ...
12
- spec.version = StructuredChangeog.new("path/to/CHANGELOG.md").version
13
- ...
14
- end
10
+ MyProject::VERSION = StructuredChangeog.new("path/to/CHANGELOG.md").version
15
11
  ```
16
12
 
17
13
  To add `rake structured_changelog:validate` and make it part of `rake release`, add this to your `Rakefile`:
@@ -20,8 +16,32 @@ To add `rake structured_changelog:validate` and make it part of `rake release`,
20
16
  require 'structured_changelog/tasks'
21
17
  ```
22
18
 
19
+ ## Shiny Rake Tasks
23
20
 
21
+ To validate your changelog:
24
22
 
23
+ $ bundle exec rake changelog:validate
24
+
25
+ To view your the release notes of every release:
26
+
27
+ $ bundle exec rake changelog:notes
28
+ $ bundle exec rake changelog:notes[ALL]
29
+
30
+ for a specific release:
31
+
32
+ $ bundle exec rake changelog:notes[1.0.4]
33
+
34
+ for all releases inclusively after a given release:
35
+
36
+ $ bundle exec rake changelog:notes[1.0.4<]
37
+
38
+ for all releases inclusively before a given release:
39
+
40
+ $ bundle exec rake changelog:notes[<2.0.4]
41
+
42
+ for all releases inclusively between two releases:
43
+
44
+ $ bundle exec rake changelog:notes[1.0.4<2.0.4]
25
45
 
26
46
  ## Installation
27
47
 
@@ -1,7 +1,7 @@
1
1
  require 'pathname'
2
2
  require 'structured_changelog/release'
3
3
  require 'structured_changelog/roadmap'
4
- require 'structured_changelog/release_comparators'
4
+ require 'structured_changelog/release_filters'
5
5
 
6
6
  class StructuredChangelog
7
7
  attr_reader :path, :releases, :roadmaps
@@ -34,9 +34,9 @@ class StructuredChangelog
34
34
  end
35
35
 
36
36
  def find_releases(query)
37
- comparator = ReleaseComparators.comparator_for(query)
38
-
39
- releases.select(&comparator)
37
+ ReleaseFilters
38
+ .filter_for(query)
39
+ .filter_releases(releases)
40
40
  end
41
41
 
42
42
  private
@@ -7,7 +7,7 @@ class StructuredChangelog
7
7
  end
8
8
 
9
9
  def initialize(contents)
10
- @contents = contents
10
+ @contents = contents.strip
11
11
  end
12
12
 
13
13
  def validate
@@ -0,0 +1,32 @@
1
+ Dir[File.join(File.dirname(__FILE__), "release_filters", "*.rb")].each(&method(:require))
2
+
3
+ class StructuredChangelog
4
+ IllegalQuery = Class.new(StandardError)
5
+
6
+ module ReleaseFilters
7
+ def self.filter_for(query)
8
+ filter_class = filter_class_for_query(query)
9
+
10
+ raise IllegalQuery.new(query) unless filter_class
11
+
12
+ filter_class.new(query)
13
+ end
14
+
15
+ def self.filter_class_for_query(query)
16
+ filter_classes.find do |filter_class|
17
+ filter_class.appropriate_for_query?(query)
18
+ end
19
+ end
20
+
21
+ def self.filter_classes
22
+ [
23
+ MatchesCurrentVersion,
24
+ MatchesAllVersions,
25
+ MatchesSingleVersion,
26
+ MatchesVersionsGreaterThanOrEqualTo,
27
+ MatchesVersionsLessThanOrEqualTo,
28
+ MatchesVersionsBetween
29
+ ]
30
+ end
31
+ end
32
+ end
@@ -1,5 +1,5 @@
1
1
  class StructuredChangelog
2
- module ReleaseComparators
2
+ module ReleaseFilters
3
3
  class Base
4
4
  def self.appropriate_for_query?(query)
5
5
  !query.match(pattern).nil?
@@ -9,10 +9,6 @@ class StructuredChangelog
9
9
  @query = query
10
10
  end
11
11
 
12
- def to_proc
13
- method(:call).to_proc
14
- end
15
-
16
12
  private
17
13
 
18
14
  attr_reader :query
@@ -0,0 +1,15 @@
1
+ require 'structured_changelog/release_filters/base'
2
+
3
+ class StructuredChangelog
4
+ module ReleaseFilters
5
+ class MatchesAllVersions < Base
6
+ def self.pattern
7
+ /^all$/
8
+ end
9
+
10
+ def filter_releases(releases)
11
+ releases
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ require 'structured_changelog/release_filters/base'
2
+
3
+ class StructuredChangelog
4
+ module ReleaseFilters
5
+ class MatchesCurrentVersion < Base
6
+ def self.pattern
7
+ /^current$/
8
+ end
9
+
10
+ def filter_releases(releases)
11
+ [releases.max]
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,17 @@
1
+ require 'structured_changelog/release_filters/base'
2
+
3
+ class StructuredChangelog
4
+ module ReleaseFilters
5
+ class MatchesSingleVersion < Base
6
+ def self.pattern
7
+ /^\d+\.\d+\.\d+$/
8
+ end
9
+
10
+ def filter_releases(releases)
11
+ releases.select do |release|
12
+ release.version == query
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,14 +1,16 @@
1
- require 'structured_changelog/release_comparators/base'
1
+ require 'structured_changelog/release_filters/base'
2
2
 
3
3
  class StructuredChangelog
4
- module ReleaseComparators
4
+ module ReleaseFilters
5
5
  class MatchesVersionsBetween < Base
6
6
  def self.pattern
7
7
  /^(?<floor>\d+\.\d+\.\d+)\<(?<ceiling>\d+\.\d+\.\d+)$/
8
8
  end
9
9
 
10
- def call(release)
11
- floor < release.version && release.version < ceiling
10
+ def filter_releases(releases)
11
+ releases.select do |release|
12
+ floor <= release.version && release.version <= ceiling
13
+ end
12
14
  end
13
15
 
14
16
  private
@@ -1,14 +1,16 @@
1
- require 'structured_changelog/release_comparators/base'
1
+ require 'structured_changelog/release_filters/base'
2
2
 
3
3
  class StructuredChangelog
4
- module ReleaseComparators
4
+ module ReleaseFilters
5
5
  class MatchesVersionsGreaterThanOrEqualTo < Base
6
6
  def self.pattern
7
7
  /^(?<version>\d+\.\d+\.\d+)\<$/
8
8
  end
9
9
 
10
- def call(release)
11
- version <= release.version
10
+ def filter_releases(releases)
11
+ releases.select do |release|
12
+ version <= release.version
13
+ end
12
14
  end
13
15
 
14
16
  private
@@ -1,14 +1,16 @@
1
- require 'structured_changelog/release_comparators/base'
1
+ require 'structured_changelog/release_filters/base'
2
2
 
3
3
  class StructuredChangelog
4
- module ReleaseComparators
4
+ module ReleaseFilters
5
5
  class MatchesVersionsLessThanOrEqualTo < Base
6
6
  def self.pattern
7
7
  /^\<(?<version>\d+\.\d+\.\d+)$/
8
8
  end
9
9
 
10
- def call(release)
11
- release.version <= version
10
+ def filter_releases(releases)
11
+ releases.select do |release|
12
+ release.version <= version
13
+ end
12
14
  end
13
15
 
14
16
  private
@@ -9,7 +9,7 @@ class StructuredChangelog
9
9
  end
10
10
 
11
11
  def initialize(contents)
12
- @contents = contents
12
+ @contents = contents.strip
13
13
  end
14
14
 
15
15
  def version
@@ -2,14 +2,12 @@ require 'structured_changelog'
2
2
 
3
3
  desc "Display Release Notes for One or Multiple Versions"
4
4
  task "changelog:notes", [:query, :path] do |_task, arguments|
5
- query = arguments.to_h.fetch(:query) { "ALL" }
5
+ query = arguments.to_h.fetch(:query) { "current" }
6
6
  path = arguments.to_h.fetch(:path) { "CHANGELOG.md" }
7
7
 
8
8
  changelog = StructuredChangelog.new(path)
9
9
  releases = changelog.find_releases(query)
10
10
 
11
- releases.each do |release|
12
- puts release.contents
13
- end
11
+ puts releases.map(&:contents).join("\n\n")
14
12
  end
15
13
 
@@ -0,0 +1,10 @@
1
+ require 'structured_changelog'
2
+
3
+ desc 'Display the Current Version'
4
+ task 'changelog:version', [:path] do |_task, arguments|
5
+ path = arguments.to_h.fetch(:path) { "CHANGELOG.md" }
6
+
7
+ changelog = StructuredChangelog.new(path)
8
+
9
+ puts changelog.version
10
+ end
@@ -1,5 +1,3 @@
1
1
  require 'structured_changelog'
2
2
 
3
- class StructuredChangelog
4
- VERSION = StructuredChangelog.new("CHANGELOG.md").version
5
- end
3
+ StructuredChangelog::VERSION = StructuredChangelog.new("CHANGELOG.md").version
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: structured_changelog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Hoffman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-04 00:00:00.000000000 Z
11
+ date: 2016-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -113,17 +113,19 @@ files:
113
113
  - bin/setup
114
114
  - lib/structured_changelog.rb
115
115
  - lib/structured_changelog/release.rb
116
- - lib/structured_changelog/release_comparators.rb
117
- - lib/structured_changelog/release_comparators/base.rb
118
- - lib/structured_changelog/release_comparators/matches_all_versions.rb
119
- - lib/structured_changelog/release_comparators/matches_single_version.rb
120
- - lib/structured_changelog/release_comparators/matches_versions_between.rb
121
- - lib/structured_changelog/release_comparators/matches_versions_greater_than_or_equal_to.rb
122
- - lib/structured_changelog/release_comparators/matches_versions_less_than_or_equal_to.rb
116
+ - lib/structured_changelog/release_filters.rb
117
+ - lib/structured_changelog/release_filters/base.rb
118
+ - lib/structured_changelog/release_filters/matches_all_versions.rb
119
+ - lib/structured_changelog/release_filters/matches_current_version.rb
120
+ - lib/structured_changelog/release_filters/matches_single_version.rb
121
+ - lib/structured_changelog/release_filters/matches_versions_between.rb
122
+ - lib/structured_changelog/release_filters/matches_versions_greater_than_or_equal_to.rb
123
+ - lib/structured_changelog/release_filters/matches_versions_less_than_or_equal_to.rb
123
124
  - lib/structured_changelog/roadmap.rb
124
125
  - lib/structured_changelog/tasks.rb
125
126
  - lib/structured_changelog/tasks/notes.rb
126
127
  - lib/structured_changelog/tasks/validate.rb
128
+ - lib/structured_changelog/tasks/version.rb
127
129
  - lib/structured_changelog/version.rb
128
130
  - structured_changelog.gemspec
129
131
  homepage: https://www.github.com/yarmiganosca/structured_changelog
@@ -1,31 +0,0 @@
1
- Dir[File.join(File.dirname(__FILE__), "release_comparators", "*.rb")].each(&method(:require))
2
-
3
- class StructuredChangelog
4
- IllegalQuery = Class.new(StandardError)
5
-
6
- module ReleaseComparators
7
- def self.comparator_for(query)
8
- comparator_class = comparator_class_for_query(query)
9
-
10
- raise IllegalQuery.new(query) unless comparator_class
11
-
12
- comparator_class.new(query)
13
- end
14
-
15
- def self.comparator_class_for_query(query)
16
- comparator_classes.find do |comparator_class|
17
- comparator_class.appropriate_for_query?(query)
18
- end
19
- end
20
-
21
- def self.comparator_classes
22
- [
23
- MatchesAllVersions,
24
- MatchesSingleVersion,
25
- MatchesVersionsGreaterThanOrEqualTo,
26
- MatchesVersionsLessThanOrEqualTo,
27
- MatchesVersionsBetween
28
- ]
29
- end
30
- end
31
- end
@@ -1,15 +0,0 @@
1
- require 'structured_changelog/release_comparators/base'
2
-
3
- class StructuredChangelog
4
- module ReleaseComparators
5
- class MatchesAllVersions < Base
6
- def self.pattern
7
- /^ALL$/
8
- end
9
-
10
- def call(release)
11
- true
12
- end
13
- end
14
- end
15
- end
@@ -1,15 +0,0 @@
1
- require 'structured_changelog/release_comparators/base'
2
-
3
- class StructuredChangelog
4
- module ReleaseComparators
5
- class MatchesSingleVersion < Base
6
- def self.pattern
7
- /^\d+\.\d+\.\d+$/
8
- end
9
-
10
- def call(release)
11
- release.version == query
12
- end
13
- end
14
- end
15
- end