logchange 0.0.2 → 0.0.3

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: fbb503711f7f99daa59a349a06ab5cff1181d8b0
4
- data.tar.gz: cd98aaf7e2dec7877bcb0319f44f3012faebe9aa
3
+ metadata.gz: 597a7cbd6d976eb5570297e794b945a45335cd7c
4
+ data.tar.gz: a2ba139b4f28bc53c3605359a11b945709dae056
5
5
  SHA512:
6
- metadata.gz: 8cbf29f028730e470c8cca827ab6c0b06230e0670e200fda7943f6f42b4014d22339d69d8ec0a52d81c949e9c466af3b0434441b9cff13b8a33636acc3956b17
7
- data.tar.gz: 1e2df6b2c579cd13e7972e74b4009cb4c24eab6c530e4a2af2f96bac808fedf23ffd168c18279b07163a82199f55d02978cc4755bc80a93a503221101cf5670e
6
+ metadata.gz: dc2d8ced37426c7d2a3934b83086f8e3ccd276aaf1af4873f7ce7934d3c91c2aeecec5c91136fec89f353b68540f743b31259b77b45b7b25306d21d37c8c22c1
7
+ data.tar.gz: b818cd56ed32b2b68c94550fcebbc42edaa5e7ac8d24ac28c3b0b4b410765b92721438012a711e2bc5570d6090eae80d7b77d39cd82ab9c4b3e26f972bd8a404
data/README.md CHANGED
@@ -11,7 +11,7 @@ timed releases, depending on what your project needs. New entries are kept in `c
11
11
  command is used to append it to `changelog/YEAR.yaml` file.
12
12
 
13
13
  This repository's _changelog_ is maintained using _logchange_. See the automatically generated `changelog/2017.yaml`.
14
- Unreleased changes go to `changelog/unreleased`.
14
+ Unreleased changes (if any) go to `changelog/unreleased`.
15
15
 
16
16
  ## Why?
17
17
 
@@ -39,7 +39,7 @@ Or install the gem with:
39
39
  If you've just completed work on a feature, log it with:
40
40
 
41
41
  $ logchange new "A cool new feature has been added"
42
- Created [..]/changelog/unreleased/20170521-a-cool-new-feature-has-been-added.yml`
42
+ Created [..]/changelog/unreleased/20170521-a-cool-new-feature-has-been-added.yml
43
43
 
44
44
  This will create a new timestamped `.yaml` file in the `changelog/unreleased` folder.
45
45
 
@@ -48,7 +48,7 @@ timestamp: 2017-05-21T06:45:08Z
48
48
  title: The title for your change goes here.
49
49
  ```
50
50
 
51
- To extend the default template used, create a `changelog/template.yaml` file. See customization instructions below.
51
+ To extend the default template used, create `changelog/template.yaml`. See customization instructions below.
52
52
 
53
53
  To _release_ all new _public_ changes to the flat file, run:
54
54
 
@@ -61,7 +61,7 @@ and the time of release will be recorded. You can optionally specify a _tag_ suc
61
61
 
62
62
  This will group current set of changes and add a `tag` key along with the release `timestamp`.
63
63
 
64
- ## Customize the template
64
+ ### Customize the template
65
65
 
66
66
  Create a `changelog/template.yaml` file to add additional keys for information that you'd like to track in your project.
67
67
 
@@ -70,14 +70,27 @@ Create a `changelog/template.yaml` file to add additional keys for information t
70
70
  # You can add any number of additional keys - this depends on your workflow.
71
71
  # A few examples are below.
72
72
 
73
- description: >
74
- Add more detailed information
75
- that spans multiple lines.
76
-
73
+ description: Add more detailed information about the change?
77
74
  github_issue_link: Add link to related Github issue.
78
- private: Hide this change from the public?
75
+ private: Hide this change from the public? Set to true or false.
79
76
  ```
80
77
 
78
+ ### Interactive mode
79
+
80
+ If the template is customized, you can use Logchange's interactive mode to supply required data, instead of passing it
81
+ directly via the command:
82
+
83
+ $ logchange new
84
+ title: A cool new feature has been added.
85
+
86
+ github_issue_link: Add link to related Github issue.
87
+ https://github.com/harigopal/logchange/issues/1
88
+
89
+ private: Hide this change from the public? Set to true or false.
90
+ false
91
+
92
+ Created [..]/changelog/unreleased/20170521-a-cool-new-feature-has-been-added.yml
93
+
81
94
  ## Development
82
95
 
83
96
  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.
data/changelog/2017.yaml CHANGED
@@ -1,5 +1,10 @@
1
1
  ---
2
2
  changelog:
3
+ - timestamp: '2017-05-23T15:42:28Z'
4
+ tag: v0.0.3
5
+ changes:
6
+ - timestamp: '2017-05-23T15:42:04Z'
7
+ title: Add the ability to interactively accept user input to form changelog.
3
8
  - timestamp: '2017-05-22T17:26:09Z'
4
9
  tag: v0.0.2
5
10
  changes:
data/lib/logchange.rb CHANGED
@@ -3,6 +3,7 @@ require 'logchange/configuration'
3
3
  require 'logchange/dispatch'
4
4
  require 'logchange/initialize'
5
5
  require 'logchange/logger'
6
+ require 'logchange/interactive_logger'
6
7
  require 'logchange/release'
7
8
 
8
9
  module Logchange
@@ -8,7 +8,11 @@ module Logchange
8
8
  when :init
9
9
  Logchange::Initialize.new.execute
10
10
  when :new
11
- Logchange::Logger.new(ARGV[1]).execute
11
+ if ARGV[1].nil?
12
+ Logchange::InteractiveLogger.new.execute
13
+ else
14
+ Logchange::Logger.new(ARGV[1]).execute
15
+ end
12
16
  when :release
13
17
  Logchange::Release.new(ARGV[1]).execute
14
18
  else
@@ -0,0 +1,49 @@
1
+ require_relative 'template'
2
+
3
+ module Logchange
4
+ class InteractiveLogger
5
+ def initialize
6
+ @title = nil
7
+ @template = {}
8
+ end
9
+
10
+ def execute
11
+ input_title
12
+
13
+ template = Logchange::Template.load
14
+
15
+ template.each do |key, value|
16
+ input(key, value)
17
+ end
18
+
19
+ Logchange::Logger.new(@title, template: @template).execute
20
+ end
21
+
22
+ private
23
+
24
+ def input_title
25
+ while @title.nil?
26
+ print 'title: '
27
+ @title = STDIN.gets.chomp
28
+
29
+ if @title.length.zero?
30
+ puts "Title cannot be blank.\n\n"
31
+ @title = nil
32
+ end
33
+ end
34
+ end
35
+
36
+ def input(key, value)
37
+ puts "#{key}: #{value}"
38
+ user_input = STDIN.gets.chomp
39
+
40
+ # Preserve booleans.
41
+ if %w[true false].include?(user_input)
42
+ user_input = (user_input == 'true')
43
+ end
44
+
45
+ @template[key] = user_input
46
+ puts "\n"
47
+ end
48
+ end
49
+ end
@@ -1,11 +1,14 @@
1
1
  require 'yaml'
2
2
  require 'time'
3
3
 
4
+ require_relative 'template'
5
+
4
6
  module Logchange
5
7
  # Logs a new change.
6
8
  class Logger
7
- def initialize(title)
9
+ def initialize(title, template: Logchange::Template.load)
8
10
  @title = title
11
+ @template = template
9
12
  end
10
13
 
11
14
  def execute
@@ -20,13 +23,7 @@ module Logchange
20
23
  YAML.dump({
21
24
  'timestamp' => Time.now.utc.iso8601,
22
25
  'title' => @title
23
- }.merge(template))
24
- end
25
-
26
- def template
27
- template_path = File.join(Logchange.configuration.changelog_directory_path, 'template.yaml')
28
- return {} unless File.exist?(template_path)
29
- YAML.load(File.read(template_path))
26
+ }.merge(@template))
30
27
  end
31
28
 
32
29
  def filename
@@ -0,0 +1,9 @@
1
+ module Logchange
2
+ class Template
3
+ def self.load
4
+ template_path = File.join(Logchange.configuration.changelog_directory_path, 'template.yaml')
5
+ return {} unless File.exist?(template_path)
6
+ YAML.load(File.read(template_path))
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module Logchange
2
- VERSION = -'0.0.2'
2
+ VERSION = -'0.0.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logchange
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hari Gopal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-22 00:00:00.000000000 Z
11
+ date: 2017-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -88,8 +88,10 @@ files:
88
88
  - lib/logchange/configuration.rb
89
89
  - lib/logchange/dispatch.rb
90
90
  - lib/logchange/initialize.rb
91
+ - lib/logchange/interactive_logger.rb
91
92
  - lib/logchange/logger.rb
92
93
  - lib/logchange/release.rb
94
+ - lib/logchange/template.rb
93
95
  - lib/logchange/version.rb
94
96
  - logchange.gemspec
95
97
  homepage: https://github.com/harigopal/logchange