pragmater 9.2.0 → 10.1.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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/LICENSE.adoc +207 -155
- data/README.adoc +23 -49
- data/{bin → exe}/pragmater +0 -1
- data/lib/pragmater/cli/actions/config.rb +35 -0
- data/lib/pragmater/cli/actions/run.rb +23 -0
- data/lib/pragmater/cli/parser.rb +31 -0
- data/lib/pragmater/cli/parsers/core.rb +75 -0
- data/lib/pragmater/cli/parsers/flag.rb +46 -0
- data/lib/pragmater/cli/shell.rb +23 -40
- data/lib/pragmater/configuration/content.rb +23 -0
- data/lib/pragmater/configuration/defaults.yml +3 -0
- data/lib/pragmater/configuration/loader.rb +35 -0
- data/lib/pragmater/container.rb +40 -0
- data/lib/pragmater/formatters/main.rb +2 -3
- data/lib/pragmater/parsers/comments.rb +3 -9
- data/lib/pragmater/processors/handler.rb +1 -3
- data/lib/pragmater/runner.rb +18 -10
- data/lib/pragmater.rb +9 -18
- data/pragmater.gemspec +37 -0
- data.tar.gz.sig +0 -0
- metadata +66 -20
- metadata.gz.sig +0 -0
- data/lib/pragmater/cli/options/assembler.rb +0 -45
- data/lib/pragmater/cli/options/configuration.rb +0 -37
- data/lib/pragmater/cli/options/core.rb +0 -56
- data/lib/pragmater/cli/options/defaults.yml +0 -6
- data/lib/pragmater/cli/options/insert_remove.rb +0 -38
- data/lib/pragmater/cli/options/merger.rb +0 -52
- data/lib/pragmater/context.rb +0 -14
- data/lib/pragmater/identity.rb +0 -12
metadata.gz.sig
CHANGED
Binary file
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "optparse"
|
4
|
-
require "forwardable"
|
5
|
-
|
6
|
-
module Pragmater
|
7
|
-
module CLI
|
8
|
-
module Options
|
9
|
-
# Coalesces all options and arguments into a single hash for further processing.
|
10
|
-
class Assembler
|
11
|
-
extend Forwardable
|
12
|
-
|
13
|
-
PARSER = OptionParser.new nil, 40, " "
|
14
|
-
SECTIONS = [Core, InsertRemove, Configuration].freeze
|
15
|
-
|
16
|
-
EXCEPTIONS = [
|
17
|
-
OptionParser::InvalidOption,
|
18
|
-
OptionParser::MissingArgument,
|
19
|
-
OptionParser::InvalidArgument
|
20
|
-
].freeze
|
21
|
-
|
22
|
-
delegate %i[to_s] => :parser
|
23
|
-
|
24
|
-
def initialize sections: SECTIONS, parser: PARSER, exceptions: EXCEPTIONS
|
25
|
-
@sections = sections
|
26
|
-
@parser = parser
|
27
|
-
@options = {}
|
28
|
-
@exceptions = exceptions
|
29
|
-
end
|
30
|
-
|
31
|
-
def call arguments = []
|
32
|
-
sections.each { |section| section.new(options, parser: parser).call }
|
33
|
-
parser.parse! arguments
|
34
|
-
options
|
35
|
-
rescue *EXCEPTIONS
|
36
|
-
{}
|
37
|
-
end
|
38
|
-
|
39
|
-
private
|
40
|
-
|
41
|
-
attr_reader :parser, :sections, :options, :exceptions
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Pragmater
|
4
|
-
module CLI
|
5
|
-
module Options
|
6
|
-
# Defines gem configuration options.
|
7
|
-
class Configuration
|
8
|
-
def initialize values, parser: OptionParser.new
|
9
|
-
@parser = parser
|
10
|
-
@values = values
|
11
|
-
end
|
12
|
-
|
13
|
-
def call
|
14
|
-
parser.separator "\nConfiguration:\n"
|
15
|
-
private_methods.grep(/add_/).each { |method| __send__ method }
|
16
|
-
parser
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
attr_reader :parser, :values
|
22
|
-
|
23
|
-
def add_edit
|
24
|
-
parser.on "--edit", "Edit configuration." do
|
25
|
-
values[:edit] = true
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def add_info
|
30
|
-
parser.on "--info", "Print configuration." do
|
31
|
-
values[:info] = true
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Pragmater
|
4
|
-
module CLI
|
5
|
-
module Options
|
6
|
-
# Defines gem primary options.
|
7
|
-
class Core
|
8
|
-
def initialize values, parser: OptionParser.new
|
9
|
-
@values = values
|
10
|
-
@parser = parser
|
11
|
-
end
|
12
|
-
|
13
|
-
def call
|
14
|
-
parser.banner = "#{Identity::LABEL} - #{Identity::SUMMARY}"
|
15
|
-
parser.separator "\nUSAGE:\n"
|
16
|
-
private_methods.grep(/add_/).each { |method| __send__ method }
|
17
|
-
parser
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
attr_reader :values, :parser
|
23
|
-
|
24
|
-
def add_configuration
|
25
|
-
parser.on "-c", "--config [options]", "Manage gem configuration." do
|
26
|
-
values[:config] = true
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def add_insert
|
31
|
-
parser.on "-i", "--insert [PATH]", "Insert pragam comments into files." do |path|
|
32
|
-
values[:insert] = path || "."
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def add_remove
|
37
|
-
parser.on "-r", "--remove [options]", "Remove pragam comments from files." do |path|
|
38
|
-
values[:remove] = path || "."
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def add_version
|
43
|
-
parser.on "-v", "--version", "Show gem version." do
|
44
|
-
values[:version] = Identity::VERSION
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def add_help
|
49
|
-
parser.on "-h", "--help", "Show this message." do
|
50
|
-
values[:help] = true
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Pragmater
|
4
|
-
module CLI
|
5
|
-
module Options
|
6
|
-
# Defines gem insert and remove options.
|
7
|
-
class InsertRemove
|
8
|
-
def initialize values, parser: OptionParser.new
|
9
|
-
@values = values
|
10
|
-
@parser = parser
|
11
|
-
end
|
12
|
-
|
13
|
-
def call
|
14
|
-
parser.separator "\nOPTIONS:\n"
|
15
|
-
parser.separator "\nInsert/Remove:\n"
|
16
|
-
private_methods.grep(/add_/).each { |method| __send__ method }
|
17
|
-
parser
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
attr_reader :values, :parser
|
23
|
-
|
24
|
-
def add_comments
|
25
|
-
parser.on "--comments a,b,c", Array, "Add pragma comments." do |comments|
|
26
|
-
values[:comments] = comments
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def add_includes
|
31
|
-
parser.on "--includes a,b,c", Array, "Add console support." do |includes|
|
32
|
-
values[:includes] = includes
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "yaml"
|
4
|
-
require "pathname"
|
5
|
-
require "runcom"
|
6
|
-
|
7
|
-
module Pragmater
|
8
|
-
module CLI
|
9
|
-
module Options
|
10
|
-
# Merges arguments with configuration for fully assembled configuration for use by shell.
|
11
|
-
class Merger
|
12
|
-
DEFAULTS = YAML.load_file(Pathname(__dir__).join("defaults.yml")).freeze
|
13
|
-
CONFIGURATION = Runcom::Config.new "#{Identity::NAME}/configuration.yml", defaults: DEFAULTS
|
14
|
-
|
15
|
-
def initialize configuration = CONFIGURATION, assembler = Assembler.new
|
16
|
-
@configuration = configuration
|
17
|
-
@assembler = assembler
|
18
|
-
end
|
19
|
-
|
20
|
-
def call arguments = []
|
21
|
-
assembler.call(arguments).then do |options|
|
22
|
-
case options
|
23
|
-
in insert: path, **settings then build_insert_options path, settings
|
24
|
-
in remove: path, **settings then build_remove_options path, settings
|
25
|
-
else options
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def configuration_path
|
31
|
-
configuration.current
|
32
|
-
end
|
33
|
-
|
34
|
-
def usage
|
35
|
-
assembler.to_s
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
attr_reader :configuration, :assembler
|
41
|
-
|
42
|
-
def build_insert_options path, options
|
43
|
-
{insert: path, **configuration.to_h.fetch(:insert).merge(options)}
|
44
|
-
end
|
45
|
-
|
46
|
-
def build_remove_options path, options
|
47
|
-
{remove: path, **configuration.to_h.fetch(:remove).merge(options)}
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
data/lib/pragmater/context.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Pragmater
|
4
|
-
# Provides context for runner.
|
5
|
-
Context = Struct.new :action, :root_dir, :comments, :includes, keyword_init: true do
|
6
|
-
def initialize *arguments
|
7
|
-
super
|
8
|
-
|
9
|
-
self[:root_dir] ||= "."
|
10
|
-
self[:comments] = Array comments
|
11
|
-
self[:includes] = Array includes
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
data/lib/pragmater/identity.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Pragmater
|
4
|
-
# Gem identity information.
|
5
|
-
module Identity
|
6
|
-
NAME = "pragmater"
|
7
|
-
LABEL = "Pragmater"
|
8
|
-
VERSION = "9.2.0"
|
9
|
-
VERSION_LABEL = "#{LABEL} #{VERSION}".freeze
|
10
|
-
SUMMARY = "A command line interface for managing/formatting source file pragma comments."
|
11
|
-
end
|
12
|
-
end
|