Class: Txgh::Handlers::DownloadHandler

Inherits:
Object
  • Object
show all
Includes:
ResponseHelpers
Defined in:
lib/txgh/handlers/download_handler.rb

Constant Summary collapse

DEFAULT_FORMAT =
'.zip'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project, repo, params, logger) ⇒ DownloadHandler

Returns a new instance of DownloadHandler.



49
50
51
52
53
54
# File 'lib/txgh/handlers/download_handler.rb', line 49

def initialize(project, repo, params, logger)
  @project = project
  @repo = repo
  @params = params
  @logger = logger
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



47
48
49
# File 'lib/txgh/handlers/download_handler.rb', line 47

def logger
  @logger
end

#paramsObject (readonly)

Returns the value of attribute params.



47
48
49
# File 'lib/txgh/handlers/download_handler.rb', line 47

def params
  @params
end

#projectObject (readonly)

Returns the value of attribute project.



47
48
49
# File 'lib/txgh/handlers/download_handler.rb', line 47

def project
  @project
end

#repoObject (readonly)

Returns the value of attribute repo.



47
48
49
# File 'lib/txgh/handlers/download_handler.rb', line 47

def repo
  @repo
end

Class Method Details

.handle_request(request, logger = nil) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/txgh/handlers/download_handler.rb', line 10

def handle_request(request, logger = nil)
  handle_safely do
    config = config_from(request)
    project, repo = [config.transifex_project, config.github_repo]
    params = params_from(request)
    handler = new(project, repo, params, logger)
    handler.execute
  end
end

Instance Method Details

#executeObject



56
57
58
59
60
61
62
# File 'lib/txgh/handlers/download_handler.rb', line 56

def execute
  downloader = ResourceDownloader.new(
    project, repo, params['branch'], languages: project.languages
  )

  response_class.new(attachment, downloader.each)
end