radical 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -0
  3. data/Gemfile +4 -2
  4. data/README.md +1 -1
  5. data/exe/rad +41 -0
  6. data/lib/radical/app.rb +64 -12
  7. data/lib/radical/asset.rb +24 -0
  8. data/lib/radical/asset_compiler.rb +40 -0
  9. data/lib/radical/assets.rb +45 -0
  10. data/lib/radical/controller.rb +52 -11
  11. data/lib/radical/database.rb +1 -1
  12. data/lib/radical/flash.rb +61 -0
  13. data/lib/radical/form.rb +73 -15
  14. data/lib/radical/generator/app/.env +5 -0
  15. data/lib/radical/generator/app/Gemfile +7 -0
  16. data/lib/radical/generator/app/app.rb +37 -0
  17. data/lib/radical/generator/app/config.ru +5 -0
  18. data/lib/radical/generator/app/controllers/controller.rb +4 -0
  19. data/lib/radical/generator/app/models/model.rb +4 -0
  20. data/lib/radical/generator/app/routes.rb +5 -0
  21. data/lib/radical/generator/blank_migration.rb +11 -0
  22. data/lib/radical/generator/controller.rb +59 -0
  23. data/lib/radical/generator/migration.rb +13 -0
  24. data/lib/radical/generator/model.rb +9 -0
  25. data/lib/radical/generator/views/_form.rb +6 -0
  26. data/lib/radical/generator/views/edit.rb +3 -0
  27. data/lib/radical/generator/views/index.rb +24 -0
  28. data/lib/radical/generator/views/new.rb +4 -0
  29. data/lib/radical/generator/views/show.rb +5 -0
  30. data/lib/radical/generator.rb +155 -0
  31. data/lib/radical/model.rb +1 -1
  32. data/lib/radical/router.rb +142 -43
  33. data/lib/radical/routes.rb +17 -6
  34. data/lib/radical/security_headers.rb +27 -0
  35. data/lib/radical/strings.rb +17 -0
  36. data/lib/radical/view.rb +17 -9
  37. data/lib/radical.rb +7 -0
  38. data/radical.gemspec +3 -2
  39. metadata +41 -16
data/lib/radical/view.rb CHANGED
@@ -22,20 +22,28 @@ module Radical
22
22
  class << self
23
23
  attr_accessor :_views_path, :_layout
24
24
 
25
- def view_path(dir, name)
26
- filename = File.join(@_views_path || '.', 'views', dir, "#{name}.erb")
25
+ def view_path!(dir, name)
26
+ filename = view_path(dir, name)
27
27
 
28
28
  raise "Could not find view file: #{filename}. You need to create it." unless File.exist?(filename)
29
29
 
30
30
  filename
31
31
  end
32
32
 
33
+ def view_path(dir, name)
34
+ File.join(@_views_path || '.', 'views', dir, "#{name}.erb")
35
+ end
36
+
33
37
  def template(dir, name)
34
38
  Tilt.new(view_path(dir, name), engine_class: CaptureEngine, escape_html: true)
35
39
  end
36
40
 
37
- def path(path = nil, test = Env.test?)
38
- @_views_path = path || ((test ? 'test' : '') + __dir__)
41
+ def template!(dir, name)
42
+ Tilt.new(view_path!(dir, name), engine_class: CaptureEngine, escape_html: true)
43
+ end
44
+
45
+ def path(path = nil)
46
+ @_views_path = path
39
47
  end
40
48
 
41
49
  def layout(name)
@@ -43,13 +51,13 @@ module Radical
43
51
  end
44
52
 
45
53
  def render(dir, name, scope, options = {})
46
- t = template(dir, name)
54
+ t = template!(dir, name)
47
55
 
48
- if @_layout && options[:layout] != false
49
- layout = template('', @_layout)
56
+ layout = template('', @_layout || 'layout') unless options[:layout] != false
50
57
 
51
- layout.render(scope, {}) do
52
- t.render scope
58
+ if layout
59
+ layout.render scope, {} do
60
+ t.render scope, options[:locals] || {}
53
61
  end
54
62
  else
55
63
  t.render scope
data/lib/radical.rb CHANGED
@@ -6,3 +6,10 @@ require_relative 'radical/view'
6
6
  require_relative 'radical/model'
7
7
  require_relative 'radical/migration'
8
8
  require_relative 'radical/routes'
9
+ require_relative 'radical/env'
10
+
11
+ module Radical
12
+ def self.env
13
+ Radical::Env
14
+ end
15
+ end
data/radical.gemspec CHANGED
@@ -3,7 +3,7 @@
3
3
  Gem::Specification.new do |spec|
4
4
  spec.platform = Gem::Platform::RUBY
5
5
  spec.name = 'radical'
6
- spec.version = '1.1.0'
6
+ spec.version = '1.2.0'
7
7
  spec.author = 'Sean Walker'
8
8
  spec.email = 'sean@swlkr.com'
9
9
 
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.bindir = 'exe'
30
30
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
31
  spec.require_paths = ['lib']
32
+ spec.required_ruby_version = '>= 2.7.0'
32
33
 
33
34
  spec.add_development_dependency 'minitest', '~> 5.14'
34
35
  spec.add_development_dependency 'puma', '~> 5.5'
@@ -36,10 +37,10 @@ Gem::Specification.new do |spec|
36
37
  spec.add_development_dependency 'rake', '~> 13.0'
37
38
  spec.add_development_dependency 'sorbet', '~> 0.5'
38
39
 
40
+ spec.add_dependency 'brotli', '~> 0.4'
39
41
  spec.add_dependency 'erubi', '~> 1.10'
40
42
  spec.add_dependency 'rack', '~> 2.2'
41
43
  spec.add_dependency 'rack_csrf', '~> 2.6'
42
- spec.add_dependency 'rack-flash3', '~> 1.0'
43
44
  spec.add_dependency 'sorbet-runtime', '~> 0.5'
44
45
  spec.add_dependency 'sqlite3', '~> 1.4'
45
46
  spec.add_dependency 'tilt', '~> 2.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radical
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Walker
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-07 00:00:00.000000000 Z
11
+ date: 2021-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -81,61 +81,61 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.5'
83
83
  - !ruby/object:Gem::Dependency
84
- name: erubi
84
+ name: brotli
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '1.10'
89
+ version: '0.4'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '1.10'
96
+ version: '0.4'
97
97
  - !ruby/object:Gem::Dependency
98
- name: rack
98
+ name: erubi
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '2.2'
103
+ version: '1.10'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '2.2'
110
+ version: '1.10'
111
111
  - !ruby/object:Gem::Dependency
112
- name: rack_csrf
112
+ name: rack
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '2.6'
117
+ version: '2.2'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '2.6'
124
+ version: '2.2'
125
125
  - !ruby/object:Gem::Dependency
126
- name: rack-flash3
126
+ name: rack_csrf
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '1.0'
131
+ version: '2.6'
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '1.0'
138
+ version: '2.6'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: sorbet-runtime
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -180,7 +180,8 @@ dependencies:
180
180
  version: '2.0'
181
181
  description: This gem helps you write rails-like web applications
182
182
  email: sean@swlkr.com
183
- executables: []
183
+ executables:
184
+ - rad
184
185
  extensions: []
185
186
  extra_rdoc_files: []
186
187
  files:
@@ -192,16 +193,40 @@ files:
192
193
  - LICENSE
193
194
  - README.md
194
195
  - Rakefile
196
+ - exe/rad
195
197
  - lib/radical.rb
196
198
  - lib/radical/app.rb
199
+ - lib/radical/asset.rb
200
+ - lib/radical/asset_compiler.rb
201
+ - lib/radical/assets.rb
197
202
  - lib/radical/controller.rb
198
203
  - lib/radical/database.rb
199
204
  - lib/radical/env.rb
205
+ - lib/radical/flash.rb
200
206
  - lib/radical/form.rb
207
+ - lib/radical/generator.rb
208
+ - lib/radical/generator/app/.env
209
+ - lib/radical/generator/app/Gemfile
210
+ - lib/radical/generator/app/app.rb
211
+ - lib/radical/generator/app/config.ru
212
+ - lib/radical/generator/app/controllers/controller.rb
213
+ - lib/radical/generator/app/models/model.rb
214
+ - lib/radical/generator/app/routes.rb
215
+ - lib/radical/generator/blank_migration.rb
216
+ - lib/radical/generator/controller.rb
217
+ - lib/radical/generator/migration.rb
218
+ - lib/radical/generator/model.rb
219
+ - lib/radical/generator/views/_form.rb
220
+ - lib/radical/generator/views/edit.rb
221
+ - lib/radical/generator/views/index.rb
222
+ - lib/radical/generator/views/new.rb
223
+ - lib/radical/generator/views/show.rb
201
224
  - lib/radical/migration.rb
202
225
  - lib/radical/model.rb
203
226
  - lib/radical/router.rb
204
227
  - lib/radical/routes.rb
228
+ - lib/radical/security_headers.rb
229
+ - lib/radical/strings.rb
205
230
  - lib/radical/table.rb
206
231
  - lib/radical/view.rb
207
232
  - radical.gemspec
@@ -223,7 +248,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
223
248
  requirements:
224
249
  - - ">="
225
250
  - !ruby/object:Gem::Version
226
- version: '0'
251
+ version: 2.7.0
227
252
  required_rubygems_version: !ruby/object:Gem::Requirement
228
253
  requirements:
229
254
  - - ">="