Skip to content

Commit

Permalink
Merge branch 'release/1.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
leogdion committed Dec 9, 2016
2 parents 9bc24da + 2c6eb90 commit 06ee271
Show file tree
Hide file tree
Showing 12 changed files with 168 additions and 41 deletions.
2 changes: 1 addition & 1 deletion application/Info.plist
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<string>$(DEFAULT_VERSION_SEMVER)</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSApplicationCategoryType</key>
Expand Down
117 changes: 98 additions & 19 deletions application/main.swift
Expand Up @@ -45,19 +45,20 @@ let formatter: NumberFormatter = {
return formatter
}()

extension SemVer : Hashable {
public var hashValue: Int {
return self.description.hashValue
}
}

public func ==(left: SemVer, right: SemVer) -> Bool {
return left.major == right.major && left.minor == right.minor && left.patch == right.patch
}

enum Stage : CustomStringConvertible {
static let all : Set<Stage> = [.alpha, .beta, .production]
case alpha, beta, production

public static func current (for version: Version) -> Stage {
let result = self.minimumBuildVersions.filter{
$0.value < version.build
}.max(by: {$0.value < $1.value})
return result?.key ?? .alpha
}

static let minimumBuildVersions : [Stage: UInt8] = [.beta : 15, .production : 17]

var description: String {
switch self {
case .alpha:
Expand All @@ -69,18 +70,77 @@ enum Stage : CustomStringConvertible {
}
}

var minimumBuildVersion : UInt8? {
return type(of: self).minimumBuildVersions[self]
init?(string: String) {
for stage in Stage.all {
if string.compare(stage.description, options: String.CompareOptions.caseInsensitive, range: nil, locale: nil) == ComparisonResult.orderedSame {
self = stage
return
}
}
return nil
}

public static let dictionary: StageBuildDictionaryProtocol! = {
guard let url = Bundle.main.url(forResource: "versions", withExtension: "plist") else {
return StageBuildDictionary(dictionary: StageBuildDictionaryBase())
}

let data = try! Data(contentsOf: url)
let plistObj = try! PropertyListSerialization.propertyList(from: data, options: PropertyListSerialization.ReadOptions(), format: nil)
let plist = plistObj as! [String : [String : Int]]
let dictionary = plist.reduce(StageBuildDictionaryBase(), { (previous, pair) -> StageBuildDictionaryBase in
var mutable = previous
mutable[SemVer(versionString: pair.key)!] = pair.value.reduce(
[Stage : UInt8](),
{(previous, pair) -> [Stage : UInt8] in

var mutable = previous
mutable[Stage(string: pair.key)!] = UInt8(pair.value)
return mutable
})
return mutable
})

return StageBuildDictionary(dictionary: dictionary)
}()
}

struct StageBuildDictionary : StageBuildDictionaryProtocol {

let dictionary : StageBuildDictionaryBase

func stage(withBuildForVersion version: Version) -> StageBuild? {
let result = self.dictionary[version.semver]?.filter{
$0.value <= version.build
}.max(by: {$0.value < $1.value})
if let result = result {
return (stage: result.key, minimum: result.value)
} else {
return nil
}
}

public init (dictionary: StageBuildDictionaryBase) {
self.dictionary = dictionary
}
}

typealias StageBuildDictionaryBase = [SemVer : [Stage : UInt8]]
typealias StageBuild = (stage: Stage, minimum: UInt8)

protocol StageBuildDictionaryProtocol {
func stage (withBuildForVersion version: Version) -> StageBuild?
}

func -(a: UInt8?, b: UInt8?) -> UInt8? {
guard let a = a, let b = b else {
return nil
}
return a - b
}



extension Version : CustomStringConvertible {
public var extra:Double {
if let extraString = self.versionControl?.EXTRA {
Expand All @@ -89,19 +149,36 @@ extension Version : CustomStringConvertible {
return 0
}
}
public var description:String {
let suffix = (Double(self.build) + (Double(self.versionControl?.TICK ?? 0) + self.extra/1000.0)/10000.0)/100.0
let suffixString = formatter.string(for: suffix)!.components(separatedBy: ".")[1]
return "\(self.semver)\(suffixString)"
}
func descriptionWithStage (_ stage: Stage) -> String {

var shortDescription:String {
let stage:Stage
let build:UInt8?
if let stagebuild = Stage.dictionary.stage(withBuildForVersion: self) {
stage = stagebuild.stage
build = stagebuild.minimum
} else {
stage = .production
build = nil
}
switch stage {
case .production:
return self.semver.description
default:
return "\(self.semver)-\(stage)\(self.build - ((stage.minimumBuildVersion - 1) ?? 0))"
return "\(self.semver)-\(stage)\(self.build - ((build - 1) ?? 0))"
}

}

var fullDescription:String {
let suffix = (Double(self.build) + (Double(self.versionControl?.TICK ?? 0) + self.extra/1000.0)/10000.0)/100.0
let suffixString = formatter.string(for: suffix)!.components(separatedBy: ".")[1]
return "\(self.semver)\(suffixString)"
}

public var description:String {
return self.fullDescription
}

}

public enum CommandLineParameter : String {
Expand All @@ -114,6 +191,7 @@ extension Array: SpeculidArgumentsProtocol {

Speculid.begin(withArguments: CommandLine.arguments,{
(speculid) in

let helpText = try! String(contentsOf: Bundle.main.bundlePath.url(forResource: "help", withExtension: "txt")!)

let output = FileHandle.standardOutput
Expand Down Expand Up @@ -148,7 +226,8 @@ Speculid.begin(withArguments: CommandLine.arguments,{
if let param = CommandLineParameter(rawValue: parameter.substring(with: rangeIndex!)) {
switch param {
case .Version :
print("Speculid v\(speculid.version.descriptionWithStage(Stage.current(for: speculid.version))) [\(speculid.version)]")

print("Speculid v\(speculid.version.shortDescription) [\(speculid.version)]")
break
default:
print(helpText)
Expand Down
13 changes: 13 additions & 0 deletions application/versions.plist
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>1.0.1</key>
<dict>
<key>beta</key>
<integer>4</integer>
<key>production</key>
<integer>5</integer>
</dict>
</dict>
</plist>
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "geometry.1x~universal.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "geometry.2x~universal.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "geometry.3x~universal.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
5 changes: 5 additions & 0 deletions examples/Assets/Image Set (Scaled).speculid
@@ -0,0 +1,5 @@
{
"set" : "Assets.xcassets/ImageSetScaled.imageset",
"source" : "geometry.svg",
"geometry" : "25"
}
4 changes: 4 additions & 0 deletions examples/examples.xcodeproj/project.pbxproj
Expand Up @@ -85,6 +85,7 @@
B3AF65CE1DA3F6F900BD008B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B38F73D01DA2B600008469FE /* Assets.xcassets */; };
B3AF65CF1DA3F6F900BD008B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B38F73D01DA2B600008469FE /* Assets.xcassets */; };
B3AF65D01DA3F6FA00BD008B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B38F73D01DA2B600008469FE /* Assets.xcassets */; };
B3D744331DF8ED18007A1216 /* Image Set (Scaled).speculid in Resources */ = {isa = PBXBuildFile; fileRef = B3D744321DF8ED18007A1216 /* Image Set (Scaled).speculid */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -190,6 +191,7 @@
B38F73D01DA2B600008469FE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
B38F73D51DA2C1AB008469FE /* macOS AppIcon.speculid */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "macOS AppIcon.speculid"; sourceTree = "<group>"; };
B38F73D71DA2C1F1008469FE /* geometry.svg */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = geometry.svg; sourceTree = "<group>"; };
B3D744321DF8ED18007A1216 /* Image Set (Scaled).speculid */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "Image Set (Scaled).speculid"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -292,6 +294,7 @@
B38F73D41DA2C149008469FE /* Assets */ = {
isa = PBXGroup;
children = (
B3D744321DF8ED18007A1216 /* Image Set (Scaled).speculid */,
B38DDF3A1DA2E5AE005AA837 /* iOS AppIcon.speculid */,
B38F73D71DA2C1F1008469FE /* geometry.svg */,
B38F73D51DA2C1AB008469FE /* macOS AppIcon.speculid */,
Expand Down Expand Up @@ -458,6 +461,7 @@
buildActionMask = 2147483647;
files = (
B30005CB1DB54EB1000A8166 /* Image Set.speculid in Resources */,
B3D744331DF8ED18007A1216 /* Image Set (Scaled).speculid in Resources */,
B38F73D11DA2B600008469FE /* Assets.xcassets in Resources */,
B38F73641DA2B358008469FE /* MainMenu.xib in Resources */,
B38DDF3C1DA2E5AE005AA837 /* iOS AppIcon.speculid in Resources */,
Expand Down
2 changes: 1 addition & 1 deletion examples/shasum
@@ -1 +1 @@
35388c0230c3c15943e465c507c90b048bf2904aa5bbe8685817787992f3325401784a7eaa782d705583b9f877fe0f02217064a8dbb82b27e169f72df00efec7 -
d8d65120ef77d026a965b4515fd8aa53681b7e45e9580add63e832367d0cd79e6b3e01b1415d34fbbbd9e68ac8b281ef389914ed4c86250b50e4aceb7fccbb58 -
8 changes: 4 additions & 4 deletions framework/Builders/SVGImageConversionBuilder.swift
Expand Up @@ -29,16 +29,16 @@ public struct SVGImageConversionBuilder : ImageConversionBuilderProtocol {
arguments.append(contentsOf: [specifications.contentsDirectoryURL.appendingPathComponent(specifications.destination(forImage: imageSpecification)).path,dimension,"\(length)", specifications.sourceImageURL.absoluteURL.path])
} else if let geometryValue = specifications.geometry?.value {
let dimension: String
let length: Int
let length: CGFloat
switch geometryValue {
case .Width(let value):
dimension = "-w"
length = value
length = CGFloat(value) * scale
case .Height(let value):
dimension = "-h"
length = value
length = CGFloat(value) * scale
}
arguments.append(contentsOf: [specifications.contentsDirectoryURL.appendingPathComponent(specifications.destination(forImage: imageSpecification)).path,dimension,"\(length)", specifications.sourceImageURL.absoluteURL.path])
arguments.append(contentsOf: [specifications.contentsDirectoryURL.appendingPathComponent(specifications.destination(forImage: imageSpecification)).path,dimension,"\(Int(length))", specifications.sourceImageURL.absoluteURL.path])
} else {
// convert to
arguments.append(contentsOf: [specifications.contentsDirectoryURL.appendingPathComponent(specifications.destination(forImage: imageSpecification)).path, "-d", "\(90*scale)" ,specifications.sourceImageURL.absoluteURL.path])
Expand Down
1 change: 1 addition & 0 deletions framework/Controllers/Speculid.swift
Expand Up @@ -29,6 +29,7 @@ public struct Speculid {

public static func begin (withArguments arguments: SpeculidArgumentsProtocol, _ callback: @escaping (SpeculidApplicationProtocol) -> Void) {
let operatingSystem = ProcessInfo.processInfo.operatingSystemVersionString

let analyticsConfiguration = AnalyticsConfiguration(trackingIdentifier: "UA-33667276-6", applicationName: "speculid", applicationVersion : String(describing: self.version), customParameters : [.operatingSystemVersion : operatingSystem])
let tracker = AnalyticsTracker(configuration: analyticsConfiguration, sessionManager: AnalyticsSessionManager())
NSSetUncaughtExceptionHandler(exceptionHandlerMethod)
Expand Down
2 changes: 1 addition & 1 deletion framework/Info.plist
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<string>$(DEFAULT_VERSION_SEMVER)</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
18 changes: 9 additions & 9 deletions framework/VCS.swift
Expand Up @@ -3,16 +3,16 @@
let VCS_TYPE = "git"
let VCS_BASENAME = "speculid"
let VCS_UUID: String? = "b6fd659a7d2088d5420f962a307b1f7f7e5d0604"
let VCS_NUM: Int = 428
let VCS_DATE = "2016-10-20T14:54:01Z"
let VCS_BRANCH: String = "release/1.0.0"
let VCS_TAG: String? = "1.0.0-beta2"
let VCS_TICK: Int? = 5
let VCS_EXTRA: String? = "11"
let VCS_NUM: Int = 448
let VCS_DATE = "2016-12-09T16:31:53Z"
let VCS_BRANCH: String = "release/1.0.1"
let VCS_TAG: String? = "1.0.1-alpha3"
let VCS_TICK: Int? = 1
let VCS_EXTRA: String? = "35"

let VCS_ACTION_STAMP: String? = "2016-10-20T14:54:01Z!leogdion@brightdigit.com"
let VCS_FULL_HASH: String = "1fb2d82ba3ebff406f51a14ecc14bbcd65267a28"
let VCS_SHORT_HASH: String = "1fb2d82"
let VCS_ACTION_STAMP: String? = "2016-12-09T16:31:53Z!leogdion@brightdigit.com"
let VCS_FULL_HASH: String = "39c7134a41040511e13464206b68ea1e47771b5f"
let VCS_SHORT_HASH: String = "39c7134"

let VCS_WC_MODIFIED: Bool = true

Expand Down

0 comments on commit 06ee271

Please sign in to comment.