Class: Fastlane::Helper::FlutterHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/flutter/helper/flutter_helper.rb

Class Method Summary collapse

Class Method Details

.restore_l10n_timestamp(file_name, old_content) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fastlane/plugin/flutter/helper/flutter_helper.rb', line 9

def self.restore_l10n_timestamp(file_name, old_content)
  new_content_tree = JSON.parse(File.read(file_name))
  old_content_tree = JSON.parse(old_content)

  new_content_tree['@@last_modified'] =
    old_content_tree['@@last_modified']

  # Use to_json to compare the objects deep and in consistent format.
  if new_content_tree.to_json == old_content_tree.to_json
    # Except for the @@last_modified attribute that we replaced
    # above, the objects are identical. Restore previous timestamp.
    File.write(file_name, old_content)
    return true
  end

  false
end