Skip to content

Commit

Permalink
Crystal 0.34
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-alexandrov committed Apr 8, 2020
1 parent 6e5e565 commit 8f169f1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
4 changes: 2 additions & 2 deletions shard.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: shrine
version: 0.4.1
version: 0.5.0
description: |
File Attachment toolkit for Crystal applications
authors:
- Igor Alexandrov <igor.alexandrov@gmail.com>

crystal: 0.33
crystal: 0.34

license: MIT

Expand Down
18 changes: 9 additions & 9 deletions spec/lib/shrine_spec.cr
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
require "../spec_helper"

Spectator.describe Shrine do
describe "logger" do
it "responds_to `logger`" do
expect(Shrine).to respond_to(:logger)
end
# describe "logger" do
# it "responds_to `logger`" do
# expect(Shrine).to respond_to(:logger)
# end

it "sets default log_level to WARN" do
expect(Shrine.settings.log_level).to eq(Logger::WARN)
expect(Shrine.logger.level).to eq(Logger::WARN)
end
end
# it "sets default log_level to WARN" do
# expect(Shrine.settings.log_level).to eq(Logger::WARN)
# expect(Shrine.logger.level).to eq(Logger::WARN)
# end
# end
end
11 changes: 6 additions & 5 deletions src/shrine.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ require "./shrine/uploaded_file"

require "habitat"

require "logger"
require "log"

Log.setup_from_env

class Shrine
PLUGINS = [] of Nil
Expand All @@ -24,7 +26,6 @@ class Shrine

Habitat.create do
setting storages : Hash(String, Storage::Base) = Hash(String, Storage::Base).new
setting log_level : Logger::Severity = Logger::WARN
end

struct PluginSettings
Expand Down Expand Up @@ -127,7 +128,7 @@ class Shrine

module ClassMethods
macro extended
class_property logger = Logger.new(STDOUT, level: settings.log_level)
Log = ::Log.for("shrine.cr")
end

# Retrieves the storage under the given identifier (Symbol), raising Shrine::Error if the storage is missing.
Expand Down Expand Up @@ -158,7 +159,7 @@ class Shrine

# Prints a warning to the logger.
def warn(message)
Shrine.logger.warn "SHRINE WARNING: #{message}"
Log.warn { "SHRINE WARNING: #{message}" }
end
end

Expand Down Expand Up @@ -204,7 +205,7 @@ class Shrine

# Prints a warning to the logger.
def warn(message)
Shrine.logger.warn "SHRINE WARNING: #{message}"
Log.warn { "SHRINE WARNING: #{message}" }
end

# Extracts filename, size and MIME type from the file, which is later
Expand Down
2 changes: 1 addition & 1 deletion src/shrine/plugins/determine_mime_type.cr
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class Shrine
else
raise Error.new "file command failed: #{stderr.to_s}"
end
rescue Errno
rescue RuntimeError
raise Error.new("file command-line tool is not installed")
end

Expand Down
2 changes: 1 addition & 1 deletion src/shrine/storage/file_system.cr
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Shrine
def open(id : String, **options) : File
# TODO pass other options
File.open(path(id), mode: "rb")
rescue Errno
rescue RuntimeError
raise Shrine::FileNotFound.new "file #{id.inspect} not found on storage"
end

Expand Down

0 comments on commit 8f169f1

Please sign in to comment.