From f1cbf0431887d617a8aa4e7dea33a19492895131 Mon Sep 17 00:00:00 2001 From: Sergey Kopytov Date: Mon, 16 Sep 2019 22:27:51 +0300 Subject: [PATCH] add lanes generator --- .../generate_lanes_template.rb | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 xcode/config_generator/generate_lanes_template.rb diff --git a/xcode/config_generator/generate_lanes_template.rb b/xcode/config_generator/generate_lanes_template.rb new file mode 100644 index 0000000..313689c --- /dev/null +++ b/xcode/config_generator/generate_lanes_template.rb @@ -0,0 +1,30 @@ +require 'json' + +# call python script and generate configs to config file +system("python gen_configurations.py > configs_data.json") + +# generate fastlane lane block +def generate_lane(lane_name) + first_line = "lane :" + lane_name + " do |options|\n" + second_line = "\tbuildConfiguration(options)\n" + third_line = "end\n" + separator = "\n" + return first_line + second_line + third_line + separator +end + +# open configs for rendering +configs = JSON.load(File.open("configs_data.json"))["configurations"] + +# map configs to lanes +lanes = configs.map { |config| generate_lane(config["name"]) } + +# make all lanes uniq +lanes.uniq! + +# write lanes to file +File.open("lanes_template", 'w') { |file| + file.puts(lanes) +} + +# remove config file, it's trash +File.delete("configs_data.json") if File.exist?("configs_data.json")