pragmater 10.3.1 → 11.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/lib/pragmater/cli/actions/config.rb +5 -7
- data/lib/pragmater/cli/actions/container.rb +21 -0
- data/lib/pragmater/cli/actions/import.rb +11 -0
- data/lib/pragmater/cli/actions/run.rb +5 -5
- data/lib/pragmater/cli/parser.rb +9 -6
- data/lib/pragmater/cli/parsers/core.rb +5 -5
- data/lib/pragmater/cli/shell.rb +7 -18
- data/lib/pragmater/container.rb +2 -24
- data/lib/pragmater/import.rb +7 -0
- data/lib/pragmater/runner.rb +6 -6
- data/pragmater.gemspec +3 -2
- data.tar.gz.sig +0 -0
- metadata +36 -19
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d021a7fae626bd79a5b4bdfb262485521118f8de0bfcaecd6639d7c0d6a8d83a
|
4
|
+
data.tar.gz: a30562c36228973dca573c35c4d4f4945c4b89fbcdafeee9a7dc81d206329cc4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb21ad7bba61e71a2a99fbef23d124fb46dfe8fbb6088442f993b4ce3f4eb904549493b06fe0c7e765412a2d0238c88acfa40d75752af67d24f349ed3caaaa64
|
7
|
+
data.tar.gz: 81f04639e7f187ec4c052d9639c5c953f972f9598083a7b32aac2a3ce305c8ab22bf02060ecd79e19ec316d0aced14a2e0572959b7d01de644e972ecc430c25a
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -5,9 +5,11 @@ module Pragmater
|
|
5
5
|
module Actions
|
6
6
|
# Handles the config action.
|
7
7
|
class Config
|
8
|
-
|
8
|
+
include Pragmater::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 Pragmater
|
|
20
22
|
|
21
23
|
private
|
22
24
|
|
23
|
-
attr_reader :client
|
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 Pragmater
|
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 Pragmater::Container
|
15
|
+
|
16
|
+
register(:config) { Config.new }
|
17
|
+
register(:run) { Run.new }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -5,18 +5,18 @@ module Pragmater
|
|
5
5
|
module Actions
|
6
6
|
# Handles insert or remove actions.
|
7
7
|
class Run
|
8
|
-
|
8
|
+
include Pragmater::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) = runner.call(configuration) { |path| logger.info { path } }
|
14
16
|
|
15
17
|
private
|
16
18
|
|
17
|
-
attr_reader :runner
|
18
|
-
|
19
|
-
def logger = container[__method__]
|
19
|
+
attr_reader :runner
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
data/lib/pragmater/cli/parser.rb
CHANGED
@@ -6,26 +6,29 @@ module Pragmater
|
|
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
|
12
|
+
SECTIONS = [Parsers::Core, Parsers::Flag].freeze # Order matters.
|
11
13
|
|
12
|
-
def initialize sections: SECTIONS, client: CLIENT,
|
14
|
+
def initialize sections: SECTIONS, client: CLIENT, **dependencies
|
15
|
+
super(**dependencies)
|
13
16
|
@sections = sections
|
14
17
|
@client = client
|
15
|
-
@
|
18
|
+
@configuration_duplicate = configuration.dup
|
16
19
|
end
|
17
20
|
|
18
21
|
def call arguments = []
|
19
|
-
sections.each { |section| section.call
|
22
|
+
sections.each { |section| section.call configuration_duplicate, client: }
|
20
23
|
client.parse arguments
|
21
|
-
|
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, :
|
31
|
+
attr_reader :sections, :client, :configuration_duplicate
|
29
32
|
end
|
30
33
|
end
|
31
34
|
end
|
@@ -7,16 +7,18 @@ module Pragmater
|
|
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
16
|
def initialize configuration = Container[:configuration],
|
15
17
|
client: Parser::CLIENT,
|
16
|
-
|
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 Pragmater
|
|
29
31
|
|
30
32
|
private
|
31
33
|
|
32
|
-
attr_reader :configuration, :client
|
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 Pragmater
|
|
67
69
|
end
|
68
70
|
|
69
71
|
def root_dir = configuration.root_dir
|
70
|
-
|
71
|
-
def specification = container[__method__]
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
data/lib/pragmater/cli/shell.rb
CHANGED
@@ -4,12 +4,11 @@ module Pragmater
|
|
4
4
|
module CLI
|
5
5
|
# The main Command Line Interface (CLI) object.
|
6
6
|
class Shell
|
7
|
-
|
7
|
+
include Actions::Import[:config, :run, :specification, :logger]
|
8
8
|
|
9
|
-
def initialize parser: Parser.new,
|
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 Pragmater
|
|
20
19
|
|
21
20
|
private
|
22
21
|
|
23
|
-
attr_reader :parser
|
22
|
+
attr_reader :parser
|
24
23
|
|
25
24
|
def perform configuration
|
26
25
|
case configuration
|
27
|
-
in action_config: Symbol => action then config action
|
28
|
-
in {action_insert: true} | {action_remove: true} then run configuration
|
26
|
+
in action_config: Symbol => action then config.call action
|
27
|
+
in {action_insert: true} | {action_remove: true} then run.call configuration
|
29
28
|
in action_version: true then logger.info { specification.labeled_version }
|
30
|
-
else
|
29
|
+
else logger.any { parser.to_s }
|
31
30
|
end
|
32
31
|
end
|
33
|
-
|
34
|
-
def config(action) = actions.fetch(__method__).call(action)
|
35
|
-
|
36
|
-
def run(configuration) = actions.fetch(__method__).call(configuration)
|
37
|
-
|
38
|
-
def usage = logger.unknown(parser.to_s)
|
39
|
-
|
40
|
-
def specification = container[__method__]
|
41
|
-
|
42
|
-
def logger = container[__method__]
|
43
32
|
end
|
44
33
|
end
|
45
34
|
end
|
data/lib/pragmater/container.rb
CHANGED
@@ -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 Pragmater
|
@@ -12,28 +11,7 @@ module Pragmater
|
|
12
11
|
|
13
12
|
register(:configuration) { Configuration::Loader.call }
|
14
13
|
register(:specification) { Spek::Loader.call "#{__dir__}/../../pragmater.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
|
data/lib/pragmater/runner.rb
CHANGED
@@ -5,14 +5,16 @@ require "refinements/pathnames"
|
|
5
5
|
module Pragmater
|
6
6
|
# Adds/removes pragma comments for files in given path.
|
7
7
|
class Runner
|
8
|
+
include Import[:logger]
|
9
|
+
|
8
10
|
using Refinements::Pathnames
|
9
11
|
|
10
|
-
def initialize parser: Parsers::File.new,
|
12
|
+
def initialize parser: Parsers::File.new, **dependencies
|
13
|
+
super(**dependencies)
|
11
14
|
@parser = parser
|
12
|
-
@container = container
|
13
15
|
end
|
14
16
|
|
15
|
-
def call configuration =
|
17
|
+
def call configuration = Container[:configuration]
|
16
18
|
Pathname(configuration.root_dir).files("{#{configuration.includes.join ","}}").map do |path|
|
17
19
|
yield path if block_given?
|
18
20
|
|
@@ -26,12 +28,10 @@ module Pragmater
|
|
26
28
|
|
27
29
|
private
|
28
30
|
|
29
|
-
attr_reader :parser
|
31
|
+
attr_reader :parser
|
30
32
|
|
31
33
|
def write path, configuration, action
|
32
34
|
path.write parser.call(path, configuration.comments, action:).join
|
33
35
|
end
|
34
|
-
|
35
|
-
def logger = container[__method__]
|
36
36
|
end
|
37
37
|
end
|
data/pragmater.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "pragmater"
|
5
|
-
spec.version = "
|
5
|
+
spec.version = "11.0.0"
|
6
6
|
spec.authors = ["Brooke Kuhlmann"]
|
7
7
|
spec.email = ["brooke@alchemists.io"]
|
8
8
|
spec.homepage = "https://www.alchemists.io/projects/pragmater"
|
@@ -22,8 +22,9 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.cert_chain = [Gem.default_cert_path]
|
23
23
|
|
24
24
|
spec.required_ruby_version = "~> 3.1"
|
25
|
+
spec.add_dependency "auto_injector", "~> 0.4"
|
26
|
+
spec.add_dependency "cogger", "~> 0.0"
|
25
27
|
spec.add_dependency "dry-container", "~> 0.9"
|
26
|
-
spec.add_dependency "pastel", "~> 0.8"
|
27
28
|
spec.add_dependency "refinements", "~> 9.2"
|
28
29
|
spec.add_dependency "runcom", "~> 8.2"
|
29
30
|
spec.add_dependency "spek", "~> 0.2"
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pragmater
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 11.0.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/
|
14
|
-
|
15
|
-
|
13
|
+
MIIC/jCCAeagAwIBAgIBBTANBgkqhkiG9w0BAQsFADAlMSMwIQYDVQQDDBpicm9v
|
14
|
+
a2UvREM9YWxjaGVtaXN0cy9EQz1pbzAeFw0yMjAzMTkxNzI0MzJaFw0yMzAzMTkx
|
15
|
+
NzI0MzJaMCUxIzAhBgNVBAMMGmJyb29rZS9EQz1hbGNoZW1pc3RzL0RDPWlvMIIB
|
16
16
|
IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6l1qpXTiomH1RfMRloyw7MiE
|
17
17
|
xyVx/x8Yc3EupdH7uhNaTXQGyORN6aOY//1QXXMHIZ9tW74nZLhesWMSUMYy0XhB
|
18
18
|
brs+KkurHnc9FnEJAbG7ebGvl/ncqZt72nQvaxpDxvuCBHgJAz+8i5wl6FhLw+oT
|
@@ -20,44 +20,58 @@ cert_chain:
|
|
20
20
|
D5vkU0YlAm1r98BymuJlcQ1qdkVEI1d48ph4kcS0S0nv1RiuyVb6TCAR3Nu3VaVq
|
21
21
|
3fPzZKJLZBx67UvXdbdicWPiUR75elI4PXpLIic3xytaF52ZJYyKZCNZJhNwfQID
|
22
22
|
AQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU0nzow9vc
|
23
|
-
2CdikiiE3fJhP/
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
23
|
+
2CdikiiE3fJhP/gY4ggwDQYJKoZIhvcNAQELBQADggEBAJbbNyWzFjqUNVPPCUCo
|
24
|
+
IMrhDa9xf1xkORXNYYbmXgoxRy/KyNbUr+jgEEoWJAm9GXlcqxxWAUI6pK/i4/Qi
|
25
|
+
X6rPFEFmeObDOHNvuqy8Hd6AYsu+kP94U/KJhe9wnWGMmGoNKJNU3EkW3jM/osSl
|
26
|
+
+JRxiH5t4WtnDiVyoYl5nYC02rYdjJkG6VMxDymXTqn7u6HhYgZkGujq1UPar8x2
|
27
|
+
hNIWJblDKKSu7hA2d6+kUthuYo13o1sg1Da/AEDg0hoZSUvhqDEF5Hy232qb3pDt
|
28
|
+
CxDe2+VuChj4I1nvIHdu+E6XoEVlanUPKmSg6nddhkKn2gC45Kyzh6FZqnzH/CRp
|
29
|
+
RFE=
|
30
30
|
-----END CERTIFICATE-----
|
31
|
-
date: 2022-
|
31
|
+
date: 2022-04-09 00:00:00.000000000 Z
|
32
32
|
dependencies:
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
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.
|
39
|
+
version: '0.4'
|
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.
|
46
|
+
version: '0.4'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
48
|
+
name: cogger
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '0.
|
53
|
+
version: '0.0'
|
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.
|
60
|
+
version: '0.0'
|
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
|
@@ -129,6 +143,8 @@ files:
|
|
129
143
|
- exe/pragmater
|
130
144
|
- lib/pragmater.rb
|
131
145
|
- lib/pragmater/cli/actions/config.rb
|
146
|
+
- lib/pragmater/cli/actions/container.rb
|
147
|
+
- lib/pragmater/cli/actions/import.rb
|
132
148
|
- lib/pragmater/cli/actions/run.rb
|
133
149
|
- lib/pragmater/cli/helper.rb
|
134
150
|
- lib/pragmater/cli/parser.rb
|
@@ -142,6 +158,7 @@ files:
|
|
142
158
|
- lib/pragmater/formatters/general.rb
|
143
159
|
- lib/pragmater/formatters/main.rb
|
144
160
|
- lib/pragmater/formatters/shebang.rb
|
161
|
+
- lib/pragmater/import.rb
|
145
162
|
- lib/pragmater/parsers/comments.rb
|
146
163
|
- lib/pragmater/parsers/file.rb
|
147
164
|
- lib/pragmater/processors/handler.rb
|
@@ -174,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
191
|
- !ruby/object:Gem::Version
|
175
192
|
version: '0'
|
176
193
|
requirements: []
|
177
|
-
rubygems_version: 3.3.
|
194
|
+
rubygems_version: 3.3.11
|
178
195
|
signing_key:
|
179
196
|
specification_version: 4
|
180
197
|
summary: A command line interface for managing/formatting source file pragma comments.
|
metadata.gz.sig
CHANGED
Binary file
|