Class: Txgh::Handlers::Transifex::HookHandler

Inherits:
Object
  • Object
show all
Includes:
CategorySupport, ResponseHelpers
Defined in:
lib/txgh/handlers/transifex/hook_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from CategorySupport

#deserialize_categories, #escape_category, #join_categories, #serialize_categories

Constructor Details

#initialize(options = {}) ⇒ HookHandler

Returns a new instance of HookHandler.



12
13
14
15
16
17
18
# File 'lib/txgh/handlers/transifex/hook_handler.rb', line 12

def initialize(options = {})
  @project = options.fetch(:project)
  @repo = options.fetch(:repo)
  @resource_slug = options.fetch(:resource_slug)
  @language = options.fetch(:language)
  @logger = options.fetch(:logger) { Logger.new(STDOUT) }
end

Instance Attribute Details

#languageObject (readonly)

Returns the value of attribute language.



10
11
12
# File 'lib/txgh/handlers/transifex/hook_handler.rb', line 10

def language
  @language
end

#loggerObject (readonly)

Returns the value of attribute logger.



10
11
12
# File 'lib/txgh/handlers/transifex/hook_handler.rb', line 10

def logger
  @logger
end

#projectObject (readonly)

Returns the value of attribute project.



10
11
12
# File 'lib/txgh/handlers/transifex/hook_handler.rb', line 10

def project
  @project
end

#repoObject (readonly)

Returns the value of attribute repo.



10
11
12
# File 'lib/txgh/handlers/transifex/hook_handler.rb', line 10

def repo
  @repo
end

#resource_slugObject (readonly)

Returns the value of attribute resource_slug.



10
11
12
# File 'lib/txgh/handlers/transifex/hook_handler.rb', line 10

def resource_slug
  @resource_slug
end

Instance Method Details

#executeObject



20
21
22
23
24
25
26
27
28
# File 'lib/txgh/handlers/transifex/hook_handler.rb', line 20

def execute
  logger.info(resource_slug)

  check_error_response || begin
    committer = ResourceCommitter.new(project, repo, logger)
    committer.commit_resource(tx_resource, branch, language)
    respond_with(200, true)
  end
end