tocer 13.0.0 → 13.2.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: f01d37e55755b4242744ef97618aa53d885ebc991720b6dc51e61d0ffc33bdf3
4
- data.tar.gz: f64c607d7696f9f8b558beec2cd2d7ff4d65e3744b3a3d7a88e684af620e806e
3
+ metadata.gz: 106fe66e91b4c302490857f948a672413a10e7729d56af5800964a3409fcfb17
4
+ data.tar.gz: b1569fe8b8ef51f0f2174d2506c8f1cba3b2180bdc47c8c60c28c0a6712e2e78
5
5
  SHA512:
6
- metadata.gz: c551b013375913a6de8e5c4f0d61bf10113a6f05598e418214c8f0f22bd2b2208b12a69d04bdec8157d51e2ab80bd175ca1ed49271978340d82bcd55373f35dc
7
- data.tar.gz: 2a61d437c27b50bce2a5d537fe7a1edba22af45599a1c4fc0b3d2c97be4cf3460a3a6a17b7dfc5b7824b3cfbc41c771721545fbf1f8e5dae472997f702742fe6
6
+ metadata.gz: 7574ea429e82b68a289e7c9c288b417d87a7d93f0a9b123766e2579c90eca585e63b97c1c41947f03696e430ec183112ff04d38095b7b4b98f34e269692b7a5d
7
+ data.tar.gz: 10378c3612273946c194e6a414c614ad4bb47dde72aa1c407cadc9122f9549eb939e223f059acdce5cf904be7be2fb11424627792c0db18871c11551829d0481
checksums.yaml.gz.sig CHANGED
Binary file
data/README.adoc CHANGED
@@ -4,13 +4,6 @@
4
4
 
5
5
  = Tocer
6
6
 
7
- [link=http://badge.fury.io/rb/tocer]
8
- image::https://badge.fury.io/rb/tocer.svg[Gem Version]
9
- [link=https://www.alchemists.io/projects/code_quality]
10
- image::https://img.shields.io/badge/code_style-alchemists-brightgreen.svg[Alchemists Style Guide]
11
- [link=https://circleci.com/gh/bkuhlmann/tocer]
12
- image::https://circleci.com/gh/bkuhlmann/tocer.svg?style=svg[Circle CI Status]
13
-
14
7
  Tocer (a.k.a. Table of Contenter) is a command line interface for generating table of contents for
15
8
  Markdown files. Use this tool to automatically manage and update your documentation with minimal
16
9
  effort. Works on single files or multiple files within nested directory structures.
@@ -176,35 +169,17 @@ To test, run:
176
169
  bundle exec rake
177
170
  ----
178
171
 
179
- == Versioning
180
-
181
- Read link:https://semver.org[Semantic Versioning] for details. Briefly, it means:
182
-
183
- * Major (X.y.z) - Incremented for any backwards incompatible public API changes.
184
- * Minor (x.Y.z) - Incremented for new, backwards compatible, public API enhancements/fixes.
185
- * Patch (x.y.Z) - Incremented for small, backwards compatible, bug fixes.
186
-
187
- == Code of Conduct
188
-
189
- Please note that this project is released with a link:CODE_OF_CONDUCT.adoc[CODE OF CONDUCT]. By
190
- participating in this project you agree to abide by its terms.
191
-
192
- == Contributions
193
-
194
- Read link:CONTRIBUTING.adoc[CONTRIBUTING] for details.
195
-
196
- == Community
172
+ == link:https://www.alchemists.io/policies/license[License]
197
173
 
198
- Feel free to link:https://www.alchemists.io/community[join the commmunity] for discussions related
199
- to this project and much more.
174
+ == link:https://www.alchemists.io/policies/security[Security]
200
175
 
201
- == License
176
+ == link:https://www.alchemists.io/policies/code_of_conduct[Code of Conduct]
202
177
 
203
- Read link:LICENSE.adoc[LICENSE] for details.
178
+ == link:https://www.alchemists.io/policies/contributions[Contributions]
204
179
 
205
- == Changes
180
+ == link:https://www.alchemists.io/projects/tocer/versions[Versions]
206
181
 
207
- Read link:CHANGES.adoc[CHANGES] for details.
182
+ == link:https://www.alchemists.io/community[Community]
208
183
 
209
184
  == Credits
210
185
 
data/exe/tocer CHANGED
@@ -3,5 +3,4 @@
3
3
 
4
4
  require "tocer"
5
5
 
6
- Process.setproctitle Tocer::Identity::VERSION_LABEL
7
6
  Tocer::CLI::Shell.new.call ARGV
@@ -5,26 +5,30 @@ module Tocer
5
5
  module Actions
6
6
  # Handles the config action.
7
7
  class Config
8
- def initialize client: Configuration::Loader::CLIENT, kernel: Kernel
8
+ def initialize client: Configuration::Loader::CLIENT, container: Container
9
9
  @client = client
10
- @kernel = kernel
10
+ @container = container
11
11
  end
12
12
 
13
- def call action
14
- case action
13
+ def call selection
14
+ case selection
15
15
  when :edit then edit
16
16
  when :view then view
17
- else kernel.puts "Invalid configuration action: #{action}."
17
+ else logger.error { "Invalid configuration selection: #{selection}." }
18
18
  end
19
19
  end
20
20
 
21
21
  private
22
22
 
23
- attr_reader :client, :kernel
23
+ attr_reader :client, :container
24
24
 
25
25
  def edit = kernel.system("$EDITOR #{client.current}")
26
26
 
27
27
  def view = kernel.system("cat #{client.current}")
28
+
29
+ def kernel = container[__method__]
30
+
31
+ def logger = container[__method__]
28
32
  end
29
33
  end
30
34
  end
@@ -5,15 +5,20 @@ module Tocer
5
5
  module Actions
6
6
  # Handles the insert action.
7
7
  class Insert
8
- def initialize runner: Runner.new
8
+ def initialize runner: Runner.new, container: Container
9
9
  @runner = runner
10
+ @container = container
10
11
  end
11
12
 
12
- def call(configuration) = runner.call(configuration) { |path| puts " #{path}" }
13
+ def call configuration
14
+ runner.call(configuration) { |path| logger.info { " #{path}" } }
15
+ end
13
16
 
14
17
  private
15
18
 
16
- attr_reader :runner
19
+ attr_reader :runner, :container
20
+
21
+ def logger = container[__method__]
17
22
  end
18
23
  end
19
24
  end
@@ -9,10 +9,10 @@ module Tocer
9
9
  CLIENT = OptionParser.new nil, 40, " "
10
10
  SECTIONS = [Parsers::Core, Parsers::Flag].freeze # Order is important.
11
11
 
12
- def initialize configuration = Configuration::Loader.call, sections: SECTIONS, client: CLIENT
13
- @configuration = configuration.dup
12
+ def initialize sections: SECTIONS, client: CLIENT, container: Container
14
13
  @sections = sections
15
14
  @client = client
15
+ @configuration = container[:configuration].dup
16
16
  end
17
17
 
18
18
  def call arguments = []
@@ -25,7 +25,7 @@ module Tocer
25
25
 
26
26
  private
27
27
 
28
- attr_reader :configuration, :sections, :client
28
+ attr_reader :sections, :client, :configuration
29
29
  end
30
30
  end
31
31
  end
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "tocer/identity"
4
3
  require "refinements/structs"
5
4
 
6
5
  module Tocer
@@ -12,13 +11,16 @@ module Tocer
12
11
 
13
12
  def self.call(...) = new(...).call
14
13
 
15
- def initialize configuration = Configuration::Loader.call, client: Parser::CLIENT
14
+ def initialize configuration = Configuration::Loader.call,
15
+ client: Parser::CLIENT,
16
+ container: Container
16
17
  @configuration = configuration
17
18
  @client = client
19
+ @container = container
18
20
  end
19
21
 
20
22
  def call arguments = []
21
- client.banner = "#{Identity::LABEL} - #{Identity::SUMMARY}"
23
+ client.banner = specification.labeled_summary
22
24
  client.separator "\nUSAGE:\n"
23
25
  collate
24
26
  client.parse arguments
@@ -27,7 +29,7 @@ module Tocer
27
29
 
28
30
  private
29
31
 
30
- attr_reader :configuration, :client
32
+ attr_reader :configuration, :client, :container
31
33
 
32
34
  def collate = private_methods.sort.grep(/add_/).each { |method| __send__ method }
33
35
 
@@ -65,6 +67,8 @@ module Tocer
65
67
  configuration.merge! action_help: true
66
68
  end
67
69
  end
70
+
71
+ def specification = container[__method__]
68
72
  end
69
73
  end
70
74
  end
@@ -6,9 +6,10 @@ module Tocer
6
6
  class Shell
7
7
  ACTIONS = {config: Actions::Config.new, insert: Actions::Insert.new}.freeze
8
8
 
9
- def initialize parser: Parser.new, actions: ACTIONS
9
+ def initialize parser: Parser.new, actions: ACTIONS, container: Container
10
10
  @parser = parser
11
11
  @actions = actions
12
+ @container = container
12
13
  end
13
14
 
14
15
  def call arguments = []
@@ -19,13 +20,13 @@ module Tocer
19
20
 
20
21
  private
21
22
 
22
- attr_reader :parser, :actions
23
+ attr_reader :parser, :actions, :container
23
24
 
24
25
  def perform configuration
25
26
  case configuration
26
27
  in action_config: Symbol => action then process_config action
27
28
  in action_insert: true then process_insert configuration
28
- in action_version: true then puts Identity::VERSION_LABEL
29
+ in action_version: true then logger.info { specification.labeled_version }
29
30
  else usage
30
31
  end
31
32
  end
@@ -35,6 +36,10 @@ module Tocer
35
36
  def process_insert(configuration) = actions.fetch(:insert).call(configuration)
36
37
 
37
38
  def usage = puts(parser.to_s)
39
+
40
+ def specification = container[__method__]
41
+
42
+ def logger = container[__method__]
38
43
  end
39
44
  end
40
45
  end
@@ -12,7 +12,7 @@ module Tocer
12
12
  using Refinements::Structs
13
13
 
14
14
  DEFAULTS = YAML.load_file(Pathname(__dir__).join("defaults.yml")).freeze
15
- CLIENT = Runcom::Config.new "#{Identity::NAME}/configuration.yml", defaults: DEFAULTS
15
+ CLIENT = Runcom::Config.new "tocer/configuration.yml", defaults: DEFAULTS
16
16
 
17
17
  def self.call = new.call
18
18
 
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dry-container"
4
+ require "logger"
5
+ require "pastel"
6
+ require "spek"
7
+
8
+ module Tocer
9
+ # Provides a global gem container for injection into other objects.
10
+ module Container
11
+ extend Dry::Container::Mixin
12
+
13
+ register(:configuration) { Configuration::Loader.call }
14
+ register(:specification) { Spek::Loader.call "#{__dir__}/../../tocer.gemspec" }
15
+ register(:colorizer) { Pastel.new enabled: $stdout.tty? }
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
38
+ end
39
+ end
@@ -12,7 +12,7 @@ module Tocer
12
12
 
13
13
  def call markdown
14
14
  transformers.find do |pattern, transformer|
15
- break transformer.new(markdown) if pattern.match? markdown
15
+ break transformer.new markdown if pattern.match? markdown
16
16
  end
17
17
  end
18
18
 
data/lib/tocer/writer.rb CHANGED
@@ -48,10 +48,10 @@ module Tocer
48
48
  end
49
49
 
50
50
  def new_lines lines, label, finish_index
51
- if builder.unbuildable?(lines)
51
+ if builder.unbuildable? lines
52
52
  builder.comments
53
53
  else
54
- content(lines[finish_index, lines.length], label)
54
+ content lines[finish_index, lines.length], label
55
55
  end
56
56
  end
57
57
 
data/lib/tocer.rb CHANGED
@@ -4,7 +4,7 @@ require "zeitwerk"
4
4
 
5
5
  Zeitwerk::Loader.for_gem.then do |loader|
6
6
  loader.inflector.inflect "cli" => "CLI"
7
- loader.ignore "#{__dir__}/rake/setup.rb"
7
+ loader.ignore "#{__dir__}/tocer/rake"
8
8
  loader.setup
9
9
  end
10
10
 
data/tocer.gemspec ADDED
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "tocer"
5
+ spec.version = "13.2.0"
6
+ spec.authors = ["Brooke Kuhlmann"]
7
+ spec.email = ["brooke@alchemists.io"]
8
+ spec.homepage = "https://www.alchemists.io/projects/tocer"
9
+ spec.summary = "A command line interface for generating table of contents for Markdown files."
10
+ spec.license = "Hippocratic-3.0"
11
+
12
+ spec.metadata = {
13
+ "bug_tracker_uri" => "https://github.com/bkuhlmann/tocer/issues",
14
+ "changelog_uri" => "https://www.alchemists.io/projects/tocer/versions",
15
+ "documentation_uri" => "https://www.alchemists.io/projects/tocer",
16
+ "label" => "Tocer",
17
+ "rubygems_mfa_required" => "true",
18
+ "source_code_uri" => "https://github.com/bkuhlmann/tocer"
19
+ }
20
+
21
+ spec.signing_key = Gem.default_key_path
22
+ spec.cert_chain = [Gem.default_cert_path]
23
+
24
+ spec.required_ruby_version = "~> 3.1"
25
+ spec.add_dependency "dry-container", "~> 0.9"
26
+ spec.add_dependency "pastel", "~> 0.8"
27
+ spec.add_dependency "refinements", "~> 9.1"
28
+ spec.add_dependency "runcom", "~> 8.2"
29
+ spec.add_dependency "spek", "~> 0.0"
30
+ spec.add_dependency "zeitwerk", "~> 2.5"
31
+
32
+ spec.bindir = "exe"
33
+ spec.executables << "tocer"
34
+ spec.extra_rdoc_files = Dir["README*", "LICENSE*"]
35
+ spec.files = Dir["*.gemspec", "lib/**/*"]
36
+ end
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.0.0
4
+ version: 13.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -28,36 +28,78 @@ cert_chain:
28
28
  lkHilIrX69jq8wMPpBhlaw2mRmeSL50Wv5u6xVBvOHhXFSP1crXM95vfLhLyRYod
29
29
  W2A=
30
30
  -----END CERTIFICATE-----
31
- date: 2021-12-29 00:00:00.000000000 Z
31
+ date: 2022-02-06 00:00:00.000000000 Z
32
32
  dependencies:
33
+ - !ruby/object:Gem::Dependency
34
+ name: dry-container
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '0.9'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '0.9'
47
+ - !ruby/object:Gem::Dependency
48
+ name: pastel
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '0.8'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '0.8'
33
61
  - !ruby/object:Gem::Dependency
34
62
  name: refinements
35
63
  requirement: !ruby/object:Gem::Requirement
36
64
  requirements:
37
65
  - - "~>"
38
66
  - !ruby/object:Gem::Version
39
- version: '9.0'
67
+ version: '9.1'
40
68
  type: :runtime
41
69
  prerelease: false
42
70
  version_requirements: !ruby/object:Gem::Requirement
43
71
  requirements:
44
72
  - - "~>"
45
73
  - !ruby/object:Gem::Version
46
- version: '9.0'
74
+ version: '9.1'
47
75
  - !ruby/object:Gem::Dependency
48
76
  name: runcom
49
77
  requirement: !ruby/object:Gem::Requirement
50
78
  requirements:
51
79
  - - "~>"
52
80
  - !ruby/object:Gem::Version
53
- version: '8.0'
81
+ version: '8.2'
82
+ type: :runtime
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '8.2'
89
+ - !ruby/object:Gem::Dependency
90
+ name: spek
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '0.0'
54
96
  type: :runtime
55
97
  prerelease: false
56
98
  version_requirements: !ruby/object:Gem::Requirement
57
99
  requirements:
58
100
  - - "~>"
59
101
  - !ruby/object:Gem::Version
60
- version: '8.0'
102
+ version: '0.0'
61
103
  - !ruby/object:Gem::Dependency
62
104
  name: zeitwerk
63
105
  requirement: !ruby/object:Gem::Requirement
@@ -96,8 +138,8 @@ files:
96
138
  - lib/tocer/configuration/content.rb
97
139
  - lib/tocer/configuration/defaults.yml
98
140
  - lib/tocer/configuration/loader.rb
141
+ - lib/tocer/container.rb
99
142
  - lib/tocer/elements/comment_block.rb
100
- - lib/tocer/identity.rb
101
143
  - lib/tocer/parsers/header.rb
102
144
  - lib/tocer/rake/setup.rb
103
145
  - lib/tocer/rake/tasks.rb
@@ -106,13 +148,15 @@ files:
106
148
  - lib/tocer/transformers/link.rb
107
149
  - lib/tocer/transformers/text.rb
108
150
  - lib/tocer/writer.rb
151
+ - tocer.gemspec
109
152
  homepage: https://www.alchemists.io/projects/tocer
110
153
  licenses:
111
154
  - Hippocratic-3.0
112
155
  metadata:
113
156
  bug_tracker_uri: https://github.com/bkuhlmann/tocer/issues
114
- changelog_uri: https://www.alchemists.io/projects/tocer/changes.html
157
+ changelog_uri: https://www.alchemists.io/projects/tocer/versions
115
158
  documentation_uri: https://www.alchemists.io/projects/tocer
159
+ label: Tocer
116
160
  rubygems_mfa_required: 'true'
117
161
  source_code_uri: https://github.com/bkuhlmann/tocer
118
162
  post_install_message:
@@ -130,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
174
  - !ruby/object:Gem::Version
131
175
  version: '0'
132
176
  requirements: []
133
- rubygems_version: 3.3.3
177
+ rubygems_version: 3.3.6
134
178
  signing_key:
135
179
  specification_version: 4
136
180
  summary: A command line interface for generating table of contents for Markdown files.
metadata.gz.sig CHANGED
Binary file
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Tocer
4
- # Gem identity information.
5
- module Identity
6
- NAME = "tocer"
7
- LABEL = "Tocer"
8
- VERSION = "13.0.0"
9
- VERSION_LABEL = "#{LABEL} #{VERSION}".freeze
10
- SUMMARY = "A command line interface for generating table of contents for Markdown files."
11
- end
12
- end