Class: Fastlane::Actions::FivSelectClientAction

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

Class Method Summary collapse

Class Method Details

.authorObject



50
51
52
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_select_client.rb', line 50

def self.author
  "Marc"
end

.available_optionsObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_select_client.rb', line 35

def self.available_options
    [
        FastlaneCore::ConfigItem.new(
            key: :clients_folder,
            env_name: "FIV_CLIENTS_FOLDER", # The name of the environment variable
            description: "Clients folder path for SelectClientAction", # a short description of this parameter
            default_value: "clients",
            is_string: true,
            verify_block: proc do |value|
                UI.user_error!("No client folder path for SelectClientAction given, pass using `client_folder: '../path_to_clients_folder'`") unless (value and not value.empty?)
                UI.user_error!("Couldn't find clients folder at path '#{value}'") unless File.directory?(value)
            end)
      ]
end

.descriptionObject



31
32
33
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_select_client.rb', line 31

def self.description
  "Select a client"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_select_client.rb', line 54

def self.is_supported?(platform)
  [:ios, :mac, :android].include? platform
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
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_select_client.rb', line 4

def self.run(params)
    Dir.chdir "#{params[:clients_folder]}" do
        clients_folders = Dir.glob('*').sort.select {|f| File.directory? f}
        if (ENV["CLIENT"])
          if (clients_folders.include?(ENV["CLIENT"]))
            puts("
              ***********************************************
                Selected client: #{ENV["CLIENT"]}
              ***********************************************
              ")
              return ENV["CLIENT"]
          else
              UI.user_error!("Client #{ENV["CLIENT"]} is not available.")
          end
        end
        
        selected_client = UI.select("Select one client: ", clients_folders)
    
        puts("
        ***********************************************
            Selected client: #{selected_client}
        ***********************************************
        ")
        return selected_client
    end
end