kamaze-project 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +18 -0
- data/bin/plop +5 -0
- data/lib/kamaze-project.rb +39 -0
- data/lib/kamaze/project.rb +155 -0
- data/lib/kamaze/project/boot/core_ext.rb +16 -0
- data/lib/kamaze/project/boot/listen.rb +38 -0
- data/lib/kamaze/project/concern.rb +13 -0
- data/lib/kamaze/project/concern/cli.rb +53 -0
- data/lib/kamaze/project/concern/cli/with_exit_on_failure.rb +36 -0
- data/lib/kamaze/project/concern/env.rb +63 -0
- data/lib/kamaze/project/concern/helper.rb +20 -0
- data/lib/kamaze/project/concern/mode.rb +19 -0
- data/lib/kamaze/project/concern/observable.rb +132 -0
- data/lib/kamaze/project/concern/sh.rb +91 -0
- data/lib/kamaze/project/concern/tasks.rb +55 -0
- data/lib/kamaze/project/concern/tools.rb +27 -0
- data/lib/kamaze/project/config.rb +58 -0
- data/lib/kamaze/project/core_ext/object.rb +27 -0
- data/lib/kamaze/project/core_ext/pp.rb +28 -0
- data/lib/kamaze/project/debug.rb +136 -0
- data/lib/kamaze/project/dsl.rb +16 -0
- data/lib/kamaze/project/dsl/definition.rb +43 -0
- data/lib/kamaze/project/dsl/setup.rb +11 -0
- data/lib/kamaze/project/helper.rb +63 -0
- data/lib/kamaze/project/helper/inflector.rb +44 -0
- data/lib/kamaze/project/helper/project.rb +34 -0
- data/lib/kamaze/project/helper/project/config.rb +25 -0
- data/lib/kamaze/project/observable.rb +20 -0
- data/lib/kamaze/project/observer.rb +37 -0
- data/lib/kamaze/project/resources/Vagrantfile +128 -0
- data/lib/kamaze/project/resources/config/tools.yml +15 -0
- data/lib/kamaze/project/struct.rb +34 -0
- data/lib/kamaze/project/tasks/cs.rb +23 -0
- data/lib/kamaze/project/tasks/cs/control.rb +17 -0
- data/lib/kamaze/project/tasks/cs/correct.rb +17 -0
- data/lib/kamaze/project/tasks/cs/pre_commit.rb +66 -0
- data/lib/kamaze/project/tasks/doc.rb +21 -0
- data/lib/kamaze/project/tasks/doc/watch.rb +41 -0
- data/lib/kamaze/project/tasks/gem.rb +14 -0
- data/lib/kamaze/project/tasks/gem/build.rb +34 -0
- data/lib/kamaze/project/tasks/gem/compile.rb +30 -0
- data/lib/kamaze/project/tasks/gem/gemspec.rb +20 -0
- data/lib/kamaze/project/tasks/gem/install.rb +32 -0
- data/lib/kamaze/project/tasks/gem/push.rb +27 -0
- data/lib/kamaze/project/tasks/misc/gitignore.rb +29 -0
- data/lib/kamaze/project/tasks/shell.rb +17 -0
- data/lib/kamaze/project/tasks/sources.rb +6 -0
- data/lib/kamaze/project/tasks/sources/license.rb +35 -0
- data/lib/kamaze/project/tasks/test.rb +16 -0
- data/lib/kamaze/project/tasks/vagrant.rb +71 -0
- data/lib/kamaze/project/tasks/version/edit.rb +16 -0
- data/lib/kamaze/project/tools.rb +18 -0
- data/lib/kamaze/project/tools/base_tool.rb +55 -0
- data/lib/kamaze/project/tools/console.rb +48 -0
- data/lib/kamaze/project/tools/console/output.rb +120 -0
- data/lib/kamaze/project/tools/console/output/buffer.rb +48 -0
- data/lib/kamaze/project/tools/gemspec.rb +33 -0
- data/lib/kamaze/project/tools/gemspec/builder.rb +99 -0
- data/lib/kamaze/project/tools/gemspec/concern.rb +13 -0
- data/lib/kamaze/project/tools/gemspec/concern/reading.rb +49 -0
- data/lib/kamaze/project/tools/gemspec/packager.rb +67 -0
- data/lib/kamaze/project/tools/gemspec/packer.rb +89 -0
- data/lib/kamaze/project/tools/gemspec/packer/command.rb +143 -0
- data/lib/kamaze/project/tools/gemspec/reader.rb +70 -0
- data/lib/kamaze/project/tools/gemspec/reader/decorator.rb +78 -0
- data/lib/kamaze/project/tools/gemspec/writer.rb +127 -0
- data/lib/kamaze/project/tools/gemspec/writer/dep_gen.rb +61 -0
- data/lib/kamaze/project/tools/gemspec/writer/dependency.rb +104 -0
- data/lib/kamaze/project/tools/git.rb +95 -0
- data/lib/kamaze/project/tools/git/hooks.rb +66 -0
- data/lib/kamaze/project/tools/git/hooks/base_hook.rb +33 -0
- data/lib/kamaze/project/tools/git/hooks/pre_commit.rb +81 -0
- data/lib/kamaze/project/tools/git/status.rb +101 -0
- data/lib/kamaze/project/tools/git/status/decorator.rb +39 -0
- data/lib/kamaze/project/tools/git/status/file.rb +180 -0
- data/lib/kamaze/project/tools/git/status/files_array.rb +39 -0
- data/lib/kamaze/project/tools/git/status/index.rb +77 -0
- data/lib/kamaze/project/tools/git/status/worktree.rb +19 -0
- data/lib/kamaze/project/tools/git/util.rb +35 -0
- data/lib/kamaze/project/tools/licenser.rb +197 -0
- data/lib/kamaze/project/tools/packager.rb +86 -0
- data/lib/kamaze/project/tools/packager/filesystem.rb +178 -0
- data/lib/kamaze/project/tools/packager/filesystem/operator.rb +83 -0
- data/lib/kamaze/project/tools/packager/filesystem/operator/utils.rb +77 -0
- data/lib/kamaze/project/tools/process_locker.rb +106 -0
- data/lib/kamaze/project/tools/rspec.rb +115 -0
- data/lib/kamaze/project/tools/rubocop.rb +128 -0
- data/lib/kamaze/project/tools/rubocop/arguments.rb +19 -0
- data/lib/kamaze/project/tools/rubocop/config.rb +43 -0
- data/lib/kamaze/project/tools/shell.rb +85 -0
- data/lib/kamaze/project/tools/vagrant.rb +182 -0
- data/lib/kamaze/project/tools/vagrant/composer.rb +88 -0
- data/lib/kamaze/project/tools/vagrant/composer/file.rb +79 -0
- data/lib/kamaze/project/tools/vagrant/remote.rb +79 -0
- data/lib/kamaze/project/tools/vagrant/shell.rb +102 -0
- data/lib/kamaze/project/tools/vagrant/writer.rb +81 -0
- data/lib/kamaze/project/tools/yardoc.rb +75 -0
- data/lib/kamaze/project/tools/yardoc/file.rb +55 -0
- data/lib/kamaze/project/tools/yardoc/watchable.rb +70 -0
- data/lib/kamaze/project/tools/yardoc/watcher.rb +106 -0
- data/lib/kamaze/project/tools_provider.rb +161 -0
- data/lib/kamaze/project/tools_provider/resolver.rb +42 -0
- data/lib/kamaze/project/version.rb +104 -0
- data/lib/kamaze/project/version.yml +17 -0
- metadata +321 -0
@@ -0,0 +1,6 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# Copyright (C) 2017-2018 Dimitri Arrigoni <dimitri@arrigoni.me>
|
3
|
+
# License GPLv3+: GNU GPL version 3 or later
|
4
|
+
# <http://www.gnu.org/licenses/gpl.html>.
|
5
|
+
# This is free software: you are free to change and redistribute it.
|
6
|
+
# There is NO WARRANTY, to the extent permitted by law.
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (C) 2017-2018 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
|
+
writer = tools.fetch(:gemspec_writer)
|
10
|
+
|
11
|
+
desc 'Apply license on (ruby) source files'
|
12
|
+
task 'sources:license', [:output] => [writer.to_s] do |task, args|
|
13
|
+
output = args[:output] ? Pathname.new(args[:output]) : nil
|
14
|
+
builder = tools.fetch(:gemspec_builder)
|
15
|
+
|
16
|
+
begin
|
17
|
+
tools.fetch(:licenser).process do |process|
|
18
|
+
process.output = output if output
|
19
|
+
process.license = project.version.license_header
|
20
|
+
process.files = builder.source_files.select do |file|
|
21
|
+
# @todo use a better ruby files recognition
|
22
|
+
# @todo implement better exclusion
|
23
|
+
if file.extname.gsub(/^\./, '') == 'rb'
|
24
|
+
file.basename.to_s != 'gems.rb'
|
25
|
+
else
|
26
|
+
false
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
rescue SystemExit, Interrupt
|
31
|
+
exit(Errno::ECANCELED::Errno)
|
32
|
+
rescue Errno::EPIPE => e
|
33
|
+
exit(e.class.const_get(:Errno))
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (C) 2017-2018 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
|
+
desc 'Run test suites'
|
10
|
+
task :test do |task, args|
|
11
|
+
tags = args.extras
|
12
|
+
|
13
|
+
tools.fetch(:rspec).tap do |rspec|
|
14
|
+
rspec.tags = tags
|
15
|
+
end.run
|
16
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (C) 2017-2018 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
|
+
require 'rake/clean'
|
10
|
+
require 'shellwords'
|
11
|
+
require 'yaml'
|
12
|
+
|
13
|
+
vagrant = tools.fetch(:vagrant)
|
14
|
+
|
15
|
+
CLOBBER.include('Vagrantfile')
|
16
|
+
|
17
|
+
file 'Vagrantfile': vagrant.sources do
|
18
|
+
vagrant.install
|
19
|
+
end
|
20
|
+
|
21
|
+
task 'vagrant:init': ['Vagrantfile']
|
22
|
+
|
23
|
+
# :vagrant -----------------------------------------------------------
|
24
|
+
{
|
25
|
+
'rsync-auto': 'Watch all rsync synced folders',
|
26
|
+
'status': 'Current machine states',
|
27
|
+
}.each do |k, v|
|
28
|
+
desc v
|
29
|
+
task "vagrant:#{k}" => ['vagrant:init'] do |task|
|
30
|
+
vagrant.execute(k.to_s)
|
31
|
+
|
32
|
+
task.reenable
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
desc 'Dump config'
|
37
|
+
task 'vagrant:dump', [:box_id] => ['vagrant:init'] do |task, args|
|
38
|
+
dump = args[:box_id] ? vagrant.boxes.fetch(args[:box_id]) : vagrant.boxes
|
39
|
+
|
40
|
+
$stdout.puts(YAML.dump(dump))
|
41
|
+
|
42
|
+
task.reenable
|
43
|
+
end
|
44
|
+
|
45
|
+
# :vagrant:vm --------------------------------------------------------
|
46
|
+
vagrant.boxes.each do |box_id, config|
|
47
|
+
next if config['disabled']
|
48
|
+
|
49
|
+
task_ns = "vagrant:vm:#{box_id}"
|
50
|
+
{
|
51
|
+
up: [:halt],
|
52
|
+
halt: [:up],
|
53
|
+
reload: [:reload, :halt],
|
54
|
+
provision: [:provision],
|
55
|
+
rsync: [:rsync]
|
56
|
+
}.each do |command, tasks|
|
57
|
+
desc "#{command.to_s.gsub(/(\w+)/, &:capitalize)} #{box_id}"
|
58
|
+
task "#{task_ns}:#{command}" => ['vagrant:init'] do
|
59
|
+
vagrant.execute(command.to_s, box_id)
|
60
|
+
|
61
|
+
tasks.each { |tid| Rake::Task["#{task_ns}:#{tid}"].reenable }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
desc "Ssh #{box_id}"
|
66
|
+
task "#{task_ns}:ssh", [:command] => ['vagrant:init'] do |task, args|
|
67
|
+
vagrant.ssh(box_id, args[:command])
|
68
|
+
|
69
|
+
task.reenable
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (C) 2017-2018 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
|
+
desc 'Edit version file'
|
10
|
+
task 'version:edit' do |task|
|
11
|
+
require 'tty/editor'
|
12
|
+
|
13
|
+
TTY::Editor.open(project.version.to_path).yield_self do |b|
|
14
|
+
task.reenable if b
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (C) 2017-2018 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
|
+
require_relative '../project'
|
10
|
+
require_relative 'tools_provider'
|
11
|
+
|
12
|
+
# rubocop:disable Style/Documentation
|
13
|
+
|
14
|
+
module Kamaze::Project::Tools
|
15
|
+
require_relative 'tools/base_tool'
|
16
|
+
end
|
17
|
+
|
18
|
+
# rubocop:enable Style/Documentation
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (C) 2017-2018 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
|
+
require_relative '../tools'
|
10
|
+
require_relative '../observable'
|
11
|
+
|
12
|
+
# Provides base for tools
|
13
|
+
#
|
14
|
+
# @abstract
|
15
|
+
class Kamaze::Project::Tools::BaseTool < Kamaze::Project::Observable
|
16
|
+
def initialize
|
17
|
+
super()
|
18
|
+
|
19
|
+
dispatch_event(:before_setup)
|
20
|
+
setup
|
21
|
+
dispatch_event(:after_setup)
|
22
|
+
|
23
|
+
attrs_mute!
|
24
|
+
end
|
25
|
+
|
26
|
+
# Mutable attributes
|
27
|
+
#
|
28
|
+
# Mutable attributes become ``ro`` after initialization
|
29
|
+
#
|
30
|
+
# @return [Array]
|
31
|
+
def mutable_attributes
|
32
|
+
[]
|
33
|
+
end
|
34
|
+
|
35
|
+
protected
|
36
|
+
|
37
|
+
# Execute additionnal setup
|
38
|
+
def setup
|
39
|
+
nil
|
40
|
+
end
|
41
|
+
|
42
|
+
# Mut(at)e attributes
|
43
|
+
#
|
44
|
+
# After initialization, attributes given has mutable
|
45
|
+
# become ``ro`` (protected setter)
|
46
|
+
#
|
47
|
+
# @return [self]
|
48
|
+
def attrs_mute!
|
49
|
+
mutable_attributes.each do |m|
|
50
|
+
self.singleton_class.class_eval { protected "#{m}=" }
|
51
|
+
end
|
52
|
+
|
53
|
+
self
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (C) 2017-2018 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
|
+
require_relative '../tools'
|
10
|
+
|
11
|
+
# rubocop:disable Style/Documentation
|
12
|
+
|
13
|
+
module Kamaze::Project::Tools
|
14
|
+
class Console < BaseTool
|
15
|
+
end
|
16
|
+
|
17
|
+
require_relative 'console/output'
|
18
|
+
end
|
19
|
+
|
20
|
+
# rubocop:enable Style/Documentation
|
21
|
+
|
22
|
+
# Provide access to a [console](https://en.wikipedia.org/wiki/System_console)
|
23
|
+
# having two outputs: ``stdout`` and ``stderr``
|
24
|
+
#
|
25
|
+
# @see Kamaze::Project::Tools::Console::Output
|
26
|
+
class Kamaze::Project::Tools::Console
|
27
|
+
attr_writer :stdout
|
28
|
+
attr_writer :stderr
|
29
|
+
|
30
|
+
def setup
|
31
|
+
@stdout ||= $stdout
|
32
|
+
@stderr ||= $stderr
|
33
|
+
end
|
34
|
+
|
35
|
+
# @return [Output]
|
36
|
+
def stdout
|
37
|
+
Output.new(@stdout)
|
38
|
+
end
|
39
|
+
|
40
|
+
# @return [Output]
|
41
|
+
def stderr
|
42
|
+
Output.new(@stderr)
|
43
|
+
end
|
44
|
+
|
45
|
+
def mutable_attributes
|
46
|
+
[:stdout, :stderr]
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (C) 2017-2018 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
|
+
require_relative '../console'
|
10
|
+
require_relative 'output/buffer'
|
11
|
+
|
12
|
+
# Provide a console output
|
13
|
+
#
|
14
|
+
# Console output can be initialized from a ``IO``
|
15
|
+
# (``STDOUT`` and/or ``STDERR``)
|
16
|
+
# a ``File``, using ``File.open()``, or a ``StringIO``.
|
17
|
+
#
|
18
|
+
# As a result, console provides a convenient way to suppress or replace
|
19
|
+
# standard outputs (keeping them untouched).
|
20
|
+
#
|
21
|
+
# Console output uses ``cli-ui`` to provide colored formatting.
|
22
|
+
#
|
23
|
+
# @see https://github.com/Shopify/cli-ui
|
24
|
+
# @see http://ruby-doc.org/core-2.1.3/IO.html
|
25
|
+
class Kamaze::Project::Tools::Console::Output
|
26
|
+
# @param [IO] to
|
27
|
+
def initialize(to = $stdout)
|
28
|
+
@output = to
|
29
|
+
end
|
30
|
+
|
31
|
+
# Denote is a tty
|
32
|
+
#
|
33
|
+
# @return [Boolean]
|
34
|
+
def tty?
|
35
|
+
output.respond_to?(:'tty?') ? output.tty? : false
|
36
|
+
end
|
37
|
+
|
38
|
+
# Flushes any buffered data to the underlying operating system
|
39
|
+
#
|
40
|
+
# note that this is Ruby internal buffering only;
|
41
|
+
# the OS may buffer the data as well
|
42
|
+
#
|
43
|
+
# @return [self]
|
44
|
+
def flush
|
45
|
+
output.flush if output.respond_to?(:flush)
|
46
|
+
|
47
|
+
self
|
48
|
+
end
|
49
|
+
|
50
|
+
def method_missing(method, *args, &block)
|
51
|
+
if respond_to_missing?(method)
|
52
|
+
args = bufferize(*args) if formattable_on?(method.to_sym)
|
53
|
+
|
54
|
+
return output.public_send(method, *args, &block)
|
55
|
+
end
|
56
|
+
|
57
|
+
super
|
58
|
+
end
|
59
|
+
|
60
|
+
def respond_to_missing?(method, include_private = false)
|
61
|
+
return true if output.respond_to?(method, include_private)
|
62
|
+
|
63
|
+
super(method, include_private)
|
64
|
+
end
|
65
|
+
|
66
|
+
# @!method puts(s)
|
67
|
+
# Writes the given objects to ``ios`` as with ``IO#print``.
|
68
|
+
#
|
69
|
+
# Writes a record separator (typically a newline) after any that
|
70
|
+
# do not already end with a newline sequence.
|
71
|
+
# If called with an array argument, writes each element on a new line.
|
72
|
+
# If called without arguments, outputs a single record separator.
|
73
|
+
#
|
74
|
+
# @param [String] s
|
75
|
+
# @return [nil]
|
76
|
+
|
77
|
+
# @!method print(s)
|
78
|
+
# Writes the given objects to ios as with IO#print.
|
79
|
+
#
|
80
|
+
# Writes the given object(s) to ``ios``.
|
81
|
+
#
|
82
|
+
# The stream must be opened for writing.
|
83
|
+
# If the output field separator (``$,``) is not nil,
|
84
|
+
# it will be inserted between each object.
|
85
|
+
# If the output record separator (``$\``) is not nil,
|
86
|
+
# it will be appended to the output.
|
87
|
+
# If no arguments are given, prints ``$_``.
|
88
|
+
# Objects that aren't strings will be converted by calling
|
89
|
+
# their ``to_s`` method.
|
90
|
+
# With no argument, prints the contents of the variable ``$_``.
|
91
|
+
# Returns nil.
|
92
|
+
# @param [String] s
|
93
|
+
# @return [nil]
|
94
|
+
|
95
|
+
protected
|
96
|
+
|
97
|
+
attr_reader :output
|
98
|
+
|
99
|
+
# Formattable methods
|
100
|
+
#
|
101
|
+
# @return [Array<Symbol>]
|
102
|
+
def formattables
|
103
|
+
[:puts, :print, :write]
|
104
|
+
end
|
105
|
+
|
106
|
+
# Denote given method is formattable
|
107
|
+
#
|
108
|
+
# @param [Symbol] method
|
109
|
+
def formattable_on?(method)
|
110
|
+
formattables.include?(method.to_sym)
|
111
|
+
end
|
112
|
+
|
113
|
+
# Bufferize given arguments
|
114
|
+
#
|
115
|
+
# @param [Array<String>] strings
|
116
|
+
# @return [Array<String>]
|
117
|
+
def bufferize(*strings)
|
118
|
+
strings.to_a.map { |s| Buffer.new(self, s) }
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (C) 2017-2018 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
|
+
require_relative '../output'
|
10
|
+
require 'cli/ui'
|
11
|
+
|
12
|
+
class Kamaze::Project::Tools::Console::Output
|
13
|
+
class Buffer
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# Describe a buffer
|
18
|
+
class Kamaze::Project::Tools::Console::Output::Buffer
|
19
|
+
# Get content
|
20
|
+
#
|
21
|
+
# @return [String]
|
22
|
+
attr_reader :content
|
23
|
+
|
24
|
+
# @param [Kamaze::Project::Tools::Console::Output] output
|
25
|
+
# @param [String] content
|
26
|
+
def initialize(output, content)
|
27
|
+
@output = output
|
28
|
+
@content = content
|
29
|
+
end
|
30
|
+
|
31
|
+
# @return [String]
|
32
|
+
def to_s
|
33
|
+
self.decorate(content)
|
34
|
+
end
|
35
|
+
|
36
|
+
protected
|
37
|
+
|
38
|
+
# @return [Kamaze::Project::Tools::Console::Output]
|
39
|
+
attr_reader :output
|
40
|
+
|
41
|
+
# Decorate given string depending ``output`` is a tty
|
42
|
+
#
|
43
|
+
# @param [String] str
|
44
|
+
# @return [String]
|
45
|
+
def decorate(str)
|
46
|
+
CLI::UI.fmt(str.to_s, enable_color: output.tty?)
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (C) 2017-2018 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
|
+
require_relative '../tools'
|
10
|
+
require_relative 'packager'
|
11
|
+
|
12
|
+
# Module providng several tools based on gemspec reader/writer
|
13
|
+
module Kamaze::Project::Tools::Gemspec
|
14
|
+
class Reader < Kamaze::Project::Tools::BaseTool
|
15
|
+
end
|
16
|
+
|
17
|
+
class Writer < Kamaze::Project::Tools::BaseTool
|
18
|
+
end
|
19
|
+
|
20
|
+
# @abstract
|
21
|
+
class Packager < Kamaze::Project::Tools::Packager
|
22
|
+
end
|
23
|
+
|
24
|
+
class Builder < Packager
|
25
|
+
end
|
26
|
+
|
27
|
+
class Packer < Packager
|
28
|
+
end
|
29
|
+
|
30
|
+
[:packager,
|
31
|
+
:reader, :writer,
|
32
|
+
:builder, :packer].each { |req| require_relative "gemspec/#{req}" }
|
33
|
+
end
|