diff --git a/.gitignore b/.gitignore index 58bbef9..f086bf2 100755 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,6 @@ DerivedData # CocoaPods Pods + +Packages +.build diff --git a/Fakery.podspec b/Fakery.podspec index 2b44e01..92288c1 100755 --- a/Fakery.podspec +++ b/Fakery.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "Fakery" - s.version = "3.1.0" + s.version = "3.2.0" s.summary = "Swift fake data generator" s.homepage = "https://github.com/vadymmarkov/Fakery" s.license = { @@ -27,6 +27,6 @@ Pod::Spec.new do |s| 'Faker' => ['Resources/Locales/*.{json}'] } - s.source_files = 'Source/**/*' + s.source_files = 'Sources/**/*' s.frameworks = 'Foundation' end diff --git a/Fakery.xcodeproj/project.pbxproj b/Fakery.xcodeproj/project.pbxproj index cceba54..dd74303 100644 --- a/Fakery.xcodeproj/project.pbxproj +++ b/Fakery.xcodeproj/project.pbxproj @@ -313,7 +313,7 @@ children = ( D59B6D0F1D99C6C7007CB072 /* Project */, BCFFA1471BF9F912005A3BC1 /* Resources */, - BCFFA1611BF9F912005A3BC1 /* Source */, + BCFFA1611BF9F912005A3BC1 /* Sources */, BCFFA1761BF9F912005A3BC1 /* Tests */, BCF0DF3B1BF9F77E00427DB4 /* Products */, ); @@ -374,16 +374,12 @@ path = Locales; sourceTree = ""; }; - BCFFA1611BF9F912005A3BC1 /* Source */ = { + BCFFA1611BF9F912005A3BC1 /* Sources */ = { isa = PBXGroup; children = ( - BCFFA1621BF9F912005A3BC1 /* Config.swift */, - BCFFA1681BF9F912005A3BC1 /* Faker.swift */, - BCFFA1631BF9F912005A3BC1 /* Data */, - BCFFA1661BF9F912005A3BC1 /* Extensions */, - BCFFA1691BF9F912005A3BC1 /* Generators */, + D535B6521F954FC20023F851 /* Fakery */, ); - path = Source; + path = Sources; sourceTree = ""; }; BCFFA1631BF9F912005A3BC1 /* Data */ = { @@ -431,6 +427,18 @@ path = Tests; sourceTree = ""; }; + D535B6521F954FC20023F851 /* Fakery */ = { + isa = PBXGroup; + children = ( + BCFFA1621BF9F912005A3BC1 /* Config.swift */, + BCFFA1681BF9F912005A3BC1 /* Faker.swift */, + BCFFA1631BF9F912005A3BC1 /* Data */, + BCFFA1661BF9F912005A3BC1 /* Extensions */, + BCFFA1691BF9F912005A3BC1 /* Generators */, + ); + path = Fakery; + sourceTree = ""; + }; D59B6CEC1D99C5FD007CB072 /* Fakery */ = { isa = PBXGroup; children = ( diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..55f4b0d --- /dev/null +++ b/Package.swift @@ -0,0 +1,10 @@ +// swift-tools-version:4.0 + +import PackageDescription + +let package = Package( + name: "Fakery", + targets: [ + .target(name: "Fakery") + ] +) diff --git a/Source/Config.swift b/Sources/Fakery/Config.swift similarity index 100% rename from Source/Config.swift rename to Sources/Fakery/Config.swift diff --git a/Source/Data/Parser.swift b/Sources/Fakery/Data/Parser.swift similarity index 98% rename from Source/Data/Parser.swift rename to Sources/Fakery/Data/Parser.swift index 3c13af4..25b6688 100644 --- a/Source/Data/Parser.swift +++ b/Sources/Fakery/Data/Parser.swift @@ -68,7 +68,7 @@ public final class Parser { options: .caseInsensitive) let matches = regex.matches(in: string as String, options: .reportCompletion, - range: NSMakeRange(0, string.length)) + range: NSRange(location: 0, length: string.length)) guard !matches.isEmpty else { return template diff --git a/Source/Data/Provider.swift b/Sources/Fakery/Data/Provider.swift similarity index 100% rename from Source/Data/Provider.swift rename to Sources/Fakery/Data/Provider.swift diff --git a/Source/Extensions/ArrayExtension.swift b/Sources/Fakery/Extensions/ArrayExtension.swift similarity index 72% rename from Source/Extensions/ArrayExtension.swift rename to Sources/Fakery/Extensions/ArrayExtension.swift index 89a164d..161f7d6 100644 --- a/Source/Extensions/ArrayExtension.swift +++ b/Sources/Fakery/Extensions/ArrayExtension.swift @@ -2,7 +2,7 @@ import Foundation extension Array { func at(_ index: Int?) -> Element? { - guard let index = index , index >= 0 && index < endIndex else { + guard let index = index, index >= 0 && index < endIndex else { return nil } @@ -10,6 +10,7 @@ extension Array { } func random() -> Element? { + // swiftlint:disable empty_count guard count > 0 else { return nil } diff --git a/Source/Faker.swift b/Sources/Fakery/Faker.swift similarity index 100% rename from Source/Faker.swift rename to Sources/Fakery/Faker.swift diff --git a/Source/Generators/Address.swift b/Sources/Fakery/Generators/Address.swift similarity index 99% rename from Source/Generators/Address.swift rename to Sources/Fakery/Generators/Address.swift index 2393ef6..da66bca 100644 --- a/Source/Generators/Address.swift +++ b/Sources/Fakery/Generators/Address.swift @@ -31,7 +31,7 @@ public final class Address: Generator { if stateAbbreviation.isEmpty { return bothify(generate("address.postcode")) } - + return bothify(generate("address.postcode_by_state.\(stateAbbreviation)")) } diff --git a/Source/Generators/App.swift b/Sources/Fakery/Generators/App.swift similarity index 100% rename from Source/Generators/App.swift rename to Sources/Fakery/Generators/App.swift diff --git a/Source/Generators/Bank.swift b/Sources/Fakery/Generators/Bank.swift similarity index 100% rename from Source/Generators/Bank.swift rename to Sources/Fakery/Generators/Bank.swift diff --git a/Source/Generators/Business.swift b/Sources/Fakery/Generators/Business.swift similarity index 100% rename from Source/Generators/Business.swift rename to Sources/Fakery/Generators/Business.swift diff --git a/Source/Generators/Commerce.swift b/Sources/Fakery/Generators/Commerce.swift similarity index 97% rename from Source/Generators/Commerce.swift rename to Sources/Fakery/Generators/Commerce.swift index 54313aa..ad9909c 100644 --- a/Source/Generators/Commerce.swift +++ b/Sources/Fakery/Generators/Commerce.swift @@ -29,7 +29,7 @@ public final class Commerce: Generator { } public func price() -> Double { - let arc4randoMax:Double = 0x100000000 + let arc4randoMax: Double = 0x100000000 return floor(Double((Double(arc4random()) / arc4randoMax) * 100.0) * 100) / 100.0 } diff --git a/Source/Generators/Company.swift b/Sources/Fakery/Generators/Company.swift similarity index 100% rename from Source/Generators/Company.swift rename to Sources/Fakery/Generators/Company.swift diff --git a/Source/Generators/Generator.swift b/Sources/Fakery/Generators/Generator.swift similarity index 96% rename from Source/Generators/Generator.swift rename to Sources/Fakery/Generators/Generator.swift index a49af2f..ad38549 100644 --- a/Source/Generators/Generator.swift +++ b/Sources/Fakery/Generators/Generator.swift @@ -34,7 +34,7 @@ public class Generator { } public func letterify(_ string: String) -> String { - return String(string.characters.enumerated().map { (index, item) in + return String(string.characters.enumerated().map { _, item in let count = UInt32(Constants.uppercaseLetters.count) let char = Constants.uppercaseLetters[Int(arc4random_uniform(count))] return String(item) == "?" ? char : item diff --git a/Source/Generators/Internet.swift b/Sources/Fakery/Generators/Internet.swift similarity index 96% rename from Source/Generators/Internet.swift rename to Sources/Fakery/Generators/Internet.swift index 29208b0..d3e59ba 100644 --- a/Source/Generators/Internet.swift +++ b/Sources/Fakery/Generators/Internet.swift @@ -106,13 +106,13 @@ public final class Internet: Generator { } public func templateImage(width: Int = 320, height: Int = 200, - backColorHex: String = "000000", frontColorHex: String = "ffffff") -> String { + backColorHex: String = "000000", frontColorHex: String = "ffffff") -> String { return "https://dummyimage.com/\(width)x\(height)/\(backColorHex)/\(frontColorHex)" } public func hashtag() -> String { return generate("internet.hashtag") } - + // @ToDo - slug } diff --git a/Source/Generators/Lorem.swift b/Sources/Fakery/Generators/Lorem.swift similarity index 100% rename from Source/Generators/Lorem.swift rename to Sources/Fakery/Generators/Lorem.swift diff --git a/Source/Generators/Name.swift b/Sources/Fakery/Generators/Name.swift similarity index 100% rename from Source/Generators/Name.swift rename to Sources/Fakery/Generators/Name.swift diff --git a/Source/Generators/Number.swift b/Sources/Fakery/Generators/Number.swift similarity index 100% rename from Source/Generators/Number.swift rename to Sources/Fakery/Generators/Number.swift diff --git a/Source/Generators/PhoneNumber.swift b/Sources/Fakery/Generators/PhoneNumber.swift similarity index 100% rename from Source/Generators/PhoneNumber.swift rename to Sources/Fakery/Generators/PhoneNumber.swift diff --git a/Source/Generators/Team.swift b/Sources/Fakery/Generators/Team.swift similarity index 100% rename from Source/Generators/Team.swift rename to Sources/Fakery/Generators/Team.swift