Class: Jekyll::RemoteTheme::Downloader

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll-remote-theme/downloader.rb

Constant Summary collapse

HOST =
"https://codeload.github.com".freeze
PROJECT_URL =
"https://github.com/benbalter/jekyll-remote-theme".freeze
USER_AGENT =
"Jekyll Remote Theme/#{VERSION} (+#{PROJECT_URL})".freeze
MAX_FILE_SIZE =

Size in bytes (1 GB)

1 * (1024 * 1024 * 1024)
NET_HTTP_ERRORS =
[
  Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::OpenTimeout,
  Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError,
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(theme) ⇒ Downloader

Returns a new instance of Downloader.



18
19
20
# File 'lib/jekyll-remote-theme/downloader.rb', line 18

def initialize(theme)
  @theme = theme
end

Instance Method Details

#downloaded?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/jekyll-remote-theme/downloader.rb', line 32

def downloaded?
  @downloaded ||= theme_dir_exists? && !theme_dir_empty?
end

#runObject



22
23
24
25
26
27
28
29
30
# File 'lib/jekyll-remote-theme/downloader.rb', line 22

def run
  if downloaded?
    Jekyll.logger.debug LOG_KEY, "Using existing #{theme.name_with_owner}"
    return
  end

  download
  unzip
end