diff --git a/Binary/Sources/Deli/Error/PropertyParserError.swift b/Binary/Sources/Deli/Error/PropertyParserError.swift index cc734ed..3dcb01b 100644 --- a/Binary/Sources/Deli/Error/PropertyParserError.swift +++ b/Binary/Sources/Deli/Error/PropertyParserError.swift @@ -5,7 +5,6 @@ enum PropertyParserError: Error { case propertyNotFound - case propertyIsNotString case pathNotFound case notStartedBracket @@ -18,8 +17,6 @@ enum PropertyParserError: Error { switch self { case .propertyNotFound: return "Property not found in configuration property." - case .propertyIsNotString: - return "Property is not string value." case .pathNotFound: return "Path not found in configuration property." case .notStartedBracket: diff --git a/Binary/Sources/Deli/Runner/Corrector/ConfigPropertyCorrector.swift b/Binary/Sources/Deli/Runner/Corrector/ConfigPropertyCorrector.swift index 44c57a9..4d4025f 100644 --- a/Binary/Sources/Deli/Runner/Corrector/ConfigPropertyCorrector.swift +++ b/Binary/Sources/Deli/Runner/Corrector/ConfigPropertyCorrector.swift @@ -3,6 +3,8 @@ // Deli // +import Foundation + final class ConfigPropertyCorrector: Correctable { // MARK: - Private @@ -23,11 +25,11 @@ final class ConfigPropertyCorrector: Correctable { Logger.log(.error("Not found configuration property: \(path)", info.structure.getSourceLine(with: info.content))) throw CorrectorError.notFoundConfigurationProperty } - guard let safeProperty = property as? String else { - Logger.log(.error("Not found configuration property: \(path)", info.structure.getSourceLine(with: info.content))) - throw CorrectorError.notFoundConfigurationProperty + if property is NSNull { + return "" + } else { + return "\(property)" } - return safeProperty } return result diff --git a/Binary/Sources/Deli/Runner/Corrector/QualifierByCorrector.swift b/Binary/Sources/Deli/Runner/Corrector/QualifierByCorrector.swift index 9cc5e7c..51d6ee8 100644 --- a/Binary/Sources/Deli/Runner/Corrector/QualifierByCorrector.swift +++ b/Binary/Sources/Deli/Runner/Corrector/QualifierByCorrector.swift @@ -3,6 +3,8 @@ // Deli // +import Foundation + final class QualifierByCorrector: Correctable { // MARK: - Private @@ -19,11 +21,11 @@ final class QualifierByCorrector: Correctable { Logger.log(.error("Property not found in configuration property(\(qualifierBy))", info.structure.getSourceLine(with: info.content))) throw PropertyParserError.propertyNotFound } - guard let safeProperty = property as? String else { - Logger.log(.error("Property is not string value(\(qualifierBy))", info.structure.getSourceLine(with: info.content))) - throw PropertyParserError.propertyIsNotString + if property is NSNull { + dependency.qualifier = "" + } else { + dependency.qualifier = "\(property)" } - dependency.qualifier = safeProperty } catch { Logger.log(.error("Path not found in configuration property(\(qualifierBy))", info.structure.getSourceLine(with: info.content))) throw PropertyParserError.pathNotFound diff --git a/Binary/Sources/Deli/Runner/Generator/SourceGenerator.swift b/Binary/Sources/Deli/Runner/Generator/SourceGenerator.swift index 423b6ec..b114c3e 100644 --- a/Binary/Sources/Deli/Runner/Generator/SourceGenerator.swift +++ b/Binary/Sources/Deli/Runner/Generator/SourceGenerator.swift @@ -44,7 +44,11 @@ final class SourceGenerator: Generator { } result += "\(indent)]" } else { - result += "\"\(target)\"" + if target is NSNull { + result += "\"\"" + } else { + result += "\"\(target)\"" + } } return result } diff --git a/Binary/Sources/Deli/Runner/Validator/InjectPropertyValidator.swift b/Binary/Sources/Deli/Runner/Validator/InjectPropertyValidator.swift index e7b011d..bd93780 100644 --- a/Binary/Sources/Deli/Runner/Validator/InjectPropertyValidator.swift +++ b/Binary/Sources/Deli/Runner/Validator/InjectPropertyValidator.swift @@ -18,11 +18,7 @@ final class InjectPropertyValidator: Validatable { guard let info = parser.inheritanceList(result.instanceType).first else { continue } for path in propertyResult.propertyKeys { - guard let property = try propertyParser.getProperty(path) else { - Logger.log(.error("Not found configuration property: \(path)", info.structure.getSourceLine(with: info.content))) - throw CorrectorError.notFoundConfigurationProperty - } - if property as? String == nil { + guard try propertyParser.getProperty(path) != nil else { Logger.log(.error("Not found configuration property: \(path)", info.structure.getSourceLine(with: info.content))) throw CorrectorError.notFoundConfigurationProperty }