pragmater 9.3.0 → 10.0.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 +0 -0
- data/LICENSE.adoc +207 -155
- data/README.adoc +18 -31
- 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 +70 -0
- data/lib/pragmater/cli/parsers/flag.rb +46 -0
- data/lib/pragmater/cli/shell.rb +22 -41
- 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 +37 -0
- data/lib/pragmater/formatters/main.rb +2 -3
- data/lib/pragmater/identity.rb +1 -1
- 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.tar.gz.sig +0 -0
- metadata +46 -16
- 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
@@ -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
|