Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #57 from justeat/tweak_generator_accessor_improved…
Browse files Browse the repository at this point in the history
…_code_generation_logic

Tweak generator accessor improved code generation logic
  • Loading branch information
albertodebortoli authored Jul 20, 2021
2 parents a7d426b + 35779f7 commit 94e6206
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- JustTweak (7.0.0)
- JustTweak (7.0.1)

DEPENDENCIES:
- JustTweak (from `../`)
Expand All @@ -9,7 +9,7 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
JustTweak: 61fed334d9bc9912207d225fe59dc031e2511e77
JustTweak: 76b358db90c402d9082c2e61b0b78da3fe5efd23

PODFILE CHECKSUM: a68b671e421f174879203bb91286c82eecc0444f

Expand Down
2 changes: 1 addition & 1 deletion JustTweak.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Pod::Spec.new do |s|
s.name = 'JustTweak'
s.version = '7.0.0'
s.version = '7.0.1'
s.summary = 'A framework for feature flagging, locally and remotely configure and A/B test iOS apps.'
s.description = <<-DESC
JustTweak is a framework for feature flagging, locally and remotely configure and A/B test iOS apps.
Expand Down
Binary file not shown.
22 changes: 17 additions & 5 deletions TweakAccessorGenerator/TweakAccessorGenerator/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ extension TweakAccessorGenerator {
let url: URL = URL(fileURLWithPath: outputFolder).appendingPathComponent(fileName)
let constants = codeGenerator.generateConstantsFileContent(tweaks: tweaks,
configuration: configuration)
try! constants.write(to: url, atomically: true, encoding: .utf8)
if let existingConstants = try? String(contentsOf: url, encoding: .utf8) {
if existingConstants != constants {
try! constants.write(to: url, atomically: true, encoding: .utf8)
}
} else {
try! constants.write(to: url, atomically: true, encoding: .utf8)
}
}

private func writeAccessorFile(codeGenerator: TweakAccessorCodeGenerator,
Expand All @@ -70,10 +76,16 @@ extension TweakAccessorGenerator {
configuration: Configuration) {
let fileName = "\(configuration.accessorName).swift"
let url: URL = URL(fileURLWithPath: outputFolder).appendingPathComponent(fileName)
let constants = codeGenerator.generateAccessorFileContent(tweaksFilename: tweaksFilename,
tweaks: tweaks,
configuration: configuration)
try! constants.write(to: url, atomically: true, encoding: .utf8)
let accessor = codeGenerator.generateAccessorFileContent(tweaksFilename: tweaksFilename,
tweaks: tweaks,
configuration: configuration)
if let existingAccessor = try? String(contentsOf: url, encoding: .utf8) {
if existingAccessor != accessor {
try! accessor.write(to: url, atomically: true, encoding: .utf8)
}
} else {
try! accessor.write(to: url, atomically: true, encoding: .utf8)
}
}
}

Expand Down
Binary file modified _TweakAccessorGenerator
Binary file not shown.

0 comments on commit 94e6206

Please sign in to comment.