omagem 0.1.1 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e330b39968b7711d9f1cf9f46232efec3c2f342b207ba65a772c48a5a6cac1d7
4
- data.tar.gz: dae10b20eb9dc463ca7be29c358b0f2f858cf12196604f56a67a5bd4638b1d54
3
+ metadata.gz: 0bc981fccab22219589e1c2c9ecc6cc32ddb00747e5d6de7fa8bfe0d21bb985d
4
+ data.tar.gz: c2accf94983f574ae949c2fd80edf33bde1c585827e78436dfe16eb8c68b24eb
5
5
  SHA512:
6
- metadata.gz: 7867469319e28f0f4174bb131f83808865650a561ebf375342a438b8363b201401a66722a20e21494c48878e79e4bfaf569fb3cf6529bca38d43ce7fa9083cf5
7
- data.tar.gz: f9ea24917b880e554f016b459201ea7151eb95c4f14fe52e84419a1a508faeeeb654122123030aa6707df209838dccf9242fcf5adf6ab4126d972efe44235606
6
+ metadata.gz: 89f09a6abf18ae0eb2b9ce38bfbcc1adec5a5e096b9d02d36cef53767bdc3864e68ce94e01e8d61f77171ab984b09bef8f0cd7b41b619ff8965b433b586489df
7
+ data.tar.gz: e26b908126dba3e76cf832eac257a2ff0a1818da938fd43024fe384899c928e85f5214ccd391b1fca9ba407fd3ec6e1be8352ed3a648a68da9591f152a901169
data/README.md CHANGED
@@ -6,8 +6,9 @@
6
6
 
7
7
  A small Ruby DSL for configuring and managing [Omarchy](https://omarchy.org/)
8
8
  Linux systems: themes, backgrounds, packages, services, the shell bar,
9
- plugins, toggles, snapshots, and system operations. It wraps the single
10
- `omarchy` CLI, so it stays in sync with the real command surface.
9
+ plugins, toggles, snapshots, git-installed software, and system operations.
10
+ It wraps the single `omarchy` CLI, so it stays in sync with the real command
11
+ surface.
11
12
 
12
13
  Designed to be used both in scripts and inside a Rails application.
13
14
 
@@ -18,22 +19,61 @@ Designed to be used both in scripts and inside a Rails application.
18
19
 
19
20
  ## Installation
20
21
 
22
+ ### As a dependency (Bundler)
23
+
21
24
  Add this line to your application's Gemfile:
22
25
 
23
26
  ```ruby
24
27
  gem "omagem"
25
28
  ```
26
29
 
30
+ Then execute:
31
+
32
+ ```bash
33
+ bundle install
34
+ ```
35
+
27
36
  Or install directly from the repository:
28
37
 
29
38
  ```ruby
30
39
  gem "omagem", github: "azzenabidi/OmaGem", branch: "main"
31
40
  ```
32
41
 
33
- And then execute:
42
+ ### Standalone (scripts and one-off use)
43
+
44
+ If you just want the DSL in a plain Ruby script or from the terminal:
34
45
 
35
46
  ```bash
36
- bundle install
47
+ gem install omagem
48
+ ```
49
+
50
+ Verify the gem is installed and loadable:
51
+
52
+ ```bash
53
+ ruby -e 'require "omagem"; puts OmaGem::VERSION'
54
+ ```
55
+
56
+ ## Uninstalling
57
+
58
+ ### Remove from a Bundler project
59
+
60
+ ```bash
61
+ bundle remove omagem
62
+ ```
63
+
64
+ (Or delete the `gem "omagem"` line from your Gemfile and run
65
+ `bundle install`.)
66
+
67
+ ### Uninstall the gem
68
+
69
+ ```bash
70
+ gem uninstall omagem
71
+ ```
72
+
73
+ To remove it from every RubyGems environment on the machine:
74
+
75
+ ```bash
76
+ gem uninstall omagem --all
37
77
  ```
38
78
 
39
79
  ## Usage
@@ -161,6 +201,19 @@ bar_visible :toggle
161
201
  notification_silencing # do-not-disturb
162
202
  ```
163
203
 
204
+ ### Git-installed software
205
+
206
+ ```ruby
207
+ valid_git_url? "https://...git" # true when git can clone the URL
208
+ git_themes # names of user themes cloned from git
209
+ git_plugins # IDs of third-party plugins added from git
210
+
211
+ update_git_installs # pull every git theme + plugin (yes: true skips prompts)
212
+ update_git_installs(yes: false) # keep the plugin update confirmation prompt
213
+ ```
214
+
215
+ Everything installed through the DSL from a git URL — `install_theme`, `add_plugin` — is already captured in `config.executed`. The Git methods above track what is currently git-managed and keep it up to date.
216
+
164
217
  ### Misc
165
218
 
166
219
  ```ruby
@@ -192,6 +245,75 @@ config.theme "catppuccin"
192
245
  config.executed # => [["theme", "set", "catppuccin"]]
193
246
  ```
194
247
 
248
+ ## Use cases
249
+
250
+ ### 1. Machine bootstrap / dotfiles as code
251
+
252
+ Declare the desired state of a fresh Omarchy install in a single script you
253
+ can re-run on any machine:
254
+
255
+ ```ruby
256
+ OmaGem.run do
257
+ theme "catppuccin"
258
+ add_packages "docker", "git", "lazygit"
259
+ add_packages "yay-bin", aur: true
260
+ install_service "tailscale"
261
+ default_terminal "kitty"
262
+ update(yes: true)
263
+ end
264
+ ```
265
+
266
+ ### 2. Rails admin panel
267
+
268
+ Expose theme, package, and service management through a web UI. Because
269
+ `OmaGem.run` returns the `Config`, controllers apply an operation and
270
+ immediately inspect the result:
271
+
272
+ ```ruby
273
+ class ThemesController < ApplicationController
274
+ def update
275
+ result = OmaGem.run { theme params[:theme] }
276
+ render json: { current: result.current_theme }
277
+ end
278
+ end
279
+ ```
280
+
281
+ ### 3. Scheduled automation
282
+
283
+ Drive background jobs — switches your environment on a schedule or keeps the
284
+ system up to date without touching the terminal:
285
+
286
+ ```ruby
287
+ class NightlightJob < ApplicationJob
288
+ def perform(on:)
289
+ OmaGem.run { nightlight(on ? :on : :off) }
290
+ end
291
+ end
292
+ ```
293
+
294
+ ### 4. Dry-run / preview
295
+
296
+ Preview exactly which commands a config would run, without mutating the
297
+ system, using the recording fake client (see
298
+ [Reusable, non-destructive configuration](#reusable-non-destructive-configuration)):
299
+
300
+ ```ruby
301
+ config = OmaGem::Config.new(client: OmaGem::Client::Fake.new)
302
+ config.theme "tokyo-night"
303
+ config.add_packages "docker"
304
+ config.executed
305
+ # => [["theme", "set", "tokyo-night"], ["pkg", "add", "docker"]]
306
+ ```
307
+
308
+ ### 5. Remote management
309
+
310
+ Ship an apply script to an Omarchy box and run it over SSH:
311
+
312
+ ```bash
313
+ scp apply.rb omarchy-box:
314
+ ssh omarchy-box "ruby apply.rb"
315
+ ```
316
+
195
317
  ## Errors
196
318
 
197
319
  - `OmaGem::CommandFailed` — a command exited non-zero (set `ignore_errors: true` in `OmaGem.run` to raise nothing and keep going).
data/lib/omagem/config.rb CHANGED
@@ -82,6 +82,7 @@ require_relative 'dsl/service'
82
82
  require_relative 'dsl/system'
83
83
  require_relative 'dsl/bar'
84
84
  require_relative 'dsl/plugin'
85
+ require_relative 'dsl/git'
85
86
  require_relative 'dsl/toggle'
86
87
  require_relative 'dsl/snapshot'
87
88
  require_relative 'dsl/misc'
@@ -92,6 +93,7 @@ OmaGem::Config.include(OmaGem::DSL::Service)
92
93
  OmaGem::Config.include(OmaGem::DSL::System)
93
94
  OmaGem::Config.include(OmaGem::DSL::Bar)
94
95
  OmaGem::Config.include(OmaGem::DSL::Plugin)
96
+ OmaGem::Config.include(OmaGem::DSL::Git)
95
97
  OmaGem::Config.include(OmaGem::DSL::Toggle)
96
98
  OmaGem::Config.include(OmaGem::DSL::Snapshot)
97
99
  OmaGem::Config.include(OmaGem::DSL::Misc)
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+
5
+ module OmaGem
6
+ module DSL
7
+ # Track and update software installed from git: user themes cloned from a
8
+ # repository and shell plugins added from a git URL.
9
+ module Git
10
+ # True when the URL names a repository git can clone.
11
+ def valid_git_url?(url)
12
+ client.run('git', 'url', 'check', url).success?
13
+ end
14
+
15
+ # Names of the user-installed themes that came from a git clone.
16
+ def git_themes
17
+ paths = client.run('theme', 'extras').stdout.lines.map(&:strip).reject(&:empty?)
18
+ paths.map { |path| File.basename(path) }
19
+ end
20
+
21
+ # IDs of the installed third-party shell plugins (those added from git).
22
+ def git_plugins
23
+ JSON.parse(client.run('plugin', 'list', '--json').stdout)
24
+ .select { |plugin| plugin['firstParty'] == false }
25
+ .map { |plugin| plugin['id'] }
26
+ end
27
+
28
+ # Update every theme and plugin installed from git. yes: true (default)
29
+ # skips the confirmation prompt, as scripts cannot answer it.
30
+ def update_git_installs(yes: true)
31
+ run('theme', 'update')
32
+ args = %w[plugin update]
33
+ args << '--yes' if yes
34
+ run(*args)
35
+ end
36
+ end
37
+ end
38
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OmaGem
4
- VERSION = '0.1.1'
4
+ VERSION = '0.2.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omagem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - azzen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-09-09 00:00:00.000000000 Z
11
+ date: 2026-09-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A tiny Ruby DSL that wraps the `omarchy` CLI so you can manage themes,
14
14
  packages, services, the shell bar, and more from Ruby or a Rails application.
@@ -23,6 +23,7 @@ files:
23
23
  - lib/omagem/client.rb
24
24
  - lib/omagem/config.rb
25
25
  - lib/omagem/dsl/bar.rb
26
+ - lib/omagem/dsl/git.rb
26
27
  - lib/omagem/dsl/misc.rb
27
28
  - lib/omagem/dsl/package.rb
28
29
  - lib/omagem/dsl/plugin.rb