yescode 1.0.0 → 1.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 +4 -4
- data/.gitattributes +2 -0
- data/exe/yescode +27 -3
- data/lib/yes_mail.rb +34 -25
- data/lib/yes_record.rb +2 -2
- data/lib/yes_routes.rb +12 -10
- data/lib/yes_view.rb +2 -2
- data/lib/yescode/database.rb +4 -0
- data/lib/yescode/emote.rb +0 -2
- data/lib/yescode/generator.rb +225 -15
- data/lib/yescode/request_cache/middleware.rb +23 -0
- data/lib/yescode/request_cache.rb +20 -0
- data/lib/yescode/router.rb +0 -2
- data/lib/yescode/strings.rb +19 -12
- data/lib/yescode/version.rb +5 -0
- data/lib/yescode.rb +22 -22
- data/yescode.gemspec +2 -2
- metadata +4 -3
- data/lib/yescode/refinements.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bba722061e9892e11115b24728699e0ce482589d2c487c4771238f4e3b843d6a
|
4
|
+
data.tar.gz: 44412a17dc90765b1957ca598cbbe72555b595b35eefb6994445c00b8d30bd0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a44dc51208d7e1332c67c595269e7d59ff816135fbbde13ec9fd2a0e863b323b22c0477660f79edce60fa9c7ac8660a0bdfbbbbc3640e2961c55bfb13adf61c5
|
7
|
+
data.tar.gz: de2ba9836e599de6b60a8aaee5d1e155a173f7ba3734e2661bf8357f47bf24c9d22bd36af3f6418a52fc36d277594c4efb14fe9a99713bc092837df4b9131018
|
data/.gitattributes
ADDED
data/exe/yescode
CHANGED
@@ -1,16 +1,40 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
3
5
|
require "yescode"
|
4
6
|
|
7
|
+
HELP_MESSAGE = <<~TXT
|
8
|
+
Usage: yescode <command> [options]
|
9
|
+
|
10
|
+
Supported yescode commands:
|
11
|
+
generate Generate new code (aliases: g, gen)
|
12
|
+
migrate Migrates the database with up sql in ./db/migrations/*.sql
|
13
|
+
rollback Rolls the database back with down sql in ./db/migrations/*.sql
|
14
|
+
|
15
|
+
new Create a new Yescode application
|
16
|
+
|
17
|
+
Example:
|
18
|
+
yescode new my_app
|
19
|
+
|
20
|
+
This will create a new application in ./my_app
|
21
|
+
TXT
|
22
|
+
|
5
23
|
command, *args = ARGV
|
6
24
|
|
7
25
|
case command
|
8
26
|
when "g", "gen", "generate"
|
9
27
|
Yescode::Generator.generate(*args)
|
28
|
+
when "new"
|
29
|
+
Yescode::Generator.generate_app(args[0])
|
10
30
|
when "migrate"
|
11
|
-
Yescode::Database.migrate
|
31
|
+
Yescode::Database.migrate("db/migrations")
|
12
32
|
when "rollback"
|
13
|
-
Yescode::Database.
|
33
|
+
Yescode::Database.rollback_schema("db/migrations", step: args[0])
|
34
|
+
when "-v", "--version"
|
35
|
+
puts Yescode::VERSION
|
36
|
+
when "-h", "--help"
|
37
|
+
puts HELP_MESSAGE
|
14
38
|
else
|
15
|
-
puts
|
39
|
+
puts HELP_MESSAGE
|
16
40
|
end
|
data/lib/yes_mail.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
Mail.defaults do
|
2
|
-
delivery_method :logger, logger: Logger.new($stdout) if Yescode.env.development?
|
4
|
+
delivery_method :logger, logger: Logger.new($stdout) if Yescode.env.development? || Yescode.env.test?
|
3
5
|
end
|
4
6
|
|
5
7
|
class YesMail
|
6
|
-
|
8
|
+
extend Yescode::Strings
|
7
9
|
include Emote::Helpers
|
8
10
|
|
9
11
|
class << self
|
@@ -44,29 +46,7 @@ class YesMail
|
|
44
46
|
end
|
45
47
|
|
46
48
|
def mail(from: nil, to: nil, subject: nil)
|
47
|
-
|
48
|
-
mail[:from] = from || self.class._from
|
49
|
-
mail[:to] = to
|
50
|
-
mail[:subject] = subject
|
51
|
-
|
52
|
-
default_name = self.class.to_s.snake_case
|
53
|
-
|
54
|
-
text = part(self.class._text_view || "#{default_name}.text.emote")
|
55
|
-
html = part(self.class._html_view || "#{default_name}.html.emote")
|
56
|
-
|
57
|
-
text_part = Mail::Part.new do
|
58
|
-
body text
|
59
|
-
end
|
60
|
-
|
61
|
-
html_part = Mail::Part.new do
|
62
|
-
content_type "text/html; charset=UTF-8"
|
63
|
-
body html
|
64
|
-
end
|
65
|
-
|
66
|
-
mail.text_part = text_part
|
67
|
-
mail.html_part = html_part
|
68
|
-
|
69
|
-
mail.deliver
|
49
|
+
new_mail(from:, to:, subject:).deliver
|
70
50
|
end
|
71
51
|
|
72
52
|
private
|
@@ -79,10 +59,39 @@ class YesMail
|
|
79
59
|
content = template(name)
|
80
60
|
layout = template(self.class._layout || "layout")
|
81
61
|
|
62
|
+
return unless File.exist?(layout) || File.exist?(content)
|
63
|
+
|
82
64
|
if File.exist?(layout)
|
83
65
|
emote(layout, { content: })
|
84
66
|
else
|
85
67
|
emote(content)
|
86
68
|
end
|
87
69
|
end
|
70
|
+
|
71
|
+
def new_mail(from:, to:, subject:)
|
72
|
+
mail = Mail.new
|
73
|
+
mail[:from] = from || self.class._from
|
74
|
+
mail[:to] = to
|
75
|
+
mail[:subject] = subject
|
76
|
+
|
77
|
+
filename = self.class.filename
|
78
|
+
|
79
|
+
text = part(self.class._text_view || "#{filename}.text.emote")
|
80
|
+
html = part(self.class._html_view || "#{filename}.html.emote")
|
81
|
+
|
82
|
+
if text
|
83
|
+
mail.text_part = Mail::Part.new do
|
84
|
+
body text
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
if html
|
89
|
+
mail.html_part = Mail::Part.new do
|
90
|
+
content_type "text/html; charset=UTF-8"
|
91
|
+
body html
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
mail
|
96
|
+
end
|
88
97
|
end
|
data/lib/yes_record.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class YesRecord
|
4
|
-
|
4
|
+
extend Yescode::Strings
|
5
5
|
|
6
6
|
class QueryNotFound < StandardError; end
|
7
7
|
class RecordNotFound < StandardError; end
|
@@ -12,7 +12,7 @@ class YesRecord
|
|
12
12
|
attr_writer :table_name
|
13
13
|
|
14
14
|
def table_name
|
15
|
-
@table_name ||
|
15
|
+
@table_name || filename
|
16
16
|
end
|
17
17
|
|
18
18
|
def table(name)
|
data/lib/yes_routes.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class YesRoutes
|
4
|
-
using Refinements
|
5
4
|
class RouteDoesNotExistError < StandardError; end
|
6
5
|
class RouteParamsNilError < StandardError; end
|
7
6
|
|
@@ -37,17 +36,16 @@ class YesRoutes
|
|
37
36
|
end
|
38
37
|
|
39
38
|
def resource(path_string, class_name)
|
40
|
-
snake_case = class_name.snake_case
|
41
39
|
[
|
42
|
-
[
|
43
|
-
[
|
44
|
-
[
|
45
|
-
[
|
46
|
-
[
|
47
|
-
[
|
48
|
-
[
|
40
|
+
["GET", :index, ""],
|
41
|
+
["GET", :new, "/new"],
|
42
|
+
["POST", :create, "/new"],
|
43
|
+
["GET", :show, "/:id"],
|
44
|
+
["GET", :edit, "/:id/edit"],
|
45
|
+
["POST", :update, "/:id/edit"],
|
46
|
+
["POST", :delete, "/:id/delete"]
|
49
47
|
].each do |method, method_name, suffix|
|
50
|
-
|
48
|
+
match(method, full_path(path_string, suffix), class_name, method_name)
|
51
49
|
end
|
52
50
|
end
|
53
51
|
|
@@ -60,5 +58,9 @@ class YesRoutes
|
|
60
58
|
|
61
59
|
path.gsub(re, params)
|
62
60
|
end
|
61
|
+
|
62
|
+
def full_path(prefix, suffix)
|
63
|
+
"#{prefix}/#{suffix}".gsub(%r{/+}, "/").chomp("/")
|
64
|
+
end
|
63
65
|
end
|
64
66
|
end
|
data/lib/yes_view.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class YesView
|
4
|
-
|
4
|
+
extend Yescode::Strings
|
5
5
|
include Emote::Helpers
|
6
6
|
|
7
7
|
class << self
|
@@ -25,7 +25,7 @@ class YesView
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def template_name
|
28
|
-
@template_name || "#{
|
28
|
+
@template_name || "#{filename}.emote"
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
data/lib/yescode/database.rb
CHANGED
@@ -19,6 +19,8 @@ module Yescode
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def migrate(filenames)
|
22
|
+
return unless connection_string
|
23
|
+
|
22
24
|
execute "create table if not exists yescode_migrations ( version integer primary key )"
|
23
25
|
rows = execute("select version from yescode_migrations").map { |r| r["version"] }
|
24
26
|
file_versions = filenames.map { |f| version(f) }
|
@@ -38,6 +40,8 @@ module Yescode
|
|
38
40
|
end
|
39
41
|
|
40
42
|
def rollback_schema(filenames, step: 1)
|
43
|
+
return unless connection_string
|
44
|
+
|
41
45
|
execute "create table if not exists yescode_migrations ( version integer primary key )"
|
42
46
|
rows = execute("select version from yescode_migrations order by version desc limit #{step}").map { |r| r["version"] }
|
43
47
|
|
data/lib/yescode/emote.rb
CHANGED
data/lib/yescode/generator.rb
CHANGED
@@ -5,10 +5,169 @@ require "securerandom"
|
|
5
5
|
|
6
6
|
module Yescode
|
7
7
|
class Generator
|
8
|
-
|
8
|
+
extend Strings
|
9
|
+
|
9
10
|
VIEW_DIR = File.join(".", "app", "views")
|
10
11
|
|
11
|
-
|
12
|
+
APP_HELP_MESSAGE = <<~TXT
|
13
|
+
Usage: yescode new [name]
|
14
|
+
|
15
|
+
Create a new Yescode application
|
16
|
+
|
17
|
+
Example:
|
18
|
+
yescode new todos
|
19
|
+
|
20
|
+
This will generate a new Yescode application in ./todos
|
21
|
+
TXT
|
22
|
+
|
23
|
+
CONTROLLER_HELP_MESSAGE = <<~TXT
|
24
|
+
Usage: yescode generate controller [name]
|
25
|
+
|
26
|
+
Create a new controller with all available actions
|
27
|
+
|
28
|
+
Example:
|
29
|
+
yescode generate controller todos
|
30
|
+
|
31
|
+
This will generate a controller named Todos in ./app/controllers/todos.rb
|
32
|
+
TXT
|
33
|
+
|
34
|
+
MIGRATION_HELP_MESSAGE = <<~TXT
|
35
|
+
Usage: yescode generate migration [name]
|
36
|
+
|
37
|
+
Create a new migration with -- up and -- down placeholders in ./db/migrations/[timestamp]_[migration name].sql
|
38
|
+
|
39
|
+
Example:
|
40
|
+
yescode generate migration create_table_todo
|
41
|
+
|
42
|
+
This will generate a common create table sql statement below -- up and a drop table below -- down
|
43
|
+
|
44
|
+
|
45
|
+
Example:
|
46
|
+
yescode generate migration add_created_at_to_todo
|
47
|
+
|
48
|
+
This will generate an empty sql file with -- up and -- down placeholders
|
49
|
+
TXT
|
50
|
+
|
51
|
+
MODEL_HELP_MESSAGE = <<~TXT
|
52
|
+
Usage: yescode generate model [name]
|
53
|
+
|
54
|
+
Create a new model
|
55
|
+
|
56
|
+
Example:
|
57
|
+
yescode generate model todo
|
58
|
+
|
59
|
+
This will generate a model named Todo in ./app/models/todo.rb
|
60
|
+
TXT
|
61
|
+
|
62
|
+
MVC_HELP_MESSAGE = <<~TXT
|
63
|
+
Usage: yescode generate mvc [name]
|
64
|
+
|
65
|
+
Create a new model, common views and controller all at once
|
66
|
+
|
67
|
+
Example:
|
68
|
+
yescode generate mvc todo
|
69
|
+
|
70
|
+
This will generate a model, common sql queries, views and controller:
|
71
|
+
|
72
|
+
- ./app/models/todo.rb
|
73
|
+
- ./app/models/todo.sql
|
74
|
+
- ./app/controllers/todos.rb
|
75
|
+
- ./app/views/todos_edit.rb
|
76
|
+
- ./app/views/todos_edit.emote
|
77
|
+
- ./app/views/todos_index.rb
|
78
|
+
- ./app/views/todos_index.emote
|
79
|
+
- ./app/views/todos_new.rb
|
80
|
+
- ./app/views/todos_new.emote
|
81
|
+
- ./app/views/todos_show.rb
|
82
|
+
- ./app/views/todos_show.emote
|
83
|
+
TXT
|
84
|
+
|
85
|
+
QUERIES_HELP_MESSAGE = <<~TXT
|
86
|
+
Usage: yescode generate queries [name]
|
87
|
+
|
88
|
+
Create common sql queries for a given table
|
89
|
+
|
90
|
+
Example:
|
91
|
+
yescode generate queries todo
|
92
|
+
|
93
|
+
This will generate common sql queries in ./app/models/todo.sql
|
94
|
+
TXT
|
95
|
+
|
96
|
+
TEMPLATE_HELP_MESSAGE = <<~TXT
|
97
|
+
Usage: yescode generate template [name]
|
98
|
+
|
99
|
+
Create a template file
|
100
|
+
|
101
|
+
Example:
|
102
|
+
yescode generate template todos_index
|
103
|
+
|
104
|
+
This will generate ./app/views/todos_index.emote
|
105
|
+
TXT
|
106
|
+
|
107
|
+
TEMPLATES_HELP_MESSAGE = <<~TXT
|
108
|
+
Usage: yescode generate templates [name]
|
109
|
+
|
110
|
+
Create common templates for a given controller
|
111
|
+
|
112
|
+
Example:
|
113
|
+
yescode generate templates todos
|
114
|
+
|
115
|
+
This will generate the following templates
|
116
|
+
- ./app/views/todos_edit.emote
|
117
|
+
- ./app/views/todos_index.emote
|
118
|
+
- ./app/views/todos_new.emote
|
119
|
+
- ./app/views/todos_show.emote
|
120
|
+
- ./app/views/todos_form.emote
|
121
|
+
TXT
|
122
|
+
|
123
|
+
VIEW_HELP_MESSAGE = <<~TXT
|
124
|
+
Usage: yescode generate view [name]
|
125
|
+
|
126
|
+
Create the view and template
|
127
|
+
|
128
|
+
Example:
|
129
|
+
yescode generate view todos_index
|
130
|
+
|
131
|
+
This will generate the following view and template:
|
132
|
+
- ./app/views/todos_index.rb
|
133
|
+
- ./app/views/todos_index.emote
|
134
|
+
TXT
|
135
|
+
|
136
|
+
VIEWS_HELP_MESSAGE = <<~TXT
|
137
|
+
Usage: yescode generate views [name]
|
138
|
+
|
139
|
+
Create common views and templates for a given controller
|
140
|
+
|
141
|
+
Example:
|
142
|
+
yescode generate views todos
|
143
|
+
|
144
|
+
This will generate the following views and templates
|
145
|
+
- ./app/views/todos_edit.rb
|
146
|
+
- ./app/views/todos_edit.emote
|
147
|
+
- ./app/views/todos_index.rb
|
148
|
+
- ./app/views/todos_index.emote
|
149
|
+
- ./app/views/todos_new.rb
|
150
|
+
- ./app/views/todos_new.emote
|
151
|
+
- ./app/views/todos_show.rb
|
152
|
+
- ./app/views/todos_show.emote
|
153
|
+
- ./app/views/todos_form.rb
|
154
|
+
- ./app/views/todos_form.emote
|
155
|
+
TXT
|
156
|
+
|
157
|
+
HELP_MESSAGE = <<~TXT
|
158
|
+
Usage: yescode generate GENERATOR [options]
|
159
|
+
|
160
|
+
Supported yescode generators:
|
161
|
+
controller Create a new controller with all available actions
|
162
|
+
migration Create a new migration
|
163
|
+
model Create a new model
|
164
|
+
mvc Create a new model, views and controller all at once
|
165
|
+
queries Create common sql queries for a given table
|
166
|
+
template Create just a template file
|
167
|
+
templates Create just the templates for a given controller
|
168
|
+
view Create the view and template
|
169
|
+
views Create common views and templates for a given controller
|
170
|
+
TXT
|
12
171
|
|
13
172
|
class << self
|
14
173
|
def generate(*gen_args)
|
@@ -27,6 +186,8 @@ module Yescode
|
|
27
186
|
generate_views(*args)
|
28
187
|
when "template"
|
29
188
|
generate_template(*args)
|
189
|
+
when "templates"
|
190
|
+
generate_templates(*args)
|
30
191
|
when "migration"
|
31
192
|
generate_migration(*args)
|
32
193
|
when "mvc"
|
@@ -34,11 +195,16 @@ module Yescode
|
|
34
195
|
when "app"
|
35
196
|
generate_app(*args)
|
36
197
|
else
|
37
|
-
puts
|
198
|
+
puts HELP_MESSAGE
|
38
199
|
end
|
39
200
|
end
|
40
201
|
|
41
|
-
def generate_app(dir)
|
202
|
+
def generate_app(dir = nil)
|
203
|
+
if dir.nil?
|
204
|
+
puts APP_HELP_MESSAGE
|
205
|
+
return
|
206
|
+
end
|
207
|
+
|
42
208
|
FileUtils.mkdir_p(File.join(".", dir))
|
43
209
|
{
|
44
210
|
"public" => %w[css js],
|
@@ -281,13 +447,23 @@ module Yescode
|
|
281
447
|
# app.rb
|
282
448
|
end
|
283
449
|
|
284
|
-
def generate_mvc(filename)
|
450
|
+
def generate_mvc(filename = nil)
|
451
|
+
if filename.nil?
|
452
|
+
puts MVC_HELP_MESSAGE
|
453
|
+
return
|
454
|
+
end
|
455
|
+
|
285
456
|
generate_model(filename)
|
286
457
|
generate_controller(filename)
|
287
458
|
generate_views(filename)
|
288
459
|
end
|
289
460
|
|
290
|
-
def generate_queries(filename)
|
461
|
+
def generate_queries(filename = nil)
|
462
|
+
if filename.nil?
|
463
|
+
puts QUERIES_HELP_MESSAGE
|
464
|
+
return
|
465
|
+
end
|
466
|
+
|
291
467
|
filepath = File.join(".", "app", "models", "#{filename}.sql")
|
292
468
|
contents = <<~SQL
|
293
469
|
-- name: all
|
@@ -324,9 +500,14 @@ module Yescode
|
|
324
500
|
File.write(filepath, contents)
|
325
501
|
end
|
326
502
|
|
327
|
-
def generate_model(filename)
|
503
|
+
def generate_model(filename = nil)
|
504
|
+
if filename.nil?
|
505
|
+
puts MODEL_HELP_MESSAGE
|
506
|
+
return
|
507
|
+
end
|
508
|
+
|
328
509
|
filepath = File.join(".", "app", "models", "#{filename}.rb")
|
329
|
-
class_name = filename
|
510
|
+
class_name = pascal_case(filename)
|
330
511
|
contents = <<~RB
|
331
512
|
class #{class_name} < AppRecord
|
332
513
|
queries "#{filename}.sql"
|
@@ -338,8 +519,13 @@ module Yescode
|
|
338
519
|
generate_queries(filename)
|
339
520
|
end
|
340
521
|
|
341
|
-
def generate_controller(filename)
|
342
|
-
|
522
|
+
def generate_controller(filename = nil)
|
523
|
+
if filename.nil?
|
524
|
+
puts CONTROLLER_HELP_MESSAGE
|
525
|
+
return
|
526
|
+
end
|
527
|
+
|
528
|
+
class_name = pascal_case(filename)
|
343
529
|
var_name = filename
|
344
530
|
route = <<~RB
|
345
531
|
class #{class_name} < AppController
|
@@ -412,8 +598,13 @@ module Yescode
|
|
412
598
|
File.write routes_filename, routes_file
|
413
599
|
end
|
414
600
|
|
415
|
-
def generate_view(filename, accessors = [])
|
416
|
-
|
601
|
+
def generate_view(filename = nil, accessors = [])
|
602
|
+
if filename.nil?
|
603
|
+
puts VIEW_HELP_MESSAGE
|
604
|
+
return
|
605
|
+
end
|
606
|
+
|
607
|
+
class_name = pascal_case(filename)
|
417
608
|
filepath = File.join(VIEW_DIR, "#{filename}.rb")
|
418
609
|
|
419
610
|
return if File.exist?(filepath)
|
@@ -434,12 +625,22 @@ module Yescode
|
|
434
625
|
end
|
435
626
|
|
436
627
|
def generate_views(prefix)
|
628
|
+
if prefix.nil?
|
629
|
+
puts VIEWS_HELP_MESSAGE
|
630
|
+
return
|
631
|
+
end
|
632
|
+
|
437
633
|
%w[new show edit index].each do |suffix|
|
438
634
|
generate_view("#{prefix}_#{suffix}", [])
|
439
635
|
end
|
440
636
|
end
|
441
637
|
|
442
|
-
def generate_template(filename)
|
638
|
+
def generate_template(filename = nil)
|
639
|
+
if filename.nil?
|
640
|
+
puts TEMPLATE_HELP_MESSAGE
|
641
|
+
return
|
642
|
+
end
|
643
|
+
|
443
644
|
filename = File.join(VIEW_DIR, "#{filename}.emote")
|
444
645
|
|
445
646
|
return if File.exist?(filename)
|
@@ -447,13 +648,22 @@ module Yescode
|
|
447
648
|
File.write(filename, "<div></div>")
|
448
649
|
end
|
449
650
|
|
450
|
-
def generate_templates(prefix)
|
651
|
+
def generate_templates(prefix = nil)
|
652
|
+
if prefix.nil?
|
653
|
+
puts TEMPLATES_HELP_MESSAGE
|
654
|
+
return
|
655
|
+
end
|
656
|
+
|
451
657
|
%w[index new edit show form].each do |page|
|
452
658
|
generate_template("#{prefix}_#{page}")
|
453
659
|
end
|
454
660
|
end
|
455
661
|
|
456
|
-
def generate_migration(filename, columns = [])
|
662
|
+
def generate_migration(filename = nil, columns = [])
|
663
|
+
if filename.nil?
|
664
|
+
puts MIGRATION_HELP_MESSAGE
|
665
|
+
return
|
666
|
+
end
|
457
667
|
table_name = filename.split('_').last
|
458
668
|
column_string = columns.map do |c|
|
459
669
|
name, type = c.split(':')
|
@@ -1,3 +1,26 @@
|
|
1
|
+
# Copyright (c) 2012 Steve Klabnik
|
2
|
+
#
|
3
|
+
# MIT License
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
# a copy of this software and associated documentation files (the
|
7
|
+
# "Software"), to deal in the Software without restriction, including
|
8
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
# the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
1
24
|
module Yescode
|
2
25
|
module RequestCache
|
3
26
|
class Middleware
|
@@ -1,3 +1,23 @@
|
|
1
|
+
# Copyright (c) 2012 Steve Klabnik
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
1
21
|
module Yescode
|
2
22
|
module RequestCache
|
3
23
|
def self.store
|
data/lib/yescode/router.rb
CHANGED
data/lib/yescode/strings.rb
CHANGED
@@ -1,23 +1,30 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Yescode
|
4
|
-
|
4
|
+
module Strings
|
5
5
|
SNAKE_CASE_REGEX = /\B([A-Z])/
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
def snake_case(str)
|
8
|
+
str.gsub(SNAKE_CASE_REGEX, '_\1').downcase
|
9
|
+
end
|
10
|
+
|
11
|
+
def camel_case(str)
|
12
|
+
result = pascal_case(str)
|
13
|
+
result[0] = result[0].downcase
|
14
|
+
|
15
|
+
result
|
16
|
+
end
|
11
17
|
|
12
|
-
|
13
|
-
|
18
|
+
def pascal_case(str)
|
19
|
+
str.split("_").map(&:capitalize).join
|
20
|
+
end
|
14
21
|
|
15
|
-
|
16
|
-
|
22
|
+
def class_name
|
23
|
+
to_s.split("::").last
|
24
|
+
end
|
17
25
|
|
18
|
-
|
19
|
-
|
20
|
-
end
|
26
|
+
def filename
|
27
|
+
snake_case(class_name)
|
21
28
|
end
|
22
29
|
end
|
23
30
|
end
|
data/lib/yescode.rb
CHANGED
@@ -9,29 +9,29 @@ require "rack/csrf"
|
|
9
9
|
require "stringio"
|
10
10
|
require "sqlite3"
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
12
|
+
require_relative "./yescode/request_cache"
|
13
|
+
require_relative "./yescode/request_cache/middleware"
|
14
|
+
require_relative "./yescode/emote"
|
15
|
+
require_relative "./yescode/strings"
|
16
|
+
require_relative "./yescode/env"
|
17
|
+
require_relative "./yescode/logfmt_formatter"
|
18
|
+
require_relative "./yescode/router"
|
19
|
+
require_relative "./yescode/database"
|
20
|
+
require_relative "./yescode/queries"
|
21
|
+
require_relative "./yescode/assets"
|
22
|
+
require_relative "./yescode/asset_compiler"
|
23
|
+
require_relative "./yescode/generator"
|
24
|
+
require_relative "./yescode/version"
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
26
|
+
require_relative "./yes_static"
|
27
|
+
require_relative "./yes_logger"
|
28
|
+
require_relative "./yes_rack_logger"
|
29
|
+
require_relative "./yes_routes"
|
30
|
+
require_relative "./yes_controller"
|
31
|
+
require_relative "./yes_view"
|
32
|
+
require_relative "./yes_record"
|
33
|
+
require_relative "./yes_mail"
|
34
|
+
require_relative "./yes_app"
|
35
35
|
|
36
36
|
def require_all(paths)
|
37
37
|
paths.each do |path|
|
data/yescode.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
|
1
|
+
require_relative "./lib/yescode/version"
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.platform = Gem::Platform::RUBY
|
5
5
|
spec.name = "yescode"
|
6
|
-
spec.version =
|
6
|
+
spec.version = Yescode::VERSION
|
7
7
|
spec.author = "Sean Walker"
|
8
8
|
spec.email = "sean@swlkr.com"
|
9
9
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yescode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.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: 2022-05-
|
11
|
+
date: 2022-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -101,6 +101,7 @@ executables:
|
|
101
101
|
extensions: []
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
|
+
- ".gitattributes"
|
104
105
|
- CHANGELOG.md
|
105
106
|
- Dockerfile
|
106
107
|
- Gemfile
|
@@ -126,11 +127,11 @@ files:
|
|
126
127
|
- lib/yescode/generator.rb
|
127
128
|
- lib/yescode/logfmt_formatter.rb
|
128
129
|
- lib/yescode/queries.rb
|
129
|
-
- lib/yescode/refinements.rb
|
130
130
|
- lib/yescode/request_cache.rb
|
131
131
|
- lib/yescode/request_cache/middleware.rb
|
132
132
|
- lib/yescode/router.rb
|
133
133
|
- lib/yescode/strings.rb
|
134
|
+
- lib/yescode/version.rb
|
134
135
|
- yescode.gemspec
|
135
136
|
homepage: https://github.com/swlkr/yescode
|
136
137
|
licenses:
|
data/lib/yescode/refinements.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
module Refinements
|
2
|
-
SNAKE_CASE_REGEX = /\B([A-Z])/
|
3
|
-
|
4
|
-
refine String do
|
5
|
-
def snake_case
|
6
|
-
gsub(SNAKE_CASE_REGEX, '_\1').downcase
|
7
|
-
end
|
8
|
-
|
9
|
-
def camel_case
|
10
|
-
first, *rest = split("_")
|
11
|
-
|
12
|
-
"#{first}#{rest.map(&:capitalize).join}"
|
13
|
-
end
|
14
|
-
|
15
|
-
def pascal_case
|
16
|
-
split("_").map(&:capitalize).join
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|