Module: PolyglotCli::Helper::General
- Included in:
- Command::Pull, Command::Push, Command::Setup, Command::Status
- Defined in:
- lib/polyglot_cli/helpers/general.rb
Instance Method Summary collapse
- #config ⇒ Object
- #languages(locale) ⇒ Object
- #project ⇒ Object
- #project_id ⇒ Object
- #remote_translations(language) ⇒ Object
- #server_changed? ⇒ Boolean
- #token ⇒ Object
- #update_config ⇒ Object
Instance Method Details
#config ⇒ Object
8 9 10 |
# File 'lib/polyglot_cli/helpers/general.rb', line 8 def config @config ||= PolyglotCli::IO::Config.read end |
#languages(locale) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/polyglot_cli/helpers/general.rb', line 26 def languages(locale) prompt.say('Getting languages...') results = PolyglotCli::Resource::Language.token(token).depaginate(project_id: project_id) results.select! { |l| l.locale == locale } unless locale.nil? results end |
#project ⇒ Object
16 17 18 19 |
# File 'lib/polyglot_cli/helpers/general.rb', line 16 def project prompt.say('Getting project...') PolyglotCli::Resource::Project.token(token).find(project_id).first end |
#project_id ⇒ Object
12 13 14 |
# File 'lib/polyglot_cli/helpers/general.rb', line 12 def project_id config[:project_id] end |
#remote_translations(language) ⇒ Object
38 39 40 41 |
# File 'lib/polyglot_cli/helpers/general.rb', line 38 def remote_translations(language) prompt.say("Getting #{language.name} translations...") PolyglotCli::Resource::Translation.token(token).depaginate(project_id: project_id, language_id: language.id) end |
#server_changed? ⇒ Boolean
21 22 23 24 |
# File 'lib/polyglot_cli/helpers/general.rb', line 21 def server_changed? return true if config[:project_updated_at].nil? Time.parse(project.updated_at).utc > Time.parse(config[:project_updated_at]).utc end |
#token ⇒ Object
4 5 6 |
# File 'lib/polyglot_cli/helpers/general.rb', line 4 def token @token ||= PolyglotCli::IO::Token.read end |
#update_config ⇒ Object
33 34 35 36 |
# File 'lib/polyglot_cli/helpers/general.rb', line 33 def update_config config[:project_updated_at] = project.updated_at PolyglotCli::IO::Config.write(config) end |