Skip to content

Commit

Permalink
Switch to running an_ and gp_ metadata actions via Fastfile parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
mokagio committed Jan 28, 2022
1 parent 9061436 commit d427773
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions spec/shared_examples_for_update_metadata_source_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
file_2_path = File.join(dir, '2.txt')
File.write(file_2_path, 'value 2')

described_class.run(
run_described_action(
po_file_path: output_path,
release_version: '1.0',
source_files: {
key1: file_1_path,
key2: file_2_path
Expand Down Expand Up @@ -56,7 +57,7 @@
whats_new_path = File.join(dir, 'whats_new.txt')
File.write(whats_new_path, "- something new\n- something else new")

described_class.run(
run_described_action(
po_file_path: output_path,
release_version: '1.23',
source_files: {
Expand Down Expand Up @@ -94,7 +95,7 @@
file_2_path = File.join(dir, '2.txt')
File.write(file_2_path, 'value 2')

described_class.run(
run_described_action(
po_file_path: output_path,
source_files: {
key1: file_1_path,
Expand Down Expand Up @@ -135,7 +136,7 @@
release_notes_path = File.join(dir, 'release_notes.txt')
File.write(release_notes_path, "- release notes\n- more release notes")

described_class.run(
run_described_action(
po_file_path: output_path,
release_version: '1.23',
source_files: {
Expand All @@ -159,3 +160,29 @@
end
end
end

def run_described_action(parameters)
lane_name = 'test'
lane = <<~LANE
lane :#{lane_name} do
#{described_class.action_name}(
#{stringify_for_fastlane(parameters)}
)
end
LANE
Fastlane::FastFile.new.parse(lane).runner.execute(lane_name.to_sym)
end

def stringify_for_fastlane(hash)
hash.map do |key, value|
# rubocop:disable Style/CaseLikeIf
if value.is_a?(Hash)
"#{key}: {\n#{stringify_for_fastlane(value)}\n}"
elsif value.is_a?(String)
"#{key}: \"#{value}\""
else
"#{key}: #{value}"
end
# rubocop:enable Style/CaseLikeIf
end.join(",\n")
end

0 comments on commit d427773

Please sign in to comment.