kamaze-project 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +9 -9
  3. data/lib/kamaze-project.rb +1 -31
  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 +3 -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 +47 -48
  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 -36
  88. data/lib/kamaze/project/tools/rspec.rb +5 -3
  89. data/lib/kamaze/project/tools/rubocop.rb +30 -40
  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 -17
  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 -94
  106. data/lib/kamaze/project/version.yml +5 -5
  107. metadata +23 -64
  108. data/bin/plop +0 -5
@@ -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.
@@ -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.
@@ -10,30 +10,18 @@ require_relative '../tools'
10
10
  require_relative 'base_tool'
11
11
  require 'pathname'
12
12
 
13
- # rubocop:disable Style/Documentation
14
-
15
- module Kamaze::Project::Tools
16
- class Git < BaseTool
17
- # @abstract
18
- class Util
19
- end
20
-
21
- class Status
22
- end
23
-
24
- class Hooks < Util
25
- end
26
- end
27
-
28
- [:util,
29
- :hooks,
30
- :status].each { |req| require_relative "git/#{req}" }
31
- end
13
+ # Provide a wrapper based on ``rugged`` (``libgit2``}
14
+ class Kamaze::Project::Tools::Git < Kamaze::Project::Tools::BaseTool
15
+ autoload(:Rugged, 'rugged')
32
16
 
33
- # rubocop:enable Style/Documentation
17
+ # @formatter:off
18
+ {
19
+ Util: 'util',
20
+ Hooks: 'hooks',
21
+ Status: 'status',
22
+ }.each { |k, v| autoload(k, "#{__dir__}/git/#{v}") }
23
+ # @formatter:on
34
24
 
35
- # Provide a wrapper based on ``rugged`` (``libgit2``}
36
- class Kamaze::Project::Tools::Git
37
25
  # @return [String]
38
26
  attr_writer :base_dir
39
27
 
@@ -65,7 +53,7 @@ class Kamaze::Project::Tools::Git
65
53
 
66
54
  # Get status
67
55
  #
68
- # @return [Hash]
56
+ # @return [Status]
69
57
  def status
70
58
  status = {}
71
59
  repository.status { |file, data| status[file] = data }
@@ -84,12 +72,6 @@ class Kamaze::Project::Tools::Git
84
72
 
85
73
  def setup
86
74
  @base_dir ||= Dir.pwd
87
- begin
88
- require 'rugged'
89
- @repository = Rugged::Repository.new(base_dir.to_s)
90
- rescue LoadError, Rugged::RepositoryError
91
- # @todo Load error SHOULD be stored (as a boolean?)
92
- @repository = nil
93
- end
75
+ @repository = Rugged::Repository.new(base_dir.to_s)
94
76
  end
95
77
  end
@@ -1,19 +1,25 @@
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
  require_relative '../git'
10
- require_relative 'hooks/base_hook'
11
10
  require 'kamaze/project/concern/helper'
12
11
 
13
12
  # Provide hooks
14
13
  #
15
14
  # Kind of factory registering and building hooks
16
- class Kamaze::Project::Tools::Git::Hooks
15
+ class Kamaze::Project::Tools::Git::Hooks < Kamaze::Project::Tools::Git::Util
16
+ # @formatter:off
17
+ {
18
+ BaseHook: 'base_hook',
19
+ PreCommit: 'pre_commit',
20
+ }.each { |k, v| autoload(k, "#{__dir__}/hooks/#{v}") }
21
+ # @formatter:on
22
+
17
23
  class << self
18
24
  include Kamaze::Project::Concern::Helper
19
25
 
@@ -43,9 +49,9 @@ class Kamaze::Project::Tools::Git::Hooks
43
49
 
44
50
  [:pre_commit].each { |n| self.class.register(n) }
45
51
 
46
- self.class
47
- .registered_hooks
48
- .each { |name, klass| @hooks[name] = klass.new(repository) }
52
+ self.class.registered_hooks.each do |name, klass|
53
+ @hooks[name] = klass.new(repository)
54
+ end
49
55
  end
50
56
 
51
57
  # @return [Hash]
@@ -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.
@@ -9,18 +9,10 @@
9
9
  require_relative '../hooks'
10
10
  require_relative '../../../concern/cli/with_exit_on_failure'
11
11
 
12
- # rubocop:disable Style/Documentation
13
-
14
- class Kamaze::Project::Tools::Git::Hooks
15
- class BaseHook
16
- include Kamaze::Project::Concern::Cli::WithExitOnFailure
17
- end
18
- end
19
-
20
- # rubocop:enable Style/Documentation
21
-
22
12
  # Base Hook
23
13
  class Kamaze::Project::Tools::Git::Hooks::BaseHook
14
+ include Kamaze::Project::Concern::Cli::WithExitOnFailure
15
+
24
16
  # @param [Kamaze::Project::Tools::Git] repository
25
17
  def initialize(repository)
26
18
  @repository = repository
@@ -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.
@@ -9,11 +9,6 @@
9
9
  require_relative '../hooks'
10
10
  require_relative 'base_hook'
11
11
 
12
- class Kamaze::Project::Tools::Git::Hooks
13
- class PreCommit < BaseHook
14
- end
15
- end
16
-
17
12
  # PreCommit hook
18
13
  #
19
14
  # Provide helper methods intended to write hooks relating to pre-commit
@@ -29,7 +24,7 @@ end
29
24
  # exit(retcode) unless retcode.zero?
30
25
  # end
31
26
  # ```
32
- class Kamaze::Project::Tools::Git::Hooks::PreCommit
27
+ class Kamaze::Project::Tools::Git::Hooks::PreCommit < Kamaze::Project::Tools::Git::Hooks::BaseHook
33
28
  # Process index (files)
34
29
  #
35
30
  # Exits with a status code, raising ``SystemExit``.
@@ -72,6 +67,7 @@ class Kamaze::Project::Tools::Git::Hooks::PreCommit
72
67
  options[key] = options.keys.include?(key) ? !!options[key] : false
73
68
 
74
69
  next if options[key]
70
+
75
71
  self.retcode = v.const_get(:Errno) if index.public_send("#{type}?")
76
72
  end
77
73
  end
@@ -1,17 +1,12 @@
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
  require_relative '../git'
10
- require_relative 'status/file'
11
- require_relative 'status/index'
12
- require_relative 'status/worktree'
13
- require_relative 'status/decorator'
14
- require 'pathname'
15
10
 
16
11
  # Provide status
17
12
  #
@@ -22,6 +17,17 @@ require 'pathname'
22
17
  #
23
18
  # @see Kamaze::Project::Tools::Git::Status::File
24
19
  class Kamaze::Project::Tools::Git::Status
20
+ autoload(:Pathname, 'pathname')
21
+
22
+ # @formatter:off
23
+ {
24
+ File: 'file',
25
+ Index: 'index',
26
+ Worktree: 'worktree',
27
+ Decorator: 'decorator',
28
+ }.each { |k, v| autoload(k, "#{__dir__}/status/#{v}") }
29
+ # @formatter:on
30
+
25
31
  # @return [Pathname]
26
32
  attr_reader :base_dir
27
33
 
@@ -77,9 +83,7 @@ class Kamaze::Project::Tools::Git::Status
77
83
  #
78
84
  # @return [Hash]
79
85
  def cached
80
- @cached ||= prepared
81
-
82
- @cached
86
+ (@cached ||= prepared)
83
87
  end
84
88
 
85
89
  # Get prepared filepaths with symbols (states)
@@ -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.
@@ -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.
@@ -45,6 +45,7 @@ class Kamaze::Project::Tools::Git::Status::File
45
45
  # @return [String]
46
46
  def status
47
47
  return '??' if untracked?
48
+
48
49
  states = [' ', ' ']
49
50
  mapping = { new: 'A', modified: 'M', deleted: 'D' }
50
51
  { index: 0, worktree: 1 }.each do |from, index|
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -170,7 +170,7 @@ class Kamaze::Project::Tools::Licenser < Kamaze::Project::Tools::BaseTool
170
170
  # @return [Pathname] file
171
171
  def apply_license(file)
172
172
  content = file.read
173
- licensable = !content.scan(license_regexp)[0] and !license.strip.empty?
173
+ licensable = !!(!content.scan(license_regexp)[0] and !license.strip.empty?)
174
174
  output = self.output || file
175
175
 
176
176
  if licensable
@@ -1,38 +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
9
  require_relative '../tools'
10
- require_relative 'base_tool'
11
-
12
- # rubocop:disable Style/Documentation
13
-
14
- module Kamaze::Project::Tools
15
- class Packager < BaseTool
16
- class Filesystem
17
- class Operator
18
- module Utils
19
- end
20
- end
21
- end
22
-
23
- require_relative 'packager/filesystem'
24
- require_relative 'packager/filesystem/operator'
25
- require_relative 'packager/filesystem/operator/utils'
26
- end
27
- end
28
-
29
- # rubocop:enable Style/Documentation
30
10
 
31
11
  # Provides a packager
32
12
  #
33
13
  # Packager is intended to provide basic packaging operations
34
14
  # @abstract
35
- class Kamaze::Project::Tools::Packager
15
+ class Kamaze::Project::Tools::Packager < Kamaze::Project::Tools::BaseTool
16
+ # @formatter:off
17
+ {
18
+ FileSystem: 'filesystem',
19
+ }.each { |k, v| autoload(k, "#{__dir__}/packager/#{v}") }
20
+ # @formatter:on
21
+
22
+ require_relative 'packager/filesystem'
23
+ require_relative 'packager/filesystem/operator'
24
+ require_relative 'packager/filesystem/operator/utils'
25
+
36
26
  # Get filesystem
37
27
  #
38
28
  # @return [Kamaze::Project::Tools::Packager::Filesystem]
@@ -1,14 +1,12 @@
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
  require_relative '../packager'
10
- require_relative 'filesystem/operator'
11
- require 'pathname'
12
10
 
13
11
  # Filesystem description used during packaging
14
12
  #
@@ -20,6 +18,14 @@ require 'pathname'
20
18
  # Labels are used to constitute the complete directory path
21
19
  # (relative to ``pwd``).
22
20
  class Kamaze::Project::Tools::Packager::Filesystem
21
+ autoload(:Pathname, 'pathname')
22
+
23
+ # @formatter:off
24
+ {
25
+ Operator: 'operator',
26
+ }.each { |k, v| autoload(k, "#{__dir__}/filesystem/#{v}") }
27
+ # @formatter:on
28
+
23
29
  # Package dir (root directory)
24
30
  #
25
31
  # Relative to current pwd
@@ -170,7 +176,9 @@ class Kamaze::Project::Tools::Packager::Filesystem
170
176
  # @return [self]
171
177
  def mute_attributes!(attributes)
172
178
  attributes.each do |m|
179
+ # rubocop:disable Style/AccessModifierDeclarations
173
180
  self.singleton_class.class_eval { protected "#{m}=" }
181
+ # rubocop:enable Style/AccessModifierDeclarations
174
182
  end
175
183
 
176
184
  self
@@ -1,19 +1,25 @@
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
  require 'pathname'
10
- require_relative '../filesystem'
11
- require_relative 'operator/utils'
12
10
 
13
11
  # Filesystem operator (manipulator)
14
12
  #
15
13
  # This class is intended to manipulate a ``Filesystem``.
16
14
  class Kamaze::Project::Tools::Packager::Filesystem::Operator
15
+ autoload(:Pathname, 'pathname')
16
+
17
+ # @formatter:off
18
+ {
19
+ Utils: 'utils',
20
+ }.each { |k, v| autoload(k, "#{__dir__}/operator/#{v}") }
21
+ # @formatter:on
22
+
17
23
  include Utils
18
24
 
19
25
  # @return [Kamaze::Project::Tools::Packager::Filesystem]
@@ -28,9 +34,11 @@ class Kamaze::Project::Tools::Packager::Filesystem::Operator
28
34
 
29
35
  # Pass included methods to protected
30
36
  utils_methods.each do |m|
31
- if self.public_methods.include?(m)
32
- self.singleton_class.class_eval { protected m }
33
- end
37
+ next unless self.public_methods.include?(m)
38
+
39
+ # rubocop:disable Style/AccessModifierDeclarations
40
+ self.singleton_class.class_eval { protected m }
41
+ # rubocop:enable Style/AccessModifierDeclarations
34
42
  end
35
43
  end
36
44
 
@@ -38,7 +46,7 @@ class Kamaze::Project::Tools::Packager::Filesystem::Operator
38
46
  #
39
47
  # @return [self]
40
48
  def prepare
41
- fs.package_dirs.each_value { |dir| mkdir_p(dir, options) }
49
+ fs.package_dirs.each_value { |dir| mkdir_p(dir, **options) }
42
50
 
43
51
  self.purge_purgeables.prepare_srcdir
44
52
  end
@@ -47,7 +55,7 @@ class Kamaze::Project::Tools::Packager::Filesystem::Operator
47
55
  #
48
56
  # @return [self]
49
57
  def purge_purgeables
50
- fs.purgeable_dirs.each_value { |dir| purge(dir, options) }
58
+ fs.purgeable_dirs.each_value { |dir| purge(dir, **options) }
51
59
 
52
60
  self
53
61
  end
@@ -58,7 +66,7 @@ class Kamaze::Project::Tools::Packager::Filesystem::Operator
58
66
  #
59
67
  # @return [self]
60
68
  def prepare_srcdir
61
- src_dir = ::Pathname.new(fs.package_dirs.fetch(:src))
69
+ src_dir = Pathname.new(fs.package_dirs.fetch(:src))
62
70
 
63
71
  purge(src_dir, options)
64
72
  skel_dirs(src_dir, fs.source_files, options)
@@ -66,7 +74,7 @@ class Kamaze::Project::Tools::Packager::Filesystem::Operator
66
74
  fs.source_files.map do |path|
67
75
  origin = path.realpath # resolves symlinks
68
76
 
69
- cp(origin, src_dir.join(path), options.merge(preserve: true))
77
+ cp(origin, src_dir.join(path), **options.merge(preserve: true))
70
78
  end
71
79
 
72
80
  self
@@ -78,6 +86,6 @@ class Kamaze::Project::Tools::Packager::Filesystem::Operator
78
86
 
79
87
  protected
80
88
 
81
- # @return [Hash]
89
+ # @return [Hash{Symbol => Object}]
82
90
  attr_reader :options
83
91
  end