sublime_text_kit 12.3.2 → 13.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: aaea22a9a42626c43cb59c48cdf80f875336e9ae116ef8e17d50d09f4faafd23
4
- data.tar.gz: 25aea598137ddabe35c16f69649fa75353a8db9e9956afae4a3c0d312a5da891
3
+ metadata.gz: b06454b8e8a8f1beb6e5b093b094f2b30345055b501b802fe0626930257d9597
4
+ data.tar.gz: 1a36ef68cd7ec415be40e175ce47de7f8f6044a063b49bf2f01db682400ac0c4
5
5
  SHA512:
6
- metadata.gz: 87dc53110bd71150c03e01a1685c6ba4e28968adee492e1875d386a4f57f32667ba269ce39177c38895298f25687fcc42a2cdb4193656cf47a3fd5f4c0070c9e
7
- data.tar.gz: f8cdd7955e7c611866003c507a734d7ce3c36993950b1607ebea64c5bbf4cfff014c2b19aeb7a215a9f343ee75be727b7db4c4c0c09f873a51d359d0243fdf57
6
+ metadata.gz: 381bc7bf3a0dfebae84c38fc7795a3377fb8c2e51d2f3c7df1872d2d857661f535f024554b2369d950afe2429524a7edb925263b4c0c16ec50e720858917fbe0
7
+ data.tar.gz: 93a7ebe7006e32913e58b6422884b5890d2568ab145ed62470ce11f5d8ded734194961097f5fdf08227df468d3487c577a1b6a6a2913b8057bb906156665ee1b
checksums.yaml.gz.sig CHANGED
Binary file
@@ -5,9 +5,11 @@ module SublimeTextKit
5
5
  module Actions
6
6
  # Handles gem configuration action.
7
7
  class Config
8
- def initialize configuration: Configuration::Loader::CLIENT, container: Container
8
+ include SublimeTextKit::Import[:kernel, :logger]
9
+
10
+ def initialize configuration: Configuration::Loader::CLIENT, **dependencies
11
+ super(**dependencies)
9
12
  @configuration = configuration
10
- @container = container
11
13
  end
12
14
 
13
15
  def call action
@@ -20,15 +22,11 @@ module SublimeTextKit
20
22
 
21
23
  private
22
24
 
23
- attr_reader :configuration, :container
25
+ attr_reader :configuration
24
26
 
25
27
  def edit = kernel.system("$EDITOR #{configuration.current}")
26
28
 
27
29
  def view = kernel.system("cat #{configuration.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,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dry/container"
4
+
5
+ module SublimeTextKit
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 SublimeTextKit::Container
15
+
16
+ register(:config) { Actions::Config.new }
17
+ register(:metadata) { Actions::Metadata.new }
18
+ register(:session) { Actions::Session.new }
19
+ register(:snippets) { Actions::Snippets.new }
20
+ register(:update) { Actions::Update.new }
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "auto_injector"
4
+
5
+ module SublimeTextKit
6
+ module CLI
7
+ module Actions
8
+ Import = AutoInjector[Container]
9
+ end
10
+ end
11
+ end
@@ -7,11 +7,14 @@ module SublimeTextKit
7
7
  module Actions
8
8
  # Handles metadata action.
9
9
  class Metadata
10
+ include SublimeTextKit::Import[:configuration, :logger]
11
+
10
12
  using Refinements::Pathnames
11
13
 
12
- def initialize handler: SublimeTextKit::Metadata::Handler, container: Container
14
+ def initialize handler: SublimeTextKit::Metadata::Handler, **dependencies
15
+ super(**dependencies)
16
+
13
17
  @handler = handler
14
- @container = container
15
18
  end
16
19
 
17
20
  def call kind
@@ -25,7 +28,7 @@ module SublimeTextKit
25
28
 
26
29
  private
27
30
 
28
- attr_reader :handler, :container
31
+ attr_reader :handler
29
32
 
30
33
  def create
31
34
  logger.info "Creating metadata in #{metadata_dir}..."
@@ -53,10 +56,6 @@ module SublimeTextKit
53
56
  end
54
57
 
55
58
  def metadata_dir = Pathname(configuration.metadata_dir).expand_path
56
-
57
- def configuration = container[__method__]
58
-
59
- def logger = container[__method__]
60
59
  end
61
60
  end
62
61
  end
@@ -5,9 +5,12 @@ module SublimeTextKit
5
5
  module Actions
6
6
  # Handles session action.
7
7
  class Session
8
- def initialize rebuilder: Sessions::Rebuilder.new, container: Container
8
+ include SublimeTextKit::Import[:logger]
9
+
10
+ def initialize rebuilder: Sessions::Rebuilder.new, **dependencies
11
+ super(**dependencies)
12
+
9
13
  @rebuilder = rebuilder
10
- @container = container
11
14
  end
12
15
 
13
16
  def call
@@ -17,9 +20,7 @@ module SublimeTextKit
17
20
 
18
21
  private
19
22
 
20
- attr_reader :rebuilder, :container
21
-
22
- def logger = container[__method__]
23
+ attr_reader :rebuilder
23
24
  end
24
25
  end
25
26
  end
@@ -5,31 +5,24 @@ module SublimeTextKit
5
5
  module Actions
6
6
  # Handles snippets action.
7
7
  class Snippets
8
- PRINTERS = {
9
- ascii_doc: SublimeTextKit::Snippets::Printers::ASCIIDoc.new,
10
- markdown: SublimeTextKit::Snippets::Printers::Markdown.new
11
- }.freeze
8
+ include SublimeTextKit::Import[:configuration, :logger]
12
9
 
13
- def initialize printers: PRINTERS, container: Container
14
- @printers = printers
15
- @container = container
10
+ def initialize printer: SublimeTextKit::Snippets::Printer.new, **dependencies
11
+ super(**dependencies)
12
+ @printer = printer
16
13
  end
17
14
 
18
15
  def call kind
19
- printers.fetch(kind).call
20
- rescue KeyError
21
- logger.error { "Invalid snippet format: #{kind}. Use #{formats}." }
16
+ case kind
17
+ when :ascii_doc then printer.call "*"
18
+ when :markdown then printer.call "-"
19
+ else logger.error { "Invalid snippet format: #{kind}. Use ascii_doc or markdown." }
20
+ end
22
21
  end
23
22
 
24
23
  private
25
24
 
26
- attr_reader :printers, :container
27
-
28
- def formats = printers.keys.join(" or ")
29
-
30
- def configuration = container[__method__]
31
-
32
- def logger = container[__method__]
25
+ attr_reader :printer
33
26
  end
34
27
  end
35
28
  end
@@ -5,12 +5,16 @@ module SublimeTextKit
5
5
  module Actions
6
6
  # Handles update action.
7
7
  class Update
8
+ include SublimeTextKit::Import[:configuration, :logger]
9
+
8
10
  def initialize metadata: SublimeTextKit::Metadata::Handler,
9
11
  session: Sessions::Rebuilder.new,
10
- container: Container
12
+ **dependencies
13
+
14
+ super(**dependencies)
15
+
11
16
  @metadata = metadata
12
17
  @session = session
13
- @container = container
14
18
  end
15
19
 
16
20
  def call
@@ -22,7 +26,7 @@ module SublimeTextKit
22
26
 
23
27
  private
24
28
 
25
- attr_reader :metadata, :session, :container
29
+ attr_reader :metadata, :session
26
30
 
27
31
  def create_metadata
28
32
  configuration.project_dirs.each do |directory|
@@ -32,10 +36,6 @@ module SublimeTextKit
32
36
  end
33
37
 
34
38
  def metadata_dir = Pathname(configuration.metadata_dir).expand_path
35
-
36
- def configuration = container[__method__]
37
-
38
- def logger = container[__method__]
39
39
  end
40
40
  end
41
41
  end
@@ -6,27 +6,30 @@ module SublimeTextKit
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
12
 
11
- def initialize configuration = Container[:configuration],
12
- section: Parsers::Core,
13
- client: CLIENT
14
- @configuration = configuration.dup
13
+ def initialize section: Parsers::Core,
14
+ client: CLIENT,
15
+ **dependencies
16
+ super(**dependencies)
15
17
  @section = section
16
18
  @client = client
19
+ @configuration_duplicate = configuration.dup
17
20
  end
18
21
 
19
22
  def call arguments = []
20
- section.call configuration, client: client
23
+ section.call configuration_duplicate, client: client
21
24
  client.parse arguments
22
- configuration.freeze
25
+ configuration_duplicate.freeze
23
26
  end
24
27
 
25
28
  def to_s = client.to_s
26
29
 
27
30
  private
28
31
 
29
- attr_reader :configuration, :section, :client
32
+ attr_reader :section, :client, :configuration_duplicate
30
33
  end
31
34
  end
32
35
  end
@@ -7,16 +7,20 @@ module SublimeTextKit
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
+
20
+ super(**dependencies)
21
+
17
22
  @configuration = configuration
18
23
  @client = client
19
- @container = container
20
24
  end
21
25
 
22
26
  def call arguments = []
@@ -29,7 +33,7 @@ module SublimeTextKit
29
33
 
30
34
  private
31
35
 
32
- attr_reader :configuration, :client, :container
36
+ attr_reader :configuration, :client
33
37
 
34
38
  def collate = private_methods.sort.grep(/add_/).each { |method| __send__ method }
35
39
 
@@ -96,8 +100,6 @@ module SublimeTextKit
96
100
  end
97
101
 
98
102
  def snippets_format = configuration.snippets_format
99
-
100
- def specification = container[__method__]
101
103
  end
102
104
  end
103
105
  end
@@ -4,18 +4,19 @@ module SublimeTextKit
4
4
  module CLI
5
5
  # The main Command Line Interface (CLI) object.
6
6
  class Shell
7
- ACTIONS = {
8
- config: Actions::Config.new,
9
- metadata: Actions::Metadata.new,
10
- session: Actions::Session.new,
11
- snippets: Actions::Snippets.new,
12
- update: Actions::Update.new
13
- }.freeze
14
-
15
- def initialize parser: Parser.new, actions: ACTIONS, container: Container
7
+ include Actions::Import[
8
+ :specification,
9
+ :logger,
10
+ :config,
11
+ :metadata,
12
+ :session,
13
+ :snippets,
14
+ :update
15
+ ]
16
+
17
+ def initialize parser: Parser.new, **dependencies
18
+ super(**dependencies)
16
19
  @parser = parser
17
- @actions = actions
18
- @container = container
19
20
  end
20
21
 
21
22
  def call arguments = []
@@ -26,35 +27,21 @@ module SublimeTextKit
26
27
 
27
28
  private
28
29
 
29
- attr_reader :parser, :actions, :container
30
+ attr_reader :parser
30
31
 
31
32
  def perform configuration
32
33
  case configuration
33
- in action_config: Symbol => action then config action
34
- in action_metadata: Symbol => kind then metadata kind
35
- in action_session: true then session
36
- in action_snippets: true then snippets configuration
37
- in action_update: true then update
34
+ in action_config: Symbol => action then config.call action
35
+ in action_metadata: Symbol => kind then metadata.call kind
36
+ in action_session: true then session.call
37
+ in action_snippets: true then snippets.call configuration.snippets_format
38
+ in action_update: true then update.call
38
39
  in action_version: true then logger.info { specification.labeled_version }
39
40
  else usage
40
41
  end
41
42
  end
42
43
 
43
- def config(action) = actions.fetch(__method__).call(action)
44
-
45
- def metadata(kind) = actions.fetch(__method__).call(kind)
46
-
47
- def session = actions.fetch(__method__).call
48
-
49
- def snippets(configuration) = actions.fetch(__method__).call(configuration.snippets_format)
50
-
51
- def update = actions.fetch(__method__).call
52
-
53
- def usage = logger.unknown { parser.to_s }
54
-
55
- def specification = container[__method__]
56
-
57
- def logger = container[__method__]
44
+ def usage = logger.any { parser.to_s }
58
45
  end
59
46
  end
60
47
  end
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry-container"
4
- require "logger"
5
- require "pastel"
3
+ require "cogger"
4
+ require "dry/container"
6
5
  require "spek"
7
6
 
8
7
  module SublimeTextKit
@@ -12,28 +11,7 @@ module SublimeTextKit
12
11
 
13
12
  register(:configuration) { Configuration::Loader.call }
14
13
  register(:specification) { Spek::Loader.call "#{__dir__}/../../sublime_text_kit.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,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SublimeTextKit
4
+ Import = AutoInjector[Container]
5
+ end
@@ -7,11 +7,9 @@ module SublimeTextKit
7
7
  module Sessions
8
8
  # Manages the rebuilding of session information.
9
9
  class Rebuilder
10
- using Refinements::Pathnames
10
+ include Import[:configuration]
11
11
 
12
- def initialize container: Container
13
- @container = container
14
- end
12
+ using Refinements::Pathnames
15
13
 
16
14
  def call
17
15
  session = read
@@ -28,8 +26,6 @@ module SublimeTextKit
28
26
 
29
27
  private
30
28
 
31
- attr_reader :container
32
-
33
29
  def read = source_path.exist? ? JSON(source_path.read) : {}
34
30
 
35
31
  def write(json) = JSON.dump(json).then { |content| source_path.write content }
@@ -37,8 +33,6 @@ module SublimeTextKit
37
33
  def metadata_dir = configuration.metadata_dir
38
34
 
39
35
  def source_path = configuration.session_path
40
-
41
- def configuration = container[__method__]
42
36
  end
43
37
  end
44
38
  end
@@ -6,11 +6,13 @@ module SublimeTextKit
6
6
  module Snippets
7
7
  # Collects and loads all snippets into memory for further processing.
8
8
  class Collector
9
+ include Import[:configuration]
10
+
9
11
  using Refinements::Pathnames
10
12
 
11
- def initialize reader: Reader.new, container: Container
13
+ def initialize reader: Reader.new, **dependencies
14
+ super(**dependencies)
12
15
  @reader = reader
13
- @container = container
14
16
  end
15
17
 
16
18
  def call
@@ -22,9 +24,7 @@ module SublimeTextKit
22
24
 
23
25
  private
24
26
 
25
- def configuration = container[__method__]
26
-
27
- attr_reader :reader, :container
27
+ attr_reader :reader
28
28
  end
29
29
  end
30
30
  end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SublimeTextKit
4
+ module Snippets
5
+ # Prints snippets as a list.
6
+ class Printer
7
+ include Import[:logger]
8
+
9
+ def initialize collector: Collector.new, **dependencies
10
+ super(**dependencies)
11
+ @collector = collector
12
+ end
13
+
14
+ def call bullet
15
+ collector.call.each do |snippet|
16
+ logger.info "#{bullet} #{snippet.description} - `#{snippet.trigger}`"
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ attr_reader :collector
23
+ end
24
+ end
25
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "sublime_text_kit"
5
- spec.version = "12.3.2"
5
+ spec.version = "13.0.0"
6
6
  spec.authors = ["Brooke Kuhlmann"]
7
7
  spec.email = ["brooke@alchemists.io"]
8
8
  spec.homepage = "https://www.alchemists.io/projects/sublime_text_kit"
@@ -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: sublime_text_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 12.3.2
4
+ version: 13.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -28,36 +28,50 @@ cert_chain:
28
28
  CxDe2+VuChj4I1nvIHdu+E6XoEVlanUPKmSg6nddhkKn2gC45Kyzh6FZqnzH/CRp
29
29
  RFE=
30
30
  -----END CERTIFICATE-----
31
- date: 2022-03-20 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/sublime_text_kit
130
144
  - lib/sublime_text_kit.rb
131
145
  - lib/sublime_text_kit/cli/actions/config.rb
146
+ - lib/sublime_text_kit/cli/actions/container.rb
147
+ - lib/sublime_text_kit/cli/actions/import.rb
132
148
  - lib/sublime_text_kit/cli/actions/metadata.rb
133
149
  - lib/sublime_text_kit/cli/actions/session.rb
134
150
  - lib/sublime_text_kit/cli/actions/snippets.rb
@@ -140,6 +156,7 @@ files:
140
156
  - lib/sublime_text_kit/configuration/defaults.yml
141
157
  - lib/sublime_text_kit/configuration/loader.rb
142
158
  - lib/sublime_text_kit/container.rb
159
+ - lib/sublime_text_kit/import.rb
143
160
  - lib/sublime_text_kit/metadata/handler.rb
144
161
  - lib/sublime_text_kit/metadata/pathway.rb
145
162
  - lib/sublime_text_kit/metadata/serializers/project.rb
@@ -147,8 +164,7 @@ files:
147
164
  - lib/sublime_text_kit/sessions/rebuilder.rb
148
165
  - lib/sublime_text_kit/snippets/collector.rb
149
166
  - lib/sublime_text_kit/snippets/model.rb
150
- - lib/sublime_text_kit/snippets/printers/ascii_doc.rb
151
- - lib/sublime_text_kit/snippets/printers/markdown.rb
167
+ - lib/sublime_text_kit/snippets/printer.rb
152
168
  - lib/sublime_text_kit/snippets/reader.rb
153
169
  - sublime_text_kit.gemspec
154
170
  homepage: https://www.alchemists.io/projects/sublime_text_kit
@@ -176,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
192
  - !ruby/object:Gem::Version
177
193
  version: '0'
178
194
  requirements: []
179
- rubygems_version: 3.3.9
195
+ rubygems_version: 3.3.11
180
196
  signing_key:
181
197
  specification_version: 4
182
198
  summary: A command line interface for managing Sublime Text metadata.
metadata.gz.sig CHANGED
Binary file
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SublimeTextKit
4
- module Snippets
5
- module Printers
6
- # Prints snippets in ASCII Doc format.
7
- class ASCIIDoc
8
- def initialize collector: Collector.new, container: Container
9
- @collector = collector
10
- @container = container
11
- end
12
-
13
- def call
14
- collector.call.each do |snippet|
15
- logger.info "* #{snippet.description} - `#{snippet.trigger}`"
16
- end
17
- end
18
-
19
- private
20
-
21
- attr_reader :collector, :container
22
-
23
- def logger = container[__method__]
24
- end
25
- end
26
- end
27
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SublimeTextKit
4
- module Snippets
5
- module Printers
6
- # Prints snippets in Markdown format.
7
- class Markdown
8
- def initialize collector: Collector.new, container: Container
9
- @collector = collector
10
- @container = container
11
- end
12
-
13
- def call
14
- collector.call.each do |snippet|
15
- logger.info "- #{snippet.description} - `#{snippet.trigger}`"
16
- end
17
- end
18
-
19
- private
20
-
21
- attr_reader :collector, :container
22
-
23
- def logger = container[__method__]
24
- end
25
- end
26
- end
27
- end