homebrew-core/Formula/configen.rb
2018-11-17 01:27:23 +08:00

44 lines
1.7 KiB
Ruby

class Configen < Formula
desc "Configuration file code generator for use in Xcode projects"
homepage "https://github.com/theappbusiness/ConfigGenerator"
url "https://github.com/theappbusiness/ConfigGenerator/archive/v1.0.2.tar.gz"
sha256 "272f6bc4cfc7b72831096a0579a708511410799b2ed551f835951b60d9708aef"
head "https://github.com/theappbusiness/ConfigGenerator.git"
bottle do
cellar :any_skip_relocation
sha256 "8c01dbbe02fbfcb5fd77db3a9deebdc90628a3dc6cc0836bc2ab732700e95fb8" => :mojave
sha256 "00d49b86720671684ac9ca4376ec793bfce9eadeabdb977ad1218a143c305406" => :high_sierra
sha256 "1317e904f74d0bacab2912d3eca95a4f58d6625ecd3fb22781c009348e2bdc68" => :sierra
end
depends_on :xcode => ["9.0", :build]
def install
xcodebuild "SYMROOT=build"
bin.install "build/Release/configen"
end
test do
(testpath/"test.plist").write <<~EOS
<?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>testURL</key>
<string>https://example.com/api</string>
<key>retryCount</key>
<integer>2</integer>
</dict>
</plist>
EOS
(testpath/"test.map").write <<~EOS
testURL : URL
retryCount : Int
EOS
system bin/"configen", "-p", "test.plist", "-h", "test.map", "-n", "AppConfig", "-o", testpath
assert_predicate testpath/"AppConfig.swift", :exist?, "Failed to create config class!"
assert_match "static let testURL: URL = URL(string: \"https://example.com/api\")", File.read("AppConfig.swift")
assert_match "static let retryCount: Int = 2", File.read("AppConfig.swift")
end
end