Class: Fastlane::Actions::UserDefaultSetAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::UserDefaultSetAction
- Defined in:
- lib/fastlane/plugin/user_default_set/actions/user_default_set_action.rb
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .return_value ⇒ Object
- .run(params) ⇒ Object
Class Method Details
.authors ⇒ Object
42 43 44 |
# File 'lib/fastlane/plugin/user_default_set/actions/user_default_set_action.rb', line 42 def self. ["zhangqi"] end |
.available_options ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/fastlane/plugin/user_default_set/actions/user_default_set_action.rb', line 55 def self. [ # FastlaneCore::ConfigItem.new(key: :your_option, # env_name: "USER_DEFAULT_SET_YOUR_OPTION", # description: "A description of your option", # optional: false, # type: String) FastlaneCore::ConfigItem.new(key: :path, env_name: "user_default_path_save", # The name of the environment variable description: "Path for UserDefault", # a short description of this parameter default_value: "build/.configure.fastlane", optional: true), FastlaneCore::ConfigItem.new(key: :key, env_name: "user_default_key_save", description: "key for user default", is_string: true, verify_block: proc do |value| UI.user_error!("No key for UserDefaultSetAction , pass using `key: 'key'`") unless (value and not value.empty?) # UI.user_error!("Couldn't find file at path '#{value}'") unless File.exist?(value) end), FastlaneCore::ConfigItem.new(key: :value, env_name: "user_default_value", description: "value for user default", optional: true, is_string: true, default_value: nil) ] end |
.description ⇒ Object
38 39 40 |
# File 'lib/fastlane/plugin/user_default_set/actions/user_default_set_action.rb', line 38 def self.description "fastlane save user default like ios userDefault" end |
.details ⇒ Object
50 51 52 53 |
# File 'lib/fastlane/plugin/user_default_set/actions/user_default_set_action.rb', line 50 def self.details # Optional: "use like as UserDefault" end |
.is_supported?(platform) ⇒ Boolean
84 85 86 87 88 89 |
# File 'lib/fastlane/plugin/user_default_set/actions/user_default_set_action.rb', line 84 def self.is_supported?(platform) # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example) # See: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Platforms.md # [:ios, :mac, :android].include?(platform) end |
.return_value ⇒ Object
46 47 48 |
# File 'lib/fastlane/plugin/user_default_set/actions/user_default_set_action.rb', line 46 def self.return_value # If your method provides a return value, you can describe here what it does 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 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/fastlane/plugin/user_default_set/actions/user_default_set_action.rb', line 4 def self.run(params) require 'json' # fastlane will take care of reading in the parameter and fetching the environment variable: path = params[:path] map = Hash.new isExist = File.exist? path if isExist json_string = File.read(path) json = JSON.parse(json_string) map = json if json.is_a? Hash end key = params[:key] value = params[:value] if value.nil? map.delete(key) else map[key] = value end if isExist File.open(path, "w+") do |file| file.puts(map.to_json) end else dirname = File.dirname(path) unless File.directory?(dirname) FileUtils.mkdir_p(dirname) end file = File.new(path, "w+") file.puts(map.to_json) file.close end end |