dockedit 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e0f5c8c02becb27646e58e86489ffaa4b577ee7a44095afc03ef61a005ca592b
4
+ data.tar.gz: a3bbd0cf87acb76213674a15ff5c4b24c3227c02821c24365fe2d3e0bc66a6e7
5
+ SHA512:
6
+ metadata.gz: 14174fbb8eff9f09c4c6196bdb270572e0d87504ee305fd63314e01d195a2a8de7f2e2e0af4586b29f056359078aa3322d61f0ec40de64847ab895caf8141b62
7
+ data.tar.gz: a7a61f7fb7aa5bf175d817e0f96e540dfed0fdd05c2d31f00bc1e296b62ffb463d8af9c0e875f756327c15b58a438ff5370e74760e83c3676173f34e3c7e44be
data/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --require spec_helper
2
+ --format documentation
3
+
4
+
data/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ ### 1.0.0
2
+
3
+ 2025-12-17 07:21
4
+
5
+ #### NEW
6
+
7
+ - Add standalone (non-gem) version and script to generate
8
+
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in dockedit.gemspec
6
+ gemspec
7
+
8
+ group :development, :test do
9
+ gem 'rspec', '~> 3.12'
10
+ gem 'rake', '~> 13.2'
11
+ end
12
+
data/Gemfile.lock ADDED
@@ -0,0 +1,37 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ dockedit (1.0.0)
5
+ rexml (~> 3.2)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.6.2)
11
+ rake (13.3.1)
12
+ rexml (3.4.4)
13
+ rspec (3.13.2)
14
+ rspec-core (~> 3.13.0)
15
+ rspec-expectations (~> 3.13.0)
16
+ rspec-mocks (~> 3.13.0)
17
+ rspec-core (3.13.6)
18
+ rspec-support (~> 3.13.0)
19
+ rspec-expectations (3.13.5)
20
+ diff-lcs (>= 1.2.0, < 2.0)
21
+ rspec-support (~> 3.13.0)
22
+ rspec-mocks (3.13.7)
23
+ diff-lcs (>= 1.2.0, < 2.0)
24
+ rspec-support (~> 3.13.0)
25
+ rspec-support (3.13.6)
26
+
27
+ PLATFORMS
28
+ arm64-darwin-24
29
+ ruby
30
+
31
+ DEPENDENCIES
32
+ dockedit!
33
+ rake (~> 13.2)
34
+ rspec (~> 3.12)
35
+
36
+ BUNDLED WITH
37
+ 2.7.2
data/README.md ADDED
@@ -0,0 +1,262 @@
1
+ ## dockedit
2
+
3
+ `dockedit` is a command‑line tool for editing the macOS Dock. It lets you add, remove, move, and manage apps and folders (including inserting spacer tiles) without touching System Settings.
4
+
5
+ ### Installation
6
+
7
+ - **From RubyGems**:
8
+
9
+ ```bash
10
+ gem install dockedit
11
+ ```
12
+
13
+ - **From source (local clone)**:
14
+
15
+ ```bash
16
+ bundle install
17
+ bundle exec rake test
18
+ ```
19
+
20
+ This installs the `dockedit` executable.
21
+
22
+ - **Standalone file** (no gem install required):
23
+
24
+ The repository includes a standalone `dockedit` file in the root directory that can be used directly without installing the gem. To regenerate this file after making changes to library files, run:
25
+
26
+ ```bash
27
+ ruby build_standalone.rb
28
+ ```
29
+
30
+ **Note**: If you add new library files, you must include them in the `FILE_ORDER` array in `build_standalone.rb` before running the script.
31
+
32
+ ### Basic usage
33
+
34
+ ```bash
35
+ dockedit <subcommand> [options] [args]
36
+ ```
37
+
38
+ Global behavior:
39
+
40
+ - **`dockedit --help`**: Show top‑level help and subcommand list.
41
+ - **`dockedit help <subcommand>`**: Show detailed help for a subcommand (`add`, `move`, `remove`, `space`).
42
+ - **`dockedit -v` / `dockedit --version`**: Print the current version.
43
+
44
+ Subcommands:
45
+
46
+ - `add` – add apps and/or folders to the Dock.
47
+ - `remove` – remove apps and/or folders from the Dock.
48
+ - `move` – move an existing Dock item after another item.
49
+ - `space` – insert one or more spacer tiles in the apps section.
50
+
51
+ Folder shortcuts you can use instead of full paths:
52
+
53
+ - `desktop`, `downloads`, `home`/`~`, `library`, `documents`, `applications`/`apps`, `sites`.
54
+
55
+ ---
56
+
57
+ ## Subcommands
58
+
59
+ ### `add` – add apps and folders
60
+
61
+ **Usage**:
62
+
63
+ ```bash
64
+ dockedit add [options] <app_or_folder> [...]
65
+ ```
66
+
67
+ You can pass any mix of:
68
+
69
+ - App names (e.g. `Safari`, `Terminal`, `Notes`) – resolved via Spotlight-style search.
70
+ - Explicit app paths (e.g. `/Applications/Safari.app`).
71
+ - Folder paths (e.g. `~/Downloads`, `~/Sites`), including the folder shortcuts above.
72
+
73
+ If a folder already exists in the Dock, `dockedit add` will update its view/style if you pass `--show` or `--display` rather than adding a duplicate.
74
+
75
+ **Options**:
76
+
77
+ - **`-a`, `--after ITEM`**
78
+ Insert the new item(s) after the specified Dock item (app or folder).
79
+ `ITEM` is matched fuzzily by name (e.g. `Safari`, `Terminal`, or a folder name).
80
+
81
+ - **`--show TYPE`, `--view TYPE`** (folders only)
82
+ Set the folder view mode. `TYPE` accepts:
83
+ - `fan` / `f`
84
+ - `grid` / `g`
85
+ - `list` / `l`
86
+ - `auto` / `a` (default)
87
+
88
+ - **`--display TYPE`** (folders only)
89
+ Set the folder style/appearance. `TYPE` accepts:
90
+ - `folder` / `f` – shows the folder icon
91
+ - `stack` / `s` – shows a stack of contents
92
+
93
+ **Examples**:
94
+
95
+ ```bash
96
+ # Add apps to the end of the apps section
97
+ dockedit add Safari Terminal
98
+
99
+ # Add Downloads folder as a grid-style stack
100
+ dockedit add ~/Downloads --show grid --display stack
101
+
102
+ # Add Notes after Safari
103
+ dockedit add --after Safari Notes
104
+
105
+ # Add Sites folder with folder icon and grid view
106
+ dockedit add ~/Sites --display folder --show grid
107
+ ```
108
+
109
+ ---
110
+
111
+ ### `remove` – remove apps and folders
112
+
113
+ **Usage**:
114
+
115
+ ```bash
116
+ dockedit remove <app_or_folder> [...]
117
+ ```
118
+
119
+ You can pass:
120
+
121
+ - App names or bundle identifiers (e.g. `Safari`, `com.apple.Safari`).
122
+ - Folder paths or folder names (including the defined shortcuts).
123
+
124
+ If an item can’t be found, `dockedit` prints a warning and continues with the remaining items.
125
+
126
+ **Examples**:
127
+
128
+ ```bash
129
+ # Remove multiple apps
130
+ dockedit remove Safari Terminal
131
+
132
+ # Remove Downloads folder
133
+ dockedit remove ~/Downloads
134
+ ```
135
+
136
+ To see help for this subcommand:
137
+
138
+ ```bash
139
+ dockedit help remove
140
+ ```
141
+
142
+ ---
143
+
144
+ ### `move` – move a Dock item after another
145
+
146
+ **Usage**:
147
+
148
+ ```bash
149
+ dockedit move --after <target> <item_to_move>
150
+ # or
151
+ dockedit move <item_to_move> --after <target>
152
+ ```
153
+
154
+ `move` lets you reorder existing Dock items relative to another item. Both items must already be in the Dock, and they must be in the same section (apps or folders) — moving between sections is not allowed.
155
+
156
+ **Options**:
157
+
158
+ - **`-a`, `--after ITEM`** (required)
159
+ The target item after which `item_to_move` should be placed. Fuzzy‑matched by name.
160
+
161
+ **Rules and behavior**:
162
+
163
+ - If either the target or the item to move is not found, `dockedit` exits with an error.
164
+ - You cannot move an item after itself.
165
+ - You cannot move items between the apps section and the folders section.
166
+
167
+ **Examples**:
168
+
169
+ ```bash
170
+ # Explicit: move Safari after Terminal
171
+ dockedit move --after Terminal Safari
172
+
173
+ # Alternative order: same effect
174
+ dockedit move Safari --after Terminal
175
+ ```
176
+
177
+ To see help for this subcommand:
178
+
179
+ ```bash
180
+ dockedit help move
181
+ ```
182
+
183
+ ---
184
+
185
+ ### `space` – insert spacer tiles
186
+
187
+ **Usage**:
188
+
189
+ ```bash
190
+ dockedit space [options]
191
+ ```
192
+
193
+ `space` inserts one or more spacer tiles in the apps section of the Dock. You can add a space at the end of the apps list, or after specific apps.
194
+
195
+ **Options**:
196
+
197
+ - **`-s`, `--small`, `--half`**
198
+ Insert a small/half-size space instead of a full-size spacer.
199
+
200
+ - **`-a`, `--after APP`** (repeatable)
201
+ Insert a space after the specified app. You can use this option multiple times to insert several spaces in different locations in one command. Each `APP` is fuzzy‑matched by name.
202
+
203
+ **Behavior**:
204
+
205
+ - With no `--after` options, a single space (small or full) is added at the end of the apps section.
206
+ - With one or more `--after` options, a space is inserted after each referenced app, one by one.
207
+ - If an `APP` is not found, `dockedit` exits with an error.
208
+
209
+ **Examples**:
210
+
211
+ ```bash
212
+ # Add a full-size space at the end of the apps section
213
+ dockedit space
214
+
215
+ # Add a single small space at the end
216
+ dockedit space --small
217
+
218
+ # Add a full-size space after Safari
219
+ dockedit space --after Safari
220
+
221
+ # Add small spaces after Terminal and Safari (in that order)
222
+ dockedit space --small --after Terminal --after Safari
223
+ ```
224
+
225
+ To see help for this subcommand:
226
+
227
+ ```bash
228
+ dockedit help space
229
+ ```
230
+
231
+ ---
232
+
233
+ ### Global help and version
234
+
235
+ **Top-level help**:
236
+
237
+ ```bash
238
+ dockedit --help
239
+ dockedit help
240
+ ```
241
+
242
+ Shows the main usage, subcommand list, folder shortcuts, and examples.
243
+
244
+ **Subcommand help**:
245
+
246
+ ```bash
247
+ dockedit help add
248
+ dockedit help move
249
+ dockedit help remove
250
+ dockedit help space
251
+ ```
252
+
253
+ **Version**:
254
+
255
+ ```bash
256
+ dockedit -v
257
+ dockedit --version
258
+ ```
259
+
260
+ Prints the current `dockedit` version (from `DockEdit::VERSION`).
261
+
262
+
data/Rakefile ADDED
@@ -0,0 +1,97 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rake'
5
+ require 'rdoc/task'
6
+ require 'rspec/core/rake_task'
7
+ require_relative 'lib/dockedit/version'
8
+
9
+ # Load the gemspec
10
+ Gem::Specification.load('dockedit.gemspec')
11
+
12
+ namespace :version do
13
+ desc 'Bump version: major, minor, or patch'
14
+ task :bump, [:level] do |_t, args|
15
+ level = (args[:level] || 'patch').to_sym
16
+ version_file = 'lib/dockedit/version.rb'
17
+
18
+ current_version = DockEdit::VERSION
19
+ parts = current_version.split('.').map(&:to_i)
20
+
21
+ case level
22
+ when :major
23
+ parts[0] += 1
24
+ parts[1] = 0
25
+ parts[2] = 0
26
+ when :minor
27
+ parts[1] += 1
28
+ parts[2] = 0
29
+ when :patch
30
+ parts[2] += 1
31
+ else
32
+ raise "Invalid version level: #{level}. Use major, minor, or patch"
33
+ end
34
+
35
+ new_version = parts.join('.')
36
+
37
+ # Read the version file
38
+ content = File.read(version_file)
39
+ # Replace the version
40
+ content.gsub!(/VERSION = ['"][\d.]+['"]/, "VERSION = '#{new_version}'")
41
+
42
+ # Write it back
43
+ File.write(version_file, content)
44
+
45
+ puts "Version bumped from #{current_version} to #{new_version}"
46
+ puts "Don't forget to commit and tag:"
47
+ puts " git add #{version_file}"
48
+ puts " git commit -m 'Bump version to #{new_version}'"
49
+ puts " git tag -a v#{new_version} -m 'Version #{new_version}'"
50
+ puts ' git push && git push --tags'
51
+ end
52
+
53
+ desc 'Show current version'
54
+ task :show do
55
+ puts DockEdit::VERSION
56
+ end
57
+ end
58
+
59
+ desc 'Remove generated files'
60
+ task :clobber do
61
+ require 'fileutils'
62
+ FileUtils.rm_rf('pkg')
63
+ puts 'Removed pkg directory'
64
+ end
65
+
66
+ desc 'Build the gem'
67
+ task :build do
68
+ require 'rubygems/package'
69
+ require 'fileutils'
70
+
71
+ FileUtils.mkdir_p('pkg')
72
+
73
+ sh 'gem build dockedit.gemspec'
74
+ FileUtils.mv("dockedit-#{DockEdit::VERSION}.gem", "pkg/dockedit-#{DockEdit::VERSION}.gem")
75
+ puts "Built gem: pkg/dockedit-#{DockEdit::VERSION}.gem"
76
+ end
77
+
78
+ desc 'Run the test suite (RSpec)'
79
+ RSpec::Core::RakeTask.new(:test) do |t|
80
+ t.pattern = 'spec/**/*_spec.rb'
81
+ end
82
+
83
+ desc 'Generate RDoc documentation'
84
+ RDoc::Task.new(:rdoc) do |rdoc|
85
+ rdoc.rdoc_dir = 'doc'
86
+ rdoc.title = "dockedit #{DockEdit::VERSION}"
87
+ rdoc.options = ['--line-numbers', '--inline-source']
88
+ rdoc.rdoc_files.include('README.md', 'lib/**/*.rb')
89
+ end
90
+
91
+ desc 'Package the gem (build and place in pkg/)'
92
+ task package: %i[clobber build]
93
+
94
+ desc 'Install the gem locally'
95
+ task :install do
96
+ sh "gem install pkg/dockedit-#{DockEdit::VERSION}.gem"
97
+ end
data/bin/dockedit ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # dockedit - A script to edit the macOS Dock
5
+ # Usage: dockedit <subcommand> [options] [args]
6
+
7
+ require 'dockedit'
8
+
9
+ DockEdit::CLI.run
10
+
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # Script to build a standalone, single-file version of dockedit
5
+
6
+ require 'fileutils'
7
+
8
+ LIB_DIR = File.join(__dir__, 'lib', 'dockedit')
9
+ OUTPUT_FILE = File.join(__dir__, 'dockedit')
10
+
11
+ # File order based on dependency order in lib/dockedit.rb
12
+ FILE_ORDER = %w[
13
+ version.rb
14
+ constants.rb
15
+ matcher.rb
16
+ path_utils.rb
17
+ plist_reader.rb
18
+ plist_writer.rb
19
+ app_finder.rb
20
+ tile_factory.rb
21
+ folder_updater.rb
22
+ parsers.rb
23
+ dock.rb
24
+ commands.rb
25
+ cli.rb
26
+ ].freeze
27
+
28
+ # Standard library requires from lib/dockedit.rb
29
+ STANDARD_REQUIRES = <<~RUBY
30
+ #!/usr/bin/env ruby
31
+ # frozen_string_literal: true
32
+
33
+ # dockedit - A script to edit the macOS Dock
34
+ # Usage: dockedit <subcommand> [options] [args]
35
+
36
+ require 'rexml/document'
37
+ require 'fileutils'
38
+ require 'optparse'
39
+ require 'uri'
40
+ require 'stringio'
41
+ RUBY
42
+
43
+ def remove_require_statements(content)
44
+ # Remove require_relative statements (they're not needed in a single file)
45
+ content.lines.reject { |line| line.strip.start_with?('require_relative') }.join
46
+ end
47
+
48
+ def build_standalone_file
49
+ output = String.new
50
+ output << STANDARD_REQUIRES
51
+ output << "\n"
52
+
53
+ FILE_ORDER.each do |filename|
54
+ filepath = File.join(LIB_DIR, filename)
55
+ unless File.exist?(filepath)
56
+ warn "Warning: File #{filepath} not found"
57
+ next
58
+ end
59
+
60
+ content = File.read(filepath)
61
+ content = remove_require_statements(content)
62
+ output << content
63
+ output << "\n" unless content.end_with?("\n")
64
+ output << "\n"
65
+ end
66
+
67
+ # Add main execution block
68
+ output << <<~RUBY
69
+
70
+ if __FILE__ == $0
71
+ DockEdit::CLI.run
72
+ end
73
+ RUBY
74
+
75
+ output
76
+ end
77
+
78
+ def main
79
+ standalone_content = build_standalone_file
80
+
81
+ File.write(OUTPUT_FILE, standalone_content)
82
+ FileUtils.chmod('+x', OUTPUT_FILE)
83
+
84
+ puts "Standalone file generated: #{OUTPUT_FILE}"
85
+ puts "File size: #{File.size(OUTPUT_FILE)} bytes"
86
+ end
87
+
88
+ main if __FILE__ == $0