rubysmith 2.0.1 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,26 +6,29 @@ module Rubysmith
6
6
  module CLI
7
7
  # Assembles and parses all Command Line Interface (CLI) options.
8
8
  class Parser
9
+ include Import[:configuration]
10
+
9
11
  CLIENT = OptionParser.new nil, 40, " "
10
12
  SECTIONS = [Parsers::Core, Parsers::Build].freeze # Order is important.
11
13
 
12
- def initialize sections: SECTIONS, client: CLIENT, container: Container
14
+ def initialize sections: SECTIONS, client: CLIENT, **dependencies
15
+ super(**dependencies)
13
16
  @sections = sections
14
17
  @client = client
15
- @configuration = container[:configuration].dup
18
+ @configuration_duplicate = configuration.dup
16
19
  end
17
20
 
18
21
  def call arguments = []
19
- sections.each { |section| section.call configuration, client: }
22
+ sections.each { |section| section.call configuration_duplicate, client: }
20
23
  client.parse arguments
21
- configuration.freeze
24
+ configuration_duplicate.freeze
22
25
  end
23
26
 
24
27
  def to_s = client.to_s
25
28
 
26
29
  private
27
30
 
28
- attr_reader :sections, :client, :configuration
31
+ attr_reader :sections, :client, :configuration_duplicate
29
32
  end
30
33
  end
31
34
  end
@@ -7,16 +7,18 @@ module Rubysmith
7
7
  module Parsers
8
8
  # Handles parsing of Command Line Interface (CLI) build options.
9
9
  class Build
10
+ include Import[:colorizer]
11
+
10
12
  using Refinements::Structs
11
13
 
12
14
  def self.call(...) = new(...).call
13
15
 
14
16
  def initialize configuration = Container[:configuration],
15
17
  client: Parser::CLIENT,
16
- container: Container
18
+ **dependencies
19
+ super(**dependencies)
17
20
  @configuration = configuration
18
21
  @client = client
19
- @container = container
20
22
  end
21
23
 
22
24
  def call arguments = []
@@ -28,7 +30,7 @@ module Rubysmith
28
30
 
29
31
  private
30
32
 
31
- attr_reader :configuration, :client, :container
33
+ attr_reader :configuration, :client
32
34
 
33
35
  def collate = private_methods.sort.grep(/add_/).each { |method| __send__ method }
34
36
 
@@ -113,15 +115,6 @@ module Rubysmith
113
115
  end
114
116
  end
115
117
 
116
- def add_dead_end
117
- client.on(
118
- "--[no-]dead_end",
119
- "Add Dead End gem. #{default __method__}."
120
- ) do |value|
121
- configuration.merge! build_dead_end: value
122
- end
123
- end
124
-
125
118
  def add_debug
126
119
  client.on(
127
120
  "--[no-]debug",
@@ -300,8 +293,6 @@ module Rubysmith
300
293
  .then { |boolean| boolean ? colorizer.green(boolean) : colorizer.red(boolean) }
301
294
  .then { |colored_boolean| "Default: #{colored_boolean}" }
302
295
  end
303
-
304
- def colorizer = container[__method__]
305
296
  end
306
297
  end
307
298
  end
@@ -7,16 +7,18 @@ module Rubysmith
7
7
  module Parsers
8
8
  # Handles parsing of Command Line Interface (CLI) core options.
9
9
  class Core
10
+ include Import[:specification]
11
+
10
12
  using Refinements::Structs
11
13
 
12
14
  def self.call(...) = new(...).call
13
15
 
14
16
  def initialize configuration = Container[:configuration],
15
17
  client: Parser::CLIENT,
16
- container: Container
18
+ **dependencies
19
+ super(**dependencies)
17
20
  @configuration = configuration
18
21
  @client = client
19
- @container = container
20
22
  end
21
23
 
22
24
  def call arguments = []
@@ -29,7 +31,7 @@ module Rubysmith
29
31
 
30
32
  private
31
33
 
32
- attr_reader :configuration, :client, :container
34
+ attr_reader :configuration, :client
33
35
 
34
36
  def collate = private_methods.sort.grep(/add_/).each { |method| __send__ method }
35
37
 
@@ -65,8 +67,6 @@ module Rubysmith
65
67
  configuration.merge! action_help: true
66
68
  end
67
69
  end
68
-
69
- def specification = container[__method__]
70
70
  end
71
71
  end
72
72
  end
@@ -6,16 +6,11 @@ module Rubysmith
6
6
  module CLI
7
7
  # The main Command Line Interface (CLI) object.
8
8
  class Shell
9
- ACTIONS = {
10
- config: Actions::Config.new,
11
- build: Actions::Build.new,
12
- publish: Actions::Publish.new
13
- }.freeze
9
+ include Actions::Import[:config, :build, :publish, :specification, :logger]
14
10
 
15
- def initialize parser: Parser.new, actions: ACTIONS, container: Container
11
+ def initialize parser: Parser.new, **dependencies
12
+ super(**dependencies)
16
13
  @parser = parser
17
- @actions = actions
18
- @container = container
19
14
  end
20
15
 
21
16
  def call arguments = []
@@ -26,29 +21,17 @@ module Rubysmith
26
21
 
27
22
  private
28
23
 
29
- attr_reader :parser, :actions, :container
24
+ attr_reader :parser
30
25
 
31
26
  def perform configuration
32
27
  case configuration
33
- in action_config: Symbol => action then config action
34
- in action_build: true then build configuration
35
- in action_publish: true then publish configuration
28
+ in action_config: Symbol => action then config.call action
29
+ in action_build: true then build.call configuration
30
+ in action_publish: true then publish.call configuration
36
31
  in action_version: true then logger.info { specification.labeled_version }
37
- else usage
32
+ else logger.any { parser.to_s }
38
33
  end
39
34
  end
40
-
41
- def config(action) = actions.fetch(__method__).call(action)
42
-
43
- def build(configuration) = actions.fetch(__method__).call(configuration)
44
-
45
- def publish(configuration) = actions.fetch(__method__).call(configuration)
46
-
47
- def usage = logger.unknown(parser.to_s)
48
-
49
- def specification = container[__method__]
50
-
51
- def logger = container[__method__]
52
35
  end
53
36
  end
54
37
  end
@@ -32,7 +32,6 @@ module Rubysmith
32
32
  :build_conduct,
33
33
  :build_console,
34
34
  :build_contributions,
35
- :build_dead_end,
36
35
  :build_debug,
37
36
  :build_git,
38
37
  :build_git_hub,
@@ -58,7 +57,6 @@ module Rubysmith
58
57
  :documentation_format,
59
58
  :extensions_milestoner_documentation_format,
60
59
  :extensions_milestoner_prefixes,
61
- :extensions_milestoner_sign,
62
60
  :extensions_pragmater_comments,
63
61
  :extensions_pragmater_includes,
64
62
  :extensions_tocer_includes,
@@ -14,7 +14,6 @@
14
14
  :conduct: true
15
15
  :console: true
16
16
  :contributions: true
17
- :dead_end: true
18
17
  :debug: true
19
18
  :git: true
20
19
  :git_hub: false
@@ -43,14 +42,13 @@
43
42
  :extensions:
44
43
  :milestoner:
45
44
  :documentation:
46
- :format: "md"
45
+ :format: "adoc"
47
46
  :prefixes:
48
47
  - Fixed
49
48
  - Added
50
49
  - Updated
51
50
  - Removed
52
51
  - Refactored
53
- :sign: false
54
52
  :pragmater:
55
53
  :comments:
56
54
  - "# frozen_string_literal: true"
@@ -75,7 +73,7 @@
75
73
  :license:
76
74
  :label: Hippocratic
77
75
  :name: hippocratic
78
- :version: 3.0
76
+ :version: 2.1
79
77
  :project:
80
78
  :url:
81
79
  :community:
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "cogger"
3
4
  require "dry-container"
4
- require "logger"
5
5
  require "pastel"
6
6
  require "spek"
7
7
 
@@ -10,30 +10,10 @@ module Rubysmith
10
10
  module Container
11
11
  extend Dry::Container::Mixin
12
12
 
13
+ register(:colorizer) { Pastel.new enabled: $stdout.tty? }
13
14
  register(:configuration) { Configuration::Loader.call }
14
15
  register(:specification) { Spek::Loader.call "#{__dir__}/../../rubysmith.gemspec" }
15
- register(:colorizer) { Pastel.new enabled: $stdout.tty? }
16
16
  register(:kernel) { Kernel }
17
-
18
- register :log_colors do
19
- {
20
- "DEBUG" => self[:colorizer].white.detach,
21
- "INFO" => self[:colorizer].green.detach,
22
- "WARN" => self[:colorizer].yellow.detach,
23
- "ERROR" => self[:colorizer].red.detach,
24
- "FATAL" => self[:colorizer].white.bold.on_red.detach,
25
- "ANY" => self[:colorizer].white.bold.detach
26
- }
27
- end
28
-
29
- register :logger do
30
- Logger.new $stdout,
31
- level: Logger.const_get(ENV.fetch("LOG_LEVEL", "INFO")),
32
- formatter: (
33
- lambda do |severity, _at, _name, message|
34
- self[:log_colors][severity].call "#{message}\n"
35
- end
36
- )
37
- end
17
+ register(:logger) { Cogger::Client.new }
38
18
  end
39
19
  end
@@ -29,7 +29,6 @@ module Rubysmith
29
29
  content.transmute configuration,
30
30
  documentation_format: :extensions_milestoner_documentation_format,
31
31
  prefixes: :extensions_milestoner_prefixes,
32
- sign: :extensions_milestoner_sign,
33
32
  version: :project_version
34
33
  end
35
34
  end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "auto_injector"
4
+
5
+ module Rubysmith
6
+ Import = AutoInjector[Container]
7
+ end
@@ -14,13 +14,10 @@ group :code_quality do
14
14
  gem "bundler-leak", "~> 0.2"
15
15
  <% end %>
16
16
  <% if configuration.build_caliber %>
17
- gem "caliber", "~> 0.2"
18
- <% end %>
19
- <% if configuration.build_dead_end %>
20
- gem "dead_end", "~> 3.1"
17
+ gem "caliber", "~> 0.7"
21
18
  <% end %>
22
19
  <% if configuration.build_git && configuration.build_git_lint %>
23
- gem "git-lint", "~> 3.2"
20
+ gem "git-lint", "~> 4.0"
24
21
  <% end %>
25
22
  <% if configuration.build_reek %>
26
23
  gem "reek", "~> 6.1"
@@ -59,6 +56,6 @@ group :tools do
59
56
  gem "amazing_print", "~> 1.4"
60
57
  <% end %>
61
58
  <% if configuration.build_debug %>
62
- gem "debug", "~> 1.4"
59
+ gem "debug", "~> 1.5"
63
60
  <% end %>
64
61
  end