structured_changelog 0.3.0 → 0.4.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: 2fac43fa564020667e2d18424ad4024610716f9d
4
- data.tar.gz: 54c20df05a343f68973c7eb5e3ac2d4f13f0b50d
3
+ metadata.gz: 71d85da1fe01d03fce4a37f8217be7eb23171232
4
+ data.tar.gz: 7f90cc3e3253bb41b44970789154df852a69937e
5
5
  SHA512:
6
- metadata.gz: 18be88ce8212caa08706eeba86971b346a04bcd933061a2b3b1fd0004f41e76cccb8cb53b597068fd942d7314ada658e3b46c22ea8ffcb0f330a07892c2c788e
7
- data.tar.gz: 4ff2164d4a4289d481baa7994a6056b5de418969d8c26956856a3eac25af4a20c07bc53a80e6f157e97b89475e95b9447ab7b240b68c60218a8512e7cc94239f
6
+ metadata.gz: be77a461dea2b7ed531b1bbac9b34960e3a032761dc92c4c922ac199d6dff34f8b099c93f6b1964d8c87be131a2ef13d7cc748b5664532e180e2010402bf3602
7
+ data.tar.gz: 0f7cb255f3b8b31d2a975aeea479e207063b337e49065597fb135efa22c1140636ecced8d609443dcf5e70014cf8b7eda3c6b361b76ee51e7ba19a3ff5a0ee3f
@@ -1,16 +1,24 @@
1
- ## ROADMAP 0.4.0
1
+ ## ROADMAP 1.0.0
2
2
 
3
- * FEATURE validation requires BREAKING/FEATURE/FIX prefixes for each line
3
+ * validate that each line starts with BREAKING:/FEATURE:/FIX:
4
+ * validate that each release has the appropriate version
5
+ * validate that release numbers increase monotonically
6
+ * have a README
7
+ * support variant versions (rc1, pre, alpha, etc..)
8
+ * centralize the version regex (if possible)
9
+
10
+ ## RELEASE 0.4.0
11
+
12
+ * FEATURE: view the release notes for a version (or range of versions) with "rake changelog:notes"
4
13
 
5
14
  ## RELEASE 0.3.0
6
15
 
7
- * FEATURE include a rake task
8
- * FEATURE rake task includes color output
16
+ * FEATURE: include a changelog:validate task
9
17
 
10
18
  ## RELEASE 0.2.0
11
19
 
12
- * FEATURE handle ROADMAP blocks
20
+ * FEATURE: handle ROADMAP blocks
13
21
 
14
22
  ## RELEASE 0.1.0
15
23
 
16
- * FEATURE handle RELEASE blocks
24
+ * FEATURE: handle RELEASE blocks
data/README.md CHANGED
@@ -1,8 +1,27 @@
1
1
  # StructuredChangelog
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/structured_changelog`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ You have a changelog in your repo, right? Great! Then what do you need with a `VERSION` constant?
4
+
5
+ To parse your gem's current version right off your changelog, put this in `yourproject.gemspec`:
6
+
7
+ ```ruby
8
+ require 'structured_changelog'
9
+
10
+ Gem::Specification.new do |spec|
11
+ ...
12
+ spec.version = StructuredChangeog.new("path/to/CHANGELOG.md").version
13
+ ...
14
+ end
15
+ ```
16
+
17
+ To add `rake structured_changelog:validate` and make it part of `rake release`, add this to your `Rakefile`:
18
+
19
+ ```ruby
20
+ require 'structured_changelog/tasks'
21
+ ```
22
+
23
+
4
24
 
5
- TODO: Delete this and the text above, and describe your gem
6
25
 
7
26
  ## Installation
8
27
 
@@ -20,10 +39,6 @@ Or install it yourself as:
20
39
 
21
40
  $ gem install structured_changelog
22
41
 
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
42
  ## Development
28
43
 
29
44
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -32,5 +47,5 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
47
 
33
48
  ## Contributing
34
49
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/structured_changelog. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
50
+ Bug reports and pull requests are welcome on GitHub at https://github.com/yarmiganosca/structured_changelog. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
51
 
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
- require 'structured_changelog/task'
3
+ require 'structured_changelog/tasks'
4
4
 
5
5
  RSpec::Core::RakeTask.new(:spec)
6
6
 
@@ -1,6 +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
5
 
5
6
  class StructuredChangelog
6
7
  attr_reader :path, :releases, :roadmaps
@@ -32,6 +33,12 @@ class StructuredChangelog
32
33
  notifications.empty?
33
34
  end
34
35
 
36
+ def find_releases(query)
37
+ comparator = ReleaseComparators.comparator_for(query)
38
+
39
+ releases.select(&comparator)
40
+ end
41
+
35
42
  private
36
43
 
37
44
  def latest_release
@@ -1,5 +1,7 @@
1
1
  class StructuredChangelog
2
2
  class Release
3
+ attr_reader :contents
4
+
3
5
  def self.pattern
4
6
  /^## RELEASE (?<version>\d+\.\d+\.\d+)$/
5
7
  end
@@ -23,9 +25,5 @@ class StructuredChangelog
23
25
  def <=>(release)
24
26
  version <=> release.version
25
27
  end
26
-
27
- private
28
-
29
- attr_reader :contents
30
28
  end
31
29
  end
@@ -0,0 +1,31 @@
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
@@ -0,0 +1,21 @@
1
+ class StructuredChangelog
2
+ module ReleaseComparators
3
+ class Base
4
+ def self.appropriate_for_query?(query)
5
+ !query.match(pattern).nil?
6
+ end
7
+
8
+ def initialize(query)
9
+ @query = query
10
+ end
11
+
12
+ def to_proc
13
+ method(:call).to_proc
14
+ end
15
+
16
+ private
17
+
18
+ attr_reader :query
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,15 @@
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
@@ -0,0 +1,15 @@
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
@@ -0,0 +1,25 @@
1
+ require 'structured_changelog/release_comparators/base'
2
+
3
+ class StructuredChangelog
4
+ module ReleaseComparators
5
+ class MatchesVersionsBetween < Base
6
+ def self.pattern
7
+ /^(?<floor>\d+\.\d+\.\d+)\<(?<ceiling>\d+\.\d+\.\d+)$/
8
+ end
9
+
10
+ def call(release)
11
+ floor < release.version && release.version < ceiling
12
+ end
13
+
14
+ private
15
+
16
+ def floor
17
+ query.match(self.class.pattern)[:floor]
18
+ end
19
+
20
+ def ceiling
21
+ query.match(self.class.pattern)[:ceiling]
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,21 @@
1
+ require 'structured_changelog/release_comparators/base'
2
+
3
+ class StructuredChangelog
4
+ module ReleaseComparators
5
+ class MatchesVersionsGreaterThanOrEqualTo < Base
6
+ def self.pattern
7
+ /^(?<version>\d+\.\d+\.\d+)\<$/
8
+ end
9
+
10
+ def call(release)
11
+ version <= release.version
12
+ end
13
+
14
+ private
15
+
16
+ def version
17
+ query.match(self.class.pattern)[:version]
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ require 'structured_changelog/release_comparators/base'
2
+
3
+ class StructuredChangelog
4
+ module ReleaseComparators
5
+ class MatchesVersionsLessThanOrEqualTo < Base
6
+ def self.pattern
7
+ /^\<(?<version>\d+\.\d+\.\d+)$/
8
+ end
9
+
10
+ def call(release)
11
+ release.version <= version
12
+ end
13
+
14
+ private
15
+
16
+ def version
17
+ query.match(self.class.pattern)[:version]
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1 @@
1
+ Dir[File.join(File.dirname(__FILE__), 'tasks', '*.rb')].each(&method(:require))
@@ -0,0 +1,15 @@
1
+ require 'structured_changelog'
2
+
3
+ desc "Display Release Notes for One or Multiple Versions"
4
+ task "changelog:notes", [:query, :path] do |_task, arguments|
5
+ query = arguments.to_h.fetch(:query) { "ALL" }
6
+ path = arguments.to_h.fetch(:path) { "CHANGELOG.md" }
7
+
8
+ changelog = StructuredChangelog.new(path)
9
+ releases = changelog.find_releases(query)
10
+
11
+ releases.each do |release|
12
+ puts release.contents
13
+ end
14
+ end
15
+
@@ -2,14 +2,14 @@ require 'bundler/gem_tasks'
2
2
  require 'structured_changelog'
3
3
 
4
4
  desc 'Validate your Structured Changelog'
5
- task 'structured_changelog:validate', [:path] do |_task, arguments|
5
+ task 'changelog:validate', [:path] do |_task, arguments|
6
6
  path = arguments.to_h.fetch(:path) { "CHANGELOG.md" }
7
7
 
8
8
  puts "\e[32mValid #{path}\e[0m" if StructuredChangelog.new(path).validate
9
9
  end
10
10
 
11
11
  if (guard_clean_task = Rake::Task['release:guard_clean'])
12
- guard_clean_task.enhance(['structured_changelog:validate'])
12
+ guard_clean_task.enhance(['changelog:validate'])
13
13
  elsif (release_task = Rake::Task['release'])
14
- release_task.enhance(['structured_changelog:validate'])
14
+ release_task.enhance(['changelog:validate'])
15
15
  end
@@ -0,0 +1,5 @@
1
+ require 'structured_changelog'
2
+
3
+ class StructuredChangelog
4
+ VERSION = StructuredChangelog.new("CHANGELOG.md").version
5
+ end
@@ -1,16 +1,16 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'structured_changelog'
4
+ require 'structured_changelog/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "structured_changelog"
8
- spec.version = StructuredChangelog.new("CHANGELOG.md").version
8
+ spec.version = StructuredChangelog::VERSION
9
9
  spec.authors = ["Chris Hoffman"]
10
10
  spec.email = ["yarmiganosca@gmail.com"]
11
11
 
12
- spec.summary = %q{A useful changelog for a change}
13
- spec.description = "Psychological manipulation designed to get programmers to right changelogs."
12
+ spec.summary = %q{A useful changelog, for a change.}
13
+ spec.description = "Version your gem through your changelog, not a VERSION constant."
14
14
  spec.homepage = "https://www.github.com/yarmiganosca/structured_changelog"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
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.3.0
4
+ version: 0.4.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-10-12 00:00:00.000000000 Z
11
+ date: 2016-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,7 +94,7 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
- description: Psychological manipulation designed to get programmers to right changelogs.
97
+ description: Version your gem through your changelog, not a VERSION constant.
98
98
  email:
99
99
  - yarmiganosca@gmail.com
100
100
  executables: []
@@ -113,8 +113,18 @@ 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
123
  - lib/structured_changelog/roadmap.rb
117
- - lib/structured_changelog/task.rb
124
+ - lib/structured_changelog/tasks.rb
125
+ - lib/structured_changelog/tasks/notes.rb
126
+ - lib/structured_changelog/tasks/validate.rb
127
+ - lib/structured_changelog/version.rb
118
128
  - structured_changelog.gemspec
119
129
  homepage: https://www.github.com/yarmiganosca/structured_changelog
120
130
  licenses: []
@@ -135,8 +145,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
145
  version: '0'
136
146
  requirements: []
137
147
  rubyforge_project:
138
- rubygems_version: 2.5.1
148
+ rubygems_version: 2.6.3
139
149
  signing_key:
140
150
  specification_version: 4
141
- summary: A useful changelog for a change
151
+ summary: A useful changelog, for a change.
142
152
  test_files: []