uni_rails 0.3.0 → 0.4.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 +4 -4
- data/README.md +2 -1
- data/assets/templates/default.txt +88 -0
- data/examples/hello-world.rb +0 -2
- data/examples/server-falcon-app.rb +0 -2
- data/examples/server-puma-app.rb +0 -2
- data/examples/stimulus-app.rb +41 -0
- data/examples/todos-api.rb +0 -2
- data/examples/todos-hotwire.rb +0 -2
- data/examples/todos-scaffold.rb +0 -2
- data/exe/unirails +18 -0
- data/lib/uni_rails/version.rb +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4f9cd3df989797cabd98e67117c2767bf2aa19d8d586b86e62e8db1bc5962b4
|
4
|
+
data.tar.gz: 77c6a558483c47a3f08f8acbc1139290a90e2313f9f39cb48a17efb6996542d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c10ef57227cf6742fed28dd95c35d221dc3307a126244da83b34c7dc7fdd7b2d022ef63a92f607a873e276538e8bb665a863b3828e85d95f64647eb395f7394d
|
7
|
+
data.tar.gz: 2d7db16654876db5b7f28fd10d0ca5019a1070f8e90c2e6167f96e242d8b7c9dc535194a3d77635f1fa77b405f8dafb3f5860daf140265f6956c1cc14970f565
|
data/README.md
CHANGED
@@ -8,12 +8,13 @@ Check out our [examples](/examples) to understand how the library creates Rails
|
|
8
8
|
|
9
9
|
## Installation & Usage
|
10
10
|
|
11
|
-
See some examples of how the UniRails library can be used
|
11
|
+
See some examples of how the UniRails library can be used. Running an example is a easy as `ruby filename.rb`
|
12
12
|
|
13
13
|
- [Hello world](/examples/hello-world.rb)
|
14
14
|
- [Todos app (JSON API)](/examples/todos-api.rb)
|
15
15
|
- [Todos app (Rails scaffold)](/examples/todos-scaffold.rb) based off `bin/rails g scaffold todo name completed_at:datetime`
|
16
16
|
- [Todos app (Hotwire)](/examples/todos-hotwire.rb) based off online article: [turbo-rails-101-todo-list](https://www.colby.so/posts/turbo-rails-101-todo-list) by David Colby
|
17
|
+
- [App using StimulusJS](/examples/stimulus-app.rb)
|
17
18
|
- [App using Puma server](/examples/server-puma-app.rb)
|
18
19
|
- [App using Falcon server](/examples/server-falcon-app.rb)
|
19
20
|
|
@@ -0,0 +1,88 @@
|
|
1
|
+
ENV["SECRET_KEY_BASE"] = "1212312313"
|
2
|
+
ENV["DATABASE_URL"] = "sqlite3:///#{__dir__}/database.sqlite"
|
3
|
+
|
4
|
+
require "bundler/inline"
|
5
|
+
|
6
|
+
gemfile do
|
7
|
+
source "https://www.rubygems.org"
|
8
|
+
gem "uni_rails"
|
9
|
+
gem "sqlite3", "~> 1.7"
|
10
|
+
gem "byebug"
|
11
|
+
end
|
12
|
+
|
13
|
+
require "uni_rails"
|
14
|
+
require "sqlite3"
|
15
|
+
require "byebug"
|
16
|
+
|
17
|
+
# ==== ROUTES ====
|
18
|
+
UniRails::App.routes.append do
|
19
|
+
root "resource_names#new"
|
20
|
+
resources :resource_names
|
21
|
+
end
|
22
|
+
|
23
|
+
# ==== DB SCHEMA ====
|
24
|
+
ActiveRecord::Base.establish_connection
|
25
|
+
ActiveRecord::Schema.define do
|
26
|
+
create_table :resources, force: :cascade do |t|
|
27
|
+
t.string :title
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# ==== MODELS ====
|
32
|
+
class Resource < ActiveRecord::Base
|
33
|
+
end
|
34
|
+
|
35
|
+
# ==== SEEDS ====
|
36
|
+
# Create your existing records here
|
37
|
+
|
38
|
+
# ==== CONTROLLERS ====
|
39
|
+
class ResourceNamesController < ActionController::Base
|
40
|
+
layout 'application'
|
41
|
+
|
42
|
+
def new
|
43
|
+
end
|
44
|
+
|
45
|
+
def create
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# ==== IMPORT MAPS ====
|
50
|
+
UniRails.import_maps(
|
51
|
+
'stimulus' => 'https://unpkg.com/@hotwired/stimulus/dist/stimulus.js'
|
52
|
+
)
|
53
|
+
|
54
|
+
|
55
|
+
# ==== JAVASCRTIP ====
|
56
|
+
UniRails.javascript <<~JAVASCRIPT
|
57
|
+
import { Application, Controller } from "stimulus"
|
58
|
+
window.Stimulus = Application.start()
|
59
|
+
|
60
|
+
Stimulus.register("hello", class extends Controller {
|
61
|
+
connect() {
|
62
|
+
console.log("hello world")
|
63
|
+
}
|
64
|
+
})
|
65
|
+
|
66
|
+
JAVASCRIPT
|
67
|
+
|
68
|
+
# ==== CSS ====
|
69
|
+
UniRails.css <<~CSS
|
70
|
+
html { background-color:#EEE; }
|
71
|
+
body { width:500px; height:700px; margin:auto;
|
72
|
+
background-color:white; padding:1rem;
|
73
|
+
}
|
74
|
+
form {
|
75
|
+
label { display: block; }
|
76
|
+
input[type="submit"] { display: block; margin-top:1rem; }
|
77
|
+
.field_with_errors { color:red; display:inline; }
|
78
|
+
}
|
79
|
+
CSS
|
80
|
+
|
81
|
+
# ==== VIEWS ====
|
82
|
+
UniRails.register_view "resource_names/new.html.erb", <<~HTML
|
83
|
+
HTML
|
84
|
+
|
85
|
+
UniRails.register_view "resource_names/show.html.erb", <<~HTML
|
86
|
+
HTML
|
87
|
+
|
88
|
+
UniRails.run(Port: 3000)
|
data/examples/hello-world.rb
CHANGED
data/examples/server-puma-app.rb
CHANGED
@@ -0,0 +1,41 @@
|
|
1
|
+
|
2
|
+
ENV['SECRET_KEY_BASE'] = 'my_secret_key_base'
|
3
|
+
|
4
|
+
require "bundler/inline"
|
5
|
+
|
6
|
+
gemfile(true) do
|
7
|
+
source "https://rubygems.org"
|
8
|
+
gem 'uni_rails'
|
9
|
+
end
|
10
|
+
|
11
|
+
require 'uni_rails'
|
12
|
+
|
13
|
+
UniRails::App.routes.append do
|
14
|
+
root 'pages#index'
|
15
|
+
end
|
16
|
+
|
17
|
+
UniRails.import_maps(
|
18
|
+
'stimulus' => 'https://unpkg.com/@hotwired/stimulus/dist/stimulus.js'
|
19
|
+
)
|
20
|
+
|
21
|
+
UniRails.javascript <<~JAVASCRIPT
|
22
|
+
import { Application, Controller } from "stimulus"
|
23
|
+
window.Stimulus = Application.start()
|
24
|
+
|
25
|
+
Stimulus.register("hello", class extends Controller {
|
26
|
+
connect() {
|
27
|
+
console.log("hello world")
|
28
|
+
}
|
29
|
+
})
|
30
|
+
JAVASCRIPT
|
31
|
+
|
32
|
+
class PagesController < ActionController::Base
|
33
|
+
layout 'application'
|
34
|
+
def index;end
|
35
|
+
end
|
36
|
+
|
37
|
+
UniRails.register_view "pages/index.html.erb", <<~HTML
|
38
|
+
<div data-controller="hello">Check out the dev console to see "hello world"</div>
|
39
|
+
HTML
|
40
|
+
|
41
|
+
UniRails.run(Port: 3000)
|
data/examples/todos-api.rb
CHANGED
data/examples/todos-hotwire.rb
CHANGED
data/examples/todos-scaffold.rb
CHANGED
data/exe/unirails
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# require "byebug"
|
4
|
+
# byebug
|
5
|
+
|
6
|
+
assets_path = File.expand_path('../assets', __dir__)
|
7
|
+
|
8
|
+
options = {}
|
9
|
+
case ARGV[0]
|
10
|
+
when "new"
|
11
|
+
filename = ARGV[1]
|
12
|
+
File.open(filename, 'wb+') do |f|
|
13
|
+
f.write File.read File.join(assets_path, 'templates', 'default.txt')
|
14
|
+
end
|
15
|
+
else
|
16
|
+
puts "unknown command"
|
17
|
+
puts "Usage: unirails new <filename>"
|
18
|
+
end
|
data/lib/uni_rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uni_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexandre Barret
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -55,7 +55,8 @@ dependencies:
|
|
55
55
|
description:
|
56
56
|
email:
|
57
57
|
- barret.alx@gmail.com
|
58
|
-
executables:
|
58
|
+
executables:
|
59
|
+
- unirails
|
59
60
|
extensions: []
|
60
61
|
extra_rdoc_files: []
|
61
62
|
files:
|
@@ -63,12 +64,15 @@ files:
|
|
63
64
|
- LICENSE.txt
|
64
65
|
- README.md
|
65
66
|
- Rakefile
|
67
|
+
- assets/templates/default.txt
|
66
68
|
- examples/hello-world.rb
|
67
69
|
- examples/server-falcon-app.rb
|
68
70
|
- examples/server-puma-app.rb
|
71
|
+
- examples/stimulus-app.rb
|
69
72
|
- examples/todos-api.rb
|
70
73
|
- examples/todos-hotwire.rb
|
71
74
|
- examples/todos-scaffold.rb
|
75
|
+
- exe/unirails
|
72
76
|
- lib/uni_rails.rb
|
73
77
|
- lib/uni_rails/app.rb
|
74
78
|
- lib/uni_rails/app/css.rb
|