Class: Neo4j::RakeTasks::Download

Inherits:
Object
  • Object
show all
Defined in:
lib/neo4j/rake_tasks/download.rb

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Download

Returns a new instance of Download.



7
8
9
# File 'lib/neo4j/rake_tasks/download.rb', line 7

def initialize(url)
  @url = url
end

Instance Method Details

#exists?Boolean

Returns:

  • (Boolean)


11
12
13
14
# File 'lib/neo4j/rake_tasks/download.rb', line 11

def exists?
  status = head(@url).code.to_i
  (200...300).cover?(status)
end

#fetch(message) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/neo4j/rake_tasks/download.rb', line 16

def fetch(message)
  require 'open-uri'
  open(@url,
       content_length_proc: lambda do |total|
         create_progress_bar(message, total) if total && total > 0
       end,
       progress_proc: method(:update_progress_bar)).read
end