fedux_org-stdlib 0.7.21 → 0.7.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/Gemfile +1 -1
  4. data/Gemfile.lock +23 -19
  5. data/Rakefile +16 -0
  6. data/config/rubocop/exclude.yml +44 -0
  7. data/config/rubocop/include.yml +0 -0
  8. data/fedux_org-stdlib.gemspec +9 -9
  9. data/fixtures/plugin-load-app/fedux_org_stdlib-fixtures-plugin_manager-plugin-load.gemspec +11 -11
  10. data/fixtures/plugin-no_load-app/fedux_org_stdlib-fixtures-plugin_manager-plugin-no_load.gemspec +11 -11
  11. data/lib/fedux_org_stdlib.rb +2 -1
  12. data/lib/fedux_org_stdlib/app_config.rb +22 -21
  13. data/lib/fedux_org_stdlib/colors/html_color.rb +8 -2
  14. data/lib/fedux_org_stdlib/command.rb +1 -0
  15. data/lib/fedux_org_stdlib/command/command_result.rb +1 -0
  16. data/lib/fedux_org_stdlib/command/run_command.rb +6 -5
  17. data/lib/fedux_org_stdlib/command/which.rb +17 -17
  18. data/lib/fedux_org_stdlib/core_ext/array/list.rb +6 -1
  19. data/lib/fedux_org_stdlib/core_ext/hash/list.rb +6 -1
  20. data/lib/fedux_org_stdlib/core_ext/hash/options.rb +1 -0
  21. data/lib/fedux_org_stdlib/core_ext/shellwords/clean.rb +8 -0
  22. data/lib/fedux_org_stdlib/core_ext/string/underline.rb +9 -1
  23. data/lib/fedux_org_stdlib/environment.rb +6 -4
  24. data/lib/fedux_org_stdlib/file_template.rb +8 -10
  25. data/lib/fedux_org_stdlib/filesystem.rb +30 -29
  26. data/lib/fedux_org_stdlib/filesystem/exceptions.rb +1 -1
  27. data/lib/fedux_org_stdlib/gem_plugins/exceptions.rb +1 -0
  28. data/lib/fedux_org_stdlib/gem_plugins/no_plugin.rb +1 -2
  29. data/lib/fedux_org_stdlib/gem_plugins/plugin.rb +6 -6
  30. data/lib/fedux_org_stdlib/gem_plugins/plugin_manager.rb +6 -7
  31. data/lib/fedux_org_stdlib/list.rb +24 -2
  32. data/lib/fedux_org_stdlib/logging.rb +3 -2
  33. data/lib/fedux_org_stdlib/logging/logger.rb +7 -7
  34. data/lib/fedux_org_stdlib/logging/severity.rb +3 -0
  35. data/lib/fedux_org_stdlib/logic_converters.rb +1 -0
  36. data/lib/fedux_org_stdlib/logic_converters/exceptions.rb +2 -2
  37. data/lib/fedux_org_stdlib/logic_converters/logic_converter.rb +9 -8
  38. data/lib/fedux_org_stdlib/logic_converters/on_off_converter.rb +5 -4
  39. data/lib/fedux_org_stdlib/logic_converters/true_false_converter.rb +3 -3
  40. data/lib/fedux_org_stdlib/logic_converters/y_n_converter.rb +3 -3
  41. data/lib/fedux_org_stdlib/logic_converters/yes_no_converter.rb +4 -3
  42. data/lib/fedux_org_stdlib/models/base_model.rb +24 -25
  43. data/lib/fedux_org_stdlib/models/class_based_model.rb +15 -14
  44. data/lib/fedux_org_stdlib/models/exceptions.rb +14 -15
  45. data/lib/fedux_org_stdlib/models/filesystem_based_model.rb +12 -15
  46. data/lib/fedux_org_stdlib/process_environment.rb +11 -1
  47. data/lib/fedux_org_stdlib/project.rb +0 -1
  48. data/lib/fedux_org_stdlib/project/generators/taskjuggler.rb +11 -10
  49. data/lib/fedux_org_stdlib/project/logger.rb +1 -0
  50. data/lib/fedux_org_stdlib/project/plan.rb +1 -1
  51. data/lib/fedux_org_stdlib/project/report.rb +8 -9
  52. data/lib/fedux_org_stdlib/rake/project.rb +4 -4
  53. data/lib/fedux_org_stdlib/rake/project_task.rb +2 -3
  54. data/lib/fedux_org_stdlib/rake/shell_task.rb +7 -7
  55. data/lib/fedux_org_stdlib/rake/sub_task.rb +2 -2
  56. data/lib/fedux_org_stdlib/rake/task.rb +7 -6
  57. data/lib/fedux_org_stdlib/rake/version_bump_task.rb +6 -7
  58. data/lib/fedux_org_stdlib/rake_tasks/console.rb +0 -1
  59. data/lib/fedux_org_stdlib/rake_tasks/documentation/yard.rb +2 -2
  60. data/lib/fedux_org_stdlib/rake_tasks/gems/bundler.rb +1 -1
  61. data/lib/fedux_org_stdlib/rake_tasks/gems/package.rb +1 -1
  62. data/lib/fedux_org_stdlib/rake_tasks/project/report/generate.rb +1 -2
  63. data/lib/fedux_org_stdlib/rake_tasks/project/report/open.rb +1 -2
  64. data/lib/fedux_org_stdlib/rake_tasks/project/report/open_shortcut.rb +1 -1
  65. data/lib/fedux_org_stdlib/rake_tasks/qa/rubocop.rb +1 -1
  66. data/lib/fedux_org_stdlib/rake_tasks/qa/travis.rb +1 -1
  67. data/lib/fedux_org_stdlib/rake_tasks/software_version/bump.rb +1 -1
  68. data/lib/fedux_org_stdlib/rake_tasks/software_version/restore.rb +1 -1
  69. data/lib/fedux_org_stdlib/rake_tasks/software_version/show.rb +2 -3
  70. data/lib/fedux_org_stdlib/rake_tasks/software_version/show_shortcut.rb +1 -1
  71. data/lib/fedux_org_stdlib/rake_tasks/tests/cucumber.rb +0 -1
  72. data/lib/fedux_org_stdlib/rake_tasks/tests/travis.rb +1 -1
  73. data/lib/fedux_org_stdlib/require_files.rb +5 -4
  74. data/lib/fedux_org_stdlib/roles/typable.rb +2 -3
  75. data/lib/fedux_org_stdlib/roles/versionable.rb +3 -2
  76. data/lib/fedux_org_stdlib/shell_language_detector.rb +21 -2
  77. data/lib/fedux_org_stdlib/shell_language_detector/language.rb +9 -1
  78. data/lib/fedux_org_stdlib/support_information.rb +60 -55
  79. data/lib/fedux_org_stdlib/template_directory.rb +8 -11
  80. data/lib/fedux_org_stdlib/version.rb +1 -1
  81. data/lib/fedux_org_stdlib/version_management/library_builder.rb +3 -2
  82. data/lib/fedux_org_stdlib/version_management/ruby_library.rb +2 -2
  83. data/lib/fedux_org_stdlib/version_management/rubygem_version_file.rb +3 -3
  84. data/lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb +5 -5
  85. data/lib/fedux_org_stdlib/version_management/software_version.rb +4 -3
  86. data/lib/fedux_org_stdlib/version_management/version_builder.rb +1 -0
  87. data/rakefiles/default.rake +16 -0
  88. data/script/terminal +5 -5
  89. data/spec/app_config_spec.rb +6 -6
  90. data/spec/colors/html_color_spec.rb +1 -1
  91. data/spec/core_ext/array/list_spec.rb +8 -8
  92. data/spec/core_ext/hash/options_spec.rb +17 -17
  93. data/spec/core_ext/shellwords/clean_spec.rb +1 -1
  94. data/spec/environment_spec.rb +7 -5
  95. data/spec/examples/models/class_based/invalid_2.rb +1 -1
  96. data/spec/examples/models/class_based/valid_2.rb +1 -0
  97. data/spec/gem_plugins/plugin_manager_spec.rb +1 -1
  98. data/spec/logger/logger_spec.rb +1 -1
  99. data/spec/models/base_model_spec.rb +22 -22
  100. data/spec/models/class_based_model_spec.rb +66 -66
  101. data/spec/models/filesystem_based_model_spec.rb +28 -28
  102. data/spec/project/plan_spec.rb +1 -1
  103. data/spec/project/report_spec.rb +2 -2
  104. data/spec/project/taskjuggler_spec.rb +4 -4
  105. data/spec/spec_helper.rb +1 -3
  106. data/spec/support/rspec.rb +1 -1
  107. data/spec/version_management/library_builder_spec.rb +2 -2
  108. data/spec/version_management/ruby_library_spec.rb +2 -2
  109. data/spec/version_management/rubygem_version_file_parser_spec.rb +8 -8
  110. data/spec/version_management/rubygem_version_file_spec.rb +8 -8
  111. data/spec/version_management/software_version_spec.rb +1 -1
  112. metadata +5 -2
@@ -3,6 +3,7 @@ require 'fedux_org_stdlib/command/run_command'
3
3
  require 'fedux_org_stdlib/command/which'
4
4
 
5
5
  module FeduxOrgStdlib
6
+ # Command module
6
7
  module Command
7
8
  include RunCommand
8
9
  include Which
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
  module FeduxOrgStdlib
3
3
  module Command
4
+ # Result of command execution
4
5
  class CommandResult
5
6
  attr_accessor :stderr, :stdout, :status
6
7
 
@@ -1,19 +1,20 @@
1
1
  # encoding: utf-8
2
2
  require 'fedux_org_stdlib/require_files'
3
- require_library %w{ open3 }
3
+ require_library %w(open3)
4
4
 
5
5
  require 'fedux_org_stdlib/environment'
6
6
  require 'fedux_org_stdlib/command/command_result'
7
7
 
8
8
  module FeduxOrgStdlib
9
9
  module Command
10
+ # Run command
10
11
  module RunCommand
11
12
  include Environment
12
13
 
13
14
  # Execute command
14
15
  #
15
16
  # @param [String] cmd
16
- # the command
17
+ # the command
17
18
  #
18
19
  # @param [Hash] options
19
20
  # the options for command execution
@@ -32,16 +33,16 @@ module FeduxOrgStdlib
32
33
  #
33
34
  # @return [CommandResult]
34
35
  # the result of the command execution
35
- def run_command(cmd,options={})
36
+ def run_command(cmd, options = {})
36
37
  opts = {
37
38
  env: nil,
38
39
  stdin: nil,
39
40
  binmode: false,
40
- working_directory: Dir.getwd,
41
+ working_directory: Dir.getwd
41
42
  }.merge options
42
43
 
43
44
  env = opts[:env] || ENV.to_hash
44
- stdin = opts[:stdin]
45
+ stdin = opts[:stdin]
45
46
  binmode = opts[:binmode]
46
47
  working_directory = opts[:working_directory]
47
48
 
@@ -1,11 +1,11 @@
1
1
  # encoding: utf-8
2
2
  require 'fedux_org_stdlib/require_files'
3
- require_library %w{ pathname active_support/core_ext/object/blank }
3
+ require_library %w(pathname active_support/core_ext/object/blank)
4
4
 
5
5
  module FeduxOrgStdlib
6
6
  module Command
7
+ # Find path to executable
7
8
  module Which
8
-
9
9
  # Search for command
10
10
  # @param [String] cmd
11
11
  # name of command or path to command (will be reduced to basename and then searched in PATH)
@@ -15,15 +15,15 @@ module FeduxOrgStdlib
15
15
  #
16
16
  # @param [Array,String] pathexts
17
17
  # a string containing pathexts separated by ";" or an array of pathexts
18
- #
19
- # @return [String]
18
+ #
19
+ # @return [String]
20
20
  # path to command
21
- def which(cmd, options={})
21
+ def which(cmd, options = {})
22
22
  options = {
23
23
  paths: ENV['PATH'].split(File::PATH_SEPARATOR),
24
- pathexts: ENV['PATHEXT'].to_s.split( /;/ ),
24
+ pathexts: ENV['PATHEXT'].to_s.split(/;/),
25
25
  raise_error_on_not_executable: false,
26
- raise_error_on_not_found: false,
26
+ raise_error_on_not_found: false
27
27
  }.merge options
28
28
 
29
29
  cmd = Pathname.new(cmd)
@@ -33,26 +33,26 @@ module FeduxOrgStdlib
33
33
  raise_error_on_not_executable = options[:raise_error_on_not_executable]
34
34
  raise_error_on_not_found = options[:raise_error_on_not_found]
35
35
 
36
- raise Exceptions::CommandNotFound if cmd.to_s.empty?
36
+ fail Exceptions::CommandNotFound if cmd.to_s.empty?
37
37
  return nil if cmd.to_s.empty?
38
38
 
39
- if cmd.absolute?
39
+ if cmd.absolute?
40
40
  return cmd.to_s if cmd.executable?
41
- raise Exceptions::CommandNotFound if raise_error_on_not_found and not cmd.exist?
42
- raise Exceptions::CommandNotExecutable if raise_error_on_not_executable and not cmd.executable?
41
+ fail Exceptions::CommandNotFound if raise_error_on_not_found && !cmd.exist?
42
+ fail Exceptions::CommandNotExecutable if raise_error_on_not_executable && !cmd.executable?
43
43
  return nil
44
44
  end
45
45
 
46
46
  pathexts = [''] if pathexts.blank?
47
47
 
48
- Array( paths ).each do |path|
49
- Array( pathexts ).each do |ext|
50
- file = Pathname.new( File.join(path, "#{cmd.to_s}#{ext.to_s}") )
48
+ Array(paths).each do |path|
49
+ Array(pathexts).each do |ext|
50
+ file = Pathname.new(File.join(path, "#{cmd}#{ext}"))
51
51
  return file.to_s if file.executable?
52
- raise Exceptions::CommandNotExecutable if raise_error_on_not_executable and not cmd.executable?
52
+ fail Exceptions::CommandNotExecutable if raise_error_on_not_executable && !cmd.executable?
53
53
  end
54
- end
55
- raise Exceptions::CommandNotFound if raise_error_on_not_found
54
+ end
55
+ fail Exceptions::CommandNotFound if raise_error_on_not_found
56
56
  nil
57
57
  end
58
58
  end
@@ -1,7 +1,12 @@
1
1
  # encoding: utf-8
2
+ # Array
2
3
  class Array
4
+ # Convert array to list
5
+ #
6
+ # @return [String]
7
+ # A string representation of list
3
8
  def to_list(separator: ', ', last_separator: separator, around: '"')
4
- items = self.map { |l| format("#{around}%s#{around}", l) }
9
+ items = map { |l| format("#{around}%s#{around}", l) }
5
10
 
6
11
  return items.join(last_separator) if items.size <= 2
7
12
 
@@ -1,8 +1,13 @@
1
1
  # encoding: utf-8
2
2
  require 'fedux_org_stdlib/core_ext/array/list'
3
3
 
4
+ # Hash
4
5
  class Hash
6
+ # Convert Hash to list
7
+ #
8
+ # @return [String]
9
+ # A string representation of hash as list
5
10
  def to_list
6
- self.map { |key, value| format('%s: %s', key, value) }.to_list
11
+ map { |key, value| format('%s: %s', key, value) }.to_list
7
12
  end
8
13
  end
@@ -2,6 +2,7 @@
2
2
  require 'shellwords'
3
3
  require 'fedux_org_stdlib/core_ext/shellwords/clean'
4
4
 
5
+ # Hash
5
6
  class Hash
6
7
  # Convert hash to command line options
7
8
  #
@@ -1,8 +1,16 @@
1
1
  # encoding: utf-8
2
2
  require 'shellwords'
3
3
 
4
+ # Shellwords
4
5
  module Shellwords
5
6
  class << self
7
+ # Clean string based shell pattern
8
+ #
9
+ # @param [String] string
10
+ # The string which should be clean up
11
+ #
12
+ # @return [String]
13
+ # Every character which needs to be escape in a shell has been removed
6
14
  def shellclean(string)
7
15
  shellescape(string).gsub(/\\./, '')
8
16
  end
@@ -1,9 +1,17 @@
1
1
  # encoding: utf-8
2
+ # String
2
3
  class String
4
+ # Underline a string
5
+ #
6
+ # @param [String] character ('-')
7
+ # The character used to underline the string
8
+ #
9
+ # @return [String]
10
+ # The string + underline
3
11
  def underline(character: '-')
4
12
  result = []
5
13
  result << self
6
- result << self.gsub(/./, character)
14
+ result << gsub(/./, character)
7
15
 
8
16
  result.join("\n")
9
17
  end
@@ -1,7 +1,9 @@
1
1
  # encoding: utf-8
2
2
  module FeduxOrgStdlib
3
+ # Enviroment helpers
4
+ #
5
+ # @deprecated Please use https://github.com/cucumber/aruba instead
3
6
  module Environment
4
-
5
7
  # Set environment variable for code block
6
8
  #
7
9
  # @param [Hash] new_environment_variables
@@ -11,11 +13,11 @@ module FeduxOrgStdlib
11
13
  # options for environment manipulation
12
14
  #
13
15
  # @option options [True,False] :clear
14
- # Should the environment clear before merge?
16
+ # Should the environment clear before merge?
15
17
  #
16
18
  # @yield
17
19
  # the block which should be run which the change environment
18
- def isolated_environment(new_environment_variables, options={}, &block)
20
+ def isolated_environment(new_environment_variables, options = {}, &block)
19
21
  old_environment = ENV.to_hash
20
22
 
21
23
  ENV.clear if options[:clear] == true
@@ -23,7 +25,7 @@ module FeduxOrgStdlib
23
25
 
24
26
  block.call
25
27
  ensure
26
- ENV.clear
28
+ ENV.clear
27
29
  ENV.update old_environment
28
30
  end
29
31
 
@@ -3,7 +3,7 @@ require 'fedux_org_stdlib/require_files'
3
3
  require 'fedux_org_stdlib/file_template/exceptions'
4
4
  require 'fedux_org_stdlib/core_ext/array/list'
5
5
  require 'fedux_org_stdlib/logging/logger'
6
- require_library %w{ json active_support/core_ext/string/inflections }
6
+ require_library %w(json active_support/core_ext/string/inflections)
7
7
 
8
8
  module FeduxOrgStdlib
9
9
  # This class makes a template file available as an object. You can use
@@ -25,7 +25,7 @@ module FeduxOrgStdlib
25
25
  # off, e.g "ClientTemplate" becomes "client.tt"
26
26
  #
27
27
  # Most conventions defined by me are implemented as separate methods. If one convention
28
- # is not suitable for your use case, just overwrite the method.
28
+ # is not suitable for your use case, just overwrite the method.
29
29
  #
30
30
  # If you prefer to use a different path to the template file or name of the
31
31
  # template file one of the following methods needs to be overwritten:
@@ -52,7 +52,6 @@ module FeduxOrgStdlib
52
52
  # ---
53
53
  # option1: 'data2'
54
54
  class FileTemplate
55
-
56
55
  attr_reader :working_directory, :output_directory, :logger, :file, :content
57
56
 
58
57
  # Create a new instance of template
@@ -69,7 +68,7 @@ module FeduxOrgStdlib
69
68
  # @return [AppTemplate]
70
69
  # The template instance. If the resulting data structure created by the
71
70
  # template_engine does not respond to `:[]` an empty template object will be
72
- # created.
71
+ # created.
73
72
  def initialize(
74
73
  file: nil,
75
74
  logger: FeduxOrgStdlib::Logging::Logger.new,
@@ -80,14 +79,14 @@ module FeduxOrgStdlib
80
79
  @working_directory = working_directory
81
80
  @output_directory = output_directory || working_directory
82
81
 
83
- @file ||= available_template_file
84
-
82
+ @file ||= (file || available_template_file)
83
+
85
84
  fail Exceptions::NoTemplateFileFound, "No template file found at #{allowed_template_file_paths.to_list}, therefor I'm stop working as there are methods which depend on an available template file path." unless @file
86
85
 
87
86
  begin
88
87
  @content = File.read(@file).chomp
89
88
  rescue StandardError => e
90
- fail Exceptions::TemplateFileNotReadable, JSON.dump(message: e.message, file: @file)
89
+ raise Exceptions::TemplateFileNotReadable, JSON.dump(message: e.message, file: @file)
91
90
  end
92
91
  end
93
92
 
@@ -175,7 +174,6 @@ module FeduxOrgStdlib
175
174
  ::File.expand_path(::File.join(*path))
176
175
  end
177
176
 
178
-
179
177
  # Use this path as fall back path
180
178
  def fallback_template_directory; end
181
179
 
@@ -188,11 +186,11 @@ module FeduxOrgStdlib
188
186
  end
189
187
 
190
188
  def available_template_file
191
- allowed_template_file_paths.map { |f| Dir.glob(f).first }.compact.find { |f| ::File.exists?(f) }
189
+ allowed_template_file_paths.map { |f| Dir.glob(f).first }.compact.find { |f| ::File.exist?(f) }
192
190
  end
193
191
 
194
192
  def self.reserved_key_words
195
- (methods | instance_methods | private_methods | private_instance_methods ) - (Class.methods | Class.private_methods ) | [:to_s]
193
+ (methods | instance_methods | private_methods | private_instance_methods) - (Class.methods | Class.private_methods) | [:to_s]
196
194
  end
197
195
 
198
196
  def basename
@@ -1,38 +1,39 @@
1
1
  # encoding: utf-8
2
2
  require 'fedux_org_stdlib/require_files'
3
- require_library %w{ fileutils }
3
+ require_library %w(fileutils)
4
4
 
5
5
  require 'fedux_org_stdlib/filesystem/exceptions'
6
6
 
7
7
  # helper for file system
8
8
  module FeduxOrgStdlib
9
+ # File system
10
+ # @deprecated Please use https://github.com/cucumber/aruba instead
9
11
  module Filesystem
10
-
11
12
  # The root directory of the project
12
13
  #
13
14
  # @return [String]
14
15
  # the root directory
15
16
  def root_directory
16
17
  #::File.expand_path('../../../', __FILE__)
17
- raise Exceptions::InvalidUsageOfLibrary , "Sorry, but you need to define the root directory yourself"
18
+ fail Exceptions::InvalidUsageOfLibrary, 'Sorry, but you need to define the root directory yourself'
18
19
  end
19
20
 
20
21
  # The temporary directory for the project
21
22
  #
22
23
  # @return [String]
23
- # the directory created for the tests
24
+ # the directory created for the tests
24
25
  def working_directory
25
26
  ::File.join(root_directory, 'tmp', 'test')
26
27
  end
27
28
 
28
29
  # Create temporary directory
29
30
  def create_working_directory
30
- FileUtils.mkdir_p(working_directory) unless ::File.exists? working_directory
31
+ FileUtils.mkdir_p(working_directory) unless ::File.exist? working_directory
31
32
  end
32
33
 
33
34
  # Delete temporary directory
34
35
  def delete_working_directory
35
- FileUtils.rm_rf(working_directory) if ::File.exists? working_directory
36
+ FileUtils.rm_rf(working_directory) if ::File.exist? working_directory
36
37
  end
37
38
 
38
39
  # Clean up test directory
@@ -41,7 +42,7 @@ module FeduxOrgStdlib
41
42
  create_working_directory
42
43
  end
43
44
 
44
- # Switch the current working directory to
45
+ # Switch the current working directory to
45
46
  # the temporary one and execute code block
46
47
  def switch_to_working_directory(&block)
47
48
  Dir.chdir(working_directory, &block)
@@ -53,8 +54,8 @@ module FeduxOrgStdlib
53
54
  # @param [String,Array] dirs
54
55
  # the directories to be created, multiple arguments are possible as well
55
56
  #
56
- # @return [String,Array]
57
- # returns a string if there was only one file given, and an array with
57
+ # @return [String,Array]
58
+ # returns a string if there was only one file given, and an array with
58
59
  # muliple files
59
60
  def create_directory(*dirs)
60
61
  raise_if_forbidden_path_for_create_operation(dirs)
@@ -74,8 +75,8 @@ module FeduxOrgStdlib
74
75
  # @param [String, Array] dirs
75
76
  # the directories to be deleted, multiple arguments are possible as well
76
77
  #
77
- # @return [String,Array]
78
- # returns a string if there was only one file given, and an array with
78
+ # @return [String,Array]
79
+ # returns a string if there was only one file given, and an array with
79
80
  # muliple files
80
81
  def delete_directory(*dirs)
81
82
  raise_if_forbidden_path_for_delete_operation(dirs)
@@ -101,7 +102,7 @@ module FeduxOrgStdlib
101
102
  raise_if_forbidden_path_for_create_operation(paths)
102
103
 
103
104
  paths_expanded = expand_path(paths.flatten)
104
- paths_expanded.flatten.all? { |p| ::File.exists?(p) }
105
+ paths_expanded.flatten.all? { |p| ::File.exist?(p) }
105
106
  end
106
107
 
107
108
  # Check absence of path(s)
@@ -112,7 +113,7 @@ module FeduxOrgStdlib
112
113
  # @return [TrueClass,FalseClass]
113
114
  # the result of all checks done
114
115
  def path_does_not_exist?(*paths)
115
- not path_exists?(paths)
116
+ !path_exists?(paths)
116
117
  end
117
118
 
118
119
  # Create a single file
@@ -125,14 +126,14 @@ module FeduxOrgStdlib
125
126
  #
126
127
  # @return [String]
127
128
  # the path to the created file
128
- def create_file(path, content='', mode=0644)
129
+ def create_file(path, content = '', mode = 0644)
129
130
  raise_if_forbidden_path_for_create_operation(path)
130
131
 
131
132
  file = expand_path(path).first
132
133
  directory = ::File.dirname(file)
133
134
 
134
135
  FileUtils.mkdir_p(directory) unless directory == '.'
135
- ::File.open(file, "wb") do |f|
136
+ ::File.open(file, 'wb') do |f|
136
137
  f.write content
137
138
  end
138
139
 
@@ -166,13 +167,13 @@ module FeduxOrgStdlib
166
167
  # @param [String] path
167
168
  # the path to the file
168
169
  #
169
- # @return [String,Binary]
170
+ # @return [String,Binary]
170
171
  # the content of the file
171
172
  def read_file(path)
172
173
  raise_if_forbidden_path_for_create_operation(path)
173
174
 
174
175
  file_path = expand_path(path).first
175
- return ::File.read(file_path)
176
+ ::File.read(file_path)
176
177
  end
177
178
 
178
179
  # Expand path based on temporary directory
@@ -185,18 +186,18 @@ module FeduxOrgStdlib
185
186
  def expand_path(*paths)
186
187
  raise_if_forbidden_path_for_create_operation(paths)
187
188
 
188
- paths.flatten.map do |p|
189
- case p
189
+ paths.flatten.map do |p|
190
+ case p
190
191
  when /^~/
191
- ::File.expand_path(p)
192
+ ::File.expand_path(p)
192
193
  else
193
- ::File.join(working_directory, p )
194
+ ::File.join(working_directory, p)
194
195
  end
195
196
  end
196
197
  end
197
198
 
198
199
  # Check if path is forbidden for delete operation
199
- #
200
+ #
200
201
  # @param [String, Array] paths
201
202
  # paths which should be checked
202
203
  #
@@ -205,9 +206,9 @@ module FeduxOrgStdlib
205
206
  def raise_if_forbidden_path_for_create_operation(*paths)
206
207
  flattend_paths = paths.flatten
207
208
  strings = []
208
- regex = %r[\.\.]
209
+ regex = /\.\./
209
210
 
210
- raise FileSystem::Exceptions::InvalidPath , "Sorry, but you cannot use paths matching \"#{strings.join(', ')}\" or \"#{regex.inspect}\" here!" if path_matches?(strings, regex, flattend_paths)
211
+ fail FileSystem::Exceptions::InvalidPath, "Sorry, but you cannot use paths matching \"#{strings.join(', ')}\" or \"#{regex.inspect}\" here!" if path_matches?(strings, regex, flattend_paths)
211
212
  end
212
213
 
213
214
  # Check if path is forbidden for delete operation
@@ -219,10 +220,10 @@ module FeduxOrgStdlib
219
220
  # true if path is forbidden, false if path is not forbidden
220
221
  def raise_if_forbidden_path_for_delete_operation(*paths)
221
222
  flattend_paths = paths.flatten
222
- strings = %w[ / ]
223
- regex = %r[\.\.]
223
+ strings = %w(/)
224
+ regex = /\.\./
224
225
 
225
- raise FileSystem::Exceptions::InvalidPath , "Sorry, but you cannot use paths matching \"#{strings.join(', ')}\" or \"#{regex.to_s}\" here!" if path_matches?(strings, regex, flattend_paths)
226
+ fail FileSystem::Exceptions::InvalidPath, "Sorry, but you cannot use paths matching \"#{strings.join(', ')}\" or \"#{regex}\" here!" if path_matches?(strings, regex, flattend_paths)
226
227
  end
227
228
 
228
229
  # Check if path matches
@@ -236,13 +237,13 @@ module FeduxOrgStdlib
236
237
  # @param [Array, String] paths
237
238
  # the paths to be checked
238
239
  #
239
- # @return [TrueClass, FalseClass]
240
+ # @return [TrueClass, FalseClass]
240
241
  # true if path is valid, false if invalid
241
242
  def path_matches?(strings, regex, *paths)
242
243
  flattend_paths = paths.flatten
243
244
  flattend_strings = strings.flatten
244
245
 
245
- flattend_paths.any? { |f| f =~ regex or flattend_strings.include?(f) }
246
+ flattend_paths.any? { |f| f =~ regex || flattend_strings.include?(f) }
246
247
  end
247
248
  end
248
249
  end