Class: Fastlane::Actions::UserDefaultGetAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/user_default_get/actions/user_default_get_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



21
22
23
# File 'lib/fastlane/plugin/user_default_get/actions/user_default_get_action.rb', line 21

def self.authors
  ["zhangqi"]
end

.available_optionsObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/fastlane/plugin/user_default_get/actions/user_default_get_action.rb', line 34

def self.available_options
  [
    # FastlaneCore::ConfigItem.new(key: :your_option,
    #                         env_name: "USER_DEFAULT_GET_YOUR_OPTION",
    #                      description: "A description of your option",
    #                         optional: false,
    #                             type: String)
    FastlaneCore::ConfigItem.new(key: :path,
                                 env_name: "user_default_path_get", # The name of the environment variable
                                 description: "Path for user default", # a short description of this parameter
                                 default_value: "build/.configure.fastlane",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :key,
                                 env_name: "user_default_key_get",
                                 description: "key for user default",
                                 is_string: true,
                                 verify_block: proc do |value|
                                   UI.user_error!("No key for UserDefaultGetAction , 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)


  ]
end

.descriptionObject



17
18
19
# File 'lib/fastlane/plugin/user_default_get/actions/user_default_get_action.rb', line 17

def self.description
  "get value like ios userDefault"
end

.detailsObject



29
30
31
32
# File 'lib/fastlane/plugin/user_default_get/actions/user_default_get_action.rb', line 29

def self.details
  # Optional:
  "get value from the path configure"
end

.is_supported?(platform) ⇒ Boolean



59
60
61
62
63
64
# File 'lib/fastlane/plugin/user_default_get/actions/user_default_get_action.rb', line 59

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
  #
  return [:ios, :mac, :android].include?(platform)
end

.return_valueObject



25
26
27
# File 'lib/fastlane/plugin/user_default_get/actions/user_default_get_action.rb', line 25

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
# File 'lib/fastlane/plugin/user_default_get/actions/user_default_get_action.rb', line 4

def self.run(params)
  UI.message("The user_default_get plugin is working!")
  path = params[:path]
  map = Hash.new
  if File.exist? path
    json_string = File.read(path)
    json = JSON.parse(json_string)
    map = json if json.is_a? Hash
  end
  key = params[:key]
  return map[key]
end