fedux_org-stdlib 0.7.21 → 0.7.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +23 -19
- data/Rakefile +16 -0
- data/config/rubocop/exclude.yml +44 -0
- data/config/rubocop/include.yml +0 -0
- data/fedux_org-stdlib.gemspec +9 -9
- data/fixtures/plugin-load-app/fedux_org_stdlib-fixtures-plugin_manager-plugin-load.gemspec +11 -11
- data/fixtures/plugin-no_load-app/fedux_org_stdlib-fixtures-plugin_manager-plugin-no_load.gemspec +11 -11
- data/lib/fedux_org_stdlib.rb +2 -1
- data/lib/fedux_org_stdlib/app_config.rb +22 -21
- data/lib/fedux_org_stdlib/colors/html_color.rb +8 -2
- data/lib/fedux_org_stdlib/command.rb +1 -0
- data/lib/fedux_org_stdlib/command/command_result.rb +1 -0
- data/lib/fedux_org_stdlib/command/run_command.rb +6 -5
- data/lib/fedux_org_stdlib/command/which.rb +17 -17
- data/lib/fedux_org_stdlib/core_ext/array/list.rb +6 -1
- data/lib/fedux_org_stdlib/core_ext/hash/list.rb +6 -1
- data/lib/fedux_org_stdlib/core_ext/hash/options.rb +1 -0
- data/lib/fedux_org_stdlib/core_ext/shellwords/clean.rb +8 -0
- data/lib/fedux_org_stdlib/core_ext/string/underline.rb +9 -1
- data/lib/fedux_org_stdlib/environment.rb +6 -4
- data/lib/fedux_org_stdlib/file_template.rb +8 -10
- data/lib/fedux_org_stdlib/filesystem.rb +30 -29
- data/lib/fedux_org_stdlib/filesystem/exceptions.rb +1 -1
- data/lib/fedux_org_stdlib/gem_plugins/exceptions.rb +1 -0
- data/lib/fedux_org_stdlib/gem_plugins/no_plugin.rb +1 -2
- data/lib/fedux_org_stdlib/gem_plugins/plugin.rb +6 -6
- data/lib/fedux_org_stdlib/gem_plugins/plugin_manager.rb +6 -7
- data/lib/fedux_org_stdlib/list.rb +24 -2
- data/lib/fedux_org_stdlib/logging.rb +3 -2
- data/lib/fedux_org_stdlib/logging/logger.rb +7 -7
- data/lib/fedux_org_stdlib/logging/severity.rb +3 -0
- data/lib/fedux_org_stdlib/logic_converters.rb +1 -0
- data/lib/fedux_org_stdlib/logic_converters/exceptions.rb +2 -2
- data/lib/fedux_org_stdlib/logic_converters/logic_converter.rb +9 -8
- data/lib/fedux_org_stdlib/logic_converters/on_off_converter.rb +5 -4
- data/lib/fedux_org_stdlib/logic_converters/true_false_converter.rb +3 -3
- data/lib/fedux_org_stdlib/logic_converters/y_n_converter.rb +3 -3
- data/lib/fedux_org_stdlib/logic_converters/yes_no_converter.rb +4 -3
- data/lib/fedux_org_stdlib/models/base_model.rb +24 -25
- data/lib/fedux_org_stdlib/models/class_based_model.rb +15 -14
- data/lib/fedux_org_stdlib/models/exceptions.rb +14 -15
- data/lib/fedux_org_stdlib/models/filesystem_based_model.rb +12 -15
- data/lib/fedux_org_stdlib/process_environment.rb +11 -1
- data/lib/fedux_org_stdlib/project.rb +0 -1
- data/lib/fedux_org_stdlib/project/generators/taskjuggler.rb +11 -10
- data/lib/fedux_org_stdlib/project/logger.rb +1 -0
- data/lib/fedux_org_stdlib/project/plan.rb +1 -1
- data/lib/fedux_org_stdlib/project/report.rb +8 -9
- data/lib/fedux_org_stdlib/rake/project.rb +4 -4
- data/lib/fedux_org_stdlib/rake/project_task.rb +2 -3
- data/lib/fedux_org_stdlib/rake/shell_task.rb +7 -7
- data/lib/fedux_org_stdlib/rake/sub_task.rb +2 -2
- data/lib/fedux_org_stdlib/rake/task.rb +7 -6
- data/lib/fedux_org_stdlib/rake/version_bump_task.rb +6 -7
- data/lib/fedux_org_stdlib/rake_tasks/console.rb +0 -1
- data/lib/fedux_org_stdlib/rake_tasks/documentation/yard.rb +2 -2
- data/lib/fedux_org_stdlib/rake_tasks/gems/bundler.rb +1 -1
- data/lib/fedux_org_stdlib/rake_tasks/gems/package.rb +1 -1
- data/lib/fedux_org_stdlib/rake_tasks/project/report/generate.rb +1 -2
- data/lib/fedux_org_stdlib/rake_tasks/project/report/open.rb +1 -2
- data/lib/fedux_org_stdlib/rake_tasks/project/report/open_shortcut.rb +1 -1
- data/lib/fedux_org_stdlib/rake_tasks/qa/rubocop.rb +1 -1
- data/lib/fedux_org_stdlib/rake_tasks/qa/travis.rb +1 -1
- data/lib/fedux_org_stdlib/rake_tasks/software_version/bump.rb +1 -1
- data/lib/fedux_org_stdlib/rake_tasks/software_version/restore.rb +1 -1
- data/lib/fedux_org_stdlib/rake_tasks/software_version/show.rb +2 -3
- data/lib/fedux_org_stdlib/rake_tasks/software_version/show_shortcut.rb +1 -1
- data/lib/fedux_org_stdlib/rake_tasks/tests/cucumber.rb +0 -1
- data/lib/fedux_org_stdlib/rake_tasks/tests/travis.rb +1 -1
- data/lib/fedux_org_stdlib/require_files.rb +5 -4
- data/lib/fedux_org_stdlib/roles/typable.rb +2 -3
- data/lib/fedux_org_stdlib/roles/versionable.rb +3 -2
- data/lib/fedux_org_stdlib/shell_language_detector.rb +21 -2
- data/lib/fedux_org_stdlib/shell_language_detector/language.rb +9 -1
- data/lib/fedux_org_stdlib/support_information.rb +60 -55
- data/lib/fedux_org_stdlib/template_directory.rb +8 -11
- data/lib/fedux_org_stdlib/version.rb +1 -1
- data/lib/fedux_org_stdlib/version_management/library_builder.rb +3 -2
- data/lib/fedux_org_stdlib/version_management/ruby_library.rb +2 -2
- data/lib/fedux_org_stdlib/version_management/rubygem_version_file.rb +3 -3
- data/lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb +5 -5
- data/lib/fedux_org_stdlib/version_management/software_version.rb +4 -3
- data/lib/fedux_org_stdlib/version_management/version_builder.rb +1 -0
- data/rakefiles/default.rake +16 -0
- data/script/terminal +5 -5
- data/spec/app_config_spec.rb +6 -6
- data/spec/colors/html_color_spec.rb +1 -1
- data/spec/core_ext/array/list_spec.rb +8 -8
- data/spec/core_ext/hash/options_spec.rb +17 -17
- data/spec/core_ext/shellwords/clean_spec.rb +1 -1
- data/spec/environment_spec.rb +7 -5
- data/spec/examples/models/class_based/invalid_2.rb +1 -1
- data/spec/examples/models/class_based/valid_2.rb +1 -0
- data/spec/gem_plugins/plugin_manager_spec.rb +1 -1
- data/spec/logger/logger_spec.rb +1 -1
- data/spec/models/base_model_spec.rb +22 -22
- data/spec/models/class_based_model_spec.rb +66 -66
- data/spec/models/filesystem_based_model_spec.rb +28 -28
- data/spec/project/plan_spec.rb +1 -1
- data/spec/project/report_spec.rb +2 -2
- data/spec/project/taskjuggler_spec.rb +4 -4
- data/spec/spec_helper.rb +1 -3
- data/spec/support/rspec.rb +1 -1
- data/spec/version_management/library_builder_spec.rb +2 -2
- data/spec/version_management/ruby_library_spec.rb +2 -2
- data/spec/version_management/rubygem_version_file_parser_spec.rb +8 -8
- data/spec/version_management/rubygem_version_file_spec.rb +8 -8
- data/spec/version_management/software_version_spec.rb +1 -1
- metadata +5 -2
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'fedux_org_stdlib/require_files'
|
3
|
-
require_library %w
|
3
|
+
require_library %w(find active_support/core_ext/object/blank active_support/core_ext/string/inflections)
|
4
4
|
|
5
5
|
require 'fedux_org_stdlib/models/filesystem_based_model'
|
6
6
|
|
@@ -12,9 +12,10 @@ module FeduxOrgStdlib
|
|
12
12
|
base.extend ClassMethods
|
13
13
|
end
|
14
14
|
|
15
|
+
# Class methods
|
15
16
|
module ClassMethods
|
16
17
|
def require_path(name)
|
17
|
-
path = File.join(
|
18
|
+
path = File.join(library_name.underscore, model_name.pluralize.underscore, name.to_s)
|
18
19
|
FeduxOrgStdlib.logger.debug(self) { "Path to instances of model \"#{name}\": #{path}" }
|
19
20
|
|
20
21
|
path
|
@@ -26,18 +27,18 @@ module FeduxOrgStdlib
|
|
26
27
|
raise FeduxOrgStdlib::Models::Exceptions::ExceptionNeedsToBeImplemented, "Exception \"#{library_name}::Exceptions::Invalid#{model_name}\" does not exist."
|
27
28
|
end
|
28
29
|
|
29
|
-
def check_klass(
|
30
|
-
|
30
|
+
def check_klass(klass, *methods)
|
31
|
+
fail exception_for_model, "A valid \"#{model_name}\"-class needs to respond to \"#{ methods.flatten.join(', ') }\"." unless methods.flatten.all? { |m| klass.new.respond_to? m }
|
31
32
|
end
|
32
33
|
|
33
34
|
def build_class_constant(name)
|
34
35
|
"#{library_name}::#{model_name.pluralize}::#{name.to_s.camelcase}".constantize
|
35
36
|
rescue
|
36
|
-
raise exception_for_model
|
37
|
+
raise exception_for_model, "Class \"#{library_name}::#{model_name.pluralize}::#{name.to_s.camelcase}\" cannot be found in file \"#{require_path(name)}\"."
|
37
38
|
end
|
38
39
|
|
39
40
|
def check_method
|
40
|
-
|
41
|
+
fail FeduxOrgStdlib::Models::Exceptions::MethodNeedsToBeImplemented, "Method \"check_method\" does not exist."
|
41
42
|
end
|
42
43
|
|
43
44
|
def suffix
|
@@ -47,18 +48,18 @@ module FeduxOrgStdlib
|
|
47
48
|
def load_from_filesystem
|
48
49
|
files = find_files
|
49
50
|
|
50
|
-
FeduxOrgStdlib.logger.debug(self) { "Files found at path \"#{path_to_instances}\": #{ files.join(
|
51
|
+
FeduxOrgStdlib.logger.debug(self) { "Files found at path \"#{path_to_instances}\": #{ files.join(', ') }" }
|
51
52
|
|
52
|
-
|
53
|
+
fail FeduxOrgStdlib::Models::Exceptions::NoImplementationsForModelFound, "You might need to store files at \"#{File.dirname(path_to_instances)}\" to make the library work." if files.blank?
|
53
54
|
|
54
|
-
files.each do |f|
|
55
|
-
instance_name = name(
|
55
|
+
files.each do |f|
|
56
|
+
instance_name = name(f)
|
56
57
|
|
57
|
-
require require_path(
|
58
|
+
require require_path(instance_name)
|
58
59
|
|
59
|
-
instance_klass = build_class_constant(
|
60
|
-
check_klass(
|
61
|
-
create(
|
60
|
+
instance_klass = build_class_constant(instance_name)
|
61
|
+
check_klass(instance_klass, check_method)
|
62
|
+
create(instance_name, instance_klass.new)
|
62
63
|
end
|
63
64
|
end
|
64
65
|
end
|
@@ -2,39 +2,38 @@
|
|
2
2
|
module FeduxOrgStdlib
|
3
3
|
module Models
|
4
4
|
module Exceptions
|
5
|
-
#internal error
|
5
|
+
# internal error
|
6
6
|
class InternalError < Exception; end
|
7
7
|
|
8
|
-
#raised if one tries to delete an instance which
|
9
|
-
#does not exist
|
8
|
+
# raised if one tries to delete an instance which
|
9
|
+
# does not exist
|
10
10
|
class InstanceNotFound < InternalError; end
|
11
11
|
|
12
|
-
#raised if one tries to use a keyword whose use
|
13
|
-
#is restricted
|
12
|
+
# raised if one tries to use a keyword whose use
|
13
|
+
# is restricted
|
14
14
|
class UnauthorizedUseOfKeyword < InternalError; end
|
15
15
|
|
16
|
-
#raised if one uses invalid search criteria
|
16
|
+
# raised if one uses invalid search criteria
|
17
17
|
class InvalidSearchCriteria < InternalError; end
|
18
18
|
|
19
|
-
#raised if the code which defines an import filter
|
20
|
-
#is malformed
|
19
|
+
# raised if the code which defines an import filter
|
20
|
+
# is malformed
|
21
21
|
class MethodNeedsToBeImplemented < InternalError; end
|
22
22
|
|
23
|
-
#raised if one tries to use an unimplemented exception
|
23
|
+
# raised if one tries to use an unimplemented exception
|
24
24
|
class ExceptionNeedsToBeImplemented < InternalError; end
|
25
25
|
|
26
|
-
#raised if one forgot to store files at `path_to_instances`
|
26
|
+
# raised if one forgot to store files at `path_to_instances`
|
27
27
|
class NoImplementationsForModelFound < InternalError; end
|
28
28
|
|
29
|
-
#raised if an file system error occured
|
30
|
-
class FilesystemError < Exception
|
29
|
+
# raised if an file system error occured
|
30
|
+
class FilesystemError < Exception; end
|
31
31
|
|
32
|
-
#raise if a directory does not exist in filesystem
|
32
|
+
# raise if a directory does not exist in filesystem
|
33
33
|
class DirectoryDoesNotExist < FilesystemError; end
|
34
34
|
|
35
|
-
#raise if a file does not exist in filesystem
|
35
|
+
# raise if a file does not exist in filesystem
|
36
36
|
class FileDoesNotExist < FilesystemError; end
|
37
|
-
|
38
37
|
end
|
39
38
|
end
|
40
39
|
end
|
@@ -5,14 +5,13 @@ module FeduxOrgStdlib
|
|
5
5
|
module Models
|
6
6
|
# model for import action
|
7
7
|
module FilesystemBasedModel
|
8
|
-
|
9
8
|
def self.included(base)
|
10
9
|
base.extend ClassMethods
|
11
10
|
end
|
12
11
|
|
12
|
+
# Class methods
|
13
13
|
module ClassMethods
|
14
|
-
|
15
|
-
#initialize model
|
14
|
+
# initialize model
|
16
15
|
def init
|
17
16
|
load_from_filesystem
|
18
17
|
end
|
@@ -27,7 +26,7 @@ module FeduxOrgStdlib
|
|
27
26
|
end
|
28
27
|
|
29
28
|
def fqcn
|
30
|
-
|
29
|
+
to_s.split(/::/)
|
31
30
|
end
|
32
31
|
|
33
32
|
def model_name
|
@@ -39,11 +38,11 @@ module FeduxOrgStdlib
|
|
39
38
|
end
|
40
39
|
|
41
40
|
def suffix
|
42
|
-
|
41
|
+
fail FeduxOrgStdlib::Models::Exceptions::MethodNeedsToBeImplemented, "Please defined the method \"suffix\" to make the library work."
|
43
42
|
end
|
44
43
|
|
45
44
|
def model_path
|
46
|
-
|
45
|
+
fail FeduxOrgStdlib::Models::Exceptions::MethodNeedsToBeImplemented, "Please defined the method \"model_path\" to make the library work."
|
47
46
|
end
|
48
47
|
|
49
48
|
def ignore
|
@@ -54,9 +53,9 @@ module FeduxOrgStdlib
|
|
54
53
|
files = []
|
55
54
|
Find.find(path_to_instances) do |path|
|
56
55
|
next unless File.file? path
|
57
|
-
next if suffix
|
56
|
+
next if suffix && path !~ /#{suffix}$/
|
58
57
|
next if path =~ /^\.\.?/
|
59
|
-
next if path =~
|
58
|
+
next if path =~ /#{ignore}/
|
60
59
|
|
61
60
|
files << path
|
62
61
|
end
|
@@ -67,7 +66,7 @@ module FeduxOrgStdlib
|
|
67
66
|
end
|
68
67
|
|
69
68
|
def path_to_instances
|
70
|
-
return_path = ::File.expand_path("../../#{model_name.pluralize.underscore}", model_path
|
69
|
+
return_path = ::File.expand_path("../../#{model_name.pluralize.underscore}", model_path)
|
71
70
|
|
72
71
|
FeduxOrgStdlib.logger.debug(self) { "Path to instances of model: #{return_path}" }
|
73
72
|
|
@@ -75,8 +74,8 @@ module FeduxOrgStdlib
|
|
75
74
|
end
|
76
75
|
|
77
76
|
def name(path)
|
78
|
-
name = File.basename(path, suffix
|
79
|
-
|
77
|
+
name = File.basename(path, suffix).to_sym
|
78
|
+
fail FeduxOrgStdlib::Models::Exceptions::UnauthorizedUseOfKeyword if forbidden_keywords.include? name
|
80
79
|
|
81
80
|
FeduxOrgStdlib.logger.debug(self) { "Name of model: #{name}" }
|
82
81
|
|
@@ -84,15 +83,13 @@ module FeduxOrgStdlib
|
|
84
83
|
end
|
85
84
|
|
86
85
|
def load_from_filesystem
|
87
|
-
|
86
|
+
fail FeduxOrgStdlib::Models::Exceptions::MethodNeedsToBeImplemented
|
88
87
|
end
|
89
88
|
|
90
89
|
def forbidden_keywords
|
91
|
-
[
|
90
|
+
[]
|
92
91
|
end
|
93
|
-
|
94
92
|
end
|
95
|
-
|
96
93
|
end
|
97
94
|
end
|
98
95
|
end
|
@@ -1,5 +1,16 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
module FeduxOrgStdlib
|
3
|
+
# Abstract process environment
|
4
|
+
#
|
5
|
+
# @example Init
|
6
|
+
#
|
7
|
+
# env = ProcessEnvironment.new
|
8
|
+
# env.fetch('HOME') # => /home/user
|
9
|
+
# env.fetch('HOME_123', 'default') # => default
|
10
|
+
#
|
11
|
+
# env.write('HOME_123' 'you')
|
12
|
+
# env.fetch('HOME_123') # => you
|
13
|
+
#
|
3
14
|
class ProcessEnvironment
|
4
15
|
private
|
5
16
|
|
@@ -9,7 +20,6 @@ module FeduxOrgStdlib
|
|
9
20
|
|
10
21
|
def initialize(environment = ENV)
|
11
22
|
@environment = environment
|
12
|
-
|
13
23
|
end
|
14
24
|
|
15
25
|
def fetch(key, default_value = nil)
|
@@ -1,12 +1,13 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'fedux_org_stdlib/require_files'
|
3
|
-
require_library %w
|
3
|
+
require_library %w(command_exec)
|
4
4
|
|
5
5
|
require 'fedux_org_stdlib/project/logger'
|
6
6
|
|
7
7
|
module FeduxOrgStdlib
|
8
8
|
module Project
|
9
9
|
module Generators
|
10
|
+
# Taskjuggler
|
10
11
|
class Taskjuggler
|
11
12
|
# Generate report
|
12
13
|
#
|
@@ -15,24 +16,24 @@ module FeduxOrgStdlib
|
|
15
16
|
# @param [Plan] plan
|
16
17
|
# The project plan to use
|
17
18
|
def generate_report(directory, plan)
|
18
|
-
FeduxOrgStdlib::Project.logger.debug
|
19
|
+
FeduxOrgStdlib::Project.logger.debug 'Start generating report.'
|
19
20
|
|
20
21
|
begin
|
21
|
-
command = CommandExec::Command.new(:tj3
|
22
|
-
:
|
23
|
-
:
|
24
|
-
:
|
25
|
-
:
|
22
|
+
command = CommandExec::Command.new(:tj3,
|
23
|
+
parameter: "-o #{directory} #{plan}",
|
24
|
+
error_detection_on: [:return_code],
|
25
|
+
error_indicators: {
|
26
|
+
allowed_return_code: [0]
|
26
27
|
},
|
27
|
-
:
|
28
|
+
on_error_do: :raise_error
|
28
29
|
)
|
29
30
|
command.run
|
30
31
|
rescue CommandExec::Exceptions::CommandExecutionFailed
|
31
|
-
FeduxOrgStdlib::Project.logger.fatal "Failed to generate report:\n\n#{ command.result.stderr.join(
|
32
|
+
FeduxOrgStdlib::Project.logger.fatal "Failed to generate report:\n\n#{ command.result.stderr.join("\n") }"
|
32
33
|
exit 1
|
33
34
|
end
|
34
35
|
|
35
|
-
FeduxOrgStdlib::Project.logger.info
|
36
|
+
FeduxOrgStdlib::Project.logger.info 'Generating report succeeded.'
|
36
37
|
end
|
37
38
|
end
|
38
39
|
end
|
@@ -1,16 +1,16 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'fedux_org_stdlib/require_files'
|
3
|
-
require_library %w
|
3
|
+
require_library %w(fileutils launchy)
|
4
4
|
|
5
5
|
require 'fedux_org_stdlib/logging/logger'
|
6
6
|
require 'fedux_org_stdlib/project/logger'
|
7
7
|
require 'fedux_org_stdlib/project/generators/taskjuggler'
|
8
8
|
|
9
|
-
|
10
9
|
module FeduxOrgStdlib
|
10
|
+
# Project
|
11
11
|
module Project
|
12
|
+
# Taskjugger report
|
12
13
|
class Report
|
13
|
-
|
14
14
|
attr_reader :directory, :file
|
15
15
|
|
16
16
|
private
|
@@ -28,7 +28,7 @@ module FeduxOrgStdlib
|
|
28
28
|
# @param [Generator] generator
|
29
29
|
# A generator to be used to be generator the report
|
30
30
|
def initialize(
|
31
|
-
plan:,
|
31
|
+
plan:,
|
32
32
|
output_file:,
|
33
33
|
generator: FeduxOrgStdlib::Project::Generators::Taskjuggler.new
|
34
34
|
)
|
@@ -42,10 +42,10 @@ module FeduxOrgStdlib
|
|
42
42
|
def generate
|
43
43
|
prepare_environment
|
44
44
|
|
45
|
-
if output_file_does_not_exist?
|
46
|
-
generator.generate_report(output_directory, plan)
|
45
|
+
if output_file_does_not_exist? || plan_is_newer_than_output_file?
|
46
|
+
generator.generate_report(output_directory, plan)
|
47
47
|
else
|
48
|
-
FeduxOrgStdlib::Project.logger.warn "No need to re-generate report. The plan file \"#{plan
|
48
|
+
FeduxOrgStdlib::Project.logger.warn "No need to re-generate report. The plan file \"#{plan}\" is NOT newer than output \"#{@output_file}\"."
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -61,13 +61,12 @@ module FeduxOrgStdlib
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def output_file_does_not_exist?
|
64
|
-
!File.
|
64
|
+
!File.exist? output_file
|
65
65
|
end
|
66
66
|
|
67
67
|
def plan_is_newer_than_output_file?
|
68
68
|
plan.needs_to_be_compiled? output_file
|
69
69
|
end
|
70
70
|
end
|
71
|
-
|
72
71
|
end
|
73
72
|
end
|
@@ -4,15 +4,15 @@ require 'fedux_org_stdlib/project'
|
|
4
4
|
namespace :report do
|
5
5
|
|
6
6
|
plan = FeduxOrgStdlib::Project::Plan.new
|
7
|
-
report = FeduxOrgStdlib::Project::Report.new(
|
7
|
+
report = FeduxOrgStdlib::Project::Report.new(plan)
|
8
8
|
|
9
|
-
desc
|
9
|
+
desc 'Generate report'
|
10
10
|
task :generate do
|
11
11
|
report.generate
|
12
12
|
end
|
13
13
|
|
14
|
-
desc
|
15
|
-
task :
|
14
|
+
desc 'Show report'
|
15
|
+
task show: :generate do
|
16
16
|
report.open
|
17
17
|
end
|
18
18
|
end
|
@@ -8,7 +8,6 @@ module FeduxOrgStdlib
|
|
8
8
|
#
|
9
9
|
# @see Rakefile
|
10
10
|
class ProjectTask < Task
|
11
|
-
|
12
11
|
# @!attribute [r] report
|
13
12
|
# The report to be generated
|
14
13
|
attr_reader :report
|
@@ -26,12 +25,12 @@ module FeduxOrgStdlib
|
|
26
25
|
# FeduxOrgStdlib::Rake::ProjectTask.new
|
27
26
|
#
|
28
27
|
# @example Create new task using a different report file
|
29
|
-
# FeduxOrgStdlib::Rake::ProjectTask.new(
|
28
|
+
# FeduxOrgStdlib::Rake::ProjectTask.new(
|
30
29
|
# report_file: File.join(Dir.getwd, 'reports', 'Index.html')
|
31
30
|
# )
|
32
31
|
#
|
33
32
|
# @example Create new task using a different project plan and adding additional files
|
34
|
-
# FeduxOrgStdlib::Rake::ProjectTask.new(
|
33
|
+
# FeduxOrgStdlib::Rake::ProjectTask.new(
|
35
34
|
# plan_file: File.join(Dir.getwd, 'project1.tjp'),
|
36
35
|
# additional_files: %W{
|
37
36
|
# #{File.join(Dir.getwd, 'resources.tjp')}
|
@@ -2,7 +2,7 @@
|
|
2
2
|
require 'fedux_org_stdlib/require_files'
|
3
3
|
require 'fedux_org_stdlib/rake/task'
|
4
4
|
require 'fedux_org_stdlib/require_files'
|
5
|
-
require_library %w
|
5
|
+
require_library %w(erubis)
|
6
6
|
|
7
7
|
module FeduxOrgStdlib
|
8
8
|
module Rake
|
@@ -19,7 +19,7 @@ module FeduxOrgStdlib
|
|
19
19
|
attr_reader :use_bundler
|
20
20
|
|
21
21
|
# Create a new shell task
|
22
|
-
#
|
22
|
+
#
|
23
23
|
# @param [String] command
|
24
24
|
# The command to be executed
|
25
25
|
#
|
@@ -29,8 +29,8 @@ module FeduxOrgStdlib
|
|
29
29
|
# @see Task
|
30
30
|
# For other arguments accepted
|
31
31
|
def initialize(
|
32
|
-
command:,
|
33
|
-
use_bundler: false,
|
32
|
+
command:,
|
33
|
+
use_bundler: false,
|
34
34
|
**args
|
35
35
|
)
|
36
36
|
super(**args)
|
@@ -40,14 +40,14 @@ module FeduxOrgStdlib
|
|
40
40
|
end
|
41
41
|
|
42
42
|
# @private
|
43
|
-
def run_task(
|
43
|
+
def run_task(_verbose)
|
44
44
|
logger.warn 'Gemfile does not exist. Running bundler will fail. I am going to run the command without `bundle exec`.' unless gemfile_exists?
|
45
45
|
|
46
46
|
cmd = []
|
47
|
-
cmd << 'bundle exec' if use_bundler
|
47
|
+
cmd << 'bundle exec' if use_bundler && gemfile_exists?
|
48
48
|
cmd << command
|
49
49
|
|
50
|
-
sh Erubis::Eruby.new(cmd.join(' ')).result(
|
50
|
+
sh Erubis::Eruby.new(cmd.join(' ')).result(instance_binding)
|
51
51
|
end
|
52
52
|
|
53
53
|
private
|