Skip to content

Commit

Permalink
Crystal 0.35.0 (#1210)
Browse files Browse the repository at this point in the history
* Use Compress::Gzip and Compress::Deflate

* Use Process#signal

* Use Compress::Zip

* Use crystal-lang/yaml_mapping.cr

* Use crystal-lang/json_mapping.cr

* Update crystal-pg and crystal-mysql

* update shards

* include ameba

* bump versions to fix minor bugs

* upgrade liquid.cr shard

* renamed warning to warn

* reverse order of travis scripts

Co-authored-by: Brian J. Cardiff <bcardiff@gmail.com>
  • Loading branch information
drujensen and bcardiff authored Jun 13, 2020
1 parent bd6e9a0 commit bb1db0b
Show file tree
Hide file tree
Showing 17 changed files with 94 additions and 36 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM crystallang/crystal:0.34.0
FROM crystallang/crystal:0.35.0

# Install Dependencies
ARG DEBIAN_FRONTEND=noninteractive
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "amber",
"version": "0.34.0",
"version": "0.35.0",
"description": "Front-end configuration for Amber Framework",
"private": true,
"author": "Amber",
Expand Down
22 changes: 15 additions & 7 deletions shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version: 0.34.0
authors:
- Amber Team and Contributors <amberframework.org>

crystal: 0.33.0
crystal: 0.35.0

license: MIT

Expand All @@ -19,8 +19,8 @@ dependencies:
version: ~> 0.3.0

cli:
github: drujensen/cli
version: ~> 0.8.0
github: amberframework/cli
version: ~> 0.9.1

compiled_license:
github: elorest/compiled_license
Expand All @@ -32,19 +32,19 @@ dependencies:

liquid:
github: TechMagister/liquid.cr
#version: ~> 0.3.0
version: ~> 0.3.3

micrate:
github: amberframework/micrate
version: ~> 0.8.0

pg:
github: will/crystal-pg
version: ~> 0.21.0
version: ~> 0.21.1

mysql:
github: crystal-lang/crystal-mysql
version: ~> 0.11.0
version: ~> 0.11.1

sqlite3:
github: crystal-lang/crystal-sqlite3
Expand All @@ -68,11 +68,19 @@ dependencies:

teeplate:
github: mosop/teeplate
version: ~> 0.9.0
version: ~> 0.10.1

exception_page:
github: crystal-loot/exception_page

yaml_mapping:
github: crystal-lang/yaml_mapping.cr
version: ~> 0.1.0

json_mapping:
github: crystal-lang/json_mapping.cr
version: ~> 0.1.0

development_dependencies:
ameba:
github: veelenga/ameba
Expand Down
2 changes: 1 addition & 1 deletion spec/amber/environment/settings_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Amber::Environment
test_yaml = File.read(File.expand_path("./spec/support/config/test.yml"))
settings = Amber::Settings.from_yaml(test_yaml)

settings.logging.severity.should eq Log::Severity::Warning
settings.logging.severity.should eq Log::Severity::Warn
settings.logging.colorize.should eq true
settings.database_url.should eq "mysql://root@localhost:3306/test_settings_test"
settings.host.should eq "0.0.0.0"
Expand Down
2 changes: 1 addition & 1 deletion spec/support/config/fake_env.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
logging:
severity: "warning"
severity: "warn"
colorize: true
filter:
- password
Expand Down
2 changes: 1 addition & 1 deletion spec/support/config/test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
logging:
severity: "warning"
severity: "warn"
colorize: true
filter:
- password
Expand Down
2 changes: 1 addition & 1 deletion spec/support/config/test_with_color.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
secret_key_base: ox7cTo_408i4WZkKZ_5OZZtB5plqJYhD4rxrz2hriA4
logging:
severity: "warning"
severity: "warn"
colorize: true
color: red
filter:
Expand Down
1 change: 1 addition & 0 deletions spec/support/helpers/cli_helper.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require "file_utils"
require "json"
require "json_mapping"

class RouteJSON
JSON.mapping({
Expand Down
2 changes: 2 additions & 0 deletions src/amber/cli/config.cr
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require "yaml_mapping"

module Amber::CLI
def self.config
if File.exists? AMBER_YML
Expand Down
6 changes: 5 additions & 1 deletion src/amber/cli/helpers/process_runner.cr
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ module Sentry
log task, "Terminating process..."
end
procs.each do |process|
process.kill unless process.terminated?
{% if compare_versions(Crystal::VERSION, "0.35.0-0") >= 0 %}
process.signal(:term) unless process.terminated?
{% else %}
process.kill unless process.terminated?
{% end %}
end
procs.clear
end
Expand Down
35 changes: 26 additions & 9 deletions src/amber/cli/recipes/recipe_fetcher.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
require "http/client"
require "zip"
{% if compare_versions(Crystal::VERSION, "0.35.0-0") >= 0 %}
require "compress/zip"
{% else %}
require "zip"
{% end %}

module Amber::Recipes
class RecipeFetcher
Expand Down Expand Up @@ -109,16 +113,29 @@ module Amber::Recipes
def save_zip(response : HTTP::Client::Response)
Dir.mkdir_p(@template_path)

Zip::Reader.open(response.body_io) do |zip|
zip.each_entry do |entry|
path = "#{@template_path}/#{entry.filename}"
if entry.dir?
Dir.mkdir_p(path)
else
File.write(path, entry.io.gets_to_end)
{% if compare_versions(Crystal::VERSION, "0.35.0-0") >= 0 %}
Compress::Zip::Reader.open(response.body_io) do |zip|
zip.each_entry do |entry|
path = "#{@template_path}/#{entry.filename}"
if entry.dir?
Dir.mkdir_p(path)
else
File.write(path, entry.io.gets_to_end)
end
end
end
end
{% else %}
Zip::Reader.open(response.body_io) do |zip|
zip.each_entry do |entry|
path = "#{@template_path}/#{entry.filename}"
if entry.dir?
Dir.mkdir_p(path)
else
File.write(path, entry.io.gets_to_end)
end
end
end
{% end %}

if Dir.exists?("#{@template_path}/#{@kind}")
return "#{@template_path}/#{@kind}"
Expand Down
5 changes: 5 additions & 0 deletions src/amber/cli/templates/app/.travis.yml
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
language: crystal

script:
- crystal spec
- crystal tool format --check
- bin/ameba
2 changes: 1 addition & 1 deletion src/amber/cli/templates/app/Dockerfile.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM amberframework/amber:<%= Amber::VERSION %>
WORKDIR /app

COPY shard.* /app/
RUN shards install
RUN shards install

COPY . /app

Expand Down
6 changes: 3 additions & 3 deletions src/amber/cli/templates/app/config/logger.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require "log"
# About logger.cr File
#
# Amber is using the crystal standard library Log
# You can read details here: https://crystal-lang.org/api/0.34.0/Log.html
# You can read details here: https://crystal-lang.org/api/0.35.0/Log.html

# Using environment settings:
backend = Log::IOBackend.new(STDOUT)
Expand Down Expand Up @@ -36,12 +36,12 @@ Log.builder.bind "*", Amber.settings.logging.severity, backend

# Using more advanced options:
# backend = Log::IOBackend.new
# Log.builder.bind "*", :warning, backend
# Log.builder.bind "*", :warn, backend
# Log.builder.bind "request", :debug, backend
# Log.builder.bind "headers", :debug, backend
# Log.builder.bind "cookies", :debug, backend
# Log.builder.bind "params", :debug, backend
# Log.builder.bind "session", :debug, backend
# Log.builder.bind "errors", :warning, backend
# Log.builder.bind "errors", :warn, backend
# Log.builder.bind "granite.*", :info, backend
# Log.builder.bind "*", :error, ElasticSearchBackend.new("http://localhost:9200")
7 changes: 5 additions & 2 deletions src/amber/cli/templates/app/shard.yml.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ dependencies:
<% case @database when "pg" -%>
pg:
github: will/crystal-pg
version: ~> 0.21.0
version: ~> 0.21.1
<% when "mysql" -%>
mysql:
github: crystal-lang/crystal-mysql
version: ~> 0.11.0
version: ~> 0.11.1
<% when "sqlite" -%>
sqlite3:
github: crystal-lang/crystal-sqlite3
Expand All @@ -56,3 +56,6 @@ development_dependencies:
garnet_spec:
github: amberframework/garnet-spec
version: 0.2.0
ameba:
github: veelenga/ameba
version: ~> 0.12.1
1 change: 1 addition & 0 deletions src/amber/environment/settings.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require "yaml"
require "yaml_mapping"

module Amber::Environment
class Settings
Expand Down
31 changes: 24 additions & 7 deletions src/amber/pipes/static.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
require "zlib"
{% if compare_versions(Crystal::VERSION, "0.35.0-0") >= 0 %}
require "compress/gzip"
require "compress/deflate"
{% else %}
require "zlib"
{% end %}

module Amber
module Pipe
Expand Down Expand Up @@ -139,16 +144,28 @@ module Amber

private def gzip_encoding(env, file)
env.response.headers["Content-Encoding"] = "gzip"
Gzip::Writer.open(env.response) do |deflate|
IO.copy(file, deflate)
end
{% if compare_versions(Crystal::VERSION, "0.35.0-0") >= 0 %}
Compress::Gzip::Writer.open(env.response) do |deflate|
IO.copy(file, deflate)
end
{% else %}
Gzip::Writer.open(env.response) do |deflate|
IO.copy(file, deflate)
end
{% end %}
end

private def deflate_endcoding(env, file)
env.response.headers["Content-Encoding"] = "deflate"
Flate::Writer.open(env.response) do |deflate|
IO.copy(file, deflate)
end
{% if compare_versions(Crystal::VERSION, "0.35.0-0") >= 0 %}
Compress::Deflate::Writer.open(env.response) do |deflate|
IO.copy(file, deflate)
end
{% else %}
Flate::Writer.open(env.response) do |deflate|
IO.copy(file, deflate)
end
{% end %}
end

private def multipart(file, env)
Expand Down

0 comments on commit bb1db0b

Please sign in to comment.