class PolyglotIos::Command::Projects
Attributes
options[RW]
Public Class Methods
init(options = Commander::Command::Options.new)
click to toggle source
# File lib/ios_polyglot_cli/commands/projects.rb, line 12 def self.init(options = Commander::Command::Options.new) new(options).call end
new(options = Commander::Command::Options.new)
click to toggle source
# File lib/ios_polyglot_cli/commands/projects.rb, line 16 def initialize(options = Commander::Command::Options.new) @options = options end
Public Instance Methods
call()
click to toggle source
# File lib/ios_polyglot_cli/commands/projects.rb, line 20 def call list_projects end
filtered_projects()
click to toggle source
# File lib/ios_polyglot_cli/commands/projects.rb, line 24 def filtered_projects projects .select { |key, _id| key[/^(.*?(#{option_query})[^$]*)$/i] } .sort_by { |p| p[0].downcase } .to_h end
option_query()
click to toggle source
# File lib/ios_polyglot_cli/commands/projects.rb, line 38 def option_query @option_query ||= @options.__hash__.fetch(:query, '') end
projects()
click to toggle source
# File lib/ios_polyglot_cli/commands/projects.rb, line 31 def projects prompt.say('Getting projects...') PolyglotIos::Resource::Project.token(token).depaginate.each_with_object({}) do |r, hash| hash[r.name] = r.id end end
Private Instance Methods
list_projects()
click to toggle source
# File lib/ios_polyglot_cli/commands/projects.rb, line 44 def list_projects projects = filtered_projects selection = projects .each_with_object({}) do |project, hash| project_name = project[0] project_id = project[1] display_name = "#{project_name} => #{project_id}" hash[display_name] = project_id end prompt.say(" Name - ID: \n ----------") selected_id = prompt .select("", selection) end