class Transifex::Project

Holds data for a Transifex project

Attributes

client[R]
description[R]
main_language[R]
name[R]
paths[R]
slug[R]

Public Class Methods

new(project_data, client) click to toggle source
# File lib/transifex/project.rb, line 8
def initialize(project_data, client)
  @name          = project_data.name
  @description   = project_data.description
  @slug          = project_data.slug
  @paths         = Paths.new(@slug)
  @main_language = project_data.source_language_code
  @client        = client
end

Public Instance Methods

languages() click to toggle source
# File lib/transifex/project.rb, line 31
def languages
  @languages ||= client.get(paths.languages).map(&:language_code)
end
resource(resource_slug) click to toggle source
# File lib/transifex/project.rb, line 25
def resource(resource_slug)
  resource_data = client.get(paths.resource(resource_slug))
  return if resource_data == 'Not Found'
  Resource.new(resource_data, self)
end
resources() click to toggle source
# File lib/transifex/project.rb, line 17
def resources
   @resources ||= begin
     client.get(paths.resources).map do |resource_data|
       Resource.new(resource_data, self)
     end
   end
end
translation(resource, language_code) click to toggle source
# File lib/transifex/project.rb, line 35
def translation(resource, language_code)
  translation_data = client.get(paths.translations(resource.slug, language_code))
  return if translation_data == 'Not Found'
  Translation.new(translation_data, resource)
end
update_resource(resource, file_path) click to toggle source
# File lib/transifex/project.rb, line 41
def update_resource(resource, file_path)
  client.put(paths.update_resource(resource.slug), file_path)
end