Class: Txgh::ResourceCommitter
- Inherits:
-
Object
- Object
- Txgh::ResourceCommitter
- Defined in:
- lib/txgh/resource_committer.rb
Constant Summary collapse
- DEFAULT_COMMIT_MESSAGE =
"Updating %{language} translations in %{file_name}"
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
Instance Method Summary collapse
- #commit_resource(tx_resource, branch, language) ⇒ Object
-
#initialize(project, repo, logger = nil) ⇒ ResourceCommitter
constructor
A new instance of ResourceCommitter.
Constructor Details
#initialize(project, repo, logger = nil) ⇒ ResourceCommitter
Returns a new instance of ResourceCommitter.
7 8 9 10 11 |
# File 'lib/txgh/resource_committer.rb', line 7 def initialize(project, repo, logger = nil) @project = project @repo = repo @logger = logger || Logger.new(STDOUT) end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
5 6 7 |
# File 'lib/txgh/resource_committer.rb', line 5 def logger @logger end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
5 6 7 |
# File 'lib/txgh/resource_committer.rb', line 5 def project @project end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
5 6 7 |
# File 'lib/txgh/resource_committer.rb', line 5 def repo @repo end |
Instance Method Details
#commit_resource(tx_resource, branch, language) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/txgh/resource_committer.rb', line 13 def commit_resource(tx_resource, branch, language) return if prevent_commit_on?(branch) return if language == tx_resource.source_lang file_name, translations = download(tx_resource, branch, language) = (language, file_name) return unless translations repo.api.update_contents( branch, [{ path: file_name, contents: translations }], ) Txgh.events.publish( 'github.resource.committed', { project: project, repo: repo, resource: tx_resource, language: language, branch: branch } ) end |