Class: Txgh::ResourceCommitter

Inherits:
Object
  • Object
show all
Defined in:
lib/txgh/resource_committer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project, repo, logger = nil) ⇒ ResourceCommitter

Returns a new instance of ResourceCommitter.



5
6
7
8
9
# File 'lib/txgh/resource_committer.rb', line 5

def initialize(project, repo, logger = nil)
  @project = project
  @repo = repo
  @logger = logger || Logger.new(STDOUT)
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



3
4
5
# File 'lib/txgh/resource_committer.rb', line 3

def logger
  @logger
end

#projectObject (readonly)

Returns the value of attribute project.



3
4
5
# File 'lib/txgh/resource_committer.rb', line 3

def project
  @project
end

#repoObject (readonly)

Returns the value of attribute repo.



3
4
5
# File 'lib/txgh/resource_committer.rb', line 3

def repo
  @repo
end

Instance Method Details

#commit_resource(tx_resource, branch, language) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/txgh/resource_committer.rb', line 11

def commit_resource(tx_resource, branch, language)
  return if prevent_commit_on?(branch)

  unless language == tx_resource.source_lang
    file_name, translations = download(tx_resource, branch, language)

    if translations
      repo.api.commit(repo.name, branch, { file_name => translations })
    end
  end
end