Class: Fastlane::Actions::ReadJsonAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::ReadJsonAction
- Defined in:
- lib/fastlane/plugin/json_auth/actions/read_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
84 85 86 |
# File 'lib/fastlane/plugin/json_auth/actions/read_json_action.rb', line 84 def self. ["Martin Gonzalez"] end |
.available_options ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/fastlane/plugin/json_auth/actions/read_json_action.rb', line 55 def self. [ FastlaneCore::ConfigItem.new(key: :json_path, description: "Path to json file", is_string: true, optional: true), FastlaneCore::ConfigItem.new(key: :json_string, description: "A json as string", is_string: true, optional: true), FastlaneCore::ConfigItem.new(key: :verbose, description: "verbose", optional: true, type: Boolean) ] end |
.description ⇒ Object
47 48 49 |
# File 'lib/fastlane/plugin/json_auth/actions/read_json_action.rb', line 47 def self.description "Read a json file and expose a hash with symbolized names as result" end |
.details ⇒ Object
51 52 53 |
# File 'lib/fastlane/plugin/json_auth/actions/read_json_action.rb', line 51 def self.details "Use this action to read a json file and access to it as Hash with symbolized names" end |
.is_supported?(_platform) ⇒ Boolean
88 89 90 |
# File 'lib/fastlane/plugin/json_auth/actions/read_json_action.rb', line 88 def self.is_supported?(_platform) true end |
.print_params(options) ⇒ Object
73 74 75 76 77 78 |
# File 'lib/fastlane/plugin/json_auth/actions/read_json_action.rb', line 73 def self.print_params() table_title = "Params for read_json #{Fastlane::JsonAuth::VERSION}" FastlaneCore::PrintTable.print_values(config: , hide_keys: [], title: table_title) end |
.put_error!(message) ⇒ Object
42 43 44 45 |
# File 'lib/fastlane/plugin/json_auth/actions/read_json_action.rb', line 42 def self.put_error!() UI.user_error!() raise StandardError, end |
.return_value ⇒ Object
80 81 82 |
# File 'lib/fastlane/plugin/json_auth/actions/read_json_action.rb', line 80 def self.return_value "Hash" end |
.run(params) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/fastlane/plugin/json_auth/actions/read_json_action.rb', line 12 def self.run(params) json_path = params[:json_path] json_string = params[:json_string] @is_verbose = params[:verbose] if json_path.nil? && json_string.nil? put_error!("You need to provide a json_path (file to path) or json_string (json as string).") return nil end print_params(params) if @is_verbose json_content = json_string unless json_path.nil? unless File.file?(json_path) put_error!("File at path #{json_path} does not exist. Verify that the path is correct.") return nil end json_content = File.read(json_path) end begin JSON.parse(json_content, symbolize_names: true) rescue StandardError put_error!("File at path #{json_path} has invalid content.") end end |