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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5284cb9d791cfcc1d19fbefe8ccc8bcb956f3e4762d62351d5a281243078e6c0
4
- data.tar.gz: e6a8431dae7394313394ed39ecdbb25e6cad0dce6f2e8e7c85a114edc4bac0d4
3
+ metadata.gz: d021a7fae626bd79a5b4bdfb262485521118f8de0bfcaecd6639d7c0d6a8d83a
4
+ data.tar.gz: a30562c36228973dca573c35c4d4f4945c4b89fbcdafeee9a7dc81d206329cc4
5
5
  SHA512:
6
- metadata.gz: d5e0f46386f5ee817fdd813b9f7471359d5994074abe12fecc4fed855ab68b7e4b9bc81ef9c0d9829a34fa62f84aff12505fdfb622509fb5ec26eb29cc20166f
7
- data.tar.gz: 3f3c71546dc4cc46e473c94a386d53b59d42b4bc127b6185b0d67cbe2b6a4a61106909fe570166257d4a707f35d78f8cf303b22a47e9345664af0461a7391e59
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
- def initialize client: Configuration::Loader::CLIENT, container: Container
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, :container
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
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "auto_injector"
4
+
5
+ module Pragmater
6
+ module CLI
7
+ module Actions
8
+ Import = AutoInjector[Container]
9
+ end
10
+ end
11
+ end
@@ -5,18 +5,18 @@ module Pragmater
5
5
  module Actions
6
6
  # Handles insert or remove actions.
7
7
  class Run
8
- def initialize runner: Runner.new, container: Container
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, :container
18
-
19
- def logger = container[__method__]
19
+ attr_reader :runner
20
20
  end
21
21
  end
22
22
  end
@@ -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 is important.
12
+ SECTIONS = [Parsers::Core, Parsers::Flag].freeze # Order matters.
11
13
 
12
- def initialize sections: SECTIONS, client: CLIENT, container: Container
14
+ def initialize sections: SECTIONS, client: CLIENT, **dependencies
15
+ super(**dependencies)
13
16
  @sections = sections
14
17
  @client = client
15
- @configuration = container[:configuration].dup
18
+ @configuration_duplicate = configuration.dup
16
19
  end
17
20
 
18
21
  def call arguments = []
19
- sections.each { |section| section.call configuration, client: }
22
+ sections.each { |section| section.call configuration_duplicate, client: }
20
23
  client.parse arguments
21
- configuration.freeze
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, :configuration
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
- container: Container
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, :container
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
@@ -4,12 +4,11 @@ module Pragmater
4
4
  module CLI
5
5
  # The main Command Line Interface (CLI) object.
6
6
  class Shell
7
- ACTIONS = {config: Actions::Config.new, run: Actions::Run.new}.freeze
7
+ include Actions::Import[:config, :run, :specification, :logger]
8
8
 
9
- def initialize parser: Parser.new, actions: ACTIONS, container: Container
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, :actions, :container
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 usage
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
@@ -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
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "auto_injector"
4
+
5
+ module Pragmater
6
+ Import = AutoInjector[Container]
7
+ end
@@ -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, container: Container
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 = Configuration::Loader.call
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, :container
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 = "10.3.1"
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: 10.3.1
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/jCCAeagAwIBAgIBBDANBgkqhkiG9w0BAQsFADAlMSMwIQYDVQQDDBpicm9v
14
- a2UvREM9YWxjaGVtaXN0cy9EQz1pbzAeFw0yMTAzMTkxMjQ4MDZaFw0yMjAzMTkx
15
- MjQ4MDZaMCUxIzAhBgNVBAMMGmJyb29rZS9EQz1hbGNoZW1pc3RzL0RDPWlvMIIB
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/gY4ggwDQYJKoZIhvcNAQELBQADggEBAEjpaOXHHp8s/7GL2qCb
24
- YAs7urOLv9VHSPfQWAwaTMVnSsIf3Sw4xzISOP/mmfEPBPXtz61K5esrE/uTFtgb
25
- FyjxQk2H0sEWgrRXGGNHBWQRhhEs7LP/TByoC15A0br++xLxRz4r7HBLGAWQQDpg
26
- 66BJ2TBVjxS6K64tKbq7+ACyrOZGgTfNHACh4M076y0x0oRf/rwBrU39/KRfuhbb
27
- cm+nNCEtO35gTmZ2bVDHLGvWazi3gJt6+huQjfXTCUUG2YYBxwhu+GPdAGQPxpf9
28
- lkHilIrX69jq8wMPpBhlaw2mRmeSL50Wv5u6xVBvOHhXFSP1crXM95vfLhLyRYod
29
- W2A=
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-03-04 00:00:00.000000000 Z
31
+ date: 2022-04-09 00:00:00.000000000 Z
32
32
  dependencies:
33
33
  - !ruby/object:Gem::Dependency
34
- name: dry-container
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.9'
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.9'
46
+ version: '0.4'
47
47
  - !ruby/object:Gem::Dependency
48
- name: pastel
48
+ name: cogger
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '0.8'
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.8'
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.8
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