sublime_text_kit 10.0.2 → 11.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/README.adoc +18 -48
  4. data/bin/sublime_text_kit +1 -3
  5. data/lib/sublime_text_kit/cli/actions/config.rb +35 -0
  6. data/lib/sublime_text_kit/cli/actions/metadata.rb +63 -0
  7. data/lib/sublime_text_kit/cli/actions/session.rb +26 -0
  8. data/lib/sublime_text_kit/cli/actions/snippets.rb +35 -0
  9. data/lib/sublime_text_kit/cli/actions/update.rb +42 -0
  10. data/lib/sublime_text_kit/cli/configuration/content.rb +45 -0
  11. data/lib/sublime_text_kit/cli/configuration/defaults.yml +3 -0
  12. data/lib/sublime_text_kit/cli/configuration/loader.rb +37 -0
  13. data/lib/sublime_text_kit/cli/parsers/assembler.rb +32 -0
  14. data/lib/sublime_text_kit/cli/parsers/core.rb +96 -0
  15. data/lib/sublime_text_kit/cli/parsers.rb +11 -0
  16. data/lib/sublime_text_kit/cli/shell.rb +58 -0
  17. data/lib/sublime_text_kit/container.rb +37 -0
  18. data/lib/sublime_text_kit/identity.rb +3 -2
  19. data/lib/sublime_text_kit/metadata/handler.rb +43 -0
  20. data/lib/sublime_text_kit/metadata/pathway.rb +19 -0
  21. data/lib/sublime_text_kit/metadata/serializers/project.rb +24 -0
  22. data/lib/sublime_text_kit/metadata/serializers/workspace.rb +27 -0
  23. data/lib/sublime_text_kit/sessions/rebuilder.rb +44 -0
  24. data/lib/sublime_text_kit/snippets/collector.rb +13 -19
  25. data/lib/sublime_text_kit/snippets/model.rb +31 -0
  26. data/lib/sublime_text_kit/snippets/printers/ascii_doc.rb +7 -5
  27. data/lib/sublime_text_kit/snippets/printers/markdown.rb +7 -3
  28. data/lib/sublime_text_kit/snippets/reader.rb +21 -0
  29. data/lib/sublime_text_kit.rb +11 -10
  30. data.tar.gz.sig +0 -0
  31. metadata +56 -14
  32. metadata.gz.sig +0 -0
  33. data/lib/sublime_text_kit/cli.rb +0 -182
  34. data/lib/sublime_text_kit/metadata/base.rb +0 -60
  35. data/lib/sublime_text_kit/metadata/project_metadata.rb +0 -20
  36. data/lib/sublime_text_kit/metadata/workspace_metadata.rb +0 -23
  37. data/lib/sublime_text_kit/session.rb +0 -44
  38. data/lib/sublime_text_kit/snippets/snippet.rb +0 -56
@@ -1,60 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "json"
4
- require "pathname"
5
-
6
- module SublimeTextKit
7
- module Metadata
8
- # Abstract class for processing metadata.
9
- class Base
10
- attr_reader :name, :project_dir, :metadata_dir, :metadata_file
11
-
12
- def self.create projects_dir, metadata_dir
13
- instance = new projects_dir, metadata_dir
14
- return unless valid_dir? instance.project_dir, "Projects"
15
- return unless valid_dir? instance.metadata_dir, "Metadata"
16
-
17
- project_paths = ::Pathname.new(instance.project_dir).children.select(&:directory?)
18
- project_paths.each { |project_dir| new(project_dir, metadata_dir).save }
19
- end
20
-
21
- def self.delete metadata_dir
22
- instance = new "", metadata_dir
23
- return unless valid_dir? instance.metadata_dir, "Metadata"
24
-
25
- ::Pathname.glob("#{instance.metadata_dir}/*.#{instance.file_extension}").each(&:delete)
26
- end
27
-
28
- def initialize project_dir, metadata_dir
29
- @name = File.basename project_dir
30
- @project_dir = File.expand_path project_dir
31
- @metadata_dir = File.expand_path metadata_dir
32
- @metadata_file = File.join @metadata_dir, "#{name}.#{file_extension}"
33
- end
34
-
35
- def file_extension
36
- "sublime-unknown"
37
- end
38
-
39
- def to_h
40
- {}
41
- end
42
-
43
- def save
44
- return if File.exist? metadata_file
45
-
46
- File.open(metadata_file, "w") { |file| file.write JSON.dump(to_h) }
47
- end
48
-
49
- def self.valid_dir? dir, label
50
- if File.exist? dir
51
- true
52
- else
53
- puts "#{label} directory doesn't exist: #{dir}."
54
- false
55
- end
56
- end
57
- private_class_method :valid_dir?
58
- end
59
- end
60
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SublimeTextKit
4
- module Metadata
5
- # Processes project metadata.
6
- class Project < Base
7
- def file_extension
8
- "sublime-project"
9
- end
10
-
11
- def to_h
12
- {
13
- folders: [
14
- {path: project_dir}
15
- ]
16
- }
17
- end
18
- end
19
- end
20
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SublimeTextKit
4
- module Metadata
5
- # Processes workspace metadata.
6
- class Workspace < Base
7
- def file_extension
8
- "sublime-workspace"
9
- end
10
-
11
- def to_h
12
- {
13
- expanded_folders: [project_dir],
14
- select_project: {
15
- selected_items: [
16
- [name, File.join(metadata_dir, "#{name}.sublime-project")]
17
- ]
18
- }
19
- }
20
- end
21
- end
22
- end
23
- end
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "json"
4
-
5
- module SublimeTextKit
6
- # Manages Sublime Text session data.
7
- class Session
8
- attr_reader :metadata_dir
9
-
10
- def self.home_path
11
- ENV.fetch "HOME"
12
- end
13
-
14
- def self.session_path
15
- "#{home_path}/Library/Application Support/Sublime Text 3/Local/Session.sublime_session"
16
- end
17
-
18
- def initialize metadata_directory
19
- @metadata_dir = File.expand_path metadata_directory
20
- end
21
-
22
- def workspaces
23
- Dir["#{metadata_dir}/*.sublime-workspace"]
24
- end
25
-
26
- def rebuild_recent_workspaces
27
- session = load_session
28
- return unless session && session["workspaces"] && session["workspaces"]["recent_workspaces"]
29
-
30
- session["workspaces"]["recent_workspaces"] = workspaces
31
- save_session session
32
- end
33
-
34
- private
35
-
36
- def load_session
37
- File.exist?(self.class.session_path) ? JSON.parse(File.read(self.class.session_path)) : {}
38
- end
39
-
40
- def save_session json
41
- File.open(self.class.session_path, "w") { |file| file.write JSON.dump(json) }
42
- end
43
- end
44
- end
@@ -1,56 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rexml/document"
4
-
5
- module SublimeTextKit
6
- module Snippets
7
- class Snippet
8
- ELEMENT_TRANSLATIONS = {
9
- "content" => :content,
10
- "tabTrigger" => :trigger,
11
- "description" => :description,
12
- "scope" => :scope
13
- }.freeze
14
-
15
- ALLOWED_METHODS = ELEMENT_TRANSLATIONS.values.freeze
16
-
17
- def initialize document
18
- @document = document
19
- assign_elements
20
- end
21
-
22
- private
23
-
24
- attr_reader :document,
25
- :content_element,
26
- :trigger_element,
27
- :description_element,
28
- :scope_element
29
-
30
- def assign_elements
31
- root_element.elements.each do |element|
32
- name = element.name
33
-
34
- fail StandardError, "Unknown element: #{element}." unless ELEMENT_TRANSLATIONS.key? name
35
-
36
- instance_variable_set "@#{ELEMENT_TRANSLATIONS[name]}_element", element
37
- end
38
- end
39
-
40
- def root_element
41
- document.root || REXML::Element.new
42
- end
43
-
44
- def method_missing name, *arguments, &block
45
- return super unless respond_to_missing? name
46
-
47
- String((__send__("#{name}_element") || REXML::Element.new).text)
48
- end
49
-
50
- # :reek:BooleanParameter
51
- def respond_to_missing? name, include_private = false
52
- ALLOWED_METHODS.include?(name) || super
53
- end
54
- end
55
- end
56
- end