Skip to content

Commit 1259f58

Browse files
authored
Crystal v0.30.0 changes (#1126)
* Annotate return types of, and implement abstract methods * Upgrade to Crystal v0.30.0 * shard updates * Update granite to latest DSL * update specs and fix auth generator * template fixes * use compatible garnet-spec * fix specs * update version in docker file
1 parent 3465f1d commit 1259f58

12 files changed

Lines changed: 40 additions & 34 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM crystallang/crystal:0.29.0
1+
FROM crystallang/crystal:0.30.0
22

33
# Install Dependencies
44
ARG DEBIAN_FRONTEND=noninteractive

shard.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ dependencies:
1919
version: ~> 0.3.0
2020

2121
cli:
22-
github: mosop/cli
23-
version: ~> 0.7.0
22+
github: drujensen/cli
23+
version: ~> 0.8.0
2424

2525
compiled_license:
2626
github: elorest/compiled_license
@@ -32,23 +32,23 @@ dependencies:
3232

3333
liquid:
3434
github: TechMagister/liquid.cr
35-
version: ~> 0.3.0
35+
#version: ~> 0.3.0
3636

3737
micrate:
3838
github: amberframework/micrate
3939
version: ~> 0.3.3
4040

4141
pg:
4242
github: will/crystal-pg
43-
version: ~> 0.16.1
43+
version: ~> 0.18.0
4444

4545
mysql:
4646
github: crystal-lang/crystal-mysql
47-
version: ~> 0.6.0
47+
version: ~> 0.8.0
4848

4949
sqlite3:
5050
github: crystal-lang/crystal-sqlite3
51-
version: ~> 0.12.0
51+
version: ~> 0.13.0
5252

5353
redis:
5454
github: stefanwille/crystal-redis
@@ -68,7 +68,7 @@ dependencies:
6868

6969
teeplate:
7070
github: mosop/teeplate
71-
version: ~> 0.7.0
71+
version: ~> 0.8.0
7272

7373
exception_page:
7474
github: crystal-loot/exception_page

spec/amber/cli/commands/init_spec.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module Amber::CLI
2222
[camel_case, snake_case].each do |arg|
2323
MainCommand.run ["generate", "model", "-y", arg]
2424
filename = snake_case
25-
granite_table_name = "table_name #{snake_case}s"
25+
granite_table_name = "table #{snake_case}s"
2626
src_filepath = "./src/models/#{filename}.cr"
2727
spec_filepath = "./spec/models/#{filename}_spec.cr"
2828
File.exists?(src_filepath).should be_true

spec/amber/router/cookies_spec.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ module Amber::Router
4040

4141
cookies.set "that & guy", "foo & bar => baz"
4242

43-
cookie_header(cookies).should eq "that%20%26%20guy=foo%20%26%20bar%20%3D%3E%20baz; path=/"
43+
cookie_header(cookies).should eq "that+%26+guy=foo+%26+bar+%3D%3E+baz; path=/"
4444
end
4545

4646
it "sets the cookie with expiration" do

spec/support/fixtures/cli_fixtures.cr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,16 @@ module CLIFixtures
5656
def expected_post_model
5757
<<-MODEL
5858
class Post < Granite::Base
59-
adapter pg
60-
table_name posts
59+
connection pg
60+
table posts
6161
6262
belongs_to :user
6363
64-
primary id : Int64
65-
field title : String
66-
field body : String
67-
field published : Bool
68-
field likes : Int32
64+
column id : Int64, primary: true
65+
column title : String?
66+
column body : String?
67+
column published : Bool?
68+
column likes : Int32?
6969
timestamps
7070
end
7171
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require "granite/adapter/<%= @database %>"
22

3-
Granite::Adapters << Granite::Adapter::<%= @database.capitalize %>.new({name: "<%= @database %>", url: Amber.settings.database_url})
3+
Granite::Connections << Granite::Adapter::<%= @database.capitalize %>.new(name: "<%= @database %>", url: Amber.settings.database_url)
44
Granite.settings.logger = Amber.settings.logger.dup
55
Granite.settings.logger.not_nil!.progname = "Granite"

src/amber/cli/templates/app/shard.yml.ecr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ dependencies:
2323

2424
granite:
2525
github: amberframework/granite
26-
version: ~> 0.16.0
26+
version: ~> 0.17.0
2727

2828
quartz_mailer:
2929
github: amberframework/quartz-mailer
@@ -36,22 +36,22 @@ dependencies:
3636
<% case @database when "pg" -%>
3737
pg:
3838
github: will/crystal-pg
39-
version: ~> 0.16.1
39+
version: ~> 0.18.0
4040
<% when "mysql" -%>
4141
mysql:
4242
github: crystal-lang/crystal-mysql
43-
version: ~> 0.6.0
43+
version: ~> 0.8.0
4444
<% when "sqlite" -%>
4545
sqlite3:
4646
github: crystal-lang/crystal-sqlite3
47-
version: ~> 0.12.0
47+
version: ~> 0.13.0
4848
<% end -%>
4949

5050
citrine-i18n:
5151
github: amberframework/citrine-i18n
52-
version: 0.3.2
52+
version: 0.4.0
5353

5454
development_dependencies:
5555
garnet_spec:
5656
github: amberframework/garnet-spec
57-
version: ~> 0.2.1
57+
version: 0.2.1

src/amber/cli/templates/auth/src/models/{{name}}.cr.ecr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ require "crypto/bcrypt/password"
22

33
class <%= class_name %> < Granite::Base
44
include Crypto
5-
adapter <%= config.database %>
6-
<%= "table_name #{table_name}" %>
5+
connection <%= config.database %>
6+
<%= "table #{table_name}" %>
77

8-
primary id : Int64
8+
column id : Int64, primary: true
99
<% @fields.reject{|f| f.hidden }.each do |field| -%>
10-
field <%= field.name %> : <%= field.cr_type %>
10+
column <%= field.name %> : <%= field.cr_type %>?
1111
<% end -%>
1212
<% if config.database != "sqlite" -%>
1313
timestamps

src/amber/cli/templates/model/src/models/{{name}}.cr.ecr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
class <%= class_name %> < Granite::Base
2-
adapter <%= config.database %>
3-
<%= "table_name #{table_name}" %>
2+
connection <%= config.database %>
3+
<%= "table #{table_name}" %>
44
<% @fields.select{|f| f.reference? }.each do |field| %>
55
belongs_to :<%= field.name %>
66
<% end -%>
77

8-
primary id : Int64
8+
column id : Int64, primary: true
99
<% @fields.reject{|f| f.hidden || f.reference? }.each do |field| -%>
10-
field <%= field.name %> : <%= field.cr_type %>
10+
column <%= field.name %> : <%= field.cr_type %>?
1111
<% end -%>
1212
<% if config.database != "sqlite" -%>
1313
timestamps

src/amber/controller/filters.cr

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ module Amber::Controller
8080
filters[filter.precedence] << filter
8181
end
8282

83+
def each(&block : {Symbol, Array(Filter)} -> _)
84+
filters.each do |key, filter|
85+
yield({key, filter})
86+
end
87+
end
88+
8389
def run(precedence : Symbol, action : Symbol, except_action : Symbol | Nil = nil)
8490
filters[precedence].each do |filter|
8591
next if except_filter_and_has_action?(filter, except_action)

0 commit comments

Comments
 (0)