Class: Txbr::Uploader

Inherits:
Object
  • Object
show all
Defined in:
lib/txbr/uploader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project) ⇒ Uploader

Returns a new instance of Uploader.



5
6
7
# File 'lib/txbr/uploader.rb', line 5

def initialize(project)
  @project = project
end

Instance Attribute Details

#projectObject (readonly)

Returns the value of attribute project.



3
4
5
# File 'lib/txbr/uploader.rb', line 3

def project
  @project
end

Instance Method Details

#upload_allObject



9
10
11
12
13
# File 'lib/txbr/uploader.rb', line 9

def upload_all
  project.handler.each_resource do |resource|
    upload_resource(resource)
  end
end

#upload_resource(resource) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/txbr/uploader.rb', line 15

def upload_resource(resource)
  stream = StringIO.new
  resource.write_to(stream)
  project.transifex_api.create_or_update(
    resource.tx_resource, stream.string
  )
end