kamaze-project 1.0.4 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +9 -9
  3. data/lib/kamaze-project.rb +1 -30
  4. data/lib/kamaze/project.rb +37 -31
  5. data/lib/kamaze/project/autoload.rb +38 -0
  6. data/lib/kamaze/project/boot/core_ext.rb +8 -8
  7. data/lib/kamaze/project/boot/listen.rb +11 -13
  8. data/lib/kamaze/project/bundled.rb +79 -0
  9. data/lib/kamaze/project/concern.rb +17 -2
  10. data/lib/kamaze/project/concern/cli.rb +4 -1
  11. data/lib/kamaze/project/concern/cli/with_exit_on_failure.rb +2 -6
  12. data/lib/kamaze/project/concern/env.rb +14 -12
  13. data/lib/kamaze/project/concern/helper.rb +1 -2
  14. data/lib/kamaze/project/concern/mode.rb +1 -1
  15. data/lib/kamaze/project/concern/observable.rb +12 -11
  16. data/lib/kamaze/project/concern/sh.rb +7 -7
  17. data/lib/kamaze/project/concern/tasks.rb +36 -10
  18. data/lib/kamaze/project/concern/tools.rb +2 -3
  19. data/lib/kamaze/project/config.rb +1 -1
  20. data/lib/kamaze/project/core_ext/object.rb +17 -8
  21. data/lib/kamaze/project/core_ext/pp.rb +14 -16
  22. data/lib/kamaze/project/debug.rb +40 -49
  23. data/lib/kamaze/project/dsl.rb +9 -5
  24. data/lib/kamaze/project/dsl/definition.rb +6 -12
  25. data/lib/kamaze/project/dsl/setup.rb +1 -3
  26. data/lib/kamaze/project/helper.rb +1 -1
  27. data/lib/kamaze/project/helper/inflector.rb +9 -27
  28. data/lib/kamaze/project/helper/project.rb +1 -1
  29. data/lib/kamaze/project/helper/project/config.rb +1 -1
  30. data/lib/kamaze/project/inflector.rb +15 -0
  31. data/lib/kamaze/project/observable.rb +1 -4
  32. data/lib/kamaze/project/observer.rb +1 -1
  33. data/lib/kamaze/project/resources/Vagrantfile +1 -1
  34. data/lib/kamaze/project/struct.rb +1 -1
  35. data/lib/kamaze/project/tasks/cs.rb +1 -1
  36. data/lib/kamaze/project/tasks/cs/control.rb +1 -1
  37. data/lib/kamaze/project/tasks/cs/correct.rb +1 -1
  38. data/lib/kamaze/project/tasks/cs/pre_commit.rb +4 -6
  39. data/lib/kamaze/project/tasks/doc.rb +2 -4
  40. data/lib/kamaze/project/tasks/doc/watch.rb +4 -6
  41. data/lib/kamaze/project/tasks/gem.rb +15 -6
  42. data/lib/kamaze/project/tasks/gem/build.rb +33 -17
  43. data/lib/kamaze/project/tasks/gem/compile.rb +1 -1
  44. data/lib/kamaze/project/tasks/gem/gemspec.rb +12 -11
  45. data/lib/kamaze/project/tasks/gem/install.rb +1 -1
  46. data/lib/kamaze/project/tasks/gem/push.rb +16 -17
  47. data/lib/kamaze/project/tasks/misc/gitignore.rb +1 -1
  48. data/lib/kamaze/project/tasks/shell.rb +1 -1
  49. data/lib/kamaze/project/tasks/sources.rb +1 -1
  50. data/lib/kamaze/project/tasks/sources/license.rb +1 -1
  51. data/lib/kamaze/project/tasks/test.rb +3 -5
  52. data/lib/kamaze/project/tasks/vagrant.rb +1 -1
  53. data/lib/kamaze/project/tasks/version/edit.rb +1 -1
  54. data/lib/kamaze/project/tools.rb +18 -6
  55. data/lib/kamaze/project/tools/base_tool.rb +6 -2
  56. data/lib/kamaze/project/tools/console.rb +4 -13
  57. data/lib/kamaze/project/tools/console/output.rb +14 -6
  58. data/lib/kamaze/project/tools/console/output/buffer.rb +8 -3
  59. data/lib/kamaze/project/tools/gemspec.rb +11 -21
  60. data/lib/kamaze/project/tools/gemspec/builder.rb +43 -31
  61. data/lib/kamaze/project/tools/gemspec/concern.rb +6 -1
  62. data/lib/kamaze/project/tools/gemspec/concern/reading.rb +2 -5
  63. data/lib/kamaze/project/tools/gemspec/packager.rb +10 -10
  64. data/lib/kamaze/project/tools/gemspec/packer.rb +11 -15
  65. data/lib/kamaze/project/tools/gemspec/packer/command.rb +1 -1
  66. data/lib/kamaze/project/tools/gemspec/reader.rb +22 -14
  67. data/lib/kamaze/project/tools/gemspec/reader/decorator.rb +3 -6
  68. data/lib/kamaze/project/tools/gemspec/writer.rb +43 -19
  69. data/lib/kamaze/project/tools/gemspec/writer/dep_gen.rb +9 -6
  70. data/lib/kamaze/project/tools/gemspec/writer/dependency.rb +1 -1
  71. data/lib/kamaze/project/tools/git.rb +13 -31
  72. data/lib/kamaze/project/tools/git/hooks.rb +12 -6
  73. data/lib/kamaze/project/tools/git/hooks/base_hook.rb +3 -11
  74. data/lib/kamaze/project/tools/git/hooks/pre_commit.rb +3 -7
  75. data/lib/kamaze/project/tools/git/status.rb +13 -9
  76. data/lib/kamaze/project/tools/git/status/decorator.rb +1 -1
  77. data/lib/kamaze/project/tools/git/status/file.rb +2 -1
  78. data/lib/kamaze/project/tools/git/status/files_array.rb +1 -1
  79. data/lib/kamaze/project/tools/git/status/index.rb +1 -1
  80. data/lib/kamaze/project/tools/git/status/worktree.rb +1 -1
  81. data/lib/kamaze/project/tools/git/util.rb +1 -1
  82. data/lib/kamaze/project/tools/licenser.rb +2 -2
  83. data/lib/kamaze/project/tools/packager.rb +12 -22
  84. data/lib/kamaze/project/tools/packager/filesystem.rb +11 -3
  85. data/lib/kamaze/project/tools/packager/filesystem/operator.rb +19 -11
  86. data/lib/kamaze/project/tools/packager/filesystem/operator/utils.rb +22 -16
  87. data/lib/kamaze/project/tools/process_locker.rb +67 -38
  88. data/lib/kamaze/project/tools/rspec.rb +5 -3
  89. data/lib/kamaze/project/tools/rubocop.rb +30 -41
  90. data/lib/kamaze/project/tools/rubocop/arguments.rb +1 -1
  91. data/lib/kamaze/project/tools/rubocop/config.rb +2 -4
  92. data/lib/kamaze/project/tools/shell.rb +7 -8
  93. data/lib/kamaze/project/tools/vagrant.rb +6 -16
  94. data/lib/kamaze/project/tools/vagrant/composer.rb +1 -1
  95. data/lib/kamaze/project/tools/vagrant/composer/file.rb +1 -1
  96. data/lib/kamaze/project/tools/vagrant/remote.rb +1 -1
  97. data/lib/kamaze/project/tools/vagrant/shell.rb +1 -1
  98. data/lib/kamaze/project/tools/vagrant/writer.rb +1 -1
  99. data/lib/kamaze/project/tools/yardoc.rb +14 -18
  100. data/lib/kamaze/project/tools/yardoc/file.rb +7 -7
  101. data/lib/kamaze/project/tools/yardoc/watchable.rb +9 -15
  102. data/lib/kamaze/project/tools/yardoc/watcher.rb +28 -35
  103. data/lib/kamaze/project/tools_provider.rb +28 -40
  104. data/lib/kamaze/project/tools_provider/resolver.rb +1 -1
  105. data/lib/kamaze/project/version.rb +5 -91
  106. data/lib/kamaze/project/version.yml +6 -6
  107. metadata +23 -51
  108. data/.rubocop.yml +0 -37
  109. data/bin/plop +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f0e2ae276b151393bd708be9998316505347439ac05a5242d6820731e84b7b56
4
- data.tar.gz: 65fb72404120d12a4e3919a8ee477a90f66dbca9dbe684d26789eeb5450b1b39
3
+ metadata.gz: 73295f0f7906e0a30f2e93dc9b21f85bc52d8e86549b6b8f83815ec627ee1d48
4
+ data.tar.gz: 1ec30804e058002c7e573113584128c990766141cf4da77cba508aba99637b76
5
5
  SHA512:
6
- metadata.gz: 4a2768ac776e57cf07bf74b73ea932679b9faa6e95b64ded489f856ba7ab31f2889aa595793cea31e63542a7bc509b55f0e334d0fc0bd714dd36b03c90f37d2f
7
- data.tar.gz: fc80a5aa6b5cfdcdde647a678378115d4df55423daf71edc807ccb2856101d445f0e57e20ba859f486ed5abff0ab82935e903ac9fc690ac95aa83b8966aa1db5
6
+ metadata.gz: 473533f87853e0ccbdf50215f512253cfd81c9179f4dccd88a1001403b63440ab49b496a62f94bf10a94dc2d93e3820029ac2c403dcf967cf3a14efe028ee976
7
+ data.tar.gz: 0245a0642542dd33d33764528d43234921bc78031d1ed06748602a0fd671c28931de47b9aa0e98d81211312bdd7949b06fcdf4f2c355d620a20d6acc9a3f461a
data/.yardopts CHANGED
@@ -1,16 +1,16 @@
1
1
  # vim: ft=sh
2
2
 
3
- lib/**/*.rb \
4
- --no-progress \
5
- --markup-provider 'redcarpet' \
6
- --markup 'markdown' \
7
- --charset 'utf-8' \
8
- --protected --private --embed-mixins \
9
- --tag type:'type' --hide-tag 'type' \
10
- --readme README.md \
3
+ lib/**/*.rb \
4
+ --no-progress \
5
+ --markup-provider 'redcarpet' \
6
+ --markup 'markdown' \
7
+ --charset 'utf-8' \
8
+ --protected --private --embed-mixins \
9
+ --tag type:'type' --hide-tag 'type' \
10
+ --readme README.md \
11
11
  --exclude 'lib/kamaze/project/tasks/.*' \
12
12
  --exclude 'lib/kamaze/project/boot/.*' \
13
- --exclude '_flymake\\.rb$' \
13
+ --exclude '_flymake\\.rb$' \
14
14
  --exclude '/\\.#'
15
15
 
16
16
  # Local Variables:
@@ -1,38 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (C) 2017-2018 Dimitri Arrigoni <dimitri@arrigoni.me>
3
+ # Copyright (C) 2017-2021 Dimitri Arrigoni <dimitri@arrigoni.me>
4
4
  # License GPLv3+: GNU GPL version 3 or later
5
5
  # <http://www.gnu.org/licenses/gpl.html>.
6
6
  # This is free software: you are free to change and redistribute it.
7
7
  # There is NO WARRANTY, to the extent permitted by law.
8
8
 
9
9
  $LOAD_PATH.unshift(__dir__)
10
-
11
- lock = Dir.chdir("#{__dir__}/..") do
12
- [['gems.rb', 'gems.locked'], ['Gemfile', 'Gemfile.lock']]
13
- .map { |m| Dir.glob(m).size >= 2 }
14
- .include?(true)
15
- end
16
-
17
- if lock
18
- require 'rubygems'
19
- require 'bundler/setup'
20
- end
21
-
22
- if lock and :development == (ENV['PROJECT_MODE'] || 'development').to_sym
23
- bootsnap_config = {
24
- cache_dir: "#{__dir__}/../cache",
25
- development_mode: true,
26
- load_path_cache: true,
27
- autoload_paths_cache: false,
28
- disable_trace: true,
29
- compile_cache_iseq: true,
30
- compile_cache_yaml: true,
31
- }
32
-
33
- require 'yaml'
34
- unless YAML.safe_load(ENV['BOOTSNAP_DISABLE'].to_s)
35
- require 'bootsnap'
36
- Bootsnap.setup(bootsnap_config)
37
- end
38
- end
@@ -1,49 +1,38 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (C) 2017-2018 Dimitri Arrigoni <dimitri@arrigoni.me>
3
+ # Copyright (C) 2017-2021 Dimitri Arrigoni <dimitri@arrigoni.me>
4
4
  # License GPLv3+: GNU GPL version 3 or later
5
5
  # <http://www.gnu.org/licenses/gpl.html>.
6
6
  # This is free software: you are free to change and redistribute it.
7
7
  # There is NO WARRANTY, to the extent permitted by law.
8
8
 
9
- require 'pathname'
10
-
11
- # Base module (almost a namespace)
9
+ # Kamaze namesapace
12
10
  module Kamaze
13
- # rubocop:disable Style/Documentation
14
-
15
- class Project
16
- module Concern
17
- [nil, :env, :mode, :helper,
18
- :tasks, :tools].each do |req|
19
- require_relative "project/concern/#{req}".gsub(%r{/$}, '')
20
- end
21
- end
22
-
23
- require_relative 'project/version'
24
-
25
- VERSION = Version.new.freeze
26
-
27
- # @see Kamaze::Project::Version
28
- # @return [Object]
29
- def version
30
- subject.const_get('VERSION')
11
+ class Project # rubocop:disable Style/Documentation
12
+ # @formatter:off
13
+ {
14
+ YAML: 'yaml',
15
+ Pathname: 'pathname',
16
+ Autoload: "#{__dir__}/project/autoload"
17
+ }.each { |s, fp| autoload(s, fp) }
18
+ # @formatter:on
19
+
20
+ Autoload.new.call("#{__dir__}/project")
21
+
22
+ include(Bundled).tap do
23
+ self.base_path = self.base_path.join('..')
24
+ require 'bundler/setup' if bundled?
25
+ require_relative './project/core_ext/pp' if development?
31
26
  end
32
27
  end
33
28
 
34
- # rubocop:enable Style/Documentation
35
- end
36
-
37
- # Base namespace
38
- module Kamaze
39
29
  class << self
40
- include Project::Concern::Helper
41
-
42
30
  # Get an instance of project
43
31
  #
32
+ # @deprecated
44
33
  # @return [Kamaze::Project]
45
34
  def project(&block)
46
- helper.get(:project).setup(&block)
35
+ Project.instance(&block)
47
36
  end
48
37
  end
49
38
  end
@@ -65,6 +54,23 @@ class Kamaze::Project
65
54
  include Concern::Tasks
66
55
  include Concern::Tools
67
56
 
57
+ class << self
58
+ include Concern::Helper
59
+
60
+ # Get an instance of project
61
+ #
62
+ # @return [Kamaze::Project]
63
+ def instance(&block)
64
+ helper.get(:project).setup(&block)
65
+ end
66
+ end
67
+
68
+ # @see Kamaze::Project::Version
69
+ # @return [Object]
70
+ def version
71
+ subject.const_get('VERSION')
72
+ end
73
+
68
74
  # Project name
69
75
  #
70
76
  # @return [Symbol]
@@ -121,7 +127,7 @@ class Kamaze::Project
121
127
 
122
128
  # @return [Pathname]
123
129
  def pwd
124
- ::Pathname.new(Dir.pwd)
130
+ Pathname.new(Dir.pwd)
125
131
  end
126
132
 
127
133
  protected
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (C) 2017-2021 Dimitri Arrigoni <dimitri@arrigoni.me>
4
+ # License GPLv3+: GNU GPL version 3 or later
5
+ # <http://www.gnu.org/licenses/gpl.html>.
6
+ # This is free software: you are free to change and redistribute it.
7
+ # There is NO WARRANTY, to the extent permitted by law.
8
+
9
+ # Autoload class
10
+ class Kamaze::Project::Autoload < ::Hash
11
+ def initialize # rubocop:disable Metrics/MethodLength
12
+ # @formatter:off
13
+ {
14
+ VERSION: 'version',
15
+ Bundled: 'bundled',
16
+ Concern: 'concern',
17
+ Config: 'config',
18
+ Debug: 'debug',
19
+ DSL: 'dsl',
20
+ Helper: 'helper',
21
+ Inflector: 'inflector',
22
+ Observable: 'observable',
23
+ Observer: 'observer',
24
+ Struct: 'struct',
25
+ Tools: 'tools',
26
+ ToolsProvider: 'tools_provider',
27
+ }.each { |k, v| self[k] = v }
28
+ # @formatter:on
29
+ end
30
+
31
+ def call(path)
32
+ self.tap do
33
+ self.each do |s, fp|
34
+ Kamaze::Project.__send__(:autoload, s, "#{path}/#{fp}")
35
+ end
36
+ end
37
+ end
38
+ end
@@ -1,16 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (C) 2017-2018 Dimitri Arrigoni <dimitri@arrigoni.me>
3
+ # Copyright (C) 2017-2021 Dimitri Arrigoni <dimitri@arrigoni.me>
4
4
  # License GPLv3+: GNU GPL version 3 or later
5
5
  # <http://www.gnu.org/licenses/gpl.html>.
6
6
  # This is free software: you are free to change and redistribute it.
7
7
  # There is NO WARRANTY, to the extent permitted by law.
8
8
 
9
- {
10
- pp: proc { ENV['PROJECT_MODE'] == 'development' },
11
- object: proc { true },
12
- }.each do |requirement, conditionner|
13
- next unless conditionner.call
14
-
15
- require_relative "../core_ext/#{requirement}"
9
+ # @formatter:off
10
+ [
11
+ ENV['PROJECT_MODE'] =~ /^dev.*/ ? :pp : nil,
12
+ :object,
13
+ ].compact.each do |requirement|
14
+ require "#{__dir__}/../core_ext/#{requirement}"
16
15
  end
16
+ # @formatter:on
@@ -1,18 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (C) 2017-2018 Dimitri Arrigoni <dimitri@arrigoni.me>
3
+ # Copyright (C) 2017-2021 Dimitri Arrigoni <dimitri@arrigoni.me>
4
4
  # License GPLv3+: GNU GPL version 3 or later
5
5
  # <http://www.gnu.org/licenses/gpl.html>.
6
6
  # This is free software: you are free to change and redistribute it.
7
7
  # There is NO WARRANTY, to the extent permitted by law.
8
8
 
9
+ autoload(:YAML, 'yaml')
10
+ autoload(:Gem, 'rubygems')
11
+
9
12
  patchable = lambda do
10
- if Gem::Specification.find_all_by_name('listen').any?
11
- require 'listen'
12
- return YAML.safe_load(ENV['SILENCE_DUPLICATE_DIRECTORY_ERRORS'].to_s)
13
- end
13
+ return false unless Gem::Specification.find_all_by_name('listen').any?
14
14
 
15
- false
15
+ YAML.safe_load(ENV['SILENCE_DUPLICATE_DIRECTORY_ERRORS'].to_s)
16
16
  end
17
17
 
18
18
  # rubocop:disable all
@@ -22,14 +22,12 @@ end
22
22
  # Listen >=2.8
23
23
  # patch to silence duplicate directory errors. USE AT YOUR OWN RISK
24
24
  if patchable.call
25
+ require 'listen'
26
+
25
27
  if Gem::Version.new(Listen::VERSION) >= Gem::Version.new('2.8.0')
26
- module Listen
27
- class Record
28
- class SymlinkDetector
29
- def _fail(_, _)
30
- fail Error, "Don't watch locally-symlinked directory twice"
31
- end
32
- end
28
+ class Listen::Record::SymlinkDetector
29
+ def _fail(_, _)
30
+ fail Error, "Don't watch locally-symlinked directory twice"
33
31
  end
34
32
  end
35
33
  end
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (C) 2017-2021 Dimitri Arrigoni <dimitri@arrigoni.me>
4
+ # License GPLv3+: GNU GPL version 3 or later
5
+ # <http://www.gnu.org/licenses/gpl.html>.
6
+ # This is free software: you are free to change and redistribute it.
7
+ # There is NO WARRANTY, to the extent permitted by law.
8
+
9
+ # Copyright (C) 2019-2020 Dimitri Arrigoni <dimitri@arrigoni.me>
10
+ # License GPLv3+: GNU GPL version 3 or later
11
+ # <http://www.gnu.org/licenses/gpl.html>.
12
+ # This is free software: you are free to change and redistribute it.
13
+ # There is NO WARRANTY, to the extent permitted by law.
14
+
15
+ require_relative('../project')
16
+
17
+ # Bundled behavior.
18
+ #
19
+ # Allow to detect bundled execution due to ``gems.rb`` and ``gems.locked``
20
+ # files presence, and``development`` execution (``gemspec.tpl`` file presence).
21
+ module Kamaze::Project::Bundled
22
+ autoload(:Pathname, 'pathname')
23
+
24
+ class << self
25
+ def included(base)
26
+ base.extend(ClassMethods)
27
+
28
+ Pathname.new(caller_locations.first.path).dirname.tap do |caller_path|
29
+ (base.__send__(:base_path) || caller_path).tap do |basepath|
30
+ base.__send__(:base_path=, Pathname(basepath).join('..'))
31
+ end
32
+ end
33
+ end
34
+ end
35
+
36
+ # Class methods
37
+ module ClassMethods
38
+ protected
39
+
40
+ # Set `base_path` from given `path`.
41
+ #
42
+ # @param [String] path
43
+ # @return [Pathname]
44
+ def base_path=(path)
45
+ @base_path = Pathname.new(path).realpath
46
+ end
47
+
48
+ # @return [Pathname]
49
+ def base_path
50
+ @base_path
51
+ end
52
+
53
+ # Denote current class is used in a bundled context.
54
+ #
55
+ # @return [Boolean]
56
+ def bundled?
57
+ # @formatter:off
58
+ [%w[gems.rb gems.locked], %w[Gemfile Gemfile.lock]].map do |m|
59
+ Dir.chdir(base_path) do
60
+ m.map { |f| Pathname(f).file? }.uniq
61
+ end
62
+ end.include?([true])
63
+ # @formatter:on
64
+ end
65
+
66
+ # Denote current class is used in development context.
67
+ #
68
+ # @return [Boolean]
69
+ def development?
70
+ # @formatter:off
71
+ bundled? and [['gemspec.tpl']].map do |m|
72
+ Dir.chdir(base_path) do
73
+ m.map { |f| Pathname(f).file? }
74
+ end
75
+ end.include?([true])
76
+ # @formatter:on
77
+ end
78
+ end
79
+ end
@@ -1,13 +1,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (C) 2017-2018 Dimitri Arrigoni <dimitri@arrigoni.me>
3
+ # Copyright (C) 2017-2021 Dimitri Arrigoni <dimitri@arrigoni.me>
4
4
  # License GPLv3+: GNU GPL version 3 or later
5
5
  # <http://www.gnu.org/licenses/gpl.html>.
6
6
  # This is free software: you are free to change and redistribute it.
7
7
  # There is NO WARRANTY, to the extent permitted by law.
8
8
 
9
- require 'kamaze/project'
9
+ require_relative '../project'
10
10
 
11
11
  # Namespace for ``Concern``
12
12
  module Kamaze::Project::Concern
13
+ # @formatter:off
14
+ {
15
+ Cli: 'cli',
16
+ Env: 'env',
17
+ Helper: 'helper',
18
+ Mode: 'mode',
19
+ Observable: 'observable',
20
+ Sh: 'sh',
21
+ Tasks: 'tasks',
22
+ }.each { |s, fp| autoload(s, "#{__dir__}/concern/#{fp}") }
23
+ # @formatter:on
24
+
25
+ [nil, :env, :mode, :helper, :tasks, :tools].each do |req|
26
+ require_relative "./concern/#{req}".gsub(%r{/$}, '')
27
+ end
13
28
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (C) 2017-2018 Dimitri Arrigoni <dimitri@arrigoni.me>
3
+ # Copyright (C) 2017-2021 Dimitri Arrigoni <dimitri@arrigoni.me>
4
4
  # License GPLv3+: GNU GPL version 3 or later
5
5
  # <http://www.gnu.org/licenses/gpl.html>.
6
6
  # This is free software: you are free to change and redistribute it.
@@ -12,6 +12,8 @@ require_relative '../concern'
12
12
  #
13
13
  # This module provides base methods focused on ``retcode``.
14
14
  module Kamaze::Project::Concern::Cli
15
+ autoload(:WithExitOnFailure, "#{__dir__}/cli/with_exit_on_failure")
16
+
15
17
  # @!attribute [r] retcode
16
18
  # @return [Fixnum] retcode
17
19
 
@@ -36,6 +38,7 @@ module Kamaze::Project::Concern::Cli
36
38
  #
37
39
  # @return [Boolean]
38
40
  def success?
41
+ # noinspection RubyResolve
39
42
  Errno::NOERROR::Errno == retcode
40
43
  end
41
44
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (C) 2017-2018 Dimitri Arrigoni <dimitri@arrigoni.me>
3
+ # Copyright (C) 2017-2021 Dimitri Arrigoni <dimitri@arrigoni.me>
4
4
  # License GPLv3+: GNU GPL version 3 or later
5
5
  # <http://www.gnu.org/licenses/gpl.html>.
6
6
  # This is free software: you are free to change and redistribute it.
@@ -27,10 +27,6 @@ module Kamaze::Project::Concern::Cli::WithExitOnFailure
27
27
  # @raise [SystemExit]
28
28
  # @return [Object]
29
29
  def with_exit_on_failure
30
- result = yield(self)
31
-
32
- exit(retcode) if failure?
33
-
34
- result
30
+ yield(self).tap { exit(retcode) if failure? }
35
31
  end
36
32
  end