sublime_text_kit 8.4.0 → 8.5.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: b98a6f65a6ec31ad8c445a4000e813066a638449539666f4cad5e9d4e60284b4
4
- data.tar.gz: a4cffa1cf98f5e61a436b390129a7bfd62024bf1396b020486bf4fd44e1aced8
3
+ metadata.gz: 7b788ee61f4fdbadc934eb1fdecff98055a85689d9ac55f5f402d618c8a4e191
4
+ data.tar.gz: 6ffc9e2d639071d55d30e8458b340caea334d64531fe9cbaa764ac6f27d26699
5
5
  SHA512:
6
- metadata.gz: 6426bbf5b6aede0ae8a89052de384f138da311b74abb1ff6761b22c6c67997ac1084e47c78d0386485526f926284c99fe0d0ae6359bfcf0fb0709a758f8566c5
7
- data.tar.gz: 0143b37fcfee3cdfbfc0991b77a39e18fbd29b41045b623a9bf375bdc99ac0287f06d0426d2b878dd56111bc387dbdb70f6f962bf92931adfcc4d75a108fb87b
6
+ metadata.gz: dfd05a251edd98c2536d3f8ea76a9dd7325c823a0b4cf2e5374ad0b1cf5c7a0b5507c15756317fdcdb39f7ca5655150473731ee6d7ef9b6ec3c1d21355e99c54
7
+ data.tar.gz: 47f5373525585f6d6b5ae8c2c4d3da74afb5206b5381d93609f20cee10e1a7953faca0ef45477b02e112a8cd6ad7dcc339fd43dc9bd2c644d64a63c58a2ba02d
Binary file
data.tar.gz.sig CHANGED
@@ -1 +1,2 @@
1
- ����P�ʮKZ� 4w�)��M�?:�S8���Ұ�`�ࣛ�>���E��2ܫ�Q>���,<�`N/�����
1
+ `���&���!�;���Sy��eGU����7_ь�A(�%f*��dŜ�.��H,vc�~`W*�c
2
+ ��e��W�?��~D���1(`�"j��5inذ�ׂwUd\ş��Q���ZE�^=d�:�f��3���0��>�w �+�Q�
data/README.md CHANGED
@@ -44,7 +44,7 @@ A command line interface for managing Sublime Text metadata.
44
44
 
45
45
  ## Screencasts
46
46
 
47
- [![asciicast](https://asciinema.org/a/92707.png)](https://asciinema.org/a/92707)
47
+ [![asciicast](https://asciinema.org/a/250653.svg)](https://asciinema.org/a/250653)
48
48
 
49
49
  ## Requirements
50
50
 
@@ -66,6 +66,7 @@ From the command line, type: `sublime_text_kit`
66
66
  sublime_text_kit -c, [--config] # Manage gem configuration.
67
67
  sublime_text_kit -h, [--help=COMMAND] # Show this message or get help for a command.
68
68
  sublime_text_kit -m, [--metadata] # Manage project/workspace metadata.
69
+ sublime_text_kit -p, [--snippets] # Print user defined snippets.
69
70
  sublime_text_kit -s, [--session] # Manage session metadata.
70
71
  sublime_text_kit -u, [--update] # Update Sublime Text with current settings.
71
72
  sublime_text_kit -v, [--version] # Show gem version.
@@ -85,14 +86,17 @@ For session options, type: `sublime_text_kit --help --session`
85
86
 
86
87
  -R, [--rebuild], [--no-rebuild] # Rebuild session metadata.
87
88
 
89
+ For snippet options, type: `sublime_text_kit --help --snippets`
90
+
91
+ -m, [--markdown], [--no-markdown] # Print snippets in Markdown format.
92
+
88
93
  ### Customization
89
94
 
90
95
  This gem can be configured via a global configuration:
91
96
 
92
97
  ~/.config/sublime_text_kit/configuration.yml
93
98
 
94
- It can also be configured via [XDG environment variables](https://github.com/bkuhlmann/runcom#xdg)
95
- as provided by the [Runcom](https://github.com/bkuhlmann/runcom) gem.
99
+ It can also be configured via [XDG](https://github.com/bkuhlmann/xdg) environment variables.
96
100
 
97
101
  An example configuration could be:
98
102
 
@@ -4,5 +4,7 @@ require "sublime_text_kit/identity"
4
4
  require "sublime_text_kit/metadata/base"
5
5
  require "sublime_text_kit/metadata/project_metadata"
6
6
  require "sublime_text_kit/metadata/workspace_metadata"
7
+ require "sublime_text_kit/snippets/snippet"
8
+ require "sublime_text_kit/snippets/printers/markdown"
7
9
  require "sublime_text_kit/session"
8
10
  require "sublime_text_kit/cli"
@@ -18,6 +18,7 @@ module SublimeTextKit
18
18
  # Initialize.
19
19
  def initialize args = [], options = {}, config = {}
20
20
  super args, options, config
21
+ @markdown_printer = Snippets::Printers::Markdown.new
21
22
  end
22
23
 
23
24
  desc "-u, [--update]", "Update Sublime Text with current settings."
@@ -41,6 +42,19 @@ module SublimeTextKit
41
42
  say
42
43
  end
43
44
 
45
+ desc "-p, [--snippets]", "Print user defined snippets."
46
+ map %w[-p --snippets] => :snippets
47
+ method_option :markdown,
48
+ aliases: "-m",
49
+ desc: "Print snippets in Markdown format.",
50
+ type: :boolean,
51
+ default: false
52
+ def snippets
53
+ say
54
+ options.markdown? ? markdown_printer.call : help("--snippets")
55
+ say
56
+ end
57
+
44
58
  desc "-m, [--metadata]", "Manage project/workspace metadata."
45
59
  map %w[-m --metadata] => :metadata
46
60
  method_option :create, aliases: "-c", desc: "Create metadata.", type: :boolean, default: false
@@ -94,6 +108,8 @@ module SublimeTextKit
94
108
 
95
109
  private
96
110
 
111
+ attr_reader :markdown_printer
112
+
97
113
  def project_roots
98
114
  @project_roots ||= self.class.configuration.to_h.fetch :project_roots, []
99
115
  end
@@ -12,7 +12,7 @@ module SublimeTextKit
12
12
  end
13
13
 
14
14
  def self.version
15
- "8.4.0"
15
+ "8.5.0"
16
16
  end
17
17
 
18
18
  def self.version_label
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "open3"
4
+
5
+ module SublimeTextKit
6
+ module Snippets
7
+ module Printers
8
+ class Markdown
9
+ DEFAULT_USER_PATH = "Library/Application Support/Sublime Text 3/Packages/User"
10
+
11
+ def initialize user_path = DEFAULT_USER_PATH, environment: ENV
12
+ @user_path = user_path
13
+ @environment = environment
14
+ end
15
+
16
+ def home_path
17
+ Pathname environment.fetch("HOME")
18
+ end
19
+
20
+ def root_path
21
+ home_path.join user_path
22
+ end
23
+
24
+ def call
25
+ snippets.sort_by(&:description).each do |snippet|
26
+ puts "- #{snippet.description} - `#{snippet.trigger}`\n"
27
+ end
28
+ end
29
+
30
+ private
31
+
32
+ attr_reader :user_path, :environment
33
+
34
+ def snippets
35
+ root_path.glob("*.sublime-snippet").map do |path|
36
+ Snippet.new REXML::Document.new(File.open(path))
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,56 @@
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
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: 8.4.0
4
+ version: 8.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -28,7 +28,7 @@ cert_chain:
28
28
  dKvURM+1PwDCzC5tvRwjhUJIizau6+MtkFCvJHmaAj1aZL3odcPejHj5Hxt/0CUW
29
29
  y84=
30
30
  -----END CERTIFICATE-----
31
- date: 2019-06-01 00:00:00.000000000 Z
31
+ date: 2019-06-09 00:00:00.000000000 Z
32
32
  dependencies:
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: runcom
@@ -100,6 +100,34 @@ dependencies:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0.6'
103
+ - !ruby/object:Gem::Dependency
104
+ name: gemsmith
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '13.5'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '13.5'
117
+ - !ruby/object:Gem::Dependency
118
+ name: git-cop
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: '3.5'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: '3.5'
103
131
  - !ruby/object:Gem::Dependency
104
132
  name: guard-rspec
105
133
  requirement: !ruby/object:Gem::Requirement
@@ -288,6 +316,8 @@ files:
288
316
  - lib/sublime_text_kit/metadata/project_metadata.rb
289
317
  - lib/sublime_text_kit/metadata/workspace_metadata.rb
290
318
  - lib/sublime_text_kit/session.rb
319
+ - lib/sublime_text_kit/snippets/printers/markdown.rb
320
+ - lib/sublime_text_kit/snippets/snippet.rb
291
321
  homepage: https://github.com/bkuhlmann/sublime_text_kit
292
322
  licenses:
293
323
  - Apache-2.0
metadata.gz.sig CHANGED
Binary file