Class: Fastlane::Actions::WriteJsonAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::WriteJsonAction
- Defined in:
- lib/fastlane/plugin/json_auth/actions/write_json_action.rb
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .is_supported?(_platform) ⇒ Boolean
- .print_params(options) ⇒ Object
- .put_error!(message) ⇒ Object
- .return_value ⇒ Object
- .run(params) ⇒ Object
Class Method Details
.authors ⇒ Object
79 80 81 |
# File 'lib/fastlane/plugin/json_auth/actions/write_json_action.rb', line 79 def self. ["Martin Gonzalez"] end |
.available_options ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/fastlane/plugin/json_auth/actions/write_json_action.rb', line 45 def self. [ FastlaneCore::ConfigItem.new(key: :hash, description: "Hash that you want to save as a json file", optional: false, type: Hash, verify_block: proc do |value| UI.user_error!("You must set hash: parameter") unless value && !value.empty? end), FastlaneCore::ConfigItem.new(key: :file_path, description: "Path where you want to save your json", is_string: true, optional: false, verify_block: proc do |value| UI.user_error!("You must set file_path: parameter") unless value && !value.empty? end), FastlaneCore::ConfigItem.new(key: :verbose, description: "verbose", optional: true, type: Boolean) ] end |
.description ⇒ Object
37 38 39 |
# File 'lib/fastlane/plugin/json_auth/actions/write_json_action.rb', line 37 def self.description "Write a json file from a hash at the provided path" end |
.details ⇒ Object
41 42 43 |
# File 'lib/fastlane/plugin/json_auth/actions/write_json_action.rb', line 41 def self.details "Use this action to serialize a hash into a json file in a provided path." end |
.is_supported?(_platform) ⇒ Boolean
83 84 85 |
# File 'lib/fastlane/plugin/json_auth/actions/write_json_action.rb', line 83 def self.is_supported?(_platform) true end |
.print_params(options) ⇒ Object
68 69 70 71 72 73 |
# File 'lib/fastlane/plugin/json_auth/actions/write_json_action.rb', line 68 def self.print_params() table_title = "Params for write_json #{Fastlane::JsonAuth::VERSION}" FastlaneCore::PrintTable.print_values(config: , hide_keys: [], title: table_title) end |
.put_error!(message) ⇒ Object
32 33 34 35 |
# File 'lib/fastlane/plugin/json_auth/actions/write_json_action.rb', line 32 def self.put_error!() UI.user_error!() raise StandardError, end |
.return_value ⇒ Object
75 76 77 |
# File 'lib/fastlane/plugin/json_auth/actions/write_json_action.rb', line 75 def self.return_value "Nothing" end |
.run(params) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/fastlane/plugin/json_auth/actions/write_json_action.rb', line 12 def self.run(params) hash = params[:hash] file_path = params[:file_path] @is_verbose = params[:verbose] print_params(params) if @is_verbose put_error!("file_path: value cannot be nil or empty") if file_path.nil? || file_path.empty? put_error!("hash: value cannot be nil") if hash.nil? = File.(file_path) file_dir = File.dirname() Dir.mkdir(file_dir) unless File.directory?(file_dir) begin File.write(file_path, JSON.pretty_generate(hash)) rescue StandardError put_error!("File at path #{file_path} has invalid content.") end end |