Skip to content

Commit

Permalink
fix deprecation warnings for 0.35.1
Browse files Browse the repository at this point in the history
* Remove YAML.mapping in favor of YAML::Serializable
* Process.kill was deprecated
  • Loading branch information
watzon authored Aug 16, 2020
1 parent ea45344 commit edcafd8
Showing 1 changed file with 31 additions and 58 deletions.
89 changes: 31 additions & 58 deletions src/sentry.cr
Original file line number Diff line number Diff line change
Expand Up @@ -5,59 +5,37 @@ module Sentry
FILE_TIMESTAMPS = {} of String => String # {file => timestamp}

class Config
include YAML::Serializable

# `shard_name` is set as a class property so that it can be inferred from
# the `shard.yml` in the project directory.
class_property shard_name : String?

YAML.mapping(
display_name: {
type: String?,
getter: false,
setter: false,
default: nil,
},
info: {
type: Bool,
default: false,
},
build: {
type: String?,
getter: false,
default: nil,
},
build_args: {
type: String,
getter: false,
default: "",
},
run: {
type: String?,
getter: false,
default: nil,
},
run_args: {
type: String,
getter: false,
default: "",
},
watch: {
type: Array(String),
default: ["./src/**/*.cr", "./src/**/*.ecr"],
},
install_shards: {
type: Bool,
default: false,
},
colorize: {
type: Bool,
default: true,
}
)

@[YAML::Field(ignore: true)]
property? sets_display_name : Bool = false

@[YAML::Field(ignore: true)]
property? sets_build_command : Bool = false

@[YAML::Field(ignore: true)]
property? sets_run_command : Bool = false

property info : Bool = false

property? colorize : Bool = true

property? install_shards : Bool = false

property? colorize : Bool = false

setter build_args : String = ""

setter run_args : String = ""

property watch : Array(String) = ["./src/**/*.cr", "./src/**/*.ecr"]

property install_shards : Bool = false

# Initializing an empty configuration provides no default values.
def initialize
@display_name = nil
Expand All @@ -72,6 +50,8 @@ module Sentry
@colorize = true
end

@display_name : String?

def display_name
@display_name ||= self.class.shard_name
end
Expand All @@ -85,6 +65,8 @@ module Sentry
display_name.not_nil!
end

@build : String?

def build
@build ||= "crystal build ./src/#{self.class.shard_name}.cr"
end
Expand All @@ -98,6 +80,8 @@ module Sentry
@build_args.strip.split(" ").reject(&.empty?)
end

@run : String?

def run
@run ||= "./#{self.class.shard_name}"
end
Expand All @@ -111,18 +95,7 @@ module Sentry
@run_args.strip.split(" ").reject(&.empty?)
end

setter install_shards : Bool = false

def install_shards?
@install_shards
end

setter colorize : Bool = false

def colorize?
@colorize
end

@[YAML::Field(ignore: true)]
setter should_build : Bool = true

def should_build?
Expand Down Expand Up @@ -212,7 +185,7 @@ module Sentry
if app_process.is_a? Process
unless app_process.terminated?
stdout "🤖 killing #{display_name}..."
app_process.kill
app_process.signal(:kill)
app_process.wait
end
end
Expand Down

0 comments on commit edcafd8

Please sign in to comment.