Class: Spaceship::Client::UserInterface
- Inherits:
-
Object
- Object
- Spaceship::Client::UserInterface
- Defined in:
- spaceship/lib/spaceship/ui.rb,
spaceship/lib/spaceship/portal/ui/select_team.rb
Overview
All User Interface related code lives in this class
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Access the client this UserInterface object is for.
Class Method Summary collapse
-
.ci? ⇒ Boolean
rubocop:disable Require/MissingRequireStatement.
- .interactive? ⇒ Boolean
Instance Method Summary collapse
-
#initialize(c) ⇒ UserInterface
constructor
Is called by the client to generate one instance of UserInterface.
-
#select_team(team_id: nil, team_name: nil) ⇒ Object
rubocop:enable Require/MissingRequireStatement.
Constructor Details
#initialize(c) ⇒ UserInterface
Is called by the client to generate one instance of UserInterface
15 16 17 |
# File 'spaceship/lib/spaceship/ui.rb', line 15 def initialize(c) @client = c end |
Instance Attribute Details
#client ⇒ Object (readonly)
Access the client this UserInterface object is for
12 13 14 |
# File 'spaceship/lib/spaceship/ui.rb', line 12 def client @client end |
Class Method Details
.ci? ⇒ Boolean
rubocop:disable Require/MissingRequireStatement
35 36 37 38 39 40 |
# File 'spaceship/lib/spaceship/portal/ui/select_team.rb', line 35 def self.ci? if Object.const_defined?("FastlaneCore") && FastlaneCore.const_defined?("Helper") return FastlaneCore::Helper.ci? end return false end |
.interactive? ⇒ Boolean
42 43 44 45 46 47 |
# File 'spaceship/lib/spaceship/portal/ui/select_team.rb', line 42 def self.interactive? if Object.const_defined?("FastlaneCore") && FastlaneCore.const_defined?("UI") return FastlaneCore::UI.interactive? end return true end |
Instance Method Details
#select_team(team_id: nil, team_name: nil) ⇒ Object
rubocop:enable Require/MissingRequireStatement
50 51 52 53 54 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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'spaceship/lib/spaceship/portal/ui/select_team.rb', line 50 def select_team(team_id: nil, team_name: nil) teams = client.teams if teams.count == 0 puts("No teams available on the Developer Portal") puts("You must accept an invitation to a team for it to be available") puts("To learn more about teams and how to use them visit https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/ManagingYourTeam/ManagingYourTeam.html") raise "Your account is in no teams" end team_id = (team_id || ENV['FASTLANE_TEAM_ID'] || '').strip team_name = (team_name || ENV['FASTLANE_TEAM_NAME'] || '').strip if team_id.length > 0 # User provided a value, let's see if it's valid teams.each_with_index do |team, i| # There are 2 different values - one from the login page one from the Dev Team Page return team['teamId'] if team['teamId'].strip == team_id return team['teamId'] if team['currentTeamMember']['teamMemberId'].to_s.strip == team_id end puts("Couldn't find team with ID '#{team_id}'") end if team_name.length > 0 # User provided a value, let's see if it's valid teams.each_with_index do |team, i| return team['teamId'] if team['name'].strip == team_name end puts("Couldn't find team with Name '#{team_name}'") end return teams[0]['teamId'] if teams.count == 1 # user is just in one team unless self.class.interactive? puts("Multiple teams found on the Developer Portal, Your Terminal is running in non-interactive mode! Cannot continue from here.") puts("Please check that you set FASTLANE_TEAM_ID or FASTLANE_TEAM_NAME to the right value.") puts("Available Teams:") teams.each_with_index do |team, i| puts("#{i + 1}) #{team['teamId']} \"#{team['name']}\" (#{team['type']})") end raise "Multiple Teams found; unable to choose, terminal not interactive!" end # User Selection loop do # Multiple teams, user has to select puts("Multiple teams found on the " + "Developer Portal".yellow + ", please enter the number of the team you want to use: ") teams.each_with_index do |team, i| puts("#{i + 1}) #{team['teamId']} \"#{team['name']}\" (#{team['type']})") end selected = ($stdin.gets || '').strip.to_i - 1 team_to_use = teams[selected] if selected >= 0 return team_to_use['teamId'] if team_to_use end end |