Skip to content

Commit fc08095

Browse files
authored
Merge pull request #96 from insanoid/v1.5.1
V1.5.1
2 parents 3d1bc6b + 465d2f2 commit fc08095

39 files changed

+1522
-518
lines changed

.swiftformat

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
# file options
22

3-
--exclude Tests/XCTestManifests.swift,Snapshots
4-
5-
# format options
6-
73
--allman false
84
--binarygrouping 4,8
95
--commas always
@@ -35,4 +31,4 @@
3531

3632
# rules
3733

38-
--enable isEmpty
34+
--enable isEmpty

.swiftlint

Lines changed: 0 additions & 7 deletions
This file was deleted.

.swiftlint.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
disabled_rules:
2+
- trailing_whitespace
3+
- line_length
4+
- compiler_protocol_init
5+
- force_try
6+
opt_in_rules:
7+
- empty_count
8+
- empty_string
9+
excluded:
10+
- Pods
11+
- SwiftyJSONAccelerator/UI/External-Libraries
12+
function_body_length:
13+
warning: 300
14+
error: 500
15+
function_parameter_count:
16+
warning: 6
17+
error: 8
18+
type_body_length:
19+
warning: 300
20+
error: 500
21+
file_length:
22+
warning: 1000
23+
error: 1500
24+
ignore_comment_only_lines: true
25+
cyclomatic_complexity:
26+
warning: 15
27+
error: 25
28+
reporter: "xcode"

.travis.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
language: swift
2+
3+
osx_image: xcode10.2
4+
xcode_workspace: SwiftyJSONAccelerator.xcworkspace
5+
xcode_scheme: SwiftyJSONAccelerator
6+
xcode_sdk: macosx10.14
7+
8+
before_install:
9+
- gem install xcpretty
10+
- gem install slather
11+
- gem install cocoapods
12+
- gem install xcov
13+
14+
addons:
15+
homebrew:
16+
packages:
17+
- swiftlint
18+
- swiftformat
19+
update: true
20+
21+
script:
22+
- xcodebuild -workspace SwiftyJSONAccelerator.xcworkspace -scheme "SwiftyJSONAccelerator" CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO test
23+
24+
after_success:
25+
- xcov -w SwiftyJSONAccelerator.xcworkspace -s SwiftyJSONAccelerator -o build/xcov --coveralls_service_name travis-ci --coveralls_service_job_id $TRAVIS_JOB_ID

.xcovignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Not core code
2+
- Pods
3+
- SwiftyJSONAccelerator/UI
4+
- SwiftyJSONAccelerator/Support

Core/Constants.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ enum ConstructType: String {
3434
/// - Swift: Pure Swift 5 Codeable
3535
/// - SwiftCodeExtended: Codeextended along with Swift 5 - https://github.com/JohnSundell/Codextended
3636
enum JSONMappingMethod: String {
37-
case Swift = "SwiftCodingVanilla"
38-
case SwiftCodeExtended
37+
case swiftNormal = "swiftCodingVanilla"
38+
case swiftCodeExtended
3939
}
4040

4141
/// Types of property.
@@ -54,3 +54,8 @@ enum PropertyType: String {
5454
case emptyArray
5555
case nullType
5656
}
57+
58+
/// Place to store actual constants that don't fit in classes.
59+
struct Constants {
60+
static let filePathKey: String = "path"
61+
}

Core/Generator/FileGenerator.swift

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,12 @@ struct FileGenerator {
1313
///
1414
/// - Parameter filename: Name of the file to be loaded
1515
/// - Returns: String containing the template.
16-
static func loadFileWith(_ filename: String) -> String {
16+
static func loadFileWith(_ filename: String) throws -> String {
1717
let bundle = Bundle.main
18-
let path = bundle.path(forResource: filename, ofType: "txt")
19-
20-
do {
21-
let content = try String(contentsOfFile: path!)
22-
return content
23-
} catch {}
24-
25-
return ""
18+
guard let path = bundle.path(forResource: filename, ofType: "txt") else {
19+
return ""
20+
}
21+
let content = try String(contentsOfFile: path)
22+
return content
2623
}
2724
}

Core/Generator/FileGeneratorExtension.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Foundation
1010

1111
extension FileGenerator {
1212
static func generateFileContentWith(_ modelFile: ModelFile, configuration: ModelGenerationConfiguration) -> String {
13-
var content = loadFileWith("BaseTemplate")
13+
var content = try! loadFileWith("BaseTemplate")
1414
let singleTab = " ", doubleTab = " "
1515
content = content.replacingOccurrences(of: "{OBJECT_NAME}", with: modelFile.fileName)
1616
content = content.replacingOccurrences(of: "{DATE}", with: todayDateString())

Core/Generator/ModalGenerator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public struct ModelGenerator {
7272

7373
switch variableType {
7474
case .array:
75-
if value.arrayValue.count <= 0 {
75+
if value.arrayValue.isEmpty {
7676
currentModel.generateAndAddComponentsFor(PropertyComponent(variableName, VariableType.array.rawValue, stringConstantName, key, .emptyArray))
7777
} else {
7878
let subClassType = value.arrayValue.first!.detailedValueType()

Core/Generator/Model-File-Components/ModelComponent.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,11 @@ internal struct ModelComponent {
1616
var stringConstants: [String]
1717
/// Initialisers for the properties.
1818
var initialisers: [String]
19-
/// Encoders for NSCoding support.
20-
var encoders: [String]
21-
/// Decoders for NSCoding support.
22-
var decoders: [String]
23-
/// Description printer for each of the properties.
24-
var description: [String]
2519

2620
/// Initialise a blank model component structure.
2721
init() {
2822
declarations = []
2923
stringConstants = []
3024
initialisers = []
31-
encoders = []
32-
decoders = []
33-
description = []
3425
}
3526
}

0 commit comments

Comments
 (0)