Class: Fastlane::Actions::SourceEnvFromFileAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::SourceEnvFromFileAction
- Defined in:
- lib/fastlane/plugin/source_env_from_file/actions/source_env_from_file_action.rb
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .example_code ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .run(params) ⇒ Object
Class Method Details
.authors ⇒ Object
44 45 46 |
# File 'lib/fastlane/plugin/source_env_from_file/actions/source_env_from_file_action.rb', line 44 def self. ["xiongzenghui"] end |
.available_options ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/fastlane/plugin/source_env_from_file/actions/source_env_from_file_action.rb', line 52 def self. [ FastlaneCore::ConfigItem.new( key: :filepath, description: "filepath for env key=value file", verify_block: proc do |value| UI.user_error!("No filepath given") unless (value and not value.empty?) UI.error("file not exist: #{value}") unless File.exist?(value) end ) ] end |
.description ⇒ Object
40 41 42 |
# File 'lib/fastlane/plugin/source_env_from_file/actions/source_env_from_file_action.rb', line 40 def self.description "set ENV['key']=value from file like key=value" end |
.details ⇒ Object
48 49 50 |
# File 'lib/fastlane/plugin/source_env_from_file/actions/source_env_from_file_action.rb', line 48 def self.details "set ENV['key']=value from file like key=value" end |
.example_code ⇒ Object
69 70 71 72 73 74 |
# File 'lib/fastlane/plugin/source_env_from_file/actions/source_env_from_file_action.rb', line 69 def self.example_code [ 'source_env_from_file(filepath: "/Users/xiongzenghui/Desktop/env_data") pp ENV["XXX"]' ] end |
.is_supported?(platform) ⇒ Boolean
65 66 67 |
# File 'lib/fastlane/plugin/source_env_from_file/actions/source_env_from_file_action.rb', line 65 def self.is_supported?(platform) true end |
.run(params) ⇒ Object
7 8 9 10 11 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 |
# File 'lib/fastlane/plugin/source_env_from_file/actions/source_env_from_file_action.rb', line 7 def self.run(params) filepath = params[:filepath] IO.foreach(filepath) {|line| aline = line.gsub('export', '') # UI.important "aline: #{aline}" # key='value' mach_result = /(.*)=\"(.*)\"/.match(aline) # key=value unless mach_result mach_result = /(.*)=(.*)/.match(aline) end # key=value unless mach_result mach_result = /(.*)=(.*)/.match(aline) end next unless mach_result key = mach_result[1] value = mach_result[2] if key && value key.strip! value.strip! # UI.important "#{key}=#{value}" ENV[key] = value end } end |