sublime_text_kit 2.0.0 → 3.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.tar.gz.sig +2 -3
- data/README.md +53 -33
- data/lib/sublime_text_kit.rb +3 -1
- data/lib/sublime_text_kit/cli.rb +76 -31
- data/lib/sublime_text_kit/metadata/base.rb +58 -0
- data/lib/sublime_text_kit/metadata/project_metadata.rb +21 -0
- data/lib/sublime_text_kit/metadata/workspace_metadata.rb +24 -0
- data/lib/sublime_text_kit/session.rb +5 -5
- data/lib/sublime_text_kit/version.rb +1 -1
- metadata +6 -4
- metadata.gz.sig +0 -0
- data/lib/sublime_text_kit/project_metadata.rb +0 -59
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a314305161fb7d4e24fa3d19a53838ce27f1708
|
4
|
+
data.tar.gz: fe173ec68939df2d472460f9350eab1caaaf620d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e38ddf46046f2dba762e4dbbf15e29e6c62465a135973c0d2db60c72e31f92903014939d77c8624f1359089d67f566e07a2d9e9489e019ad56734636dc29da9
|
7
|
+
data.tar.gz: 789a7ff63ca6eb6a2ba5d9383e70de11432de3c6a685da1ffc97aeda9d42f168d23f101e00c05e6c4be832d6326728fb622d450504ddc9176feff50024986ec6
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1,3 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
��6�bl_QՁ��C#�$��f`
|
1
|
+
J+��+?ƌ�gr��Q�ϵ�Tv�סڗ0�u��(B��u��'���������z�t�#�*��Gʈ������}Wߨѹ� V�w,~
|
2
|
+
죕���>�����f�O�d�F�
|
data/README.md
CHANGED
@@ -11,12 +11,13 @@ Provides a collection of utilities that aid in Sublime Text management.
|
|
11
11
|
|
12
12
|
# Features
|
13
13
|
|
14
|
-
-
|
15
|
-
shortcut.
|
16
|
-
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
- Provides project metadata (i.e. *.sublime-project and *.sublime-workspace files) management for project
|
15
|
+
switching via the `CONTROL+COMMAND+P` shortcut.
|
16
|
+
- Rebuilds project history (Project -> Recent Projects) from existing project files (assumes project
|
17
|
+
metadata is in a directory) so one can easily toggle between up-to-date project information via the
|
18
|
+
`CONTROL+COMMAND+P` shortcut.
|
19
|
+
|
20
|
+
[![asciicast](https://asciinema.org/a/19858.png)](https://asciinema.org/a/19858)
|
20
21
|
|
21
22
|
# Requirements
|
22
23
|
|
@@ -50,12 +51,12 @@ Example:
|
|
50
51
|
- "~/Dropbox/Development/Misc"
|
51
52
|
- "~/Dropbox/Development/OSS"
|
52
53
|
- "~/Dropbox/Development/Work"
|
53
|
-
:
|
54
|
+
:metadata_dir: "~/Dropbox/Cache/Sublime"
|
54
55
|
|
55
|
-
The project roots
|
56
|
-
*.sublime-project) is generated, the name of the metadata file will be the same name as that
|
57
|
-
project metadata, regardless of root location, is written to the same
|
58
|
-
shown above and assuming the following directory structure exists...
|
56
|
+
The project roots define the root level directories where project folders are located. When project metadata (i.e.
|
57
|
+
*.sublime-project, *.sublime-workspace) is generated, the name of the metadata file will be the same name as that
|
58
|
+
of the project folder. All project metadata, regardless of root location, is written to the same metadata directory.
|
59
|
+
If using the example settings shown above and assuming the following directory structure exists...
|
59
60
|
|
60
61
|
~/Dropbox/Development/Misc/example
|
61
62
|
~/Dropbox/Development/OSS/sublime_text_kit
|
@@ -63,26 +64,30 @@ shown above and assuming the following directory structure exists...
|
|
63
64
|
...the project metadata will be created in the workspace directory as follows:
|
64
65
|
|
65
66
|
~/Dropbox/Cache/Sublime/example.sublime-project
|
67
|
+
~/Dropbox/Cache/Sublime/example.sublime-workspace
|
66
68
|
~/Dropbox/Cache/Sublime/sublime_text_kit.sublime-project
|
69
|
+
~/Dropbox/Cache/Sublime/sublime_text_kit.sublime-workspace
|
67
70
|
|
68
71
|
# Usage
|
69
72
|
|
70
|
-
From the command line, type: stk
|
73
|
+
From the command line, type: `stk`
|
71
74
|
|
75
|
+
stk -c, [--configure] # Configure Sublime Text with current settings.
|
72
76
|
stk -e, [--edit] # Edit settings in default editor (assumes $EDITOR environment variable).
|
73
77
|
stk -h, [--help=HELP] # Show this message or get help for a command.
|
74
|
-
stk -
|
75
|
-
stk -s, [--session] # Manage session
|
78
|
+
stk -m, [--metadata] # Manage project/workspace metadata.
|
79
|
+
stk -s, [--session] # Manage session metadata.
|
76
80
|
stk -v, [--version] # Show version.
|
77
81
|
|
78
|
-
For
|
82
|
+
For metadata options, type: `stk --metadata`
|
79
83
|
|
80
|
-
-c, [--create], [--no-create] # Create
|
81
|
-
-D, [--destroy], [--no-destroy] # Destroy
|
84
|
+
-c, [--create], [--no-create] # Create metadata.
|
85
|
+
-D, [--destroy], [--no-destroy] # Destroy metadata.
|
86
|
+
-R, [--rebuild], [--no-rebuild] # Rebuild metadata.
|
82
87
|
|
83
|
-
For session options, type: stk --session
|
88
|
+
For session options, type: `stk --session`
|
84
89
|
|
85
|
-
-r, [--rebuild-
|
90
|
+
-r, [--rebuild-session], [--no-rebuild-session] # Rebuild session metadata.
|
86
91
|
|
87
92
|
# Tests
|
88
93
|
|
@@ -90,26 +95,35 @@ To test, run:
|
|
90
95
|
|
91
96
|
bundle exec rspec spec
|
92
97
|
|
98
|
+
# Upgrading
|
99
|
+
|
100
|
+
For those upgrading from Sublime Text Kit v2.0.0 or earlier, be mindful of the following changes:
|
101
|
+
|
102
|
+
0. Ensure you are using Sublime Text 3 (it is currently in Beta but your v2.0.0 license will work).
|
103
|
+
0. Update the `~/.sublime/settings.yml` file to switch from a `workspace_dir` to a `metadata_dir` instead.
|
104
|
+
0. Run the following commands to rebuild your project/workspace and session metadata:
|
105
|
+
|
106
|
+
stk -m -R # Destroys and rebuilds your existing project/workspace metadata to Sublime Text 3 format.
|
107
|
+
skt -s -r # Rebuilds your session history with project metadata as generated above.
|
108
|
+
|
93
109
|
# Workflow
|
94
110
|
|
95
|
-
The following demonstrates a
|
111
|
+
The following demonstrates a default Sublime Text setup:
|
96
112
|
|
97
|
-
0. Run: `stk -e` (define Sublime Text Kit settings for project roots and
|
113
|
+
0. Run: `stk -e` (define Sublime Text Kit settings for project roots and metadata directory).
|
98
114
|
0. Shutdown Sublime Text (i.e. `CONTROL+Q`).
|
99
|
-
0. Run: `stk -
|
100
|
-
|
101
|
-
|
102
|
-
0.
|
103
|
-
|
104
|
-
0. Type: `COMMAND+CONTROL+P` to toggle between projects. Notice that you can easily (fuzzy type) project names to jump
|
105
|
-
between them.
|
115
|
+
0. Run: `stk -c` (creates project metadata and rebuilds the session metadata so Sublime Text has a complete project
|
116
|
+
history from which to jump through via the `CONTROL+COMMMAND+P` shortcut).
|
117
|
+
).
|
118
|
+
0. Launch Sublime Text and use the `CONTROL+COMMAND+P` keyboard shortcut to toggle between projects. Notice that
|
119
|
+
you can (fuzzy type) project names to jump between them.
|
106
120
|
0. Breeze through your project workload with ease. :)
|
107
121
|
|
108
122
|
# Troubleshooting
|
109
123
|
|
110
124
|
- When rebuilding workspaces, ensure Sublime Text is shutdown or changes won't be applied.
|
111
125
|
- When rebuilding workspaces, ensure workspace_dir (as defined via settings.yml) points to a directory containing
|
112
|
-
*.sublime-project files.
|
126
|
+
*.sublime-project and *.sublime-workspace files.
|
113
127
|
|
114
128
|
# Versioning
|
115
129
|
|
@@ -119,13 +133,14 @@ Read [Semantic Versioning](http://semver.org) for details. Briefly, it means:
|
|
119
133
|
- Minor (x.Y.z) - Incremented for new, backwards compatible public API enhancements and/or bug fixes.
|
120
134
|
- Major (X.y.z) - Incremented for any backwards incompatible public API changes.
|
121
135
|
|
122
|
-
#
|
136
|
+
# Code of Conduct
|
123
137
|
|
124
|
-
|
138
|
+
Please note that this project is released with a [CODE OF CONDUCT](CODE_OF_CONDUCT.md). By participating in this project
|
139
|
+
you agree to abide by its terms.
|
125
140
|
|
126
|
-
#
|
141
|
+
# Contributions
|
127
142
|
|
128
|
-
|
143
|
+
Read [CONTRIBUTING](CONTRIBUTING.md) for details.
|
129
144
|
|
130
145
|
# License
|
131
146
|
|
@@ -136,3 +151,8 @@ Read the [LICENSE](LICENSE.md) for details.
|
|
136
151
|
|
137
152
|
Read the [CHANGELOG](CHANGELOG.md) for details.
|
138
153
|
Built with [Gemsmith](https://github.com/bkuhlmann/gemsmith).
|
154
|
+
|
155
|
+
# Credits
|
156
|
+
|
157
|
+
Developed by [Brooke Kuhlmann](https://www.alchemists.io) at [Alchemists](https://www.alchemists.io).
|
158
|
+
|
data/lib/sublime_text_kit.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
1
|
require "sublime_text_kit/version"
|
2
|
-
require "sublime_text_kit/project_metadata"
|
3
2
|
require "sublime_text_kit/session"
|
3
|
+
require "sublime_text_kit/metadata/base"
|
4
|
+
require "sublime_text_kit/metadata/project_metadata"
|
5
|
+
require "sublime_text_kit/metadata/workspace_metadata"
|
data/lib/sublime_text_kit/cli.rb
CHANGED
@@ -3,7 +3,7 @@ require "thor"
|
|
3
3
|
require "thor/actions"
|
4
4
|
require "thor_plus/actions"
|
5
5
|
|
6
|
-
module SublimeTextKit
|
6
|
+
module SublimeTextKit
|
7
7
|
class CLI < Thor
|
8
8
|
include Thor::Actions
|
9
9
|
include ThorPlus::Actions
|
@@ -15,30 +15,54 @@ module SublimeTextKit
|
|
15
15
|
@settings = load_yaml @settings_file
|
16
16
|
end
|
17
17
|
|
18
|
-
desc "-
|
19
|
-
map %w(-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
desc "-c, [--configure]", "Configure Sublime Text with current settings."
|
19
|
+
map %w(-c --configure) => :configure
|
20
|
+
def configure
|
21
|
+
create_metadata
|
22
|
+
say
|
23
|
+
rebuild_session
|
24
|
+
end
|
25
|
+
|
26
|
+
desc "-s, [--session]", "Manage session metadata."
|
27
|
+
map %w(-s --session) => :session
|
28
|
+
method_option :rebuild_session, aliases: "-r", desc: "Rebuild session metadata.", type: :boolean, default: false
|
29
|
+
def session
|
30
|
+
say
|
31
|
+
|
32
|
+
case
|
33
|
+
when options[:rebuild_session] then rebuild_session
|
34
|
+
else help("--session")
|
35
|
+
end
|
36
|
+
|
37
|
+
say
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "-m, [--metadata]", "Manage project/workspace metadata."
|
41
|
+
map %w(-m --metadata) => :metadata
|
42
|
+
method_option :create, aliases: "-c", desc: "Create metadata.", type: :boolean, default: false
|
43
|
+
method_option :destroy, aliases: "-D", desc: "Destroy metadata.", type: :boolean, default: false
|
44
|
+
method_option :rebuild, aliases: "-R", desc: "Rebuild metadata.", type: :boolean, default: false
|
45
|
+
def metadata
|
23
46
|
say
|
24
47
|
|
25
48
|
case
|
26
|
-
when options[:create] then
|
27
|
-
when options[:destroy] then
|
28
|
-
|
49
|
+
when options[:create] then create_metadata
|
50
|
+
when options[:destroy] then destroy_metadata
|
51
|
+
when options[:rebuild] then rebuild_metadata
|
52
|
+
else help("--metadata")
|
29
53
|
end
|
30
54
|
|
31
55
|
say
|
32
56
|
end
|
33
57
|
|
34
|
-
desc "-s, [--session]", "Manage session
|
58
|
+
desc "-s, [--session]", "Manage session metadata."
|
35
59
|
map %w(-s --session) => :session
|
36
|
-
method_option :
|
60
|
+
method_option :rebuild_session, aliases: "-r", desc: "Rebuild session metadata.", type: :boolean, default: false
|
37
61
|
def session
|
38
62
|
say
|
39
63
|
|
40
64
|
case
|
41
|
-
when options[:
|
65
|
+
when options[:rebuild_session] then rebuild_session
|
42
66
|
else help("--session")
|
43
67
|
end
|
44
68
|
|
@@ -69,37 +93,58 @@ module SublimeTextKit
|
|
69
93
|
@project_roots ||= @settings.fetch :project_roots, []
|
70
94
|
end
|
71
95
|
|
72
|
-
def
|
73
|
-
@
|
96
|
+
def metadata_dir
|
97
|
+
@metadata_dir ||= File.expand_path @settings.fetch(:metadata_dir)
|
74
98
|
end
|
75
99
|
|
76
|
-
def
|
77
|
-
info "Creating
|
78
|
-
info "
|
100
|
+
def create_metadata
|
101
|
+
info "Creating metadata..."
|
102
|
+
info "Metadata Path: #{metadata_dir}"
|
79
103
|
project_roots.each do |project_root|
|
80
104
|
info "Processing project root: #{File.expand_path project_root}..."
|
81
|
-
SublimeTextKit::
|
105
|
+
SublimeTextKit::Metadata::Project.create project_root, metadata_dir
|
106
|
+
SublimeTextKit::Metadata::Workspace.create project_root, metadata_dir
|
107
|
+
end
|
108
|
+
info "Metadata created."
|
109
|
+
end
|
110
|
+
|
111
|
+
def destroy_metadata
|
112
|
+
if yes? "Delete metadata in #{metadata_dir}?"
|
113
|
+
info "Deleting metadata..."
|
114
|
+
SublimeTextKit::Metadata::Project.delete metadata_dir
|
115
|
+
SublimeTextKit::Metadata::Workspace.delete metadata_dir
|
116
|
+
info "Metadata deleted."
|
117
|
+
else
|
118
|
+
info "Metadata deletion aborted."
|
82
119
|
end
|
83
|
-
info "Project metadata created."
|
84
120
|
end
|
85
121
|
|
86
|
-
def
|
87
|
-
if yes? "
|
88
|
-
info "Deleting
|
89
|
-
SublimeTextKit::
|
90
|
-
|
122
|
+
def rebuild_metadata
|
123
|
+
if yes? "Rebuild metadata in #{metadata_dir}?"
|
124
|
+
info "Deleting metadata..."
|
125
|
+
SublimeTextKit::Metadata::Project.delete metadata_dir
|
126
|
+
SublimeTextKit::Metadata::Workspace.delete metadata_dir
|
127
|
+
|
128
|
+
info "Creating metadata..."
|
129
|
+
project_roots.each do |project_root|
|
130
|
+
info "Processing project root: #{File.expand_path project_root}..."
|
131
|
+
SublimeTextKit::Metadata::Project.create project_root, metadata_dir
|
132
|
+
SublimeTextKit::Metadata::Workspace.create project_root, metadata_dir
|
133
|
+
end
|
134
|
+
|
135
|
+
info "Metadata rebuilt."
|
91
136
|
else
|
92
|
-
info "
|
137
|
+
info "Metadata rebuild aborted."
|
93
138
|
end
|
94
139
|
end
|
95
140
|
|
96
|
-
def
|
97
|
-
info "Rebuilding
|
98
|
-
info "
|
99
|
-
info "
|
100
|
-
session = SublimeTextKit::Session.new
|
141
|
+
def rebuild_session
|
142
|
+
info "Rebuilding session metadata..."
|
143
|
+
info "Metadata (project/workspace) Path: #{metadata_dir}"
|
144
|
+
info "Session Path: #{SublimeTextKit::Session.session_path}"
|
145
|
+
session = SublimeTextKit::Session.new metadata_dir
|
101
146
|
session.rebuild_recent_workspaces
|
102
|
-
info "
|
147
|
+
info "Session metadata rebuilt."
|
103
148
|
end
|
104
149
|
end
|
105
150
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require "multi_json"
|
2
|
+
require "pathname"
|
3
|
+
|
4
|
+
module SublimeTextKit
|
5
|
+
module Metadata
|
6
|
+
class Base
|
7
|
+
attr_reader :name, :project_dir, :metadata_dir, :metadata_file
|
8
|
+
|
9
|
+
def self.create projects_dir, metadata_dir
|
10
|
+
instance = new projects_dir, metadata_dir
|
11
|
+
return unless valid_dir?(instance.project_dir, "Projects")
|
12
|
+
return unless valid_dir?(instance.metadata_dir, "Metadata")
|
13
|
+
|
14
|
+
project_paths = ::Pathname.new(instance.project_dir).children.select {|child| child.directory? }
|
15
|
+
project_paths.each { |project_dir| new(project_dir, metadata_dir).save }
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.delete metadata_dir
|
19
|
+
instance = new '', metadata_dir
|
20
|
+
return unless valid_dir?(instance.metadata_dir, "Metadata")
|
21
|
+
|
22
|
+
::Pathname.glob("#{instance.metadata_dir}/*.#{instance.file_extension}").each(&:delete)
|
23
|
+
end
|
24
|
+
|
25
|
+
def initialize project_dir, metadata_dir
|
26
|
+
@name = File.basename project_dir
|
27
|
+
@project_dir = File.expand_path project_dir
|
28
|
+
@metadata_dir = File.expand_path metadata_dir
|
29
|
+
@metadata_file = File.join @metadata_dir, "#{name}.#{file_extension}"
|
30
|
+
end
|
31
|
+
|
32
|
+
def file_extension
|
33
|
+
"sublime-unknown"
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_h
|
37
|
+
{}
|
38
|
+
end
|
39
|
+
|
40
|
+
def save
|
41
|
+
unless File.exist? metadata_file
|
42
|
+
File.open(metadata_file, 'w') { |file| file.write MultiJson.dump(to_h, pretty: true) }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def self.valid_dir? dir, label
|
49
|
+
if File.exist?(dir)
|
50
|
+
true
|
51
|
+
else
|
52
|
+
puts "#{label} directory doesn't exist: #{dir}."
|
53
|
+
false
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module SublimeTextKit
|
2
|
+
module Metadata
|
3
|
+
class Project < Base
|
4
|
+
def initialize project_dir, metadata_dir
|
5
|
+
super project_dir, metadata_dir
|
6
|
+
end
|
7
|
+
|
8
|
+
def file_extension
|
9
|
+
"sublime-project"
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_h
|
13
|
+
{
|
14
|
+
folders: [
|
15
|
+
{path: "#{project_dir}"}
|
16
|
+
]
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module SublimeTextKit
|
2
|
+
module Metadata
|
3
|
+
class Workspace < Base
|
4
|
+
def initialize project_dir, metadata_dir
|
5
|
+
super project_dir, metadata_dir
|
6
|
+
end
|
7
|
+
|
8
|
+
def file_extension
|
9
|
+
"sublime-workspace"
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_h
|
13
|
+
{
|
14
|
+
expanded_folders: ["#{project_dir}"],
|
15
|
+
select_project: {
|
16
|
+
selected_items: [
|
17
|
+
[name, File.join(metadata_dir, "#{name}.sublime-project")]
|
18
|
+
]
|
19
|
+
}
|
20
|
+
}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -2,22 +2,22 @@ require "multi_json"
|
|
2
2
|
|
3
3
|
module SublimeTextKit
|
4
4
|
class Session
|
5
|
-
attr_reader :
|
5
|
+
attr_reader :metadata_dir
|
6
6
|
|
7
7
|
def self.home_path
|
8
8
|
ENV.fetch "HOME"
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.session_path
|
12
|
-
"#{home_path}/Library/Application Support/Sublime Text
|
12
|
+
"#{home_path}/Library/Application Support/Sublime Text 3/Local/Session.sublime_session"
|
13
13
|
end
|
14
14
|
|
15
|
-
def initialize
|
16
|
-
@
|
15
|
+
def initialize metadata_directory
|
16
|
+
@metadata_dir = File.expand_path metadata_directory
|
17
17
|
end
|
18
18
|
|
19
19
|
def workspaces
|
20
|
-
Dir["#{
|
20
|
+
Dir["#{metadata_dir}/*.sublime-workspace"].sort
|
21
21
|
end
|
22
22
|
|
23
23
|
def rebuild_recent_workspaces
|
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: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
fMlZDUGx3lQarp/vPjK+6XH7DLXjBEKqeIGBIpLthYUvDxJRp23C+T3liGSL32vg
|
31
31
|
mSpxxwmK95GDFuEy2mNPaxnazdkw8c+7DbrSpzd/CnNZkRgitxOavs8=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2015-
|
33
|
+
date: 2015-05-11 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: pry-byebug
|
@@ -257,7 +257,9 @@ files:
|
|
257
257
|
- bin/stk
|
258
258
|
- lib/sublime_text_kit.rb
|
259
259
|
- lib/sublime_text_kit/cli.rb
|
260
|
-
- lib/sublime_text_kit/
|
260
|
+
- lib/sublime_text_kit/metadata/base.rb
|
261
|
+
- lib/sublime_text_kit/metadata/project_metadata.rb
|
262
|
+
- lib/sublime_text_kit/metadata/workspace_metadata.rb
|
261
263
|
- lib/sublime_text_kit/session.rb
|
262
264
|
- lib/sublime_text_kit/version.rb
|
263
265
|
homepage: https://github.com/bkuhlmann/sublime_text_kit
|
@@ -280,7 +282,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
280
282
|
version: '0'
|
281
283
|
requirements: []
|
282
284
|
rubyforge_project:
|
283
|
-
rubygems_version: 2.4.
|
285
|
+
rubygems_version: 2.4.6
|
284
286
|
signing_key:
|
285
287
|
specification_version: 4
|
286
288
|
summary: Command line utilities for Sublime Text.
|
metadata.gz.sig
CHANGED
Binary file
|
@@ -1,59 +0,0 @@
|
|
1
|
-
require "multi_json"
|
2
|
-
require "pathname"
|
3
|
-
|
4
|
-
module SublimeTextKit
|
5
|
-
class ProjectMetadata
|
6
|
-
attr_reader :name, :project_dir, :workspace_dir, :project_file
|
7
|
-
|
8
|
-
def self.create projects_dir, workspace_dir
|
9
|
-
projects_dir = File.expand_path projects_dir
|
10
|
-
workspace_dir = File.expand_path workspace_dir
|
11
|
-
|
12
|
-
return unless valid_dir?(projects_dir, "Projects")
|
13
|
-
return unless valid_dir?(workspace_dir, "Workspace")
|
14
|
-
|
15
|
-
project_paths = ::Pathname.new(projects_dir).children.select {|child| child if child.directory? }
|
16
|
-
project_paths.each { |project_dir| new(project_dir, workspace_dir).save }
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.delete workspace_dir
|
20
|
-
workspace_dir = File.expand_path workspace_dir
|
21
|
-
|
22
|
-
return unless valid_dir?(workspace_dir, "Workspace")
|
23
|
-
|
24
|
-
::Pathname.glob("#{workspace_dir}/*.sublime-*").each(&:delete)
|
25
|
-
end
|
26
|
-
|
27
|
-
def initialize project_dir, workspace_dir
|
28
|
-
@name = File.basename project_dir
|
29
|
-
@project_dir = File.expand_path project_dir
|
30
|
-
@workspace_dir = File.expand_path workspace_dir
|
31
|
-
@project_file = File.join @workspace_dir, "#{name}.sublime-project"
|
32
|
-
end
|
33
|
-
|
34
|
-
def to_h
|
35
|
-
{
|
36
|
-
folders: [
|
37
|
-
{path: "#{project_dir}"}
|
38
|
-
]
|
39
|
-
}
|
40
|
-
end
|
41
|
-
|
42
|
-
def save
|
43
|
-
unless File.exist? project_file
|
44
|
-
File.open(project_file, 'w') { |file| file.write MultiJson.dump(to_h, pretty: true) }
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
private
|
49
|
-
|
50
|
-
def self.valid_dir? dir, label
|
51
|
-
if File.exist?(dir)
|
52
|
-
true
|
53
|
-
else
|
54
|
-
puts "#{label} directory doesn't exist: #{dir}."
|
55
|
-
false
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|