logchange 0.0.1
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 +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +21 -0
- data/README.md +77 -0
- data/Rakefile +6 -0
- data/bin/console +7 -0
- data/bin/logchange +6 -0
- data/lib/logchange/configuration.rb +16 -0
- data/lib/logchange/dispatch.rb +37 -0
- data/lib/logchange/initialize.rb +17 -0
- data/lib/logchange/logger.rb +52 -0
- data/lib/logchange/release.rb +12 -0
- data/lib/logchange/version.rb +3 -0
- data/lib/logchange.rb +19 -0
- data/logchange.gemspec +30 -0
- metadata +117 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2e6678b4bc69a5cdc2cab8bbc71ad0b43a33854a
|
4
|
+
data.tar.gz: 96c1905246dd6b04c4c99f576dea036514988e45
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dca400cee181c2967a63099d8da0a86bcecc94612a4e40f28511e4a9ba24acf83c5a6eeaa4cce5e8f3404498c0a37d054ebc69928a7f1e896650704555fd7394
|
7
|
+
data.tar.gz: 5b45666ee97abb97ff566cb53da6f11b099f1bec94d8da8377ac8b321ee2c2647e7d54973217c6903d2defa30cd7af9c67e3f7a2ac127916676a7d485f3f6e80
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Hari Gopal
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
# Logchange
|
2
|
+
|
3
|
+
Logchange is an alternative approach to managing a _changelog_. Instead of writing to a flat `CHANGELOG(.md)`, it logs
|
4
|
+
changes to `.yaml` files containing a `timestamp`, the `title`, and a boolean `public`.
|
5
|
+
|
6
|
+
Logchange allows for two _release_ changelogs to be maintained - an exhaustive one for internal use, and a public one
|
7
|
+
to display to your users. It can _release_ a public and a private changelog with one command, assuming that `public`
|
8
|
+
boolean is correctly set (see _Usage_ section).
|
9
|
+
|
10
|
+
This repository's _changelog_ is maintained using _logchange_. Since this is a public repository, there are only public
|
11
|
+
changes. See the automatically generated `changelog/2017-public.yaml`. Unreleased changes go to `changelog/unreleased`.
|
12
|
+
|
13
|
+
## Why?
|
14
|
+
|
15
|
+
It's good to let your users know what you're up to, and it's good to keep track of what changed over time. However, you
|
16
|
+
don't need to tell your users about every single change - hence the `public` flag. The _YAML_ format just makes it
|
17
|
+
easier to parse and _present_ the data on the front-end, while being readable and editable.
|
18
|
+
|
19
|
+
## Installation
|
20
|
+
|
21
|
+
Add to your `Gemfile`:
|
22
|
+
|
23
|
+
gem 'logchange', '~> 0.1'
|
24
|
+
|
25
|
+
And then:
|
26
|
+
|
27
|
+
$ bundle install
|
28
|
+
|
29
|
+
Or install the gem with:
|
30
|
+
|
31
|
+
$ gem install logchange
|
32
|
+
|
33
|
+
## Usage
|
34
|
+
|
35
|
+
If you've just completed work on a feature, log it with:
|
36
|
+
|
37
|
+
$ logchange new "A cool new feature has been added"
|
38
|
+
Created [..]/changelog/unreleased/20170521-a-cool-new-feature-has-been-added.yml`
|
39
|
+
|
40
|
+
This will create a new timestamped `.yaml` file in the `changelog` folder. By default, the `public` flag for all changes
|
41
|
+
will be set to `true`. You can change this if you want to prevent it from appearing in the release log.
|
42
|
+
|
43
|
+
To alter the default template used, create a `changelog/template.yaml` file, and set custom keys in it:
|
44
|
+
|
45
|
+
# changelog/template.yaml
|
46
|
+
|
47
|
+
public: false
|
48
|
+
github_issue: Add a link to related Github issue, or delete this key.
|
49
|
+
|
50
|
+
If present, this template will be merged into the output.
|
51
|
+
|
52
|
+
To _release_ all new _public_ changes to the flat file, run:
|
53
|
+
|
54
|
+
$ logchange release [VERSION]
|
55
|
+
|
56
|
+
## Change template
|
57
|
+
|
58
|
+
---
|
59
|
+
timestamp: 2017-05-21T06:45:08Z
|
60
|
+
title: The title for your change goes here. This string gets added to CHANGELOG.md upon release.
|
61
|
+
public: Defaults to 'true'. This means that the release command will add this change to CHANGELOG.md. Set to 'false' to prevent that.
|
62
|
+
additional_key_1: You can add any number of additional keys. Logchange will ignore these when writing CHANGELOG.md. Parsing / using these is up to you.
|
63
|
+
|
64
|
+
## Development
|
65
|
+
|
66
|
+
After checking out the repo, run `bundle install` 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.
|
67
|
+
|
68
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
69
|
+
|
70
|
+
## Contributing
|
71
|
+
|
72
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/harigopal/logchange.
|
73
|
+
|
74
|
+
## License
|
75
|
+
|
76
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
77
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/bin/logchange
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
module Logchange
|
2
|
+
# Store configuration for this gem.
|
3
|
+
class Configuration
|
4
|
+
attr_accessor :changelog_directory
|
5
|
+
attr_accessor :root_path
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@changelog_directory = 'changelog'
|
9
|
+
@root_path = Dir.pwd
|
10
|
+
end
|
11
|
+
|
12
|
+
def changelog_directory_path
|
13
|
+
File.join(@root_path, @changelog_directory)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Logchange
|
2
|
+
# Routes the user's command to appropriate handler.
|
3
|
+
class Dispatch
|
4
|
+
def execute
|
5
|
+
ensure_changelog_directory_exists unless command == :init
|
6
|
+
|
7
|
+
case command
|
8
|
+
when :init
|
9
|
+
Logchange::Initialize.new.execute
|
10
|
+
when :new
|
11
|
+
Logchange::Logger.new(ARGV[1]).execute
|
12
|
+
when :release
|
13
|
+
Logchange::Release.new.execute
|
14
|
+
else
|
15
|
+
raise "Unhandled command #{command}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def ensure_changelog_directory_exists
|
22
|
+
path = File.join(Logchange.configuration.changelog_directory_path, 'unreleased')
|
23
|
+
return if File.directory?(path)
|
24
|
+
raise "The changelog directory does not exist in this path. Run 'logchange init', or change to the correct path."
|
25
|
+
end
|
26
|
+
|
27
|
+
def command
|
28
|
+
return ARGV[0].to_sym if %w[init new release preview].include?(ARGV[0])
|
29
|
+
print_help
|
30
|
+
end
|
31
|
+
|
32
|
+
def print_help
|
33
|
+
# TODO: Write actual help response.
|
34
|
+
raise 'Unknown command encountered.'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Logchange
|
4
|
+
# Creates the changes directory if it doesn't exist, and logs the initialization.
|
5
|
+
class Initialize
|
6
|
+
def execute
|
7
|
+
path = File.join(Logchange.configuration.changelog_directory_path, 'unreleased')
|
8
|
+
|
9
|
+
if File.directory?(path)
|
10
|
+
puts 'The changelog directory already exists. Cancelling.'
|
11
|
+
else
|
12
|
+
FileUtils.mkdir_p(path)
|
13
|
+
Logchange::Logger.new('Added logchange to project.', public: false).execute
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'time'
|
3
|
+
|
4
|
+
module Logchange
|
5
|
+
# Logs a new change.
|
6
|
+
class Logger
|
7
|
+
def initialize(title, public: true)
|
8
|
+
@title = title
|
9
|
+
@public = public
|
10
|
+
end
|
11
|
+
|
12
|
+
def execute
|
13
|
+
file_path = File.join(unreleased_path, filename)
|
14
|
+
File.write(file_path, log_contents)
|
15
|
+
puts "Created #{file_path}"
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def log_contents
|
21
|
+
YAML.dump({
|
22
|
+
'timestamp' => Time.now.utc.iso8601,
|
23
|
+
'title' => @title,
|
24
|
+
'public' => @public
|
25
|
+
}.merge(template))
|
26
|
+
end
|
27
|
+
|
28
|
+
def template
|
29
|
+
template_path = File.join(Logchange.configuration.changelog_directory_path, 'template.yaml')
|
30
|
+
return {} unless File.exists?(template_path)
|
31
|
+
YAML.load(File.read(template_path))
|
32
|
+
end
|
33
|
+
|
34
|
+
def filename
|
35
|
+
"#{datetime}-#{simplified_title}.yaml"
|
36
|
+
end
|
37
|
+
|
38
|
+
def simplified_title
|
39
|
+
spaces_dashed = @title.tr(' ', '-')
|
40
|
+
specials_removed = spaces_dashed.gsub(/[^\-0-9A-Za-z]/, '')[0..60]
|
41
|
+
specials_removed.downcase
|
42
|
+
end
|
43
|
+
|
44
|
+
def unreleased_path
|
45
|
+
File.join(Logchange.configuration.changelog_directory_path, 'unreleased')
|
46
|
+
end
|
47
|
+
|
48
|
+
def datetime
|
49
|
+
"#{Time.now.utc.year}#{Time.now.utc.month.to_s.rjust(2, '0')}#{Time.now.utc.day.to_s.rjust(2, '0')}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/logchange.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'logchange/version'
|
2
|
+
require 'logchange/configuration'
|
3
|
+
require 'logchange/dispatch'
|
4
|
+
require 'logchange/initialize'
|
5
|
+
require 'logchange/logger'
|
6
|
+
|
7
|
+
module Logchange
|
8
|
+
class << self
|
9
|
+
attr_writer :configuration
|
10
|
+
|
11
|
+
def configuration
|
12
|
+
@configuration ||= Logchange::Configuration.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def configure
|
16
|
+
yield(configuration)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/logchange.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'logchange/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'logchange'
|
8
|
+
spec.version = Logchange::VERSION
|
9
|
+
spec.authors = ['Hari Gopal']
|
10
|
+
spec.email = ['mail@harigopal.in']
|
11
|
+
|
12
|
+
spec.summary = 'An alternative approach to managing a changelog.'
|
13
|
+
spec.description = 'Logs changes to individual YAML files and offers a release mechanism.'
|
14
|
+
spec.homepage = 'https://github.com/harigopal/logchange'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
|
21
|
+
spec.required_ruby_version = '>= 2.2.0'
|
22
|
+
spec.bindir = 'exe'
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ['lib']
|
25
|
+
|
26
|
+
spec.add_development_dependency 'bundler', '~> 1.14'
|
27
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
29
|
+
spec.add_development_dependency 'pry', '~> 0.10'
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logchange
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Hari Gopal
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-05-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.14'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.14'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.10'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.10'
|
69
|
+
description: Logs changes to individual YAML files and offers a release mechanism.
|
70
|
+
email:
|
71
|
+
- mail@harigopal.in
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/console
|
84
|
+
- bin/logchange
|
85
|
+
- lib/logchange.rb
|
86
|
+
- lib/logchange/configuration.rb
|
87
|
+
- lib/logchange/dispatch.rb
|
88
|
+
- lib/logchange/initialize.rb
|
89
|
+
- lib/logchange/logger.rb
|
90
|
+
- lib/logchange/release.rb
|
91
|
+
- lib/logchange/version.rb
|
92
|
+
- logchange.gemspec
|
93
|
+
homepage: https://github.com/harigopal/logchange
|
94
|
+
licenses:
|
95
|
+
- MIT
|
96
|
+
metadata: {}
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: 2.2.0
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
requirements: []
|
112
|
+
rubyforge_project:
|
113
|
+
rubygems_version: 2.6.11
|
114
|
+
signing_key:
|
115
|
+
specification_version: 4
|
116
|
+
summary: An alternative approach to managing a changelog.
|
117
|
+
test_files: []
|