tocer 13.3.1 → 14.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 787a0bdf32ff6fae3d030f20af510108e90a28d6651848e555bec5b54c400e7f
4
- data.tar.gz: 8484f1773ec6ea4e0e58fc0117b1bd5110cbb4e4fa8ce7f09ffacd78bf8d08a8
3
+ metadata.gz: e9b76d98475c47f85bfd8cf3723422aed75e059273cb3250ad2c0a45a02bdc1c
4
+ data.tar.gz: 9289b2fc4bf6d891be4a232bdf5f30a040b0168f2b5cd53cd35f5b670ae91fbc
5
5
  SHA512:
6
- metadata.gz: d489743559ec1c1ef10236567c4e608cfb6cc7e9439403a939f1cfa72a6553093830acc3cdb1c774cd0ebd5e6fc0bbd40aba7e69ad30c2a9f5df3ec4a620ee42
7
- data.tar.gz: 82b7e466c34a39798c6d66ed8df7e753d57c96e7b922cdfbf39daf736cf7d6f5f41d221d12e7309a4fe293dd19b41b57d60b64e5a3fd8d4955595859c10d57cf
6
+ metadata.gz: 40a2b0c8315abdea0fcfc2490080c799cb4b7e1bdb6fb913c8a2727a80fbcb4ad74e261a84fc190590afb35c56447f0ed11f1785438feb07292091c9480292d1
7
+ data.tar.gz: d4b5bf39dcb038bee3a62fc04a7768b8c13ad3a1d1ff9d004f823a1636deca6cce8decf256048f7289668c8b20123b1b323a66d8849a1fc7b55a394991acde23
checksums.yaml.gz.sig CHANGED
Binary file
@@ -5,9 +5,11 @@ module Tocer
5
5
  module Actions
6
6
  # Handles the config action.
7
7
  class Config
8
- def initialize client: Configuration::Loader::CLIENT, container: Container
8
+ include Tocer::Import[:kernel, :logger]
9
+
10
+ def initialize client: Configuration::Loader::CLIENT, **dependencies
11
+ super(**dependencies)
9
12
  @client = client
10
- @container = container
11
13
  end
12
14
 
13
15
  def call selection
@@ -20,15 +22,11 @@ module Tocer
20
22
 
21
23
  private
22
24
 
23
- attr_reader :client, :container
25
+ attr_reader :client
24
26
 
25
27
  def edit = kernel.system("$EDITOR #{client.current}")
26
28
 
27
29
  def view = kernel.system("cat #{client.current}")
28
-
29
- def kernel = container[__method__]
30
-
31
- def logger = container[__method__]
32
30
  end
33
31
  end
34
32
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dry/container"
4
+
5
+ module Tocer
6
+ module CLI
7
+ module Actions
8
+ # Provides a single container with application and action specific dependencies.
9
+ module Container
10
+ extend Dry::Container::Mixin
11
+
12
+ config.registry = ->(container, key, value, _options) { container[key.to_s] = value }
13
+
14
+ merge Tocer::Container
15
+
16
+ register(:config) { Config.new }
17
+ register(:insert) { Insert.new }
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "auto_injector"
4
+
5
+ module Tocer
6
+ module CLI
7
+ module Actions
8
+ Import = AutoInjector[Container]
9
+ end
10
+ end
11
+ end
@@ -5,9 +5,11 @@ module Tocer
5
5
  module Actions
6
6
  # Handles the insert action.
7
7
  class Insert
8
- def initialize runner: Runner.new, container: Container
8
+ include Tocer::Import[:logger]
9
+
10
+ def initialize runner: Runner.new, **dependencies
11
+ super(**dependencies)
9
12
  @runner = runner
10
- @container = container
11
13
  end
12
14
 
13
15
  def call configuration
@@ -16,9 +18,7 @@ module Tocer
16
18
 
17
19
  private
18
20
 
19
- attr_reader :runner, :container
20
-
21
- def logger = container[__method__]
21
+ attr_reader :runner
22
22
  end
23
23
  end
24
24
  end
@@ -6,26 +6,29 @@ module Tocer
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
- SECTIONS = [Parsers::Core, Parsers::Flag].freeze # Order is important.
12
+ SECTIONS = [Parsers::Core, Parsers::Flag].freeze # Order matters.
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 { |parser| parser.call configuration, client: }
22
+ sections.each { |parser| parser.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 Tocer
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
- def initialize configuration = Configuration::Loader.call,
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 Tocer
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
 
@@ -67,8 +69,6 @@ module Tocer
67
69
  configuration.merge! action_help: true
68
70
  end
69
71
  end
70
-
71
- def specification = container[__method__]
72
72
  end
73
73
  end
74
74
  end
@@ -11,7 +11,7 @@ module Tocer
11
11
 
12
12
  def self.call(...) = new(...).call
13
13
 
14
- def initialize configuration = Configuration::Loader.call, client: Parser::CLIENT
14
+ def initialize configuration = Container[:configuration], client: Parser::CLIENT
15
15
  @configuration = configuration
16
16
  @client = client
17
17
  end
@@ -4,12 +4,11 @@ module Tocer
4
4
  module CLI
5
5
  # The main Command Line Interface (CLI) object.
6
6
  class Shell
7
- ACTIONS = {config: Actions::Config.new, insert: Actions::Insert.new}.freeze
7
+ include Actions::Import[:config, :insert, :specification, :logger]
8
8
 
9
- def initialize parser: Parser.new, actions: ACTIONS, container: Container
9
+ def initialize parser: Parser.new, **dependencies
10
+ super(**dependencies)
10
11
  @parser = parser
11
- @actions = actions
12
- @container = container
13
12
  end
14
13
 
15
14
  def call arguments = []
@@ -20,26 +19,16 @@ module Tocer
20
19
 
21
20
  private
22
21
 
23
- attr_reader :parser, :actions, :container
22
+ attr_reader :parser
24
23
 
25
24
  def perform configuration
26
25
  case configuration
27
- in action_config: Symbol => action then process_config action
28
- in action_insert: true then process_insert configuration
26
+ in action_config: Symbol => action then config.call action
27
+ in action_insert: true then insert.call configuration
29
28
  in action_version: true then logger.info { specification.labeled_version }
30
- else usage
29
+ else logger.any { parser.to_s }
31
30
  end
32
31
  end
33
-
34
- def process_config(action) = actions.fetch(:config).call(action)
35
-
36
- def process_insert(configuration) = actions.fetch(:insert).call(configuration)
37
-
38
- def usage = puts(parser.to_s)
39
-
40
- def specification = container[__method__]
41
-
42
- def logger = container[__method__]
43
32
  end
44
33
  end
45
34
  end
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "cogger"
3
4
  require "dry-container"
4
- require "logger"
5
- require "pastel"
6
5
  require "spek"
7
6
 
8
7
  module Tocer
@@ -12,28 +11,7 @@ module Tocer
12
11
 
13
12
  register(:configuration) { Configuration::Loader.call }
14
13
  register(:specification) { Spek::Loader.call "#{__dir__}/../../tocer.gemspec" }
15
- register(:colorizer) { Pastel.new enabled: $stdout.tty? }
16
14
  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
15
+ register(:logger) { Cogger::Client.new }
38
16
  end
39
17
  end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "auto_injector"
4
+
5
+ module Tocer
6
+ Import = AutoInjector[Container]
7
+ end
@@ -13,7 +13,7 @@ module Tocer
13
13
 
14
14
  def self.setup = new.install
15
15
 
16
- def initialize configuration = Configuration::Loader.call, runner: Runner.new
16
+ def initialize configuration = Container[:configuration], runner: Runner.new
17
17
  @configuration = configuration
18
18
  @runner = runner
19
19
  end
data/lib/tocer/runner.rb CHANGED
@@ -11,7 +11,7 @@ module Tocer
11
11
  @writer = writer
12
12
  end
13
13
 
14
- def call configuration = Configuration::Loader.call
14
+ def call configuration = Container[:configuration]
15
15
  Pathname(configuration.root_dir).files(%({#{configuration.includes.join ","}}))
16
16
  .each do |path|
17
17
  yield path if block_given?
data/tocer.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "tocer"
5
- spec.version = "13.3.1"
5
+ spec.version = "14.1.0"
6
6
  spec.authors = ["Brooke Kuhlmann"]
7
7
  spec.email = ["brooke@alchemists.io"]
8
8
  spec.homepage = "https://www.alchemists.io/projects/tocer"
@@ -13,6 +13,7 @@ Gem::Specification.new do |spec|
13
13
  "bug_tracker_uri" => "https://github.com/bkuhlmann/tocer/issues",
14
14
  "changelog_uri" => "https://www.alchemists.io/projects/tocer/versions",
15
15
  "documentation_uri" => "https://www.alchemists.io/projects/tocer",
16
+ "funding_uri" => "https://github.com/sponsors/bkuhlmann",
16
17
  "label" => "Tocer",
17
18
  "rubygems_mfa_required" => "true",
18
19
  "source_code_uri" => "https://github.com/bkuhlmann/tocer"
@@ -22,11 +23,12 @@ Gem::Specification.new do |spec|
22
23
  spec.cert_chain = [Gem.default_cert_path]
23
24
 
24
25
  spec.required_ruby_version = "~> 3.1"
26
+ spec.add_dependency "auto_injector", "~> 0.5"
27
+ spec.add_dependency "cogger", "~> 0.1"
25
28
  spec.add_dependency "dry-container", "~> 0.9"
26
- spec.add_dependency "pastel", "~> 0.8"
27
- spec.add_dependency "refinements", "~> 9.2"
28
- spec.add_dependency "runcom", "~> 8.2"
29
- spec.add_dependency "spek", "~> 0.2"
29
+ spec.add_dependency "refinements", "~> 9.4"
30
+ spec.add_dependency "runcom", "~> 8.4"
31
+ spec.add_dependency "spek", "~> 0.3"
30
32
  spec.add_dependency "zeitwerk", "~> 2.5"
31
33
 
32
34
  spec.bindir = "exe"
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tocer
3
3
  version: !ruby/object:Gem::Version
4
- version: 13.3.1
4
+ version: 14.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -10,9 +10,9 @@ bindir: exe
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIC/jCCAeagAwIBAgIBBDANBgkqhkiG9w0BAQsFADAlMSMwIQYDVQQDDBpicm9v
14
- a2UvREM9YWxjaGVtaXN0cy9EQz1pbzAeFw0yMTAzMTkxMjQ4MDZaFw0yMjAzMTkx
15
- MjQ4MDZaMCUxIzAhBgNVBAMMGmJyb29rZS9EQz1hbGNoZW1pc3RzL0RDPWlvMIIB
13
+ MIIC/jCCAeagAwIBAgIBBTANBgkqhkiG9w0BAQsFADAlMSMwIQYDVQQDDBpicm9v
14
+ a2UvREM9YWxjaGVtaXN0cy9EQz1pbzAeFw0yMjAzMTkxNzI0MzJaFw0yMzAzMTkx
15
+ NzI0MzJaMCUxIzAhBgNVBAMMGmJyb29rZS9EQz1hbGNoZW1pc3RzL0RDPWlv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Sl
26
+ +JRxiH5t4WtnDiVyoYl5nYC02rYdjJkG6VMxDymXTqn7u6HhYgZkGujq1UPar8x2
27
+ hNIWJblDKKSu7hA2d6+kUthuYo13o1sg1Da/AEDg0hoZSUvhqDEF5Hy232qb3pDt
28
+ CxDe2+VuChj4I1nvIHdu+E6XoEVlanUPKmSg6nddhkKn2gC45Kyzh6FZqnzH/CRp
29
+ RFE=
30
30
  -----END CERTIFICATE-----
31
- date: 2022-03-04 00:00:00.000000000 Z
31
+ date: 2022-05-07 00:00:00.000000000 Z
32
32
  dependencies:
33
33
  - !ruby/object:Gem::Dependency
34
- name: dry-container
34
+ name: auto_injector
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '0.9'
39
+ version: '0.5'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '0.9'
46
+ version: '0.5'
47
47
  - !ruby/object:Gem::Dependency
48
- name: pastel
48
+ name: cogger
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '0.8'
53
+ version: '0.1'
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '0.8'
60
+ version: '0.1'
61
+ - !ruby/object:Gem::Dependency
62
+ name: dry-container
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '0.9'
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '0.9'
61
75
  - !ruby/object:Gem::Dependency
62
76
  name: refinements
63
77
  requirement: !ruby/object:Gem::Requirement
64
78
  requirements:
65
79
  - - "~>"
66
80
  - !ruby/object:Gem::Version
67
- version: '9.2'
81
+ version: '9.4'
68
82
  type: :runtime
69
83
  prerelease: false
70
84
  version_requirements: !ruby/object:Gem::Requirement
71
85
  requirements:
72
86
  - - "~>"
73
87
  - !ruby/object:Gem::Version
74
- version: '9.2'
88
+ version: '9.4'
75
89
  - !ruby/object:Gem::Dependency
76
90
  name: runcom
77
91
  requirement: !ruby/object:Gem::Requirement
78
92
  requirements:
79
93
  - - "~>"
80
94
  - !ruby/object:Gem::Version
81
- version: '8.2'
95
+ version: '8.4'
82
96
  type: :runtime
83
97
  prerelease: false
84
98
  version_requirements: !ruby/object:Gem::Requirement
85
99
  requirements:
86
100
  - - "~>"
87
101
  - !ruby/object:Gem::Version
88
- version: '8.2'
102
+ version: '8.4'
89
103
  - !ruby/object:Gem::Dependency
90
104
  name: spek
91
105
  requirement: !ruby/object:Gem::Requirement
92
106
  requirements:
93
107
  - - "~>"
94
108
  - !ruby/object:Gem::Version
95
- version: '0.2'
109
+ version: '0.3'
96
110
  type: :runtime
97
111
  prerelease: false
98
112
  version_requirements: !ruby/object:Gem::Requirement
99
113
  requirements:
100
114
  - - "~>"
101
115
  - !ruby/object:Gem::Version
102
- version: '0.2'
116
+ version: '0.3'
103
117
  - !ruby/object:Gem::Dependency
104
118
  name: zeitwerk
105
119
  requirement: !ruby/object:Gem::Requirement
@@ -130,6 +144,8 @@ files:
130
144
  - lib/tocer.rb
131
145
  - lib/tocer/builder.rb
132
146
  - lib/tocer/cli/actions/config.rb
147
+ - lib/tocer/cli/actions/container.rb
148
+ - lib/tocer/cli/actions/import.rb
133
149
  - lib/tocer/cli/actions/insert.rb
134
150
  - lib/tocer/cli/parser.rb
135
151
  - lib/tocer/cli/parsers/core.rb
@@ -140,6 +156,7 @@ files:
140
156
  - lib/tocer/configuration/loader.rb
141
157
  - lib/tocer/container.rb
142
158
  - lib/tocer/elements/comment_block.rb
159
+ - lib/tocer/import.rb
143
160
  - lib/tocer/parsers/header.rb
144
161
  - lib/tocer/rake/setup.rb
145
162
  - lib/tocer/rake/tasks.rb
@@ -156,6 +173,7 @@ metadata:
156
173
  bug_tracker_uri: https://github.com/bkuhlmann/tocer/issues
157
174
  changelog_uri: https://www.alchemists.io/projects/tocer/versions
158
175
  documentation_uri: https://www.alchemists.io/projects/tocer
176
+ funding_uri: https://github.com/sponsors/bkuhlmann
159
177
  label: Tocer
160
178
  rubygems_mfa_required: 'true'
161
179
  source_code_uri: https://github.com/bkuhlmann/tocer
@@ -174,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
192
  - !ruby/object:Gem::Version
175
193
  version: '0'
176
194
  requirements: []
177
- rubygems_version: 3.3.8
195
+ rubygems_version: 3.3.13
178
196
  signing_key:
179
197
  specification_version: 4
180
198
  summary: A command line interface for generating table of contents for Markdown files.
metadata.gz.sig CHANGED
Binary file