Updated dependencies and code for new Crystal version.

master
Luka Vandervelden 2019-10-19 18:08:34 +02:00
parent 1c87371196
commit 3c20783f91
4 changed files with 11 additions and 11 deletions

View File

@ -11,7 +11,7 @@ require "./service/*"
args = [] of String args = [] of String
parser = OptionParser.parse! do |parser| parser = OptionParser.parse do |parser|
parser.banner = "usage: service <command> [options]\n" + parser.banner = "usage: service <command> [options]\n" +
"\n" + "\n" +
"commands:\n" + "commands:\n" +
@ -132,7 +132,7 @@ begin
child = Process.run "#{OWN_LIBEXEC_DIR}/status", [args[1]], child = Process.run "#{OWN_LIBEXEC_DIR}/status", [args[1]],
output: Process::Redirect::Inherit, output: Process::Redirect::Inherit,
error: Process::Redirect::Inherit error: Process::Redirect::Inherit
return_value = child.exit_status / 256 return_value = (child.exit_status / 256).to_i
# Errors not registered here should probably be verbose in `status`. # Errors not registered here should probably be verbose in `status`.
if return_value == 1 if return_value == 1

View File

@ -1,4 +1,4 @@
require "specfileparser" require "specparser"
class Environment class Environment
enum Type enum Type
@ -21,7 +21,7 @@ class Environment
directory: "/srv/${ENVIRONMENT}" directory: "/srv/${ENVIRONMENT}"
end end
def initialize(specs : SpecFileParser) def initialize(specs : SpecParser)
assignments = specs.assignments assignments = specs.assignments
@name = assignments["name"].as_s @name = assignments["name"].as_s
@ -46,7 +46,7 @@ class Environment
file_path = "#{path}/#{child}" file_path = "#{path}/#{child}"
begin begin
environment = Environment.new SpecFileParser.parse(file_path).not_nil! environment = Environment.new SpecParser.parse(file_path).not_nil!
rescue e rescue e
STDERR << "error loading #{file_path}: " << e << "\n" STDERR << "error loading #{file_path}: " << e << "\n"
# FIXME: Print stacktrace? Debug mode? # FIXME: Print stacktrace? Debug mode?

View File

@ -43,7 +43,7 @@ class Service
end end
end end
def initialize(specs : SpecFileParser) def initialize(specs : SpecParser)
assignments = specs.assignments assignments = specs.assignments
@reference = ServiceDefinition.get assignments["name"].as_s @reference = ServiceDefinition.get assignments["name"].as_s
@ -302,7 +302,7 @@ class Service
end end
begin begin
specs = SpecFileParser.parse("#{path}/#{child}").not_nil! specs = SpecParser.parse("#{path}/#{child}").not_nil!
rescue rescue
next next
end end

View File

@ -1,5 +1,5 @@
require "yaml" require "yaml"
require "specfileparser" require "specparser"
class ServiceDefinition class ServiceDefinition
struct Consumes struct Consumes
@ -26,7 +26,7 @@ class ServiceDefinition
def initialize(@name, @command, @file = nil, @directory = nil) def initialize(@name, @command, @file = nil, @directory = nil)
end end
def initialize(section : SpecFileParser::Section) def initialize(section : SpecParser::Section)
@name = section.content["name"].as_s @name = section.content["name"].as_s
@file = section.content["file"]?.try &.as_s @file = section.content["file"]?.try &.as_s
@directory = section.content["directory"]?.try &.as_s @directory = section.content["directory"]?.try &.as_s
@ -47,7 +47,7 @@ class ServiceDefinition
getter checks : Array(Checks) getter checks : Array(Checks)
getter provides : Array(Provides) getter provides : Array(Provides)
def initialize(specs : SpecFileParser) def initialize(specs : SpecParser)
sections = specs.sections sections = specs.sections
specs = specs.assignments specs = specs.assignments
@name = specs["name"].as_s @name = specs["name"].as_s
@ -64,7 +64,7 @@ class ServiceDefinition
def self.load(path) def self.load(path)
Dir.each_child path do |child| Dir.each_child path do |child|
if child.match /\.spec$/ if child.match /\.spec$/
@@all << ServiceDefinition.new SpecFileParser.parse("#{path}/#{child}").not_nil! @@all << ServiceDefinition.new SpecParser.parse("#{path}/#{child}").not_nil!
else else
next next
end end