class PolyglotIos::Command::Setup

Public Class Methods

init(options = Commander::Command::Options.new) click to toggle source
# File lib/ios_polyglot_cli/commands/setup.rb, line 10
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/setup.rb, line 14
def initialize(options = Commander::Command::Options.new)
  @options = options
end

Public Instance Methods

call() click to toggle source
# File lib/ios_polyglot_cli/commands/setup.rb, line 18
def call
  project_id = project_id_prompt
  language = language_prompt
  translations_path = translations_path_prompt
  sources_path = sources_path_prompt
  project = {
    id: project_id,
    path: translations_path,
    sourceFilesPath: sources_path
  }
  config = {
    language: language,
    projects: [project]
  }
  PolyglotIos::IO::Config.write(config)
  success
end

Private Instance Methods

language_prompt() click to toggle source

Language

# File lib/ios_polyglot_cli/commands/setup.rb, line 46
def language_prompt
  languages = {'Swift' => 'swift', 'Objective-C' => 'objc'}
  prompt.select('Choose a language: ', languages)
end
project_id_prompt() click to toggle source

Project ID

# File lib/ios_polyglot_cli/commands/setup.rb, line 40
def project_id_prompt
  prompt.select('Choose a project: ', filtered_projects)
end
sources_path_prompt() click to toggle source

Sources path

# File lib/ios_polyglot_cli/commands/setup.rb, line 59
def sources_path_prompt
  prompt.ask('Where would you like to store source files?', default: './Common/Translations/')
end
translations_path_prompt() click to toggle source

Translations path

# File lib/ios_polyglot_cli/commands/setup.rb, line 53
def translations_path_prompt
  prompt.ask('Where would you like to store translation files (.strings)?', default: './Resources/Translations/')
end