opal_stimulus 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.
- checksums.yaml +7 -0
- data/.rubocop.yml +8 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +58 -0
- data/Rakefile +12 -0
- data/lib/install/Procfile.dev +2 -0
- data/lib/install/application.rb +9 -0
- data/lib/install/controllers/my_opal_controller.rb +5 -0
- data/lib/install/controllers_requires.rb +4 -0
- data/lib/install/dev +11 -0
- data/lib/install/install_opal_stimulus.rb +55 -0
- data/lib/install/opal +63 -0
- data/lib/opal_stimulus/stimulus_controller.rb +236 -0
- data/lib/opal_stimulus/version.rb +5 -0
- data/lib/opal_stimulus.rb +17 -0
- data/lib/tasks/install.rake +6 -0
- metadata +89 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e2b9722851b24c4870cc76265994a889813d4d59e826e4e945c4859b9de9f873
|
4
|
+
data.tar.gz: 6c9df0ea9b687094f3cb266abacb8824456809dcfdcd100a744fe04c667bf8bf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 05edb688629527e884549e82cb92a375b1006735d7c082ac2a013c553b3e7214ef1ae90160b904528626d3804ac281c26987480cf1081b84331566884d413675
|
7
|
+
data.tar.gz: aaad0562773f879a73bf66eed31966a8048b766056e12bf401a3f4785833d19f14b6381a9d8cd2fef68e0c1cb6239443adee71ac7176c9ac7929c800800bb473
|
data/.rubocop.yml
ADDED
data/CHANGELOG.md
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2025 Joseph Schito
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# opal_stimulus for Rails
|
2
|
+
|
3
|
+
**Opal Stimulus** is a Stimulus wrapper made with Opal (a source-to-source Ruby to JavaScript compiler) that allows you to write Stimulus controllers in Ruby instead of JavaScript (It works only with Rails).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'opal_stimulus'
|
11
|
+
```
|
12
|
+
|
13
|
+
Then execute:
|
14
|
+
|
15
|
+
```bash
|
16
|
+
bundle install
|
17
|
+
rails generate opal_stimulus:install
|
18
|
+
```
|
19
|
+
|
20
|
+
## Basic Example
|
21
|
+
|
22
|
+
Here's a Hello World example with OpalStimulus. Compare with the [original JavaScript example](https://stimulus.hotwired.dev/handbook/hello-stimulus):
|
23
|
+
|
24
|
+
**Ruby Controller:**
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
# app/opal/controllers/hello_controller.rb
|
28
|
+
class HelloController < StimulusController
|
29
|
+
self.targets = ["name", "output"]
|
30
|
+
|
31
|
+
def greet
|
32
|
+
output_target.JS[:textContent] = "Hello, #{name_target.JS[:value]}!"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
**HTML:**
|
38
|
+
|
39
|
+
```html
|
40
|
+
<div data-controller="hello">
|
41
|
+
<input data-hello-target="name" type="text">
|
42
|
+
|
43
|
+
<button data-action="click->hello#greet">
|
44
|
+
Greet
|
45
|
+
</button>
|
46
|
+
|
47
|
+
<span data-hello-target="output">
|
48
|
+
</span>
|
49
|
+
</div>
|
50
|
+
```
|
51
|
+
|
52
|
+
## Contributing
|
53
|
+
|
54
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/josephschito/opal_stimulus.
|
55
|
+
|
56
|
+
## License
|
57
|
+
|
58
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
require "opal_stimulus/stimulus_controller"
|
2
|
+
require "controllers_requires"
|
3
|
+
|
4
|
+
StimulusController.subclasses.each do |controller|
|
5
|
+
controller.define_method(:dummy) { }
|
6
|
+
|
7
|
+
return if `Stimulus.controllers`.include?(`#{controller.stimulus_name}`)
|
8
|
+
`Stimulus.register(#{controller.stimulus_name}, #{controller.stimulus_controller})`
|
9
|
+
end
|
data/lib/install/dev
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env sh
|
2
|
+
|
3
|
+
if gem list --no-installed --exact --silent foreman; then
|
4
|
+
echo "Installing foreman..."
|
5
|
+
gem install foreman
|
6
|
+
fi
|
7
|
+
|
8
|
+
# Default to port 3000 if not specified
|
9
|
+
export PORT="${PORT:-3000}"
|
10
|
+
|
11
|
+
exec foreman start -f Procfile.dev --env /dev/null "$@"
|
@@ -0,0 +1,55 @@
|
|
1
|
+
APPLICATION_LAYOUT_PATH = Rails.root.join("app/views/layouts/application.html.erb")
|
2
|
+
APPLICATION_OPAL_STIMULUS_BIN_PATH = Rails.root.join("bin")
|
3
|
+
APPLICATION_OPAL_STIMULUS_PATH = Rails.root.join("app/opal")
|
4
|
+
|
5
|
+
if File.exist? APPLICATION_LAYOUT_PATH
|
6
|
+
say "Adding Opal Stimulus to the application layout", :green
|
7
|
+
insert_into_file APPLICATION_LAYOUT_PATH, after: "<%= javascript_importmap_tags %>\n" do
|
8
|
+
<<-ERB
|
9
|
+
<script type="module">
|
10
|
+
import "application"
|
11
|
+
import "<%= javascript_path("opal") %>"
|
12
|
+
</script>
|
13
|
+
ERB
|
14
|
+
end
|
15
|
+
|
16
|
+
insert_into_file APPLICATION_LAYOUT_PATH, after: "<body>\n" do
|
17
|
+
say "Adding `my-opal` to the application layout", :green
|
18
|
+
<<-ERB
|
19
|
+
<span data-controller="my-opal"></span>
|
20
|
+
ERB
|
21
|
+
end
|
22
|
+
|
23
|
+
say "Creating Opal Stimulus files", :green
|
24
|
+
if Rails.root.join("Procfile.dev").exist?
|
25
|
+
append_to_file "Procfile.dev", "opal: bin/opal --watch\n"
|
26
|
+
else
|
27
|
+
say "Add default Procfile.dev"
|
28
|
+
copy_file "#{__dir__}/Procfile.dev", "Procfile.dev"
|
29
|
+
|
30
|
+
say "Ensure foreman is installed"
|
31
|
+
run "gem install foreman"
|
32
|
+
end
|
33
|
+
insert_into_file Rails.root.join("app/javascript/controllers/application.js") do
|
34
|
+
<<-JS
|
35
|
+
import { Controller } from "@hotwired/stimulus";
|
36
|
+
|
37
|
+
window.application = application;
|
38
|
+
window.Controller = Controller;
|
39
|
+
JS
|
40
|
+
end
|
41
|
+
append_to_file ".gitignore", "/.opal-cache\n"
|
42
|
+
append_to_file ".gitignore", "app/assets/builds/opal.js\n"
|
43
|
+
empty_directory APPLICATION_OPAL_STIMULUS_BIN_PATH
|
44
|
+
empty_directory APPLICATION_OPAL_STIMULUS_PATH
|
45
|
+
empty_directory "#{APPLICATION_OPAL_STIMULUS_PATH}/controllers"
|
46
|
+
empty_directory "#{APPLICATION_OPAL_STIMULUS_PATH}/app/assets/builds"
|
47
|
+
create_file "app/assets/builds/.keep"
|
48
|
+
copy_file "#{__dir__}/opal", "#{APPLICATION_OPAL_STIMULUS_BIN_PATH}/opal"
|
49
|
+
FileUtils.chmod("+x", "#{APPLICATION_OPAL_STIMULUS_BIN_PATH}/opal")
|
50
|
+
copy_file "#{__dir__}/dev", "#{APPLICATION_OPAL_STIMULUS_BIN_PATH}/dev"
|
51
|
+
FileUtils.chmod("+x", "#{APPLICATION_OPAL_STIMULUS_BIN_PATH}/dev")
|
52
|
+
copy_file "#{__dir__}/application.rb", "#{APPLICATION_OPAL_STIMULUS_PATH}/application.rb"
|
53
|
+
copy_file "#{__dir__}/controllers_requires.rb", "#{APPLICATION_OPAL_STIMULUS_PATH}/controllers_requires.rb"
|
54
|
+
copy_file "#{__dir__}/controllers/my_opal_controller.rb", "#{APPLICATION_OPAL_STIMULUS_PATH}/controllers/my_opal_controller.rb"
|
55
|
+
end
|
data/lib/install/opal
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "listen"
|
6
|
+
require "opal"
|
7
|
+
|
8
|
+
GEM_NAME = "opal_stimulus"
|
9
|
+
|
10
|
+
Opal.use_gem(GEM_NAME) rescue Opal.append_path(File.expand_path("lib", Bundler.rubygems.find_name(GEM_NAME).first.full_gem_path))
|
11
|
+
|
12
|
+
Opal.append_path("app/opal")
|
13
|
+
|
14
|
+
build = -> {
|
15
|
+
puts "🔨 Compiling Opal..."
|
16
|
+
|
17
|
+
builder = Opal::Builder.build("application", requirable: false)
|
18
|
+
output_path = "app/assets/builds/opal.js"
|
19
|
+
File.write(output_path, builder.to_s)
|
20
|
+
|
21
|
+
puts "✅ Compiled to #{output_path}"
|
22
|
+
}
|
23
|
+
|
24
|
+
update_opal_controllers_requires = -> {
|
25
|
+
file_path = "app/opal/controllers_requires.rb"
|
26
|
+
|
27
|
+
requires = Dir["app/opal/controllers/**/*.rb"].sort.map do |file|
|
28
|
+
"require '#{file.sub("app/opal/", "").sub(".rb", "")}'"
|
29
|
+
end
|
30
|
+
|
31
|
+
File.open(file_path, "w") do |f|
|
32
|
+
f.puts "# This file is automatically generated by `bin/opal`."
|
33
|
+
f.puts "# If you want to update this file, please run: `bin/opal --update-requires`."
|
34
|
+
f.puts
|
35
|
+
f.puts requires.join("\n")
|
36
|
+
end
|
37
|
+
|
38
|
+
puts "✅ Updated #{file_path} 🎉"
|
39
|
+
}
|
40
|
+
|
41
|
+
if ARGV.include?("--update-requires")
|
42
|
+
update_opal_controllers_requires.()
|
43
|
+
exit
|
44
|
+
end
|
45
|
+
|
46
|
+
update_opal_controllers_requires.()
|
47
|
+
build.call
|
48
|
+
|
49
|
+
exit unless ARGV.include?("--watch")
|
50
|
+
|
51
|
+
listen = Listen.to("app/opal") do |modified, added, removed|
|
52
|
+
if added.any? || removed.any?
|
53
|
+
puts "🔄 Updating opal controllers requires..."
|
54
|
+
update_opal_controllers_requires.()
|
55
|
+
end
|
56
|
+
|
57
|
+
build.call
|
58
|
+
end
|
59
|
+
|
60
|
+
puts "👀 Watching app/opal for changes..."
|
61
|
+
listen.start
|
62
|
+
Signal.trap("INT") { listen.stop }
|
63
|
+
sleep
|
@@ -0,0 +1,236 @@
|
|
1
|
+
# backtick_javascript: true
|
2
|
+
|
3
|
+
require "opal"
|
4
|
+
require "native"
|
5
|
+
|
6
|
+
class StimulusController < `Controller`
|
7
|
+
include Native::Wrapper
|
8
|
+
|
9
|
+
DEFAULT_METHODS = %i[initialize connect disconnect dispatch]
|
10
|
+
DEFAULT_GETTERS = %i[element]
|
11
|
+
|
12
|
+
def self.inherited(subclass)
|
13
|
+
::Opal.bridge(subclass.stimulus_controller, subclass)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.stimulus_controller
|
17
|
+
return @stimulus_controller if @stimulus_controller
|
18
|
+
@stimulus_controller = `class extends Controller {}`
|
19
|
+
@stimulus_controller
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.stimulus_name
|
23
|
+
self.name.gsub(/Controller$/, "").gsub(/([a-z])([A-Z])/, '\1-\2').downcase
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.method_added(name)
|
27
|
+
return if DEFAULT_GETTERS.include?(name)
|
28
|
+
|
29
|
+
self.bridge_method(name)
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.register(controller)
|
33
|
+
`Stimulus.register(#{self.stimulus_name}, #{controller})`
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.bridge_method(name)
|
37
|
+
%x{
|
38
|
+
#{self.stimulus_controller}.prototype[name] = function (...args) {
|
39
|
+
return #{self.stimulus_controller}.prototype['$' + name].apply(this, args);
|
40
|
+
}
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.targets=(targets = [])
|
45
|
+
`#{self.stimulus_controller}.targets = targets`
|
46
|
+
|
47
|
+
targets.each do |target|
|
48
|
+
define_method(target + "_target") do
|
49
|
+
`return this[#{target + "Target"}]`
|
50
|
+
end
|
51
|
+
|
52
|
+
define_method(target + "_targets") do
|
53
|
+
`return this[#{target + "Targets"}]`
|
54
|
+
end
|
55
|
+
|
56
|
+
define_method("has_" + target + "_target") do
|
57
|
+
`return this[#{"has" + target.capitalize + "Target"}]`
|
58
|
+
end
|
59
|
+
|
60
|
+
snake_case_connected = target + "_target_connected"
|
61
|
+
camel_case_connected = target + "TargetConnected"
|
62
|
+
%x{
|
63
|
+
#{self.stimulus_controller}.prototype[#{camel_case_connected}] = function() {
|
64
|
+
if (this['$respond_to?'] && this['$respond_to?'](#{snake_case_connected})) {
|
65
|
+
return this['$' + #{snake_case_connected}]();
|
66
|
+
}
|
67
|
+
}
|
68
|
+
}
|
69
|
+
|
70
|
+
snake_case_disconnected = target + "_target_disconnected"
|
71
|
+
camel_case_disconnected = target + "TargetDisconnected"
|
72
|
+
%x{
|
73
|
+
#{self.stimulus_controller}.prototype[#{camel_case_disconnected}] = function() {
|
74
|
+
if (this['$respond_to?'] && this['$respond_to?'](#{snake_case_disconnected})) {
|
75
|
+
return this['$' + #{snake_case_disconnected}]();
|
76
|
+
}
|
77
|
+
}
|
78
|
+
}
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.outlets=(outlets = [])
|
83
|
+
`#{self.stimulus_controller}.outlets = outlets`
|
84
|
+
|
85
|
+
outlets.each do |outlet|
|
86
|
+
define_method(outlet + "_outlet") do
|
87
|
+
`return this[#{outlet + "Outlet"}]`
|
88
|
+
end
|
89
|
+
|
90
|
+
define_method(outlet + "_outlets") do
|
91
|
+
`return this[#{outlet + "Outlets"}]`
|
92
|
+
end
|
93
|
+
|
94
|
+
define_method("has_" + outlet + "_outlet") do
|
95
|
+
`return this[#{"has" + outlet.capitalize + "Outlet"}]`
|
96
|
+
end
|
97
|
+
|
98
|
+
snake_case_connected = outlet + "_outlet_connected"
|
99
|
+
camel_case_connected = outlet + "OutletConnected"
|
100
|
+
%x{
|
101
|
+
#{self.stimulus_controller}.prototype[#{camel_case_connected}] = function() {
|
102
|
+
if (this['$respond_to?'] && this['$respond_to?'](#{snake_case_connected})) {
|
103
|
+
return this['$' + #{snake_case_connected}]();
|
104
|
+
}
|
105
|
+
}
|
106
|
+
}
|
107
|
+
|
108
|
+
snake_case_disconnected = outlet + "_outlet_disconnected"
|
109
|
+
camel_case_disconnected = outlet + "OutletDisconnected"
|
110
|
+
%x{
|
111
|
+
#{self.stimulus_controller}.prototype[#{camel_case_disconnected}] = function() {
|
112
|
+
if (this['$respond_to?'] && this['$respond_to?'](#{snake_case_disconnected})) {
|
113
|
+
return this['$' + #{snake_case_disconnected}]();
|
114
|
+
}
|
115
|
+
}
|
116
|
+
}
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def self.values=(values_hash = {})
|
121
|
+
js_values = {}
|
122
|
+
|
123
|
+
values_hash.each do |name, type|
|
124
|
+
js_type = case type
|
125
|
+
when String then "String"
|
126
|
+
when Integer, Float, Numeric then "Number"
|
127
|
+
when TrueClass, FalseClass, Boolean then "Boolean"
|
128
|
+
when Array then "Array"
|
129
|
+
when Hash, Object then "Object"
|
130
|
+
else "String" # Default to String for unknown types
|
131
|
+
end
|
132
|
+
|
133
|
+
js_values[name] = js_type
|
134
|
+
|
135
|
+
# Define value getter method (snake_case)
|
136
|
+
define_method(name.to_s) do
|
137
|
+
# Convert JavaScript value to appropriate Ruby type
|
138
|
+
js_value = `this[#{name + "Value"}]`
|
139
|
+
case type
|
140
|
+
when String
|
141
|
+
js_value.to_s
|
142
|
+
when Integer
|
143
|
+
js_value.to_i
|
144
|
+
when Float
|
145
|
+
js_value.to_f
|
146
|
+
when TrueClass, FalseClass, Boolean
|
147
|
+
!!js_value
|
148
|
+
when Array
|
149
|
+
Native::Array.new(js_value)
|
150
|
+
when Hash, Object
|
151
|
+
Native::Object.new(js_value)
|
152
|
+
else
|
153
|
+
js_value
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
define_method("has_#{name}") do
|
158
|
+
`return this[#{"has" + name.to_s.capitalize + "Value"}]`
|
159
|
+
end
|
160
|
+
|
161
|
+
snake_case_changed = "#{name}_value_changed"
|
162
|
+
camel_case_changed = "#{name}ValueChanged"
|
163
|
+
%x{
|
164
|
+
#{self.stimulus_controller}.prototype[#{camel_case_changed}] = function(value, previousValue) {
|
165
|
+
if (this['$respond_to?'] && this['$respond_to?'](#{snake_case_changed})) {
|
166
|
+
return this['$' + #{snake_case_changed}](value, previousValue);
|
167
|
+
}
|
168
|
+
}
|
169
|
+
}
|
170
|
+
end
|
171
|
+
|
172
|
+
`#{self.stimulus_controller}.values = #{js_values.to_n}`
|
173
|
+
end
|
174
|
+
|
175
|
+
def self.classes=(class_names = [])
|
176
|
+
`#{self.stimulus_controller}.classes = #{class_names.to_n}`
|
177
|
+
|
178
|
+
class_names.each do |class_name|
|
179
|
+
define_method("add_#{class_name}_class") do
|
180
|
+
`this.#{class_name}Classes.add()`
|
181
|
+
end
|
182
|
+
|
183
|
+
define_method("remove_#{class_name}_class") do
|
184
|
+
`this.#{class_name}Classes.remove()`
|
185
|
+
end
|
186
|
+
|
187
|
+
define_method("has_#{class_name}_class?") do
|
188
|
+
`return this.#{class_name}Classes.has()`
|
189
|
+
end
|
190
|
+
|
191
|
+
define_method("toggle_#{class_name}_class") do
|
192
|
+
`this.#{class_name}Classes.toggle()`
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
def add_class(class_name, element = nil)
|
198
|
+
if element
|
199
|
+
`this.addClass(#{class_name}, #{element})`
|
200
|
+
else
|
201
|
+
`this.addClass(#{class_name})`
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
def remove_class(class_name, element = nil)
|
206
|
+
if element
|
207
|
+
`this.removeClass(#{class_name}, #{element})`
|
208
|
+
else
|
209
|
+
`this.removeClass(#{class_name})`
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
def has_class?(class_name, element = nil)
|
214
|
+
if element
|
215
|
+
`return this.hasClass(#{class_name}, #{element})`
|
216
|
+
else
|
217
|
+
`return this.hasClass(#{class_name})`
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
def toggle_class(class_name, force = nil, element = nil)
|
222
|
+
if element && force != nil
|
223
|
+
`this.toggleClass(#{class_name}, #{force}, #{element})`
|
224
|
+
elsif element
|
225
|
+
`this.toggleClass(#{class_name}, #{element})`
|
226
|
+
elsif force != nil
|
227
|
+
`this.toggleClass(#{class_name}, #{force})`
|
228
|
+
else
|
229
|
+
`this.toggleClass(#{class_name})`
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
def element
|
234
|
+
`this.element`
|
235
|
+
end
|
236
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rake'
|
4
|
+
|
5
|
+
if RUBY_ENGINE == 'opal'
|
6
|
+
require_relative "opal_stimulus/stimulus_controller"
|
7
|
+
else
|
8
|
+
require "opal"
|
9
|
+
require_relative "opal_stimulus/version"
|
10
|
+
|
11
|
+
Opal.append_path File.expand_path('lib', __dir__)
|
12
|
+
end
|
13
|
+
|
14
|
+
Dir.glob(File.expand_path("../tasks/**/*.rake", __FILE__)).each { |r| load r }
|
15
|
+
|
16
|
+
module OpalStimulus
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: opal_stimulus
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Joseph Schito
|
8
|
+
bindir: exe
|
9
|
+
cert_chain: []
|
10
|
+
date: 2025-06-19 00:00:00.000000000 Z
|
11
|
+
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: opal
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - "~>"
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: 1.8.2
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - "~>"
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: 1.8.2
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: listen
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - "~>"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.9.0
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 3.9.0
|
40
|
+
description: Opal Stimulus provides a way to write Stimulus controllers in Ruby, leveraging
|
41
|
+
the Opal compiler to convert Ruby code into JavaScript. This allows developers familiar
|
42
|
+
with Ruby to use the Stimulus framework without needing to write JavaScript directly.
|
43
|
+
email:
|
44
|
+
- joseph.schito@gmail.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".rubocop.yml"
|
50
|
+
- CHANGELOG.md
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- lib/install/Procfile.dev
|
55
|
+
- lib/install/application.rb
|
56
|
+
- lib/install/controllers/my_opal_controller.rb
|
57
|
+
- lib/install/controllers_requires.rb
|
58
|
+
- lib/install/dev
|
59
|
+
- lib/install/install_opal_stimulus.rb
|
60
|
+
- lib/install/opal
|
61
|
+
- lib/opal_stimulus.rb
|
62
|
+
- lib/opal_stimulus/stimulus_controller.rb
|
63
|
+
- lib/opal_stimulus/version.rb
|
64
|
+
- lib/tasks/install.rake
|
65
|
+
homepage: https://github.com/josephschito/opal_stimulus
|
66
|
+
licenses:
|
67
|
+
- MIT
|
68
|
+
metadata:
|
69
|
+
homepage_uri: https://github.com/josephschito/opal_stimulus
|
70
|
+
source_code_uri: https://github.com/josephschito/opal_stimulus
|
71
|
+
changelog_uri: https://github.com/josephschito/opal_stimulus/blob/main/CHANGELOG.md
|
72
|
+
rdoc_options: []
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 3.1.0
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubygems_version: 3.6.2
|
87
|
+
specification_version: 4
|
88
|
+
summary: 'Opal Stimulus: Write Stimulus controllers in Ruby'
|
89
|
+
test_files: []
|