Class: Fastlane::Actions::TwineCheckAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::TwineCheckAction
- Defined in:
- lib/fastlane/plugin/twine/actions/twine_check_action.rb
Class Method Summary collapse
- .action_name ⇒ Object
- .authors ⇒ Object
- .available_options ⇒ Object
- .category ⇒ Object
- .description ⇒ Object
- .is_supported?(_platform) ⇒ Boolean
- .run(params) ⇒ Object
Class Method Details
.action_name ⇒ Object
64 65 66 |
# File 'lib/fastlane/plugin/twine/actions/twine_check_action.rb', line 64 def self.action_name name.split('::').last.gsub('Action', '').fastlane_underscore end |
.authors ⇒ Object
52 53 54 |
# File 'lib/fastlane/plugin/twine/actions/twine_check_action.rb', line 52 def self. ['Jonas Rottmann'] end |
.available_options ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fastlane/plugin/twine/actions/twine_check_action.rb', line 32 def self. [ FastlaneCore::ConfigItem.new(key: :configuration_path, env_name: 'TWINE_CONFIGURATION_PATH', description: 'Location to json file with configuration information', is_string: true, optional: false), FastlaneCore::ConfigItem.new(key: :visualize_diff, env_name: "TWINE_VISUALIZE_DIFF", description: "Display the diff of the files in case of a failure", is_string: false, default_value: true), FastlaneCore::ConfigItem.new(key: :use_bundle_exec, env_name: "TWINE_USE_BUNDLE_EXEC", description: "Use bundle exec when there is a Gemfile presented", is_string: false, default_value: true) ] end |
.category ⇒ Object
60 61 62 |
# File 'lib/fastlane/plugin/twine/actions/twine_check_action.rb', line 60 def self.category :building end |
.description ⇒ Object
28 29 30 |
# File 'lib/fastlane/plugin/twine/actions/twine_check_action.rb', line 28 def self.description 'Checks the source twine file against the localization file to make sure they are in sync' end |
.is_supported?(_platform) ⇒ Boolean
56 57 58 |
# File 'lib/fastlane/plugin/twine/actions/twine_check_action.rb', line 56 def self.is_supported?(_platform) true end |
.run(params) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fastlane/plugin/twine/actions/twine_check_action.rb', line 4 def self.run(params) require 'diffy' Actions.verify_gem!('twine') Helper::TwineConfigParser.parse(params).each do |config| if !File.exist?(config.source_path) UI.user_error!("Source file #{config.source_path} not found") else UI.(config.description) cmd = Helper::TwineCommandHelper.generate_command(config.source_path, config.destination_path + '.tmp', config.twine_args) cmd.prepend('bundle exec ') if params[:use_bundle_exec] && shell_out_should_use_bundle_exec? Actions.sh(cmd, error_callback: lambda { |e| UI.user_error!('Error while generating localization file ' + config.destination_path) }) files_are_the_same = FileUtils.compare_file(config.destination_path, config.destination_path + '.tmp') if params[:visualize_diff] && !files_are_the_same UI.("#{config.destination_path}:") puts Diffy::Diff.new(config.destination_path, config.destination_path + '.tmp', source: 'files').to_s(:color) end File.delete(config.destination_path + '.tmp') UI.build_failure!("Localization file #{config.destination_path} differs from the source file #{config.source_path}") unless files_are_the_same end end end |