Class: Txgh::GitStatus

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

Direct Known Subclasses

GithubStatus, GitlabStatus

Defined Under Namespace

Classes: State

Constant Summary collapse

ALL_COMPLETE_DESCRIPTION =
"Translations complete!"
TARGET_URL_TEMPLATE =
"https://www.transifex.com/%{organization}/%{project_slug}/content"
DESCRIPTION_TEMPLATE =
"%{complete}/%{total} translations complete."
CONTEXT =
'continuous-localization/txgh'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project, repo, branch) ⇒ GitStatus

Returns a new instance of GitStatus.



36
37
38
39
40
# File 'lib/txgh/git_status.rb', line 36

def initialize(project, repo, branch)
  @project = project
  @repo = repo
  @branch = branch
end

Instance Attribute Details

#branchObject (readonly)

Returns the value of attribute branch.



34
35
36
# File 'lib/txgh/git_status.rb', line 34

def branch
  @branch
end

#projectObject (readonly)

Returns the value of attribute project.



34
35
36
# File 'lib/txgh/git_status.rb', line 34

def project
  @project
end

#repoObject (readonly)

Returns the value of attribute repo.



34
35
36
# File 'lib/txgh/git_status.rb', line 34

def repo
  @repo
end

Class Method Details

.error(project, repo, branch, options = {}) ⇒ Object



29
30
31
# File 'lib/txgh/git_status.rb', line 29

def error(project, repo, branch, options = {})
  new(project, repo, branch).error(options)
end

.update(project, repo, branch) ⇒ Object



25
26
27
# File 'lib/txgh/git_status.rb', line 25

def update(project, repo, branch)
  new(project, repo, branch).update
end

Instance Method Details

#error(options = {}) ⇒ Object



52
53
54
55
56
57
58
59
60
# File 'lib/txgh/git_status.rb', line 52

def error(options = {})
  repo.api.create_status(
    sha, State.error, {
      context: context,
      target_url: options.fetch(:target_url),
      description: options.fetch(:description)
    }
  )
end

#updateObject



42
43
44
45
46
47
48
49
50
# File 'lib/txgh/git_status.rb', line 42

def update
  return if tx_resources.empty?

  repo.api.create_status(
    sha, state, {
      context: context, target_url: target_url, description: description
    }
  )
end