Skip to content

Commit b20ac7b

Browse files
vlazarmichaelhixson
authored andcommitted
Update Crystal and frameworks (#4020)
* Update Crystal and frameworks * Generate Date header using HTTP.format_time Not only it is more idiomatic, but faster as well: Time.utc_now.to_s("%a, %d %b %Y %H:%M:%S GMT") 689.84k ( 1.45µs) (± 1.35%) 242 B/op 1.37× slower HTTP.format_time(Time.now) 941.75k ( 1.06µs) (± 1.83%) 242 B/op fastest * Remove unnecessary X-Powered-By: Kemal
1 parent 87c778d commit b20ac7b

23 files changed

+95
-72
lines changed

frameworks/Crystal/amber/amber.dockerfile

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

33
WORKDIR /amber
44
COPY config config
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
require "granite_orm/adapter/pg"
1+
require "granite/adapter/pg"
22

3-
Granite::ORM.settings.logger = Logger.new(nil)
3+
Granite.settings.logger = Logger.new(nil)
4+
Granite::Adapters << Granite::Adapter::Pg.new({name: "pg", url: ENV["DATABASE_URL"]})

frameworks/Crystal/amber/shard.lock

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,73 +2,85 @@ version: 1.0
22
shards:
33
amber:
44
github: amberframework/amber
5-
version: 0.6.7
5+
version: 0.9.0
6+
7+
amber_router:
8+
github: amberframework/amber-router
9+
version: 0.2.0
610

711
callback:
812
github: mosop/callback
913
version: 0.6.3
1014

1115
cli:
12-
github: amberframework/cli
16+
github: mosop/cli
1317
version: 0.7.0
1418

19+
compiled_license:
20+
github: elorest/compiled_license
21+
version: 0.1.3
22+
1523
db:
1624
github: crystal-lang/crystal-db
1725
version: 0.5.0
1826

19-
granite_orm:
20-
github: amberframework/granite-orm
21-
version: 0.8.4
27+
granite:
28+
github: amberframework/granite
29+
version: 0.13.1
30+
31+
inflector:
32+
github: phoffer/inflector.cr
33+
version: 0.1.8
2234

2335
kilt:
2436
github: jeromegn/kilt
2537
version: 0.4.0
2638

27-
micrate:
28-
github: juanedi/micrate
39+
liquid:
40+
github: TechMagister/liquid.cr
2941
version: 0.3.0
3042

43+
micrate:
44+
github: amberframework/micrate
45+
version: 0.3.3
46+
3147
mysql:
3248
github: crystal-lang/crystal-mysql
33-
version: 0.4.0
49+
version: 0.5.0
3450

3551
optarg:
3652
github: mosop/optarg
3753
version: 0.5.8
3854

3955
pg:
4056
github: will/crystal-pg
41-
version: 0.14.1
57+
version: 0.15.0
4258

43-
radix:
44-
github: luislavena/radix
45-
version: 0.3.8
59+
pool:
60+
github: ysbaddaden/pool
61+
version: 0.2.3
4662

4763
redis:
4864
github: stefanwille/crystal-redis
49-
version: 1.9.0
65+
version: 2.0.0
5066

5167
shell-table:
52-
github: jwaldrip/shell-table.cr
53-
version: 0.9.2
68+
github: luckyframework/shell-table.cr
69+
commit: 078a04ea58ead5203bb435a3b5fff448ddabaeea
5470

5571
slang:
5672
github: jeromegn/slang
5773
version: 1.7.1
5874

59-
spinner:
60-
github: askn/spinner
61-
version: 0.1.1
62-
6375
sqlite3:
6476
github: crystal-lang/crystal-sqlite3
65-
version: 0.9.0
77+
version: 0.10.0
6678

6779
string_inflection:
6880
github: mosop/string_inflection
6981
version: 0.2.1
7082

7183
teeplate:
72-
github: amberframework/teeplate
73-
version: 0.5.0
84+
github: mosop/teeplate
85+
version: 0.6.1
7486

frameworks/Crystal/amber/shard.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ targets:
1313
dependencies:
1414
amber:
1515
github: amberframework/amber
16-
version: 0.6.7
16+
version: 0.9.0
1717

18-
granite_orm:
19-
github: amberframework/granite-orm
20-
version: 0.8.4
18+
granite:
19+
github: amberframework/granite
20+
version: 0.13.1

frameworks/Crystal/amber/src/controllers/benchmark_controller.cr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class BenchmarkController < Amber::Controller::Base
88
before_action do
99
all do
1010
response.headers["Server"] = "Amber"
11-
response.headers["Date"] = Time.utc_now.to_s("%a, %d %b %Y %H:%M:%S GMT")
11+
response.headers["Date"] = HTTP.format_time(Time.now)
1212
end
1313
end
1414

@@ -26,7 +26,7 @@ class BenchmarkController < Amber::Controller::Base
2626
response.content_type = JSON
2727
results = {} of Symbol => Int32
2828
if world = World.find rand(1..ID_MAXIMUM)
29-
results = {id: world.id, randomNumber: world.randomNumber}
29+
results = {id: world.id, randomNumber: world.randomnumber}
3030
end
3131
results.to_json
3232
end
@@ -39,7 +39,7 @@ class BenchmarkController < Amber::Controller::Base
3939

4040
results = (1..queries).map do
4141
if world = World.find rand(1..ID_MAXIMUM)
42-
{id: world.id, randomNumber: world.randomNumber}
42+
{id: world.id, randomNumber: world.randomnumber}
4343
end
4444
end
4545

@@ -54,9 +54,9 @@ class BenchmarkController < Amber::Controller::Base
5454

5555
results = (1..queries).map do
5656
if world = World.find rand(1..ID_MAXIMUM)
57-
world.randomNumber = rand(1..ID_MAXIMUM)
57+
world.randomnumber = rand(1..ID_MAXIMUM)
5858
world.save
59-
{id: world.id, randomNumber: world.randomNumber}
59+
{id: world.id, randomNumber: world.randomnumber}
6060
end
6161
end
6262

frameworks/Crystal/amber/src/models/fortune.cr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
require "granite_orm/adapter/pg"
1+
require "granite/adapter/pg"
22

3-
class Fortune < Granite::ORM::Base
3+
class Fortune < Granite::Base
44
adapter pg
55

66
table_name fortune
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
require "granite_orm/adapter/pg"
1+
require "granite/adapter/pg"
22

3-
class World < Granite::ORM::Base
3+
class World < Granite::Base
44
adapter pg
55

66
table_name world
77
primary id : Int32
8-
field randomNumber : Int32
8+
field randomnumber : Int32
99
end

frameworks/Crystal/crystal/crystal-radix.dockerfile

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

33
WORKDIR /crystal
44
COPY views views

frameworks/Crystal/crystal/crystal.dockerfile

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

33
WORKDIR /crystal
44
COPY views views

frameworks/Crystal/crystal/server.cr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ require "ecr"
66
APPDB = DB.open("postgres://benchmarkdbuser:benchmarkdbpass@tfb-database:5432/hello_world?initial_pool_size=256&max_pool_size=256&max_idle_pool_size=256")
77
ID_MAXIMUM = 10_000
88

9-
server = HTTP::Server.new("0.0.0.0", 8080) do |context|
9+
server = HTTP::Server.new do |context|
1010
response = context.response
1111
request = context.request
1212

1313
response.headers["Server"] = "Crystal"
14-
response.headers["Date"] = Time.utc_now.to_s("%a, %d %b %Y %H:%M:%S GMT")
14+
response.headers["Date"] = HTTP.format_time(Time.now)
1515

1616
case request.path
1717
when "/json"
@@ -95,4 +95,4 @@ private def sanitized_query_count(request)
9595
queries.clamp(1..500)
9696
end
9797

98-
server.listen(reuse_port: true)
98+
server.listen("0.0.0.0", 8080, reuse_port: true)

0 commit comments

Comments
 (0)