Class: TxghServer::DownloadHandler

Inherits:
Object
  • Object
show all
Includes:
ResponseHelpers
Defined in:
lib/txgh-server/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.



48
49
50
51
52
53
# File 'lib/txgh-server/download_handler.rb', line 48

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.



46
47
48
# File 'lib/txgh-server/download_handler.rb', line 46

def logger
  @logger
end

#paramsObject (readonly)

Returns the value of attribute params.



46
47
48
# File 'lib/txgh-server/download_handler.rb', line 46

def params
  @params
end

#projectObject (readonly)

Returns the value of attribute project.



46
47
48
# File 'lib/txgh-server/download_handler.rb', line 46

def project
  @project
end

#repoObject (readonly)

Returns the value of attribute repo.



46
47
48
# File 'lib/txgh-server/download_handler.rb', line 46

def repo
  @repo
end

Class Method Details

.handle_request(request, logger = nil) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/txgh-server/download_handler.rb', line 9

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

Instance Method Details

#executeObject



55
56
57
58
59
60
61
# File 'lib/txgh-server/download_handler.rb', line 55

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

  response_class.new(attachment, downloader.each)
end