sublime_text_kit 14.2.0 → 15.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: 3a1e0b0513d5fbeccd47af0053af6f66452c86bbb680e7bfae20ce5fd37561c1
4
- data.tar.gz: b444c698ead83a4bc2d31bdcd34f093879d5271cbbd2a686b7724e19201e96d9
3
+ metadata.gz: 29bf2181b4e5836ffa6d8516718c767d4ce86ffcc92dfaa64678983fea21b845
4
+ data.tar.gz: df5e8fb6df541d0fafc1cfadff71a04baaf46587fb5a8dc5688230853dcf120c
5
5
  SHA512:
6
- metadata.gz: bc2cd4e107eb01e2608e64ea12d39951ad05e23685531ecf24af1248459bfedd9fddc0416fd8800ace1898f7109c31557f847567f0a2540fc3b78dfb60827e82
7
- data.tar.gz: bab7663426d55855d9849f2e30080df73fe49a558b742d07dd0987f23b92401db34384089b966fe87404f483a87536ab682f59bf45da1e2f8cbea0e15ecb16c9
6
+ metadata.gz: 867751fb2cceaa6b81bbdc1beb1d83d626265929ed7e6c92e9c355d763fd340237c6bad8a1fa533ccd477ec700da6f87b7961a6d4552b3a0e56f420f367c58e1
7
+ data.tar.gz: cbe288a962340ae375f06f14afc9c2e581ec41ad9bf5afbb75c287f18665a1513a0897791272ac60e4ba78c3c3e1cf08a75d8976810bd12eeeb87f68b47dec2c
checksums.yaml.gz.sig CHANGED
Binary file
data/README.adoc CHANGED
@@ -48,14 +48,23 @@ gem install sublime_text_kit
48
48
  From the command line, type: `sublime_text_kit`
49
49
 
50
50
  ....
51
- USAGE:
52
- -c, --config ACTION Manage gem configuration. Actions: edit or view.
53
- -h, --help Show this message.
54
- -m, --metadata ACTION Manage project metadata. Actions: create, delete, or recreate.
55
- -S, --session Rebuild session metadata.
56
- -s, --snippets [FORMAT] View snippets. Formats: markdown or ascii_doc. Default: ascii_doc.
57
- -u, --update Update project and session metadata based on current settings.
58
- -v, --version Show gem version.
51
+ USAGE
52
+ sublime_text_kit [OPTIONS]
53
+ sublime_text_kit COMMAND [OPTIONS]
54
+
55
+ OPTIONS
56
+ -S, --session Rebuild session metadata.
57
+ -s, --snippets [FORMAT] View snippets.
58
+ Use: markdown or ascii_doc.
59
+ Default: ascii_doc.
60
+ -u, --update Update project and session metadata based on current settings.
61
+ -v, --version Show version.
62
+ -h, --help [COMMAND] Show this message.
63
+
64
+ COMMANDS
65
+ config Manage configuration.
66
+ Path is dynamic per current directory.
67
+ metadata Manage project metadata.
59
68
  ....
60
69
 
61
70
  === Customization
@@ -68,15 +77,13 @@ An example configuration could be:
68
77
 
69
78
  [source,yaml]
70
79
  ----
71
- :project_roots:
80
+ project_roots:
72
81
  - "~/Engineering/Organizations"
73
82
  - "~/Engineering/OSS"
74
- :metadata_dir: "~/Dropbox/Cache/Sublime"
75
- :snippets_format: :markdown
83
+ metadata_dir: "~/Dropbox/Cache/Sublime"
84
+ snippets_format: :markdown
76
85
  ----
77
86
 
78
- Feel free to take this configuration, modify, and save as your own.
79
-
80
87
  The `project_roots` key defines the root level directories where your project folders are located.
81
88
  When project metadata (i.e. `.sublime-project`, `.sublime-workspace`) is generated, the name of the
82
89
  metadata file will be the same name as the project folder. All project metadata, regardless of root
@@ -112,7 +119,7 @@ The following demonstrates a default Sublime Text setup:
112
119
  2. Shutdown Sublime Text (i.e. `COMMAND+q`).
113
120
  3. Run `sublime_text_kit --update` which will create project metadata and rebuild session metadata
114
121
  so Sublime Text has a complete project history from which to switch between via the
115
- `CONTROL+COMMMAND+p` shortcut.
122
+ `CONTROL+COMMAND+p` shortcut.
116
123
  4. Launch Sublime Text and use the `CONTROL+COMMAND+p` keyboard shortcut to toggle between projects.
117
124
  Notice that you can (fuzzy type) project names to jump between them.
118
125
  5. Navigate through your project workload with ease. 🎉
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "refinements/pathnames"
4
+ require "sod"
5
+
6
+ module SublimeTextKit
7
+ module CLI
8
+ module Actions
9
+ module Metadata
10
+ # Creates project metadata.
11
+ class Create < Sod::Action
12
+ include Import[:configuration, :logger]
13
+
14
+ using Refinements::Pathnames
15
+
16
+ description "Create metadata."
17
+
18
+ on %w[-c --create]
19
+
20
+ def initialize(handler: SublimeTextKit::Metadata::Handler, **)
21
+ super(**)
22
+ @handler = handler
23
+ end
24
+
25
+ def call(*)
26
+ logger.info "Creating metadata in #{metadata_dir}..."
27
+ process_projects
28
+ logger.info "Metadata created."
29
+ end
30
+
31
+ private
32
+
33
+ attr_reader :handler
34
+
35
+ def process_projects
36
+ configuration.project_dirs.each do |directory|
37
+ handler.with_project(directory, metadata_dir).create
38
+ handler.with_workspace(directory, metadata_dir).create
39
+ end
40
+ end
41
+
42
+ def metadata_dir = Pathname(configuration.metadata_dir).expand_path
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "refinements/pathnames"
4
+ require "sod"
5
+
6
+ module SublimeTextKit
7
+ module CLI
8
+ module Actions
9
+ module Metadata
10
+ # Deletes project metadata.
11
+ class Delete < Sod::Action
12
+ include Import[:configuration, :logger]
13
+
14
+ using Refinements::Pathnames
15
+
16
+ description "Delete metadata."
17
+
18
+ on %w[-d --delete]
19
+
20
+ def initialize(handler: SublimeTextKit::Metadata::Handler, **)
21
+ super(**)
22
+ @handler = handler
23
+ end
24
+
25
+ def call(*)
26
+ logger.info "Deleting metadata in #{metadata_dir}..."
27
+ process_projects
28
+ logger.info "Metadata deleted."
29
+ end
30
+
31
+ private
32
+
33
+ attr_reader :handler
34
+
35
+ def process_projects
36
+ configuration.project_dirs.each do |directory|
37
+ handler.with_project(directory, metadata_dir).delete
38
+ handler.with_workspace(directory, metadata_dir).delete
39
+ end
40
+ end
41
+
42
+ def metadata_dir = Pathname(configuration.metadata_dir).expand_path
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "refinements/pathnames"
4
+ require "sod"
5
+
6
+ module SublimeTextKit
7
+ module CLI
8
+ module Actions
9
+ module Metadata
10
+ # Recreates project metadata.
11
+ class Recreate < Sod::Action
12
+ include Import[:configuration, :logger]
13
+
14
+ using Refinements::Pathnames
15
+
16
+ description "Recreate metadata."
17
+
18
+ on %w[-r --recreate]
19
+
20
+ def initialize(handler: SublimeTextKit::Metadata::Handler, **)
21
+ super(**)
22
+ @handler = handler
23
+ end
24
+
25
+ def call(*)
26
+ logger.info "Recreating metadata in #{metadata_dir}..."
27
+ process_projects
28
+ logger.info "Metadata recreated."
29
+ end
30
+
31
+ private
32
+
33
+ attr_reader :handler
34
+
35
+ def process_projects
36
+ configuration.project_dirs.each do |directory|
37
+ handler.with_project(directory, metadata_dir).recreate
38
+ handler.with_workspace(directory, metadata_dir).recreate
39
+ end
40
+ end
41
+
42
+ def metadata_dir = Pathname(configuration.metadata_dir).expand_path
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -1,18 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "sod"
4
+
3
5
  module SublimeTextKit
4
6
  module CLI
5
7
  module Actions
6
8
  # Handles session action.
7
- class Session
8
- include SublimeTextKit::Import[:logger]
9
+ class Session < Sod::Action
10
+ include Import[:logger]
11
+
12
+ description "Rebuild session metadata."
13
+
14
+ on %w[-S --session]
9
15
 
10
16
  def initialize(rebuilder: Sessions::Rebuilder.new, **)
11
17
  super(**)
12
18
  @rebuilder = rebuilder
13
19
  end
14
20
 
15
- def call
21
+ def call(*)
16
22
  rebuilder.call
17
23
  logger.info "Session rebuilt."
18
24
  end
@@ -1,21 +1,29 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "sod"
4
+
3
5
  module SublimeTextKit
4
6
  module CLI
5
7
  module Actions
6
8
  # Handles snippets action.
7
- class Snippets
8
- include SublimeTextKit::Import[:configuration, :logger]
9
+ class Snippets < Sod::Action
10
+ include Import[:configuration, :logger]
11
+
12
+ description "View snippets."
13
+
14
+ on %w[-s --snippets], argument: "[FORMAT]", allow: %w[markdown ascii_doc]
15
+
16
+ default { Container[:configuration].snippets_format }
9
17
 
10
18
  def initialize(printer: SublimeTextKit::Snippets::Printer.new, **)
11
19
  super(**)
12
20
  @printer = printer
13
21
  end
14
22
 
15
- def call kind
23
+ def call kind = default
16
24
  case kind
17
- when :ascii_doc then printer.call "*"
18
- when :markdown then printer.call "-"
25
+ when "ascii_doc" then printer.call "*"
26
+ when "markdown" then printer.call "-"
19
27
  else logger.error { "Invalid snippet format: #{kind}. Use ascii_doc or markdown." }
20
28
  end
21
29
  end
@@ -1,11 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "sod"
4
+
3
5
  module SublimeTextKit
4
6
  module CLI
5
7
  module Actions
6
8
  # Handles update action.
7
- class Update
8
- include SublimeTextKit::Import[:configuration, :logger]
9
+ class Update < Sod::Action
10
+ include Import[:configuration, :logger]
11
+
12
+ description "Update project and session metadata based on current settings."
13
+
14
+ on %w[-u --update]
9
15
 
10
16
  def initialize(
11
17
  metadata: SublimeTextKit::Metadata::Handler,
@@ -17,7 +23,7 @@ module SublimeTextKit
17
23
  @session = session
18
24
  end
19
25
 
20
- def call
26
+ def call(*)
21
27
  logger.info "Updating metadata and session..."
22
28
  create_metadata
23
29
  session.call
@@ -1,50 +1,48 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "core"
3
+ require "sod"
4
4
 
5
5
  module SublimeTextKit
6
6
  module CLI
7
7
  # The main Command Line Interface (CLI) object.
8
8
  class Shell
9
- include Actions::Import[
10
- :config,
11
- :kernel,
12
- :logger,
13
- :metadata,
14
- :session,
15
- :snippets,
16
- :specification,
17
- :update
18
- ]
19
-
20
- def initialize(parser: Parser.new, **)
9
+ include Import[:defaults_path, :xdg_config, :specification]
10
+
11
+ def initialize(context: Sod::Context, dsl: Sod, **)
21
12
  super(**)
22
- @parser = parser
13
+ @context = context
14
+ @dsl = dsl
23
15
  end
24
16
 
25
- def call arguments = Core::EMPTY_ARRAY
26
- act_on parser.call(arguments)
27
- rescue OptionParser::ParseError, Error => error
28
- logger.error { error.message }
29
- end
17
+ def call(...) = cli.call(...)
30
18
 
31
19
  private
32
20
 
33
- attr_reader :parser
34
-
35
- def act_on configuration
36
- case configuration
37
- in action_config: Symbol => action then config.call action
38
- in action_metadata: Symbol => kind then metadata.call kind
39
- in action_session: true then session.call
40
- in action_snippets: true then snippets.call configuration.snippets_format
41
- in action_update: true then update.call
42
- in action_version: true then kernel.puts specification.labeled_version
43
- else usage
21
+ attr_reader :context, :dsl
22
+
23
+ def cli
24
+ context = build_context
25
+
26
+ dsl.new :sublime_text_kit, banner: specification.banner do
27
+ on(Sod::Prefabs::Commands::Config, context:)
28
+
29
+ on "metadata", "Manage project metadata." do
30
+ on Actions::Metadata::Create
31
+ on Actions::Metadata::Delete
32
+ on Actions::Metadata::Recreate
33
+ end
34
+
35
+ on Actions::Session
36
+ on Actions::Snippets
37
+ on Actions::Update
38
+ on(Sod::Prefabs::Actions::Version, context:)
39
+ on Sod::Prefabs::Actions::Help, self
44
40
  end
45
41
  end
46
42
 
47
- def usage = kernel.puts parser.to_s
43
+ def build_context
44
+ context[defaults_path:, xdg_config:, version_label: specification.labeled_version]
45
+ end
48
46
  end
49
47
  end
50
48
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dry/schema"
4
+ require "etcher"
5
+
6
+ Dry::Schema.load_extensions :monads
7
+
8
+ module SublimeTextKit
9
+ module Configuration
10
+ Contract = Dry::Schema.Params do
11
+ optional(:project_roots).filled :array
12
+ optional(:metadata_dir).filled Etcher::Types::Pathname
13
+ required(:snippets_format).filled :string
14
+ required(:session_path).filled Etcher::Types::Pathname
15
+ required(:user_dir).filled Etcher::Types::Pathname
16
+ end
17
+ end
18
+ end
@@ -1,3 +1 @@
1
- :project_roots:
2
- :metadata_dir:
3
- :snippets_format: :ascii_doc
1
+ snippets_format: ascii_doc
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "refinements/pathnames"
4
+
5
+ module SublimeTextKit
6
+ module Configuration
7
+ # Models the configuration.
8
+ Model = Struct.new(
9
+ :project_roots,
10
+ :metadata_dir,
11
+ :snippets_format,
12
+ :session_path,
13
+ :user_dir
14
+ ) do
15
+ using Refinements::Pathnames
16
+
17
+ def initialize(**)
18
+ super
19
+ freeze
20
+ end
21
+
22
+ def project_dirs
23
+ Array(project_roots).map { |path| Pathname(path).expand_path }
24
+ .flat_map(&:directories)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dry/monads"
4
+
5
+ module SublimeTextKit
6
+ module Configuration
7
+ module Transformers
8
+ # Transforms session path into fully qualified path based on home directory.
9
+ class SessionPath
10
+ include Dry::Monads[:result]
11
+
12
+ def initialize
13
+ path = "Library/Application Support/Sublime Text/Local/Session.sublime_session"
14
+
15
+ @path = path
16
+ end
17
+
18
+ def call content
19
+ return Success content unless content.key? :home
20
+
21
+ Pathname(content[:home]).join(path)
22
+ .then { |session_path| Success content.merge!(session_path:) }
23
+ end
24
+
25
+ private
26
+
27
+ attr_reader :path
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dry/monads"
4
+
5
+ module SublimeTextKit
6
+ module Configuration
7
+ module Transformers
8
+ # Transforms user directory into fully qualified path based on home directory.
9
+ class UserDir
10
+ include Dry::Monads[:result]
11
+
12
+ def initialize path = "Library/Application Support/Sublime Text/Packages/User"
13
+ @path = path
14
+ end
15
+
16
+ def call content
17
+ return Success content unless content.key? :home
18
+
19
+ Pathname(content[:home]).join(path)
20
+ .then { |user_dir| Success content.merge!(user_dir:) }
21
+ end
22
+
23
+ private
24
+
25
+ attr_reader :path
26
+ end
27
+ end
28
+ end
29
+ end
@@ -2,6 +2,8 @@
2
2
 
3
3
  require "cogger"
4
4
  require "dry/container"
5
+ require "etcher"
6
+ require "runcom"
5
7
  require "spek"
6
8
 
7
9
  module SublimeTextKit
@@ -9,7 +11,22 @@ module SublimeTextKit
9
11
  module Container
10
12
  extend Dry::Container::Mixin
11
13
 
12
- register(:configuration) { Configuration::Loader.call }
14
+ # :nocov:
15
+ register :configuration do
16
+ self[:defaults].add_loader(Etcher::Loaders::Environment.new(%w[HOME]))
17
+ .add_loader(Etcher::Loaders::YAML.new(self[:xdg_config].active))
18
+ .add_transformer(Configuration::Transformers::SessionPath.new)
19
+ .add_transformer(Configuration::Transformers::UserDir.new)
20
+ .then { |registry| Etcher.call registry }
21
+ end
22
+
23
+ register :defaults do
24
+ Etcher::Registry.new(contract: Configuration::Contract, model: Configuration::Model)
25
+ .add_loader(Etcher::Loaders::YAML.new(self[:defaults_path]))
26
+ end
27
+
28
+ register(:defaults_path) { Pathname(__dir__).join("configuration/defaults.yml") }
29
+ register(:xdg_config) { Runcom::Config.new "sublime_text_kit/configuration.yml" }
13
30
  register(:specification) { Spek::Loader.call "#{__dir__}/../../sublime_text_kit.gemspec" }
14
31
  register(:kernel) { Kernel }
15
32
  register(:logger) { Cogger.new formatter: :emoji }
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "infusible"
4
+
3
5
  module SublimeTextKit
4
6
  Import = Infusible.with Container
5
7
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "sublime_text_kit"
5
- spec.version = "14.2.0"
5
+ spec.version = "15.0.0"
6
6
  spec.authors = ["Brooke Kuhlmann"]
7
7
  spec.email = ["brooke@alchemists.io"]
8
8
  spec.homepage = "https://alchemists.io/projects/sublime_text_kit"
@@ -23,13 +23,16 @@ Gem::Specification.new do |spec|
23
23
  spec.cert_chain = [Gem.default_cert_path]
24
24
 
25
25
  spec.required_ruby_version = "~> 3.2"
26
- spec.add_dependency "cogger", "~> 0.8"
27
- spec.add_dependency "core", "~> 0.1"
26
+ spec.add_dependency "cogger", "~> 0.10"
28
27
  spec.add_dependency "dry-container", "~> 0.11"
29
- spec.add_dependency "infusible", "~> 1.0"
30
- spec.add_dependency "refinements", "~> 10.0"
31
- spec.add_dependency "runcom", "~> 9.0"
32
- spec.add_dependency "spek", "~> 1.0"
28
+ spec.add_dependency "dry-monads", "~> 1.6"
29
+ spec.add_dependency "dry-schema", "~> 1.13"
30
+ spec.add_dependency "etcher", "~> 0.2"
31
+ spec.add_dependency "infusible", "~> 2.0"
32
+ spec.add_dependency "refinements", "~> 11.0"
33
+ spec.add_dependency "runcom", "~> 10.0"
34
+ spec.add_dependency "sod", "~> 0.0"
35
+ spec.add_dependency "spek", "~> 2.0"
33
36
  spec.add_dependency "zeitwerk", "~> 2.6"
34
37
 
35
38
  spec.bindir = "exe"
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: 14.2.0
4
+ version: 15.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -35,7 +35,7 @@ cert_chain:
35
35
  3n5C8/6Zh9DYTkpcwPSuIfAga6wf4nXc9m6JAw8AuMLaiWN/r/2s4zJsUHYERJEu
36
36
  gZGm4JqtuSg8pYjPeIJxS960owq+SfuC+jxqmRA54BisFCv/0VOJi7tiJVY=
37
37
  -----END CERTIFICATE-----
38
- date: 2023-04-13 00:00:00.000000000 Z
38
+ date: 2023-06-16 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: cogger
@@ -43,58 +43,100 @@ dependencies:
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '0.8'
46
+ version: '0.10'
47
47
  type: :runtime
48
48
  prerelease: false
49
49
  version_requirements: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '0.8'
53
+ version: '0.10'
54
54
  - !ruby/object:Gem::Dependency
55
- name: core
55
+ name: dry-container
56
56
  requirement: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '0.1'
60
+ version: '0.11'
61
61
  type: :runtime
62
62
  prerelease: false
63
63
  version_requirements: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '0.1'
67
+ version: '0.11'
68
68
  - !ruby/object:Gem::Dependency
69
- name: dry-container
69
+ name: dry-monads
70
70
  requirement: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '0.11'
74
+ version: '1.6'
75
75
  type: :runtime
76
76
  prerelease: false
77
77
  version_requirements: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: '0.11'
81
+ version: '1.6'
82
+ - !ruby/object:Gem::Dependency
83
+ name: dry-schema
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '1.13'
89
+ type: :runtime
90
+ prerelease: false
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '1.13'
96
+ - !ruby/object:Gem::Dependency
97
+ name: etcher
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '0.2'
103
+ type: :runtime
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '0.2'
82
110
  - !ruby/object:Gem::Dependency
83
111
  name: infusible
84
112
  requirement: !ruby/object:Gem::Requirement
85
113
  requirements:
86
114
  - - "~>"
87
115
  - !ruby/object:Gem::Version
88
- version: '1.0'
116
+ version: '2.0'
89
117
  type: :runtime
90
118
  prerelease: false
91
119
  version_requirements: !ruby/object:Gem::Requirement
92
120
  requirements:
93
121
  - - "~>"
94
122
  - !ruby/object:Gem::Version
95
- version: '1.0'
123
+ version: '2.0'
96
124
  - !ruby/object:Gem::Dependency
97
125
  name: refinements
126
+ requirement: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: '11.0'
131
+ type: :runtime
132
+ prerelease: false
133
+ version_requirements: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: '11.0'
138
+ - !ruby/object:Gem::Dependency
139
+ name: runcom
98
140
  requirement: !ruby/object:Gem::Requirement
99
141
  requirements:
100
142
  - - "~>"
@@ -108,33 +150,33 @@ dependencies:
108
150
  - !ruby/object:Gem::Version
109
151
  version: '10.0'
110
152
  - !ruby/object:Gem::Dependency
111
- name: runcom
153
+ name: sod
112
154
  requirement: !ruby/object:Gem::Requirement
113
155
  requirements:
114
156
  - - "~>"
115
157
  - !ruby/object:Gem::Version
116
- version: '9.0'
158
+ version: '0.0'
117
159
  type: :runtime
118
160
  prerelease: false
119
161
  version_requirements: !ruby/object:Gem::Requirement
120
162
  requirements:
121
163
  - - "~>"
122
164
  - !ruby/object:Gem::Version
123
- version: '9.0'
165
+ version: '0.0'
124
166
  - !ruby/object:Gem::Dependency
125
167
  name: spek
126
168
  requirement: !ruby/object:Gem::Requirement
127
169
  requirements:
128
170
  - - "~>"
129
171
  - !ruby/object:Gem::Version
130
- version: '1.0'
172
+ version: '2.0'
131
173
  type: :runtime
132
174
  prerelease: false
133
175
  version_requirements: !ruby/object:Gem::Requirement
134
176
  requirements:
135
177
  - - "~>"
136
178
  - !ruby/object:Gem::Version
137
- version: '1.0'
179
+ version: '2.0'
138
180
  - !ruby/object:Gem::Dependency
139
181
  name: zeitwerk
140
182
  requirement: !ruby/object:Gem::Requirement
@@ -163,19 +205,18 @@ files:
163
205
  - README.adoc
164
206
  - exe/sublime_text_kit
165
207
  - lib/sublime_text_kit.rb
166
- - lib/sublime_text_kit/cli/actions/config.rb
167
- - lib/sublime_text_kit/cli/actions/container.rb
168
- - lib/sublime_text_kit/cli/actions/import.rb
169
- - lib/sublime_text_kit/cli/actions/metadata.rb
208
+ - lib/sublime_text_kit/cli/actions/metadata/create.rb
209
+ - lib/sublime_text_kit/cli/actions/metadata/delete.rb
210
+ - lib/sublime_text_kit/cli/actions/metadata/recreate.rb
170
211
  - lib/sublime_text_kit/cli/actions/session.rb
171
212
  - lib/sublime_text_kit/cli/actions/snippets.rb
172
213
  - lib/sublime_text_kit/cli/actions/update.rb
173
- - lib/sublime_text_kit/cli/parser.rb
174
- - lib/sublime_text_kit/cli/parsers/core.rb
175
214
  - lib/sublime_text_kit/cli/shell.rb
176
- - lib/sublime_text_kit/configuration/content.rb
215
+ - lib/sublime_text_kit/configuration/contract.rb
177
216
  - lib/sublime_text_kit/configuration/defaults.yml
178
- - lib/sublime_text_kit/configuration/loader.rb
217
+ - lib/sublime_text_kit/configuration/model.rb
218
+ - lib/sublime_text_kit/configuration/transformers/session_path.rb
219
+ - lib/sublime_text_kit/configuration/transformers/user_dir.rb
179
220
  - lib/sublime_text_kit/container.rb
180
221
  - lib/sublime_text_kit/import.rb
181
222
  - lib/sublime_text_kit/metadata/handler.rb
@@ -214,7 +255,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
255
  - !ruby/object:Gem::Version
215
256
  version: '0'
216
257
  requirements: []
217
- rubygems_version: 3.4.12
258
+ rubygems_version: 3.4.14
218
259
  signing_key:
219
260
  specification_version: 4
220
261
  summary: A command line interface for managing Sublime Text metadata.
metadata.gz.sig CHANGED
Binary file
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SublimeTextKit
4
- module CLI
5
- module Actions
6
- # Handles gem configuration action.
7
- class Config
8
- include SublimeTextKit::Import[:kernel, :logger]
9
-
10
- def initialize(configuration: Configuration::Loader::CLIENT, **)
11
- super(**)
12
- @configuration = configuration
13
- end
14
-
15
- def call action
16
- case action
17
- when :edit then edit
18
- when :view then view
19
- else logger.error { "Invalid configuration action: #{action}." }
20
- end
21
- end
22
-
23
- private
24
-
25
- attr_reader :configuration
26
-
27
- def edit = kernel.system("$EDITOR #{configuration.current}")
28
-
29
- def view = kernel.system("cat #{configuration.current}")
30
- end
31
- end
32
- end
33
- end
@@ -1,22 +0,0 @@
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
- merge SublimeTextKit::Container
13
-
14
- register(:config) { Actions::Config.new }
15
- register(:metadata) { Actions::Metadata.new }
16
- register(:session) { Actions::Session.new }
17
- register(:snippets) { Actions::Snippets.new }
18
- register(:update) { Actions::Update.new }
19
- end
20
- end
21
- end
22
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "infusible"
4
-
5
- module SublimeTextKit
6
- module CLI
7
- module Actions
8
- Import = Infusible.with Container
9
- end
10
- end
11
- end
@@ -1,61 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "refinements/pathnames"
4
-
5
- module SublimeTextKit
6
- module CLI
7
- module Actions
8
- # Handles metadata action.
9
- class Metadata
10
- include SublimeTextKit::Import[:configuration, :logger]
11
-
12
- using Refinements::Pathnames
13
-
14
- def initialize(handler: SublimeTextKit::Metadata::Handler, **)
15
- super(**)
16
- @handler = handler
17
- end
18
-
19
- def call kind
20
- case kind
21
- when :create then create
22
- when :delete then delete
23
- when :recreate then recreate
24
- else logger.error { "Unknown metadata action: #{kind}." }
25
- end
26
- end
27
-
28
- private
29
-
30
- attr_reader :handler
31
-
32
- def create
33
- logger.info "Creating metadata in #{metadata_dir}..."
34
- process_projects __method__
35
- logger.info "Metadata created."
36
- end
37
-
38
- def delete
39
- logger.info "Deleting metadata in #{metadata_dir}..."
40
- process_projects __method__
41
- logger.info "Metadata deleted."
42
- end
43
-
44
- def recreate
45
- logger.info "Recreating metadata in #{metadata_dir}..."
46
- process_projects __method__
47
- logger.info "Metadata recreated."
48
- end
49
-
50
- def process_projects method
51
- configuration.project_dirs.each do |directory|
52
- handler.with_project(directory, metadata_dir).public_send method
53
- handler.with_workspace(directory, metadata_dir).public_send method
54
- end
55
- end
56
-
57
- def metadata_dir = Pathname(configuration.metadata_dir).expand_path
58
- end
59
- end
60
- end
61
- end
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "core"
4
- require "optparse"
5
-
6
- module SublimeTextKit
7
- module CLI
8
- # Assembles and parses all Command Line Interface (CLI) options.
9
- class Parser
10
- include Import[:configuration]
11
-
12
- CLIENT = OptionParser.new nil, 40, " "
13
-
14
- def initialize(section: Parsers::Core, client: CLIENT, **)
15
- super(**)
16
- @section = section
17
- @client = client
18
- @configuration_duplicate = configuration.dup
19
- end
20
-
21
- def call arguments = Core::EMPTY_ARRAY
22
- section.call(configuration_duplicate, client:)
23
- client.parse arguments
24
- configuration_duplicate.freeze
25
- end
26
-
27
- def to_s = client.to_s
28
-
29
- private
30
-
31
- attr_reader :section, :client, :configuration_duplicate
32
- end
33
- end
34
- end
@@ -1,103 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "core"
4
- require "refinements/structs"
5
-
6
- module SublimeTextKit
7
- module CLI
8
- module Parsers
9
- # Handles parsing of Command Line Interface (CLI) core options.
10
- class Core
11
- include Import[:specification]
12
-
13
- using Refinements::Structs
14
-
15
- def self.call(...) = new(...).call
16
-
17
- def initialize(configuration = Container[:configuration], client: Parser::CLIENT, **)
18
- super(**)
19
- @configuration = configuration
20
- @client = client
21
- end
22
-
23
- def call arguments = ::Core::EMPTY_ARRAY
24
- client.banner = specification.labeled_summary
25
- client.separator "\nUSAGE:\n"
26
- collate
27
- client.parse arguments
28
- configuration
29
- end
30
-
31
- private
32
-
33
- attr_reader :configuration, :client
34
-
35
- def collate = private_methods.sort.grep(/add_/).each { |method| __send__ method }
36
-
37
- def add_config
38
- client.on(
39
- "-c",
40
- "--config ACTION",
41
- %i[edit view],
42
- "Manage gem configuration. Actions: edit or view."
43
- ) do |action|
44
- configuration.merge! action_config: action
45
- end
46
- end
47
-
48
- def add_metadata
49
- client.on(
50
- "-m",
51
- "--metadata ACTION",
52
- %i[create delete recreate],
53
- "Manage project metadata. Actions: create, delete, or recreate."
54
- ) do |action|
55
- configuration.merge! action_metadata: action
56
- end
57
- end
58
-
59
- def add_session
60
- client.on "-S", "--session", "Rebuild session metadata." do
61
- configuration.merge! action_session: true
62
- end
63
- end
64
-
65
- def add_snippets
66
- client.on(
67
- "-s",
68
- "--snippets [FORMAT]",
69
- %i[markdown ascii_doc],
70
- "View snippets. Formats: markdown or ascii_doc. " \
71
- "Default: #{snippets_format}."
72
- ) do |kind|
73
- configuration.merge! action_snippets: true, snippets_format: kind || snippets_format
74
- end
75
- end
76
-
77
- def add_update
78
- client.on(
79
- "-u",
80
- "--update",
81
- "Update project and session metadata based on current settings."
82
- ) do
83
- configuration.merge! action_update: true
84
- end
85
- end
86
-
87
- def add_version
88
- client.on "-v", "--version", "Show gem version." do
89
- configuration.merge! action_version: true
90
- end
91
- end
92
-
93
- def add_help
94
- client.on "-h", "--help", "Show this message." do
95
- configuration.merge! action_help: true
96
- end
97
- end
98
-
99
- def snippets_format = configuration.snippets_format
100
- end
101
- end
102
- end
103
- end
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "refinements/pathnames"
4
-
5
- module SublimeTextKit
6
- module Configuration
7
- # Defines configuration content as the primary source of truth for use throughout the gem.
8
- Content = Struct.new(
9
- :action_config,
10
- :action_help,
11
- :action_metadata,
12
- :action_session,
13
- :action_snippets,
14
- :action_update,
15
- :action_version,
16
- :project_roots,
17
- :metadata_dir,
18
- :snippets_format,
19
- :session_path,
20
- :user_dir,
21
- keyword_init: true
22
- ) do
23
- using Refinements::Pathnames
24
-
25
- def initialize *arguments
26
- super
27
-
28
- home = Pathname ENV.fetch("HOME", "")
29
-
30
- self[:session_path] ||= home.join(
31
- "Library/Application Support/Sublime Text/Local/Session.sublime_session"
32
- )
33
-
34
- self[:user_dir] ||= home.join "Library/Application Support/Sublime Text/Packages/User"
35
-
36
- freeze
37
- end
38
-
39
- def project_dirs
40
- Array(project_roots).map { |path| Pathname(path).expand_path }
41
- .flat_map(&:directories)
42
- end
43
- end
44
- end
45
- end
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "pathname"
4
- require "refinements/hashes"
5
- require "refinements/structs"
6
- require "runcom"
7
- require "yaml"
8
-
9
- module SublimeTextKit
10
- module Configuration
11
- # Represents the fully assembled Command Line Interface (CLI) configuration.
12
- class Loader
13
- using Refinements::Hashes
14
- using Refinements::Structs
15
-
16
- DEFAULTS = YAML.load_file(Pathname(__dir__).join("defaults.yml")).freeze
17
- CLIENT = Runcom::Config.new "sublime_text_kit/configuration.yml", defaults: DEFAULTS
18
-
19
- def self.call = new.call
20
-
21
- def self.with_defaults = new(client: DEFAULTS)
22
-
23
- def initialize content: Content.new, client: CLIENT
24
- @content = content
25
- @client = client
26
- end
27
-
28
- def call = content.merge(**client.to_h.flatten_keys)
29
-
30
- private
31
-
32
- attr_reader :content, :client
33
- end
34
- end
35
- end