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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/README.adoc +18 -48
- data/bin/sublime_text_kit +1 -3
- data/lib/sublime_text_kit/cli/actions/config.rb +35 -0
- data/lib/sublime_text_kit/cli/actions/metadata.rb +63 -0
- data/lib/sublime_text_kit/cli/actions/session.rb +26 -0
- data/lib/sublime_text_kit/cli/actions/snippets.rb +35 -0
- data/lib/sublime_text_kit/cli/actions/update.rb +42 -0
- data/lib/sublime_text_kit/cli/configuration/content.rb +45 -0
- data/lib/sublime_text_kit/cli/configuration/defaults.yml +3 -0
- data/lib/sublime_text_kit/cli/configuration/loader.rb +37 -0
- data/lib/sublime_text_kit/cli/parsers/assembler.rb +32 -0
- data/lib/sublime_text_kit/cli/parsers/core.rb +96 -0
- data/lib/sublime_text_kit/cli/parsers.rb +11 -0
- data/lib/sublime_text_kit/cli/shell.rb +58 -0
- data/lib/sublime_text_kit/container.rb +37 -0
- data/lib/sublime_text_kit/identity.rb +3 -2
- data/lib/sublime_text_kit/metadata/handler.rb +43 -0
- data/lib/sublime_text_kit/metadata/pathway.rb +19 -0
- data/lib/sublime_text_kit/metadata/serializers/project.rb +24 -0
- data/lib/sublime_text_kit/metadata/serializers/workspace.rb +27 -0
- data/lib/sublime_text_kit/sessions/rebuilder.rb +44 -0
- data/lib/sublime_text_kit/snippets/collector.rb +13 -19
- data/lib/sublime_text_kit/snippets/model.rb +31 -0
- data/lib/sublime_text_kit/snippets/printers/ascii_doc.rb +7 -5
- data/lib/sublime_text_kit/snippets/printers/markdown.rb +7 -3
- data/lib/sublime_text_kit/snippets/reader.rb +21 -0
- data/lib/sublime_text_kit.rb +11 -10
- data.tar.gz.sig +0 -0
- metadata +56 -14
- metadata.gz.sig +0 -0
- data/lib/sublime_text_kit/cli.rb +0 -182
- data/lib/sublime_text_kit/metadata/base.rb +0 -60
- data/lib/sublime_text_kit/metadata/project_metadata.rb +0 -20
- data/lib/sublime_text_kit/metadata/workspace_metadata.rb +0 -23
- data/lib/sublime_text_kit/session.rb +0 -44
- data/lib/sublime_text_kit/snippets/snippet.rb +0 -56
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "refinements/pathnames"
|
4
|
+
|
5
|
+
module SublimeTextKit
|
6
|
+
module Metadata
|
7
|
+
# Handles the creation, deletion, and recreation of metadata.
|
8
|
+
class Handler
|
9
|
+
using Refinements::Pathnames
|
10
|
+
|
11
|
+
def self.with_project project_dir, metadata_dir
|
12
|
+
new "sublime-project",
|
13
|
+
serializer: Serializers::Project.new(
|
14
|
+
Pathway[project_dir: project_dir, metadata_dir: metadata_dir]
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.with_workspace project_dir, metadata_dir
|
19
|
+
new "sublime-workspace",
|
20
|
+
serializer: Serializers::Workspace.new(
|
21
|
+
Pathway[project_dir: project_dir, metadata_dir: metadata_dir]
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
def initialize extension, serializer:
|
26
|
+
@extension = extension
|
27
|
+
@serializer = serializer
|
28
|
+
end
|
29
|
+
|
30
|
+
def create = path.exist? ? path : path.write(JSON.dump(serializer.to_h))
|
31
|
+
|
32
|
+
def delete = path.exist? ? path.delete : path
|
33
|
+
|
34
|
+
def recreate = delete && create
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
attr_reader :extension, :serializer
|
39
|
+
|
40
|
+
def path = serializer.pathway.metadata_file(extension)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SublimeTextKit
|
4
|
+
module Metadata
|
5
|
+
# Defines metadata pathways.
|
6
|
+
Pathway = Struct.new :project_dir, :metadata_dir, keyword_init: true do
|
7
|
+
using Refinements::Pathnames
|
8
|
+
|
9
|
+
def initialize *arguments
|
10
|
+
super
|
11
|
+
each_pair { |key, value| self[key] = Pathname(value).expand_path }
|
12
|
+
end
|
13
|
+
|
14
|
+
def project_name = project_dir.basename
|
15
|
+
|
16
|
+
def metadata_file(extension) = metadata_dir.join("#{project_name}.#{extension}")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SublimeTextKit
|
4
|
+
module Metadata
|
5
|
+
module Serializers
|
6
|
+
# Serializes project metadata.
|
7
|
+
class Project
|
8
|
+
attr_reader :pathway
|
9
|
+
|
10
|
+
def initialize pathway
|
11
|
+
@pathway = pathway
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_h
|
15
|
+
{
|
16
|
+
folders: [
|
17
|
+
{path: pathway.project_dir.to_s}
|
18
|
+
]
|
19
|
+
}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SublimeTextKit
|
4
|
+
module Metadata
|
5
|
+
module Serializers
|
6
|
+
# Serializes workspace metadata.
|
7
|
+
class Workspace
|
8
|
+
attr_reader :pathway
|
9
|
+
|
10
|
+
def initialize pathway
|
11
|
+
@pathway = pathway
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_h
|
15
|
+
{
|
16
|
+
expanded_folders: [pathway.project_dir.to_s],
|
17
|
+
select_project: {
|
18
|
+
selected_items: [
|
19
|
+
[pathway.project_name.to_s, pathway.metadata_file("sublime-project").to_s]
|
20
|
+
]
|
21
|
+
}
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
require "refinements/pathnames"
|
5
|
+
|
6
|
+
module SublimeTextKit
|
7
|
+
module Sessions
|
8
|
+
# Manages the rebuilding of session information.
|
9
|
+
class Rebuilder
|
10
|
+
using Refinements::Pathnames
|
11
|
+
|
12
|
+
def initialize container: Container
|
13
|
+
@container = container
|
14
|
+
end
|
15
|
+
|
16
|
+
def call
|
17
|
+
session = read
|
18
|
+
|
19
|
+
return unless session.dig "workspaces", "recent_workspaces"
|
20
|
+
|
21
|
+
Pathname(metadata_dir).expand_path
|
22
|
+
.files("*.sublime-workspace")
|
23
|
+
.then do |workspaces|
|
24
|
+
session["workspaces"]["recent_workspaces"] = workspaces
|
25
|
+
write session
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
attr_reader :container
|
32
|
+
|
33
|
+
def read = source_path.exist? ? JSON(source_path.read) : {}
|
34
|
+
|
35
|
+
def write(json) = JSON.dump(json).then { |content| source_path.write content }
|
36
|
+
|
37
|
+
def metadata_dir = configuration.metadata_dir
|
38
|
+
|
39
|
+
def source_path = configuration.session_path
|
40
|
+
|
41
|
+
def configuration = container[__method__]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -1,36 +1,30 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
4
|
-
require "rexml/document"
|
3
|
+
require "refinements/pathnames"
|
5
4
|
|
6
5
|
module SublimeTextKit
|
7
6
|
module Snippets
|
7
|
+
# Collects and loads all snippets into memory for further processing.
|
8
8
|
class Collector
|
9
|
-
|
9
|
+
using Refinements::Pathnames
|
10
10
|
|
11
|
-
def initialize
|
12
|
-
@
|
13
|
-
@
|
14
|
-
@environment = environment
|
15
|
-
end
|
16
|
-
|
17
|
-
def home_path
|
18
|
-
Pathname environment.fetch("HOME")
|
19
|
-
end
|
20
|
-
|
21
|
-
def root_path
|
22
|
-
home_path.join user_path
|
11
|
+
def initialize reader: Reader.new, container: Container
|
12
|
+
@reader = reader
|
13
|
+
@container = container
|
23
14
|
end
|
24
15
|
|
25
16
|
def call
|
26
|
-
|
27
|
-
|
28
|
-
|
17
|
+
configuration.user_dir
|
18
|
+
.files("*.sublime-snippet")
|
19
|
+
.map { |path| reader.call path }
|
20
|
+
.sort_by(&:description)
|
29
21
|
end
|
30
22
|
|
31
23
|
private
|
32
24
|
|
33
|
-
|
25
|
+
def configuration = container[__method__]
|
26
|
+
|
27
|
+
attr_reader :reader, :container
|
34
28
|
end
|
35
29
|
end
|
36
30
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SublimeTextKit
|
4
|
+
module Snippets
|
5
|
+
KEY_MAP = {
|
6
|
+
"content" => :content,
|
7
|
+
"tabTrigger" => :trigger,
|
8
|
+
"description" => :description,
|
9
|
+
"scope" => :scope
|
10
|
+
}.freeze
|
11
|
+
|
12
|
+
# Defines a snippet record.
|
13
|
+
Model = Struct.new(*KEY_MAP.values, keyword_init: true) do
|
14
|
+
def self.for document, key_map: KEY_MAP
|
15
|
+
root = document.root
|
16
|
+
|
17
|
+
return new unless root
|
18
|
+
|
19
|
+
root.elements
|
20
|
+
.reduce({}) { |attributes, element| attributes.merge element.name => element.text }
|
21
|
+
.transform_keys(key_map)
|
22
|
+
.then { |attributes| new(**attributes) }
|
23
|
+
end
|
24
|
+
|
25
|
+
def initialize *arguments
|
26
|
+
super
|
27
|
+
freeze
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,24 +1,26 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "rexml/document"
|
4
|
-
|
5
3
|
module SublimeTextKit
|
6
4
|
module Snippets
|
7
5
|
module Printers
|
6
|
+
# Prints snippets in ASCII Doc format.
|
8
7
|
class ASCIIDoc
|
9
|
-
def initialize collector: Collector.new
|
8
|
+
def initialize collector: Collector.new, container: Container
|
10
9
|
@collector = collector
|
10
|
+
@container = container
|
11
11
|
end
|
12
12
|
|
13
13
|
def call
|
14
14
|
collector.call.each do |snippet|
|
15
|
-
|
15
|
+
logger.info "* #{snippet.description} - `#{snippet.trigger}`"
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
private
|
20
20
|
|
21
|
-
attr_reader :collector
|
21
|
+
attr_reader :collector, :container
|
22
|
+
|
23
|
+
def logger = container[__method__]
|
22
24
|
end
|
23
25
|
end
|
24
26
|
end
|
@@ -3,20 +3,24 @@
|
|
3
3
|
module SublimeTextKit
|
4
4
|
module Snippets
|
5
5
|
module Printers
|
6
|
+
# Prints snippets in Markdown format.
|
6
7
|
class Markdown
|
7
|
-
def initialize collector: Collector.new
|
8
|
+
def initialize collector: Collector.new, container: Container
|
8
9
|
@collector = collector
|
10
|
+
@container = container
|
9
11
|
end
|
10
12
|
|
11
13
|
def call
|
12
14
|
collector.call.each do |snippet|
|
13
|
-
|
15
|
+
logger.info "- #{snippet.description} - `#{snippet.trigger}`"
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
17
19
|
private
|
18
20
|
|
19
|
-
attr_reader :collector
|
21
|
+
attr_reader :collector, :container
|
22
|
+
|
23
|
+
def logger = container[__method__]
|
20
24
|
end
|
21
25
|
end
|
22
26
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rexml/document"
|
4
|
+
|
5
|
+
module SublimeTextKit
|
6
|
+
module Snippets
|
7
|
+
# Reads snippet and loads record into memory.
|
8
|
+
class Reader
|
9
|
+
def initialize model: Model, document: REXML::Document
|
10
|
+
@model = model
|
11
|
+
@document = document
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(path) = path.exist? ? model.for(document.new(path.read)) : model.new
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
attr_reader :model, :document
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/sublime_text_kit.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
3
|
+
require "zeitwerk"
|
4
|
+
|
5
|
+
Zeitwerk::Loader.for_gem
|
6
|
+
.then do |loader|
|
7
|
+
loader.inflector.inflect "ascii_doc" => "ASCIIDoc", "cli" => "CLI"
|
8
|
+
loader.setup
|
9
|
+
end
|
10
|
+
|
11
|
+
# Main namespace.
|
12
|
+
module SublimeTextKit
|
13
|
+
end
|
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:
|
4
|
+
version: 11.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
@@ -28,22 +28,50 @@ cert_chain:
|
|
28
28
|
lkHilIrX69jq8wMPpBhlaw2mRmeSL50Wv5u6xVBvOHhXFSP1crXM95vfLhLyRYod
|
29
29
|
W2A=
|
30
30
|
-----END CERTIFICATE-----
|
31
|
-
date: 2021-
|
31
|
+
date: 2021-10-06 00:00:00.000000000 Z
|
32
32
|
dependencies:
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: dry-container
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0.8'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0.8'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: pastel
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0.8'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0.8'
|
33
61
|
- !ruby/object:Gem::Dependency
|
34
62
|
name: refinements
|
35
63
|
requirement: !ruby/object:Gem::Requirement
|
36
64
|
requirements:
|
37
65
|
- - "~>"
|
38
66
|
- !ruby/object:Gem::Version
|
39
|
-
version: '8.
|
67
|
+
version: '8.4'
|
40
68
|
type: :runtime
|
41
69
|
prerelease: false
|
42
70
|
version_requirements: !ruby/object:Gem::Requirement
|
43
71
|
requirements:
|
44
72
|
- - "~>"
|
45
73
|
- !ruby/object:Gem::Version
|
46
|
-
version: '8.
|
74
|
+
version: '8.4'
|
47
75
|
- !ruby/object:Gem::Dependency
|
48
76
|
name: runcom
|
49
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,19 +87,19 @@ dependencies:
|
|
59
87
|
- !ruby/object:Gem::Version
|
60
88
|
version: '7.0'
|
61
89
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
90
|
+
name: zeitwerk
|
63
91
|
requirement: !ruby/object:Gem::Requirement
|
64
92
|
requirements:
|
65
93
|
- - "~>"
|
66
94
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
95
|
+
version: '2.4'
|
68
96
|
type: :runtime
|
69
97
|
prerelease: false
|
70
98
|
version_requirements: !ruby/object:Gem::Requirement
|
71
99
|
requirements:
|
72
100
|
- - "~>"
|
73
101
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
102
|
+
version: '2.4'
|
75
103
|
description:
|
76
104
|
email:
|
77
105
|
- brooke@alchemists.io
|
@@ -86,16 +114,30 @@ files:
|
|
86
114
|
- README.adoc
|
87
115
|
- bin/sublime_text_kit
|
88
116
|
- lib/sublime_text_kit.rb
|
89
|
-
- lib/sublime_text_kit/cli.rb
|
117
|
+
- lib/sublime_text_kit/cli/actions/config.rb
|
118
|
+
- lib/sublime_text_kit/cli/actions/metadata.rb
|
119
|
+
- lib/sublime_text_kit/cli/actions/session.rb
|
120
|
+
- lib/sublime_text_kit/cli/actions/snippets.rb
|
121
|
+
- lib/sublime_text_kit/cli/actions/update.rb
|
122
|
+
- lib/sublime_text_kit/cli/configuration/content.rb
|
123
|
+
- lib/sublime_text_kit/cli/configuration/defaults.yml
|
124
|
+
- lib/sublime_text_kit/cli/configuration/loader.rb
|
125
|
+
- lib/sublime_text_kit/cli/parsers.rb
|
126
|
+
- lib/sublime_text_kit/cli/parsers/assembler.rb
|
127
|
+
- lib/sublime_text_kit/cli/parsers/core.rb
|
128
|
+
- lib/sublime_text_kit/cli/shell.rb
|
129
|
+
- lib/sublime_text_kit/container.rb
|
90
130
|
- lib/sublime_text_kit/identity.rb
|
91
|
-
- lib/sublime_text_kit/metadata/
|
92
|
-
- lib/sublime_text_kit/metadata/
|
93
|
-
- lib/sublime_text_kit/metadata/
|
94
|
-
- lib/sublime_text_kit/
|
131
|
+
- lib/sublime_text_kit/metadata/handler.rb
|
132
|
+
- lib/sublime_text_kit/metadata/pathway.rb
|
133
|
+
- lib/sublime_text_kit/metadata/serializers/project.rb
|
134
|
+
- lib/sublime_text_kit/metadata/serializers/workspace.rb
|
135
|
+
- lib/sublime_text_kit/sessions/rebuilder.rb
|
95
136
|
- lib/sublime_text_kit/snippets/collector.rb
|
137
|
+
- lib/sublime_text_kit/snippets/model.rb
|
96
138
|
- lib/sublime_text_kit/snippets/printers/ascii_doc.rb
|
97
139
|
- lib/sublime_text_kit/snippets/printers/markdown.rb
|
98
|
-
- lib/sublime_text_kit/snippets/
|
140
|
+
- lib/sublime_text_kit/snippets/reader.rb
|
99
141
|
homepage: https://www.alchemists.io/projects/sublime_text_kit
|
100
142
|
licenses:
|
101
143
|
- Apache-2.0
|
@@ -119,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
161
|
- !ruby/object:Gem::Version
|
120
162
|
version: '0'
|
121
163
|
requirements: []
|
122
|
-
rubygems_version: 3.2.
|
164
|
+
rubygems_version: 3.2.28
|
123
165
|
signing_key:
|
124
166
|
specification_version: 4
|
125
167
|
summary: A command line interface for managing Sublime Text metadata.
|
metadata.gz.sig
CHANGED
Binary file
|
data/lib/sublime_text_kit/cli.rb
DELETED
@@ -1,182 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "thor"
|
4
|
-
require "thor/actions"
|
5
|
-
require "runcom"
|
6
|
-
|
7
|
-
module SublimeTextKit
|
8
|
-
# The Command Line Interface (CLI) for the gem.
|
9
|
-
class CLI < Thor
|
10
|
-
include Thor::Actions
|
11
|
-
|
12
|
-
package_name Identity::VERSION_LABEL
|
13
|
-
|
14
|
-
def self.configuration
|
15
|
-
Runcom::Config.new "#{Identity::NAME}/configuration.yml"
|
16
|
-
end
|
17
|
-
|
18
|
-
# Initialize.
|
19
|
-
def initialize args = [], options = {}, config = {}
|
20
|
-
super args, options, config
|
21
|
-
@markdown_printer = Snippets::Printers::Markdown.new
|
22
|
-
@ascii_doc_printer = Snippets::Printers::ASCIIDoc.new
|
23
|
-
end
|
24
|
-
|
25
|
-
desc "-u, [--update]", "Update Sublime Text with current settings."
|
26
|
-
map %w[-u --update] => :update
|
27
|
-
def update
|
28
|
-
create_metadata
|
29
|
-
say
|
30
|
-
rebuild_session
|
31
|
-
end
|
32
|
-
|
33
|
-
desc "-s, [--session]", "Manage session metadata."
|
34
|
-
map %w[-s --session] => :session
|
35
|
-
method_option :rebuild,
|
36
|
-
aliases: "-R",
|
37
|
-
desc: "Rebuild session metadata.",
|
38
|
-
type: :boolean,
|
39
|
-
default: false
|
40
|
-
def session
|
41
|
-
say
|
42
|
-
options.rebuild? ? rebuild_session : help("--session")
|
43
|
-
say
|
44
|
-
end
|
45
|
-
|
46
|
-
desc "-p, [--snippets]", "Print user defined snippets."
|
47
|
-
map %w[-p --snippets] => :snippets
|
48
|
-
method_option :ascii_doc,
|
49
|
-
aliases: "-a",
|
50
|
-
desc: "Print snippets in ASCII Doc format.",
|
51
|
-
type: :boolean,
|
52
|
-
default: false
|
53
|
-
method_option :markdown,
|
54
|
-
aliases: "-m",
|
55
|
-
desc: "Print snippets in Markdown format.",
|
56
|
-
type: :boolean,
|
57
|
-
default: false
|
58
|
-
def snippets
|
59
|
-
say
|
60
|
-
|
61
|
-
if options.ascii_doc? then ascii_doc_printer.call
|
62
|
-
elsif options.markdown? then markdown_printer.call
|
63
|
-
else help "--snippets"
|
64
|
-
end
|
65
|
-
|
66
|
-
say
|
67
|
-
end
|
68
|
-
|
69
|
-
desc "-m, [--metadata]", "Manage project/workspace metadata."
|
70
|
-
map %w[-m --metadata] => :metadata
|
71
|
-
method_option :create, aliases: "-c", desc: "Create metadata.", type: :boolean, default: false
|
72
|
-
method_option :destroy, aliases: "-D", desc: "Destroy metadata.", type: :boolean, default: false
|
73
|
-
method_option :rebuild, aliases: "-R", desc: "Rebuild metadata.", type: :boolean, default: false
|
74
|
-
def metadata
|
75
|
-
say
|
76
|
-
|
77
|
-
if options.create? then create_metadata
|
78
|
-
elsif options.destroy? then destroy_metadata
|
79
|
-
elsif options.rebuild? then rebuild_metadata
|
80
|
-
else help "--metadata"
|
81
|
-
end
|
82
|
-
|
83
|
-
say
|
84
|
-
end
|
85
|
-
|
86
|
-
desc "-c, [--config]", "Manage gem configuration."
|
87
|
-
map %w[-c --config] => :config
|
88
|
-
method_option :edit,
|
89
|
-
aliases: "-e",
|
90
|
-
desc: "Edit gem configuration.",
|
91
|
-
type: :boolean,
|
92
|
-
default: false
|
93
|
-
method_option :info,
|
94
|
-
aliases: "-i",
|
95
|
-
desc: "Print gem configuration.",
|
96
|
-
type: :boolean,
|
97
|
-
default: false
|
98
|
-
def config
|
99
|
-
path = self.class.configuration.current
|
100
|
-
|
101
|
-
if options.edit? then `#{ENV["EDITOR"]} #{path}`
|
102
|
-
elsif options.info?
|
103
|
-
path ? say(path) : say("Configuration doesn't exist.")
|
104
|
-
else help :config
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
desc "-v, [--version]", "Show gem version."
|
109
|
-
map %w[-v --version] => :version
|
110
|
-
def version
|
111
|
-
say Identity::VERSION_LABEL
|
112
|
-
end
|
113
|
-
|
114
|
-
desc "-h, [--help=COMMAND]", "Show this message or get help for a command."
|
115
|
-
map %w[-h --help] => :help
|
116
|
-
def help task = nil
|
117
|
-
say and super
|
118
|
-
end
|
119
|
-
|
120
|
-
private
|
121
|
-
|
122
|
-
attr_reader :ascii_doc_printer, :markdown_printer
|
123
|
-
|
124
|
-
def project_roots
|
125
|
-
@project_roots ||= self.class.configuration.to_h.fetch :project_roots, []
|
126
|
-
end
|
127
|
-
|
128
|
-
def metadata_dir
|
129
|
-
@metadata_dir ||= File.expand_path self.class.configuration.to_h.fetch(:metadata_dir)
|
130
|
-
end
|
131
|
-
|
132
|
-
def create_metadata
|
133
|
-
say_status :info, "Creating metadata...", :green
|
134
|
-
say_status :info, "Metadata Path: #{metadata_dir}", :green
|
135
|
-
project_roots.each do |project_root|
|
136
|
-
say_status :info, "Processing project root: #{File.expand_path project_root}...", :green
|
137
|
-
Metadata::Project.create project_root, metadata_dir
|
138
|
-
Metadata::Workspace.create project_root, metadata_dir
|
139
|
-
end
|
140
|
-
say_status :info, "Metadata created.", :green
|
141
|
-
end
|
142
|
-
|
143
|
-
def destroy_metadata
|
144
|
-
if yes? "Delete metadata in #{metadata_dir}?"
|
145
|
-
say_status :info, "Deleting metadata...", :green
|
146
|
-
Metadata::Project.delete metadata_dir
|
147
|
-
Metadata::Workspace.delete metadata_dir
|
148
|
-
say_status :info, "Metadata deleted.", :green
|
149
|
-
else
|
150
|
-
say_status :info, "Metadata deletion aborted.", :green
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
def rebuild_metadata
|
155
|
-
if yes? "Rebuild metadata in #{metadata_dir}?"
|
156
|
-
say_status :info, "Deleting metadata...", :green
|
157
|
-
Metadata::Project.delete metadata_dir
|
158
|
-
Metadata::Workspace.delete metadata_dir
|
159
|
-
|
160
|
-
say_status :info, "Creating metadata...", :green
|
161
|
-
project_roots.each do |project_root|
|
162
|
-
say_status :info, "Processing project root: #{File.expand_path project_root}...", :green
|
163
|
-
Metadata::Project.create project_root, metadata_dir
|
164
|
-
Metadata::Workspace.create project_root, metadata_dir
|
165
|
-
end
|
166
|
-
|
167
|
-
say_status :info, "Metadata rebuilt.", :green
|
168
|
-
else
|
169
|
-
say_status :info, "Metadata rebuild aborted.", :green
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
def rebuild_session
|
174
|
-
say_status :info, "Rebuilding session metadata...", :green
|
175
|
-
say_status :info, "Metadata (project/workspace) Path: #{metadata_dir}", :green
|
176
|
-
say_status :info, "Session Path: #{Session.session_path}", :green
|
177
|
-
session = Session.new metadata_dir
|
178
|
-
session.rebuild_recent_workspaces
|
179
|
-
say_status :info, "Session metadata rebuilt.", :green
|
180
|
-
end
|
181
|
-
end
|
182
|
-
end
|