hexx 7.1.0 → 8.0.0

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 (82) hide show
  1. checksums.yaml +4 -4
  2. data/.coveralls.yml +2 -0
  3. data/.gitignore +9 -0
  4. data/.metrics +5 -0
  5. data/.rspec +2 -0
  6. data/.rubocop.yml +2 -63
  7. data/.travis.yml +5 -0
  8. data/.yardopts +2 -0
  9. data/Gemfile +3 -0
  10. data/Guardfile +16 -0
  11. data/{LICENSE.rdoc → LICENSE} +2 -2
  12. data/README.md +138 -0
  13. data/Rakefile +8 -14
  14. data/config/initializer.rb +5 -0
  15. data/config/initializers/capture.rb +19 -0
  16. data/config/initializers/sandbox.rb +16 -0
  17. data/config/initializers/sandbox/helpers.rb +38 -0
  18. data/config/initializers/sandbox/matchers.rb +19 -0
  19. data/config/metrics/STYLEGUIDE +230 -0
  20. data/config/metrics/cane.yml +5 -0
  21. data/config/metrics/churn.yml +6 -0
  22. data/config/metrics/flay.yml +2 -0
  23. data/config/metrics/metric_fu.yml +15 -0
  24. data/config/metrics/pippi.yml +3 -0
  25. data/config/metrics/reek.yml +1 -0
  26. data/config/metrics/roodi.yml +24 -0
  27. data/config/metrics/rubocop.yml +79 -0
  28. data/config/metrics/saikuro.yml +3 -0
  29. data/config/metrics/simplecov.yml +6 -0
  30. data/config/metrics/yardstick.yml +37 -0
  31. data/hexx.gemspec +24 -0
  32. data/lib/hexx.rb +8 -15
  33. data/lib/hexx/generator.rb +71 -0
  34. data/lib/hexx/generator/file.rb +83 -0
  35. data/lib/hexx/generator/folder.rb +68 -0
  36. data/lib/hexx/name.rb +122 -46
  37. data/lib/hexx/version.rb +6 -5
  38. data/spec/fixtures/root/_.beta +1 -0
  39. data/spec/fixtures/root/__omega +0 -0
  40. data/spec/fixtures/root/delta.erb.erb +0 -0
  41. data/spec/fixtures/root/gamma.rb.erb +1 -0
  42. data/spec/fixtures/root/subfolder/alfa.yml +0 -0
  43. data/spec/spec_helper.rb +5 -10
  44. data/spec/tests/lib/generator_spec.rb +126 -0
  45. data/spec/tests/lib/name_spec.rb +113 -0
  46. metadata +54 -168
  47. data/README.rdoc +0 -371
  48. data/lib/hexx/coercible.rb +0 -43
  49. data/lib/hexx/configurable.rb +0 -101
  50. data/lib/hexx/creators/base.rb +0 -103
  51. data/lib/hexx/creators/coercion.rb +0 -82
  52. data/lib/hexx/creators/dependency.rb +0 -87
  53. data/lib/hexx/creators/module_dependency.rb +0 -57
  54. data/lib/hexx/creators/parameter.rb +0 -40
  55. data/lib/hexx/dependable.rb +0 -51
  56. data/lib/hexx/helpers/exceptions.rb +0 -53
  57. data/lib/hexx/helpers/messages.rb +0 -26
  58. data/lib/hexx/helpers/parameters.rb +0 -47
  59. data/lib/hexx/helpers/validations.rb +0 -21
  60. data/lib/hexx/message.rb +0 -79
  61. data/lib/hexx/null.rb +0 -218
  62. data/lib/hexx/service.rb +0 -388
  63. data/lib/hexx/service/with_callbacks.rb +0 -104
  64. data/lib/hexx/service_invalid.rb +0 -73
  65. data/spec/hexx/coercible_spec.rb +0 -72
  66. data/spec/hexx/configurable_spec.rb +0 -93
  67. data/spec/hexx/dependable_spec.rb +0 -125
  68. data/spec/hexx/helpers/exceptions_spec.rb +0 -96
  69. data/spec/hexx/helpers/messages_spec.rb +0 -48
  70. data/spec/hexx/helpers/parameters_spec.rb +0 -96
  71. data/spec/hexx/helpers/validations_spec.rb +0 -32
  72. data/spec/hexx/message_spec.rb +0 -83
  73. data/spec/hexx/name_spec.rb +0 -80
  74. data/spec/hexx/null_spec.rb +0 -152
  75. data/spec/hexx/service_invalid_spec.rb +0 -46
  76. data/spec/hexx/service_spec.rb +0 -89
  77. data/spec/support/initializers/focus.rb +0 -5
  78. data/spec/support/initializers/garbage_collection.rb +0 -11
  79. data/spec/support/initializers/i18n.rb +0 -3
  80. data/spec/support/initializers/random_order.rb +0 -4
  81. data/spec/support/initializers/rspec.rb +0 -5
  82. data/spec/support/matchers/methods.rb +0 -11
@@ -0,0 +1,5 @@
1
+ ---
2
+ abc_max: "10"
3
+ line_length: "80"
4
+ no_doc: "y"
5
+ no_readme: "y"
@@ -0,0 +1,6 @@
1
+ ---
2
+ ignore_files:
3
+ - spec
4
+ - config
5
+ minimum_churn_count: 0
6
+ start_date: "1 year ago"
@@ -0,0 +1,2 @@
1
+ ---
2
+ minimum_score: 10
@@ -0,0 +1,15 @@
1
+ ---
2
+ folders: # The list of folders to be used by any metric.
3
+ - lib
4
+ - app
5
+ metrics: # The list of allowed metrics. The other metrics are disabled.
6
+ - cane
7
+ - churn
8
+ - flay
9
+ - flog
10
+ - reek
11
+ - roodi
12
+ - saikuro
13
+ format: html
14
+ output: tmp/metric_fu
15
+ verbose: false
@@ -0,0 +1,3 @@
1
+ ---
2
+ checkset: basic
3
+ output: "tmp/pippi/output.log"
@@ -0,0 +1 @@
1
+ ---
@@ -0,0 +1,24 @@
1
+ ---
2
+ AssignmentInConditionalCheck:
3
+ CaseMissingElseCheck:
4
+ ClassLineCountCheck:
5
+ line_count: 300
6
+ ClassNameCheck:
7
+ pattern: !ruby/regexp /^[A-Z][a-zA-Z0-9]*$/
8
+ ClassVariableCheck:
9
+ CyclomaticComplexityBlockCheck:
10
+ complexity: 4
11
+ CyclomaticComplexityMethodCheck:
12
+ complexity: 8
13
+ EmptyRescueBodyCheck:
14
+ ForLoopCheck:
15
+ MethodLineCountCheck:
16
+ line_count: 20
17
+ MethodNameCheck:
18
+ pattern: !ruby/regexp /^[\||\^|\&|\!]$|^[_a-z<>=\[|+-\/\*`]+[_a-z0-9_<>=~@\[\]]*[=!\?]?$/
19
+ ModuleLineCountCheck:
20
+ line_count: 300
21
+ ModuleNameCheck:
22
+ pattern: !ruby/regexp /^[A-Z][a-zA-Z0-9]*$/
23
+ ParameterNumberCheck:
24
+ parameter_count: 5
@@ -0,0 +1,79 @@
1
+ ---
2
+ # settings added by the 'hexx-suit' module
3
+ # output: "tmp/rubocop"
4
+ # format: "html"
5
+
6
+ AllCops:
7
+ Exclude:
8
+ - '**/db/schema.rb'
9
+
10
+ Lint/HandleExceptions:
11
+ Exclude:
12
+ - '**/*_spec.rb'
13
+
14
+ Lint/RescueException:
15
+ Exclude:
16
+ - '**/*_spec.rb'
17
+
18
+ Metrics/ClassLength:
19
+ Exclude:
20
+ - '**/generator.rb'
21
+
22
+ Style/AccessorMethodName:
23
+ Exclude:
24
+ - '**/*_spec.rb'
25
+
26
+ Style/AsciiComments:
27
+ Enabled: false
28
+
29
+ Style/ClassAndModuleChildren:
30
+ Exclude:
31
+ - '**/*_spec.rb'
32
+
33
+ Style/Documentation:
34
+ Exclude:
35
+ - '**/version.rb'
36
+ - '**/*_spec.rb'
37
+
38
+ Style/EmptyLinesAroundBlockBody:
39
+ Enabled: false
40
+
41
+ Style/EmptyLinesAroundClassBody:
42
+ Enabled: false
43
+
44
+ Style/EmptyLinesAroundMethodBody:
45
+ Enabled: false
46
+
47
+ Style/EmptyLinesAroundModuleBody:
48
+ Enabled: false
49
+
50
+ Style/EmptyLineBetweenDefs:
51
+ Enabled: false
52
+
53
+ Style/FileName:
54
+ Enabled: false
55
+
56
+ Style/RaiseArgs:
57
+ EnforcedStyle: compact
58
+
59
+ Style/SingleLineMethods:
60
+ Exclude:
61
+ - '**/*_spec.rb'
62
+
63
+ Style/SingleSpaceBeforeFirstArg:
64
+ Enabled: false
65
+
66
+ Style/SpecialGlobalVars:
67
+ Exclude:
68
+ - '**/Gemfile'
69
+ - '**/*.gemspec'
70
+
71
+ Style/StringLiterals:
72
+ EnforcedStyle: double_quotes
73
+
74
+ Style/StringLiteralsInInterpolation:
75
+ EnforcedStyle: double_quotes
76
+
77
+ Style/TrivialAccessors:
78
+ Exclude:
79
+ - '**/*_spec.rb'
@@ -0,0 +1,3 @@
1
+ ---
2
+ warn_cyclo: 4
3
+ error_cyclo: 6
@@ -0,0 +1,6 @@
1
+ ---
2
+ output: tmp/coverage
3
+ filters: # The list of paths to be excluded from coverage checkup
4
+ - "spec/"
5
+ - "config/"
6
+ groups: []
@@ -0,0 +1,37 @@
1
+ ---
2
+ # Settings added by the 'hexx-suit' gem
3
+ output: "tmp/yardstick/output.log"
4
+ path: "lib/**/*.rb"
5
+ rules:
6
+ ApiTag::Presence:
7
+ enabled: true
8
+ exclude: []
9
+ ApiTag::Inclusion:
10
+ enabled: true
11
+ exclude: []
12
+ ApiTag::ProtectedMethod:
13
+ enabled: true
14
+ exclude: []
15
+ ApiTag::PrivateMethod:
16
+ enabled: false
17
+ exclude: []
18
+ ExampleTag:
19
+ enabled: true
20
+ exclude: []
21
+ ReturnTag:
22
+ enabled: true
23
+ exclude: []
24
+ Summary::Presence:
25
+ enabled: true
26
+ exclude: []
27
+ Summary::Length:
28
+ enabled: true
29
+ exclude: []
30
+ Summary::Delimiter:
31
+ enabled: true
32
+ exclude: []
33
+ Summary::SingleLine:
34
+ enabled: true
35
+ exclude: []
36
+ threshold: 100
37
+ verbose: false
@@ -0,0 +1,24 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+ require "hexx/version"
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "hexx"
6
+ s.version = Hexx::VERSION.dup
7
+ s.author = "Andrew Kozin"
8
+ s.email = "andrew.kozin@gmail.com"
9
+ s.homepage = "https://github.com/nepalez/hexx"
10
+ s.description = "Collection of scaffolders."
11
+ s.summary = "Collection of scaffolders for projects that follow " \
12
+ "the hexagonal architecture."
13
+ s.license = "MIT"
14
+ s.platform = Gem::Platform::RUBY
15
+ s.required_ruby_version = ">= 2.1"
16
+
17
+ s.require_paths = ["lib"]
18
+ s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
19
+ s.test_files = Dir["spec/**/*.rb"]
20
+ s.extra_rdoc_files = Dir["README.md", "LICENSE", "config/metrics/STYLEGUIDE"]
21
+
22
+ s.add_runtime_dependency "extlib", "~> 0.9"
23
+ s.add_runtime_dependency "hexx-suit", "~> 0.0"
24
+ end
@@ -1,18 +1,11 @@
1
- # encoding: utf-8
2
- require "active_model"
3
- require "wisper"
1
+ # encodint: utf-8
2
+ require "hexx-suit"
4
3
 
5
- # Loading gem code (the order is essential).
6
- root = File.expand_path "../hexx", __FILE__
7
- Dir[
8
- "#{ root }/creators/*.rb",
9
- "#{ root }/helpers/*.rb",
10
- "#{ root }/models/**/*.rb",
11
- "#{ root }/service/**/*.rb",
12
- "#{ root }/**/*.rb"
13
- ].each { |f| require f }
4
+ require_relative "../config/initializer"
5
+ require_relative "hexx/generator"
6
+ require_relative "hexx/name"
14
7
 
15
- # @api show
16
- # Namespace for the gem.
8
+ # Collection of scaffolders for projects that follows the Hexagonal architecture
17
9
  module Hexx
18
- end
10
+
11
+ end # module Hexx
@@ -0,0 +1,71 @@
1
+ # encoding: utf-8
2
+ require_relative "generator/file"
3
+ require_relative "generator/folder"
4
+
5
+ module Hexx
6
+
7
+ # Base class for scaffolders
8
+ #
9
+ # Adds actions to the generator
10
+ #
11
+ # @example (see #from_template)
12
+ # @example (see #copy_folder)
13
+ class Generator < Thor::Group
14
+ include Thor::Actions
15
+
16
+ private
17
+
18
+ # Returns source root defined for the class
19
+ #
20
+ # @return [String, Array<String>]
21
+ def source_root
22
+ self.class.send :source_root
23
+ end
24
+
25
+ # Returns content of source (relative to source root), preprocessed by ERB
26
+ #
27
+ # @example
28
+ # # source_root/file.erb
29
+ # <%= 2 * 2 %>
30
+ #
31
+ # scaffolder = Hexx::Generator.new
32
+ # scaffolder.send :from_template, "file.erb"
33
+ # # => "4"
34
+ #
35
+ # @return [#to_s] source
36
+ #
37
+ # @api public
38
+ def from_template(source)
39
+ path = find_in_source_paths(source)
40
+ content = ::File.read(path)
41
+ ERB.new(content, nil, "-").result
42
+ end
43
+
44
+ # Copies files from source folder into the destination one
45
+ #
46
+ # Wherein:
47
+ #
48
+ # * Files with a '.erb' extension are treated as templates and preprocessed
49
+ # by ERB. They saved under initial names without '.erb' extension.
50
+ #
51
+ # * The underscore symbol "_" in the beginning of filename is removed.
52
+ # You can copy dotfiles by underscoring them.
53
+ #
54
+ # @example
55
+ # scaffolder = Hexx::Generator.new
56
+ #
57
+ # scaffolder.copy_folder "root", "spec", skip: true
58
+ # # root/_.settings --> spec/.settings
59
+ # # root/spec_helper.rb.erb --> spec/spec_helper.rb
60
+ # # root/tests/test_spec.rb --> spec/tests/test_spec.rb
61
+ #
62
+ # @return [undefined]
63
+ #
64
+ # @api public
65
+ def copy_folder(source, target = source, options = {})
66
+ Folder.new(self).copy(source, target, options)
67
+ end
68
+
69
+ end # class Generator
70
+
71
+ end # module Hexx
@@ -0,0 +1,83 @@
1
+ # encoding: utf-8
2
+ require "pathname"
3
+
4
+ module Hexx
5
+
6
+ # Utilities to copy files and folders in a scaffolder context
7
+ class Generator < Thor::Group
8
+
9
+ # Copies a file from a source path to the target folder
10
+ #
11
+ # * Files, that have '.erb' extension, are pre-processed as erb templates.
12
+ # * The starting "_" symbol is removed from a file name.
13
+ #
14
+ # @api private
15
+ class File
16
+
17
+ # @!scope class
18
+ # @!method new(scaffolder, source, target, options = {})
19
+ # Constructs the processor for given scaffolder, source and target paths
20
+ #
21
+ # @param [Thor::Actions] scaffolder
22
+ # the decorated scaffolder
23
+ # @param [Pathname] source
24
+ # the source folder path to take file from
25
+ # @param [Pathname] target
26
+ # the target folder path to copy file to
27
+ # @param [Hash] options
28
+ # the list of options to copy file
29
+ #
30
+ # @return [Hexx::Processors::File]
31
+ def initialize(scaffolder, source, target, options = {})
32
+ @__scaffolder__ = scaffolder
33
+ @source = source
34
+ @target = target
35
+ @options = options
36
+ end
37
+
38
+ # Makes a copy of given source file
39
+ #
40
+ # @param [Pathname] source_file
41
+ #
42
+ # @return [self] itself
43
+ def copy(source_file)
44
+ @source_file = source_file
45
+ __scaffolder__.send(copy_method, source_path, target_path, options)
46
+
47
+ self
48
+ end
49
+
50
+ private
51
+
52
+ attr_reader :__scaffolder__, :source, :target, :options, :source_file
53
+
54
+ def source_root
55
+ @source_root ||= Pathname.new __scaffolder__.send(:source_root)
56
+ end
57
+
58
+ def copy_method
59
+ (source_file.extname == ".erb") ? :template : :copy_file
60
+ end
61
+
62
+ def source_path
63
+ source_file.relative_path_from(source_root).to_s
64
+ end
65
+
66
+ def target_path
67
+ (target_dirname + target_filename).to_s
68
+ end
69
+
70
+ def target_dirname
71
+ target + source_file.relative_path_from(source).dirname
72
+ end
73
+
74
+ def target_filename
75
+ basename = source_file.basename(".erb").to_s
76
+ basename[0] == "_" ? basename[1..-1].to_s : basename
77
+ end
78
+
79
+ end # class File
80
+
81
+ end # class Generator
82
+
83
+ end # module Hexx
@@ -0,0 +1,68 @@
1
+ module Hexx
2
+
3
+ class Generator < Thor::Group
4
+
5
+ # Copies all files from a source folder to the target one
6
+ #
7
+ # * Files, that have '.erb' extension, are pre-processed as erb templates.
8
+ # * The starting "_" symbol is removed from a file name.
9
+ #
10
+ # @api private
11
+ class Folder
12
+
13
+ # @!scope class
14
+ # @!method new(scaffolder)
15
+ # Constructs the processor for given scaffolder
16
+ #
17
+ # @param [Thor::Actions] scaffolder
18
+ #
19
+ # @return [Hexx::Processors::Folder]
20
+ def initialize(scaffolder)
21
+ @__scaffolder__ = scaffolder
22
+ end
23
+
24
+ # Copies a source folder content to the target folder
25
+ #
26
+ # @param [String] source
27
+ # The source folder path relative to the scaffolder's source_root
28
+ # @param [String] target
29
+ # The target folder path relative to the scaffolder's destination_root
30
+ # @param [Hash] options
31
+ #
32
+ # @return [self] itself
33
+ def copy(source, target, options = {})
34
+ @source, @target, @options = source, target, options
35
+ source_files.each { |file| file_processor.copy(file) }
36
+
37
+ self
38
+ end
39
+
40
+ private
41
+
42
+ attr_reader :__scaffolder__, :source, :target, :options
43
+
44
+ def source_files
45
+ source_paths.map(&Pathname.method(:new)).select(&:file?)
46
+ end
47
+
48
+ def file_processor
49
+ File.new __scaffolder__, source_folder, target_folder, options
50
+ end
51
+
52
+ def source_paths
53
+ ::Dir[source_folder + "**/*"]
54
+ end
55
+
56
+ def source_folder
57
+ Pathname.new(__scaffolder__.send :source_root).join(source)
58
+ end
59
+
60
+ def target_folder
61
+ Pathname.new(__scaffolder__.send :destination_root).join(target)
62
+ end
63
+
64
+ end # class Folder
65
+
66
+ end # class Generator
67
+
68
+ end # module Hexx