command_deck 0.1.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.
@@ -0,0 +1,103 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Command Deck
4
+ module CommandDeck
5
+ # Registry for actions and panels
6
+ class Registry
7
+ Action = Struct.new(:title, :key, :params, :block, keyword_init: true)
8
+ Tab = Struct.new(:title, :actions, keyword_init: true)
9
+ Panel = Struct.new(:title, :tabs, :owner, :group, :key, keyword_init: true)
10
+
11
+ class << self
12
+ def panels
13
+ @panels ||= []
14
+ end
15
+
16
+ def clear!
17
+ @panels = []
18
+ end
19
+
20
+ def panel(title, **opts, &blk)
21
+ PanelBuilder.new(title, **opts).tap { |pb| pb.instance_eval(&blk) if blk }.build.then { panels << _1 }
22
+ end
23
+
24
+ def find_action(key)
25
+ panels.each do |p|
26
+ p.tabs.each do |t|
27
+ t.actions.each do |a|
28
+ return a if a.key == key
29
+ end
30
+ end
31
+ end
32
+ nil
33
+ end
34
+ end
35
+
36
+ # Panel builder
37
+ class PanelBuilder
38
+ def initialize(title, **opts)
39
+ @title = title
40
+ @tabs = []
41
+ @owner = opts[:owner]
42
+ @group = opts[:group]
43
+ @key = opts[:key] || slugify(title)
44
+ end
45
+
46
+ def tab(title, &blk)
47
+ @tabs << TabBuilder.new(title).tap { |tb| tb.instance_eval(&blk) if blk }.build
48
+ end
49
+
50
+ def build
51
+ Panel.new(title: @title, tabs: @tabs, owner: @owner, group: @group, key: @key)
52
+ end
53
+
54
+ private
55
+
56
+ def slugify(str)
57
+ str.to_s.downcase.gsub(/[^a-z0-9]+/, "-").gsub(/^-|-$/, "")
58
+ end
59
+ end
60
+
61
+ # Tab builder
62
+ class TabBuilder
63
+ def initialize(title)
64
+ @title = title
65
+ @actions = []
66
+ end
67
+
68
+ def action(title, key:, &blk)
69
+ @actions << ActionBuilder.new(title, key).tap { |ab| ab.instance_eval(&blk) if blk }.build
70
+ end
71
+
72
+ def build
73
+ Tab.new(title: @title, actions: @actions)
74
+ end
75
+ end
76
+
77
+ # Action builder
78
+ class ActionBuilder
79
+ def initialize(title, key)
80
+ @title = title
81
+ @key = key
82
+ @params = []
83
+ @block = nil
84
+ end
85
+
86
+ def param(name, type, **opts)
87
+ @params << { name: name, type: type, **opts }
88
+ end
89
+
90
+ def perform(&block)
91
+ @block = block
92
+ end
93
+
94
+ def build
95
+ Action.new(title: @title, key: @key, params: @params, block: @block)
96
+ end
97
+ end
98
+ end
99
+
100
+ def self.panel(title, **opts, &blk)
101
+ Registry.panel(title, **opts, &blk)
102
+ end
103
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CommandDeck
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "command_deck/version"
4
+ require "command_deck/registry"
5
+ require "command_deck/executor"
6
+
7
+ module CommandDeck
8
+ class Error < StandardError; end
9
+ end
10
+
11
+ if defined?(Rails)
12
+ require "command_deck/railtie"
13
+ require "command_deck/engine"
14
+ end
Binary file
@@ -0,0 +1,4 @@
1
+ module CommandDeck
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: command_deck
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - crowrojas
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2025-09-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: actionpack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '7.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '7.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: railties
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '7.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '7.0'
41
+ description: Command Deck is a tiny floating UI that allows you to run commands in
42
+ your Rails app.
43
+ email:
44
+ - cristobal.rojasbrito@gmail.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".rubocop.yml"
50
+ - CHANGELOG.md
51
+ - CODE_OF_CONDUCT.md
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - TAGS
56
+ - app/controllers/command_deck/actions_controller.rb
57
+ - app/controllers/command_deck/assets_controller.rb
58
+ - app/controllers/command_deck/base_controller.rb
59
+ - app/controllers/command_deck/panels_controller.rb
60
+ - config/routes.rb
61
+ - lib/command_deck.rb
62
+ - lib/command_deck/assets/css/main.css
63
+ - lib/command_deck/assets/js/core/api.js
64
+ - lib/command_deck/assets/js/core/dom.js
65
+ - lib/command_deck/assets/js/core/store.js
66
+ - lib/command_deck/assets/js/main.js
67
+ - lib/command_deck/assets/js/ui/overlay.js
68
+ - lib/command_deck/assets/js/ui/panel_selector.js
69
+ - lib/command_deck/assets/js/ui/position_manager.js
70
+ - lib/command_deck/assets/js/ui/settings_dropdown.js
71
+ - lib/command_deck/assets/js/ui/theme_manager.js
72
+ - lib/command_deck/engine.rb
73
+ - lib/command_deck/executor.rb
74
+ - lib/command_deck/injector.rb
75
+ - lib/command_deck/middleware.rb
76
+ - lib/command_deck/railtie.rb
77
+ - lib/command_deck/registry.rb
78
+ - lib/command_deck/version.rb
79
+ - public/img/demo.png
80
+ - sig/command_deck.rbs
81
+ homepage: https://github.com/crow-rojas/command_deck
82
+ licenses:
83
+ - MIT
84
+ metadata:
85
+ allowed_push_host: https://rubygems.org
86
+ homepage_uri: https://github.com/crow-rojas/command_deck
87
+ source_code_uri: https://github.com/crow-rojas/command_deck
88
+ changelog_uri: https://github.com/crow-rojas/command_deck/blob/master/CHANGELOG.md
89
+ rubygems_mfa_required: 'true'
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: 3.0.0
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubygems_version: 3.5.22
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: Command Deck is a tiny floating UI that allows you to run commands in your
109
+ Rails app.
110
+ test_files: []