changi 0.2.1 → 0.2.2

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: 0d7fbfb1689d7effa8bed7d6ca6ca66073b6f31f
4
- data.tar.gz: c436fe107d78b2479e66f578e0a92ba783eb3344
3
+ metadata.gz: cca32b966703139ad94bf778717d6710bfb80aac
4
+ data.tar.gz: 607d733dce85ede99d73368ba03e9ecb4284d26d
5
5
  SHA512:
6
- metadata.gz: c4e10adc77fde7170e214922b6a9845f17a0af8d4b039bb53944076e424287e126c4236ca66480da5ebf0b46f9f5534a4b1135f86929808c36cbd71ec886da23
7
- data.tar.gz: 0e8c75ba30d82a81ff03acfd492db5f8f3cd4abb75628ce3f85a15450722b748f0ab7c9d58201d09ed26d75b5fe626b4889ab49bcd859e9e8e4a17c6b6274ebf
6
+ metadata.gz: b6a866ca18edb40ed3f9911a8f02ea13cb732f213e6b37718048733bd5bf072a8585584e383a25b065dee8d169261a6fa6f6a37e4a838c91251f083438424de9
7
+ data.tar.gz: 653b5e814348386f29cf17725a88da47c6efe35f60777cf0054b79a97798dde907de05b2483f6ed6a86cb12de86baffe922c0b6be77a67c7e9673889a50a837e
@@ -14,7 +14,7 @@ module Changi
14
14
  config.updater = Updater::PrependUpdater
15
15
  config.changelog_template = <<-eod
16
16
  # <%= release.version %>, <%= Time.now.strftime('%Y-%m-%d') %><%= release.notes and ", \#{release.notes}" %>
17
- <% entry_set.entries_by_category.each do |category, entries| %>
17
+ <% entry_set.entries.group_by(&:category).each do |category, entries| %>
18
18
  ## <%= category %>
19
19
 
20
20
  <%=
data/lib/changi/entry.rb CHANGED
@@ -6,11 +6,11 @@ module Changi
6
6
 
7
7
  class << self
8
8
  def build entry_set, yaml_path
9
- new(entry_set, yaml_path).tap &:read_in_attributes
9
+ new(entry_set, yaml_path).tap(&:read_in_attributes)
10
10
  end
11
11
 
12
12
  def load entry_set, yaml_path
13
- new(entry_set, yaml_path).tap &:read_in_yaml
13
+ new(entry_set, yaml_path).tap(&:read_in_yaml)
14
14
  end
15
15
  end
16
16
 
@@ -34,9 +34,7 @@ module Changi
34
34
  end
35
35
 
36
36
  def destroy
37
- unless system "git rm '#{@path}' >/dev/null 2>&1"
38
- FileUtils.rm_f @path
39
- end
37
+ git_rm || file_rm
40
38
  end
41
39
 
42
40
  private
@@ -44,5 +42,13 @@ module Changi
44
42
  def to_yaml
45
43
  self.class.attribute_names.map { |name| [name, send(name.to_sym)] }.to_h.to_yaml
46
44
  end
45
+
46
+ def git_rm
47
+ system "git rm '#{@path}' >/dev/null 2>&1"
48
+ end
49
+
50
+ def file_rm
51
+ FileUtils.rm_f @path
52
+ end
47
53
  end
48
54
  end
@@ -17,16 +17,12 @@ module Changi
17
17
  @entries ||= yamls.map { |yml| Entry.load self, yml }
18
18
  end
19
19
 
20
- def entries_by_category
21
- entries.group_by &:category
22
- end
23
-
24
20
  def previous_categories
25
- entries.map &:category
21
+ entries.map(&:category)
26
22
  end
27
23
 
28
24
  def destroy_all
29
- entries.each &:destroy
25
+ entries.each(&:destroy)
30
26
  end
31
27
 
32
28
  private
@@ -40,10 +36,12 @@ module Changi
40
36
  end
41
37
 
42
38
  def make_entry_name
43
- if git_branch = `git rev-parse --abbrev-ref HEAD 2>/dev/null`.strip
44
- "#{Time.now.strftime('%y%m%d%H%M%S')}_from_#{git_branch}.yml"
45
- else
39
+ git_branch = `git rev-parse --abbrev-ref HEAD 2>/dev/null`.strip
40
+
41
+ if git_branch.empty?
46
42
  "#{Time.now.strftime('%y%m%d%H%M%S')}.yml"
43
+ else
44
+ "#{Time.now.strftime('%y%m%d%H%M%S')}_from_#{git_branch}.yml"
47
45
  end
48
46
  end
49
47
  end
@@ -14,7 +14,7 @@ module Changi
14
14
 
15
15
  attributes << {
16
16
  name: name,
17
- reader: (block_given? ? block : ->(*args) { reader.new.read *args }),
17
+ reader: (block_given? ? block : ->(*args) { reader.new.read(*args) }),
18
18
  opts: opts
19
19
  }
20
20
  end
@@ -2,11 +2,11 @@ module Changi
2
2
  module Reader
3
3
  class CategoryReader < StringReader
4
4
  def read attribute, owner
5
- fail 'CategoryReader can only be used for Entry attributes.' unless owner.is_a? Entry
5
+ raise 'CategoryReader can only be used for Entry attributes.' unless owner.is_a? Entry
6
6
 
7
7
  cli.say "#{attribute[:name].capitalize}:\n"
8
8
  cli.choose do |menu|
9
- menu.choices *categories(owner.entry_set)
9
+ menu.choices(*categories(owner.entry_set))
10
10
  menu.choice 'Other (create new)' do
11
11
  cli.ask "Please insert #{attribute[:name]}:"
12
12
  end
@@ -3,7 +3,7 @@ require 'tempfile'
3
3
  module Changi
4
4
  module Reader
5
5
  class MultilineReader
6
- def read attribute, owner
6
+ def read attribute, _
7
7
  tmpfile = Tempfile.new 'changi'
8
8
 
9
9
  intro tmpfile, attribute
@@ -28,8 +28,8 @@ module Changi
28
28
  tmpfile.puts
29
29
  tmpfile.puts
30
30
  tmpfile.puts "# Please enter #{attribute[:name]} above."
31
- tmpfile.puts "# Lines starting with # will be ignored."
32
- tmpfile.puts "# Empty tmpfile will abort the process." if attribute[:opts][:required]
31
+ tmpfile.puts '# Lines starting with # will be ignored.'
32
+ tmpfile.puts '# Empty tmpfile will abort the process.' if attribute[:opts][:required]
33
33
  tmpfile.sync
34
34
  tmpfile.close
35
35
  end
@@ -42,7 +42,7 @@ module Changi
42
42
 
43
43
  def editor
44
44
  editor_tests.lazy.map(&:call).find { |e| !(e.nil? || e.empty?) }.tap do |e|
45
- fail 'could not detect editor' unless e
45
+ raise 'could not detect editor' unless e
46
46
  end
47
47
  end
48
48
 
@@ -3,7 +3,7 @@ require 'highline'
3
3
  module Changi
4
4
  module Reader
5
5
  class StringReader
6
- def read attribute, owner
6
+ def read attribute, _
7
7
  cli.ask("#{attribute[:name]}: ").tap do |x|
8
8
  if attribute[:opts][:required] && [nil, ''].include?(x)
9
9
  abort "required #{attribute[:name]} attribute empty, abort"
@@ -4,7 +4,7 @@ module Changi
4
4
 
5
5
  class << self
6
6
  def build
7
- new.tap &:read_in_attributes
7
+ new.tap(&:read_in_attributes)
8
8
  end
9
9
 
10
10
  def demo
@@ -6,7 +6,7 @@ module Changi
6
6
  attr_reader :release
7
7
 
8
8
  def initialize config, entry_set, release
9
- @config = config
9
+ @config = config
10
10
  @entry_set = entry_set
11
11
  @release = release
12
12
  end
@@ -2,7 +2,7 @@ module Changi
2
2
  module Updater
3
3
  class PrependUpdater
4
4
  def update changelog_path, release_data
5
- previous = File.read changelog_path if File.exists? changelog_path
5
+ previous = File.read changelog_path if File.exist? changelog_path
6
6
 
7
7
  File.open changelog_path, 'w' do |fd|
8
8
  fd.puts release_data
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: changi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mobisol GmbH
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-13 00:00:00.000000000 Z
11
+ date: 2016-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -58,7 +58,7 @@ files:
58
58
  - lib/changi/renderer.rb
59
59
  - lib/changi/tasks.rb
60
60
  - lib/changi/updater/prepend_updater.rb
61
- homepage: https://github.org/plugintheworld/changi
61
+ homepage: https://github.com/plugintheworld/changi
62
62
  licenses:
63
63
  - MIT
64
64
  metadata: {}