tocer 12.2.0 → 13.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +2 -2
- data/LICENSE.adoc +207 -155
- data/README.adoc +18 -33
- data/exe/tocer +0 -1
- data/lib/tocer/builder.rb +5 -2
- data/lib/tocer/cli/actions/config.rb +35 -0
- data/lib/tocer/cli/actions/insert.rb +25 -0
- data/lib/tocer/cli/parser.rb +31 -0
- data/lib/tocer/cli/parsers/core.rb +27 -13
- data/lib/tocer/cli/parsers/flag.rb +51 -0
- data/lib/tocer/cli/shell.rb +21 -20
- data/lib/tocer/configuration/content.rb +22 -0
- data/lib/tocer/{cli/configuration → configuration}/defaults.yml +1 -0
- data/lib/tocer/configuration/loader.rb +33 -0
- data/lib/tocer/container.rb +40 -0
- data/lib/tocer/elements/comment_block.rb +4 -0
- data/lib/tocer/rake/tasks.rb +2 -2
- data/lib/tocer/runner.rb +8 -9
- data/lib/tocer/transformers/finder.rb +3 -2
- data/lib/tocer/writer.rb +12 -4
- data/lib/tocer.rb +11 -18
- data/tocer.gemspec +37 -0
- data.tar.gz.sig +0 -0
- metadata +62 -19
- metadata.gz.sig +0 -0
- data/lib/tocer/cli/configuration/content.rb +0 -10
- data/lib/tocer/cli/configuration/loader.rb +0 -33
- data/lib/tocer/cli/parsers/assembler.rb +0 -34
- data/lib/tocer/cli/parsers/build.rb +0 -52
- data/lib/tocer/cli/parsers.rb +0 -11
- data/lib/tocer/cli/processors/build.rb +0 -24
- data/lib/tocer/cli/processors/config.rb +0 -31
- data/lib/tocer/identity.rb +0 -12
metadata.gz.sig
CHANGED
Binary file
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "pathname"
|
4
|
-
require "refinements/structs"
|
5
|
-
require "runcom"
|
6
|
-
require "yaml"
|
7
|
-
|
8
|
-
module Tocer
|
9
|
-
module CLI
|
10
|
-
module Configuration
|
11
|
-
# Represents the fully assembled Command Line Interface (CLI) configuration.
|
12
|
-
class Loader
|
13
|
-
using Refinements::Structs
|
14
|
-
|
15
|
-
DEFAULTS = YAML.load_file(Pathname(__dir__).join("defaults.yml")).freeze
|
16
|
-
CLIENT = Runcom::Config.new "#{Identity::NAME}/configuration.yml", defaults: DEFAULTS
|
17
|
-
|
18
|
-
def self.call = new.call
|
19
|
-
|
20
|
-
def initialize content: Content.new, client: CLIENT
|
21
|
-
@content = content
|
22
|
-
@client = client
|
23
|
-
end
|
24
|
-
|
25
|
-
def call = content.merge(**client.to_h)
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
attr_reader :content, :client
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Tocer
|
4
|
-
module CLI
|
5
|
-
module Parsers
|
6
|
-
# Assembles and parses all Command Line Interface (CLI) options.
|
7
|
-
class Assembler
|
8
|
-
SECTIONS = [Core, Build].freeze # Order is important.
|
9
|
-
|
10
|
-
def initialize configuration: CLI::Configuration::Loader.call,
|
11
|
-
sections: SECTIONS,
|
12
|
-
client: CLIENT
|
13
|
-
@options = configuration.to_h
|
14
|
-
@sections = sections
|
15
|
-
@client = client
|
16
|
-
end
|
17
|
-
|
18
|
-
def call arguments = []
|
19
|
-
sections.each { |parser| parser.call client: client, options: options }
|
20
|
-
client.parse! arguments
|
21
|
-
options
|
22
|
-
end
|
23
|
-
|
24
|
-
def to_h = options
|
25
|
-
|
26
|
-
def to_s = client.to_s
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
attr_reader :options, :sections, :client
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Tocer
|
4
|
-
module CLI
|
5
|
-
module Parsers
|
6
|
-
# Handles parsing of Command Line Interface (CLI) build options.
|
7
|
-
class Build
|
8
|
-
def self.call options: {}, configuration: Configuration::Loader.call, client: CLIENT
|
9
|
-
new(options: options, configuration: configuration, client: client).call
|
10
|
-
end
|
11
|
-
|
12
|
-
def initialize options: {}, configuration: Configuration::Loader.call, client: CLIENT
|
13
|
-
@options = options
|
14
|
-
@configuration = configuration
|
15
|
-
@client = client
|
16
|
-
end
|
17
|
-
|
18
|
-
def call arguments = []
|
19
|
-
client.separator "\nBUILD OPTIONS:\n"
|
20
|
-
private_methods.sort.grep(/add_/).each { |method| __send__ method }
|
21
|
-
arguments.empty? ? arguments : client.parse!(arguments)
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
attr_reader :options, :configuration, :client
|
27
|
-
|
28
|
-
def add_label
|
29
|
-
client.on(
|
30
|
-
"-l",
|
31
|
-
"--label [LABEL]",
|
32
|
-
%(Label. Default: "#{CLI::Configuration::Loader.call.label}".)
|
33
|
-
) do |value|
|
34
|
-
options[:label] = value || configuration.to_h.fetch(:label)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def add_include
|
39
|
-
client.on(
|
40
|
-
"-i",
|
41
|
-
"--includes [a,b,c]",
|
42
|
-
Array,
|
43
|
-
%(Include pattern list. Default: #{CLI::Configuration::Loader.call.includes}.)
|
44
|
-
) do |value|
|
45
|
-
list = Array value
|
46
|
-
options[:includes] = list.empty? ? configuration.to_h.fetch(:includes) : list
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
data/lib/tocer/cli/parsers.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Tocer
|
4
|
-
module CLI
|
5
|
-
module Processors
|
6
|
-
# Handles the Command Line Interface (CLI) for building of table of contents.
|
7
|
-
class Build
|
8
|
-
def initialize runner: Runner.new
|
9
|
-
@runner = runner
|
10
|
-
end
|
11
|
-
|
12
|
-
def call root_dir = ".", configuration = {}
|
13
|
-
runner.call(root_dir: root_dir, **configuration.slice(:label, :includes)) do |path|
|
14
|
-
puts " #{path}"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
attr_reader :runner
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Tocer
|
4
|
-
module CLI
|
5
|
-
module Processors
|
6
|
-
# Handles the Command Line Interface (CLI) configuration processing.
|
7
|
-
class Config
|
8
|
-
def initialize configuration: CLI::Configuration::Loader::CLIENT, kernel: Kernel
|
9
|
-
@configuration = configuration
|
10
|
-
@kernel = kernel
|
11
|
-
end
|
12
|
-
|
13
|
-
def call action
|
14
|
-
case action
|
15
|
-
when :edit then edit
|
16
|
-
when :view then view
|
17
|
-
else fail StandardError, "Invalid configuration action: #{action}."
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
attr_reader :configuration, :kernel
|
24
|
-
|
25
|
-
def edit = kernel.system("$EDITOR #{configuration.current}")
|
26
|
-
|
27
|
-
def view = kernel.system("cat #{configuration.current}")
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
data/lib/tocer/identity.rb
DELETED
@@ -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 = "12.2.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
|