railz_lite 0.2.1 → 0.2.2
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/lib/railz_lite/cli.rb +0 -1
- data/lib/railz_lite/controllers/controller_base.rb +20 -4
- data/lib/railz_lite/generators/project.rb +3 -1
- data/lib/railz_lite/generators/templates/application.html.erb +10 -0
- data/lib/railz_lite/models/db_connection.rb +2 -1
- data/lib/railz_lite/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c174580952b1c2956cf1d6bdbe7fbc0c7991a8b4401c98d63d3d3a9718ab4319
|
4
|
+
data.tar.gz: 3e32d2b2cc43e7ed406095e6934798e3c5fbafbe55f4965e3f08b732932d92ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dca26645dca90b0a88e43ff6790083c7df11d1cff5b1b880d832156d1675e71f50e5310d2e01815b83b6f93c75f38a9c36b0b3e4ea21225e855d40b677647bfb
|
7
|
+
data.tar.gz: 6b682f976740cc0b9127bd7673fd520c7cbff38392aa54c3c7079bc5f1dc14274f452cefa3f6fdaf4388e317f73b9b97cc8b8f773c9e92499ba8e03ff0f5b93c
|
data/lib/railz_lite/cli.rb
CHANGED
@@ -5,6 +5,9 @@ require_relative './session'
|
|
5
5
|
require_relative './flash'
|
6
6
|
|
7
7
|
module RailzLite
|
8
|
+
class LayoutRenderer # dummy class used to pass yield blocks into ERB method results https://hostiledeveloper.com/2015/05/28/working-with-templates-in-ruby-erb.html
|
9
|
+
end
|
10
|
+
|
8
11
|
class ControllerBase
|
9
12
|
attr_reader :req, :res, :params
|
10
13
|
|
@@ -46,10 +49,23 @@ module RailzLite
|
|
46
49
|
# pass the rendered html to render_content
|
47
50
|
def render(template_name)
|
48
51
|
dir_path = Dir.pwd
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
52
|
+
|
53
|
+
layout_path = File.join(dir_path, 'views', 'application', 'application.html.erb')
|
54
|
+
inner_file_path = File.join(dir_path, 'views', "#{self.class.name.underscore.split('_controller').first}", "#{template_name.to_s}.html.erb")
|
55
|
+
|
56
|
+
layout_template = File.read(layout_path)
|
57
|
+
inner_template = File.read(inner_file_path)
|
58
|
+
|
59
|
+
layout = ERB.new(layout_template)
|
60
|
+
inner = ERB.new(inner_template)
|
61
|
+
|
62
|
+
layout.def_method(LayoutRenderer, 'render') # dummy method used so that blocks can be passed to ERB result
|
63
|
+
|
64
|
+
result = LayoutRenderer.new.render do
|
65
|
+
inner.result(binding)
|
66
|
+
end
|
67
|
+
|
68
|
+
render_content(result, 'text/html')
|
53
69
|
end
|
54
70
|
|
55
71
|
# method exposing a `Session` object
|
@@ -26,8 +26,10 @@ module RailzLite
|
|
26
26
|
template('server.rb', "#{project_name}/config/server.rb")
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
29
|
+
def setup_views
|
30
30
|
template('welcome_view.index.html.erb', "#{project_name}/views/welcome/index.html.erb")
|
31
|
+
template('application.html.erb', "#{project_name}/views/application/application.html.erb")
|
32
|
+
create_file("#{project_name}/views/application/application.css")
|
31
33
|
end
|
32
34
|
|
33
35
|
def add_public
|
@@ -7,6 +7,7 @@ class DBConnection
|
|
7
7
|
DB_FILE = File.join(ROOT_FOLDER, 'db', 'app.db')
|
8
8
|
|
9
9
|
def self.start
|
10
|
+
`sqlite3 #{DB_FILE}`
|
10
11
|
DBConnection.open(DB_FILE)
|
11
12
|
end
|
12
13
|
|
@@ -29,7 +30,7 @@ class DBConnection
|
|
29
30
|
end
|
30
31
|
|
31
32
|
def self.instance
|
32
|
-
|
33
|
+
start if @db.nil?
|
33
34
|
|
34
35
|
@db
|
35
36
|
end
|
data/lib/railz_lite/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: railz_lite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bryan lynch
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -166,6 +166,7 @@ files:
|
|
166
166
|
- lib/railz_lite/controllers/templates/rescue.html.erb
|
167
167
|
- lib/railz_lite/generators/project.rb
|
168
168
|
- lib/railz_lite/generators/project.rb~
|
169
|
+
- lib/railz_lite/generators/templates/application.html.erb
|
169
170
|
- lib/railz_lite/generators/templates/application_controller.rb~
|
170
171
|
- lib/railz_lite/generators/templates/server.rb
|
171
172
|
- lib/railz_lite/generators/templates/welcome_view.index.html.erb
|