Class: Fastlane::Actions::DownloadJsonAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::DownloadJsonAction
- Defined in:
- lib/fastlane/plugin/json/actions/download_json_action.rb
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .is_supported?(_platform) ⇒ Boolean
- .print_params(options) ⇒ Object
- .puts_error!(message) ⇒ Object
- .return_value ⇒ Object
- .run(params) ⇒ Object
Class Method Details
.authors ⇒ Object
68 69 70 |
# File 'lib/fastlane/plugin/json/actions/download_json_action.rb', line 68 def self. ["Martin Gonzalez"] end |
.available_options ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/fastlane/plugin/json/actions/download_json_action.rb', line 39 def self. [ FastlaneCore::ConfigItem.new(key: :json_url, description: "Url to json file", is_string: true, optional: false, verify_block: proc do |value| UI.user_error!("You must set json_url pointing to a json file") unless value && !value.empty? end), FastlaneCore::ConfigItem.new(key: :verbose, description: "verbose", optional: true, type: Boolean, default_value: false) ] end |
.description ⇒ Object
31 32 33 |
# File 'lib/fastlane/plugin/json/actions/download_json_action.rb', line 31 def self.description "Downloads a json file and expose a hash with symbolized names as result" end |
.details ⇒ Object
35 36 37 |
# File 'lib/fastlane/plugin/json/actions/download_json_action.rb', line 35 def self.details "Use this action to download a json file and access to it as Hash with symbolized names" end |
.is_supported?(_platform) ⇒ Boolean
72 73 74 |
# File 'lib/fastlane/plugin/json/actions/download_json_action.rb', line 72 def self.is_supported?(_platform) true end |
.print_params(options) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/fastlane/plugin/json/actions/download_json_action.rb', line 57 def self.print_params() table_title = "Params for download_json #{Fastlane::Json::VERSION}" FastlaneCore::PrintTable.print_values(config: , hide_keys: [], title: table_title) end |
.puts_error!(message) ⇒ Object
26 27 28 29 |
# File 'lib/fastlane/plugin/json/actions/download_json_action.rb', line 26 def self.puts_error!() UI.user_error!() raise StandardError, end |
.return_value ⇒ Object
64 65 66 |
# File 'lib/fastlane/plugin/json/actions/download_json_action.rb', line 64 def self.return_value "Hash" end |
.run(params) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/fastlane/plugin/json/actions/download_json_action.rb', line 9 def self.run(params) json_url = params[:json_url] @is_verbose = params[:verbose] uri = URI(json_url) print_params(params) if @is_verbose puts("Downloading json from #{uri}") if @is_verbose begin response = Net::HTTP.get_response(uri) JSON.parse(response.body, symbolize_names: true) rescue JSON::ParserError puts_error!("Downloaded json has invalid content ❌") rescue => exception puts_error!("Failed to download json. Message: #{exception.} ❌") end end |