Skip to content

Commit

Permalink
Add export logic when the property is empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
kawoou committed Dec 1, 2018
1 parent 2468264 commit a5efb1f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
3 changes: 0 additions & 3 deletions Binary/Sources/Deli/Error/PropertyParserError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

enum PropertyParserError: Error {
case propertyNotFound
case propertyIsNotString
case pathNotFound

case notStartedBracket
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// Deli
//

import Foundation

final class ConfigPropertyCorrector: Correctable {

// MARK: - Private
Expand All @@ -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
Expand Down
10 changes: 6 additions & 4 deletions Binary/Sources/Deli/Runner/Corrector/QualifierByCorrector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// Deli
//

import Foundation

final class QualifierByCorrector: Correctable {

// MARK: - Private
Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion Binary/Sources/Deli/Runner/Generator/SourceGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ final class SourceGenerator: Generator {
}
result += "\(indent)]"
} else {
result += "\"\(target)\""
if target is NSNull {
result += "\"\""
} else {
result += "\"\(target)\""
}
}
return result
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit a5efb1f

Please sign in to comment.