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.
- checksums.yaml +4 -4
- data/.yardopts +9 -9
- data/lib/kamaze-project.rb +1 -31
- data/lib/kamaze/project.rb +37 -31
- data/lib/kamaze/project/autoload.rb +38 -0
- data/lib/kamaze/project/boot/core_ext.rb +8 -8
- data/lib/kamaze/project/boot/listen.rb +11 -13
- data/lib/kamaze/project/bundled.rb +79 -0
- data/lib/kamaze/project/concern.rb +17 -2
- data/lib/kamaze/project/concern/cli.rb +3 -1
- data/lib/kamaze/project/concern/cli/with_exit_on_failure.rb +2 -6
- data/lib/kamaze/project/concern/env.rb +14 -12
- data/lib/kamaze/project/concern/helper.rb +1 -2
- data/lib/kamaze/project/concern/mode.rb +1 -1
- data/lib/kamaze/project/concern/observable.rb +12 -11
- data/lib/kamaze/project/concern/sh.rb +7 -7
- data/lib/kamaze/project/concern/tasks.rb +36 -10
- data/lib/kamaze/project/concern/tools.rb +2 -3
- data/lib/kamaze/project/config.rb +1 -1
- data/lib/kamaze/project/core_ext/object.rb +17 -8
- data/lib/kamaze/project/core_ext/pp.rb +14 -16
- data/lib/kamaze/project/debug.rb +47 -48
- data/lib/kamaze/project/dsl.rb +9 -5
- data/lib/kamaze/project/dsl/definition.rb +6 -12
- data/lib/kamaze/project/dsl/setup.rb +1 -3
- data/lib/kamaze/project/helper.rb +1 -1
- data/lib/kamaze/project/helper/inflector.rb +9 -27
- data/lib/kamaze/project/helper/project.rb +1 -1
- data/lib/kamaze/project/helper/project/config.rb +1 -1
- data/lib/kamaze/project/inflector.rb +15 -0
- data/lib/kamaze/project/observable.rb +1 -4
- data/lib/kamaze/project/observer.rb +1 -1
- data/lib/kamaze/project/resources/Vagrantfile +1 -1
- data/lib/kamaze/project/struct.rb +1 -1
- data/lib/kamaze/project/tasks/cs.rb +1 -1
- data/lib/kamaze/project/tasks/cs/control.rb +1 -1
- data/lib/kamaze/project/tasks/cs/correct.rb +1 -1
- data/lib/kamaze/project/tasks/cs/pre_commit.rb +4 -6
- data/lib/kamaze/project/tasks/doc.rb +2 -4
- data/lib/kamaze/project/tasks/doc/watch.rb +4 -6
- data/lib/kamaze/project/tasks/gem.rb +15 -6
- data/lib/kamaze/project/tasks/gem/build.rb +33 -17
- data/lib/kamaze/project/tasks/gem/compile.rb +1 -1
- data/lib/kamaze/project/tasks/gem/gemspec.rb +12 -11
- data/lib/kamaze/project/tasks/gem/install.rb +1 -1
- data/lib/kamaze/project/tasks/gem/push.rb +16 -17
- data/lib/kamaze/project/tasks/misc/gitignore.rb +1 -1
- data/lib/kamaze/project/tasks/shell.rb +1 -1
- data/lib/kamaze/project/tasks/sources.rb +1 -1
- data/lib/kamaze/project/tasks/sources/license.rb +1 -1
- data/lib/kamaze/project/tasks/test.rb +3 -5
- data/lib/kamaze/project/tasks/vagrant.rb +1 -1
- data/lib/kamaze/project/tasks/version/edit.rb +1 -1
- data/lib/kamaze/project/tools.rb +18 -6
- data/lib/kamaze/project/tools/base_tool.rb +6 -2
- data/lib/kamaze/project/tools/console.rb +4 -13
- data/lib/kamaze/project/tools/console/output.rb +14 -6
- data/lib/kamaze/project/tools/console/output/buffer.rb +8 -3
- data/lib/kamaze/project/tools/gemspec.rb +11 -21
- data/lib/kamaze/project/tools/gemspec/builder.rb +43 -31
- data/lib/kamaze/project/tools/gemspec/concern.rb +6 -1
- data/lib/kamaze/project/tools/gemspec/concern/reading.rb +2 -5
- data/lib/kamaze/project/tools/gemspec/packager.rb +10 -10
- data/lib/kamaze/project/tools/gemspec/packer.rb +11 -15
- data/lib/kamaze/project/tools/gemspec/packer/command.rb +1 -1
- data/lib/kamaze/project/tools/gemspec/reader.rb +22 -14
- data/lib/kamaze/project/tools/gemspec/reader/decorator.rb +3 -6
- data/lib/kamaze/project/tools/gemspec/writer.rb +43 -19
- data/lib/kamaze/project/tools/gemspec/writer/dep_gen.rb +9 -6
- data/lib/kamaze/project/tools/gemspec/writer/dependency.rb +1 -1
- data/lib/kamaze/project/tools/git.rb +13 -31
- data/lib/kamaze/project/tools/git/hooks.rb +12 -6
- data/lib/kamaze/project/tools/git/hooks/base_hook.rb +3 -11
- data/lib/kamaze/project/tools/git/hooks/pre_commit.rb +3 -7
- data/lib/kamaze/project/tools/git/status.rb +13 -9
- data/lib/kamaze/project/tools/git/status/decorator.rb +1 -1
- data/lib/kamaze/project/tools/git/status/file.rb +2 -1
- data/lib/kamaze/project/tools/git/status/files_array.rb +1 -1
- data/lib/kamaze/project/tools/git/status/index.rb +1 -1
- data/lib/kamaze/project/tools/git/status/worktree.rb +1 -1
- data/lib/kamaze/project/tools/git/util.rb +1 -1
- data/lib/kamaze/project/tools/licenser.rb +2 -2
- data/lib/kamaze/project/tools/packager.rb +12 -22
- data/lib/kamaze/project/tools/packager/filesystem.rb +11 -3
- data/lib/kamaze/project/tools/packager/filesystem/operator.rb +19 -11
- data/lib/kamaze/project/tools/packager/filesystem/operator/utils.rb +22 -16
- data/lib/kamaze/project/tools/process_locker.rb +67 -36
- data/lib/kamaze/project/tools/rspec.rb +5 -3
- data/lib/kamaze/project/tools/rubocop.rb +30 -40
- data/lib/kamaze/project/tools/rubocop/arguments.rb +1 -1
- data/lib/kamaze/project/tools/rubocop/config.rb +2 -4
- data/lib/kamaze/project/tools/shell.rb +7 -8
- data/lib/kamaze/project/tools/vagrant.rb +6 -16
- data/lib/kamaze/project/tools/vagrant/composer.rb +1 -1
- data/lib/kamaze/project/tools/vagrant/composer/file.rb +1 -1
- data/lib/kamaze/project/tools/vagrant/remote.rb +1 -1
- data/lib/kamaze/project/tools/vagrant/shell.rb +1 -1
- data/lib/kamaze/project/tools/vagrant/writer.rb +1 -1
- data/lib/kamaze/project/tools/yardoc.rb +14 -17
- data/lib/kamaze/project/tools/yardoc/file.rb +7 -7
- data/lib/kamaze/project/tools/yardoc/watchable.rb +9 -15
- data/lib/kamaze/project/tools/yardoc/watcher.rb +28 -35
- data/lib/kamaze/project/tools_provider.rb +28 -40
- data/lib/kamaze/project/tools_provider/resolver.rb +1 -1
- data/lib/kamaze/project/version.rb +5 -94
- data/lib/kamaze/project/version.yml +5 -5
- metadata +23 -64
- data/bin/plop +0 -5
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (C) 2017-
|
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-
|
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
|
-
#
|
14
|
-
|
15
|
-
|
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
|
-
#
|
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 [
|
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
|
-
|
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-
|
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
|
-
|
48
|
-
|
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-
|
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-
|
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-
|
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-
|
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-
|
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-
|
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-
|
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-
|
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-
|
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-
|
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-
|
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-
|
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-
|
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
|
-
|
32
|
-
|
33
|
-
|
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 =
|
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
|