neo4j-rake_tasks 0.5.6 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b088bea8515cd73ee7a7fc8425377d1ca5c3aae
4
- data.tar.gz: 304ad19a929b2f67982c0d74e8c8fe7fb7a5d838
3
+ metadata.gz: 1f635df119c539d9833db598349cfa146b943ec8
4
+ data.tar.gz: 3fc426ff2628e691f4ecba42a3f79710fb4159bd
5
5
  SHA512:
6
- metadata.gz: 0574df67c4ed6aa0e852de92a8575a6fec8699b61fbbaf831f842107a1d4464bc637cfd60ba6352c9d023f27c95532bb51a72a119130f66c1482c7eff94d9e8a
7
- data.tar.gz: 0985c525edeb4e41523dda4b79d83f2110ab4087e00ebeed923c9674cfbabef190aa927442a1f9669f79a884bc75c533b7562a5706e2a359bbdc87866dfbfc55
6
+ metadata.gz: c4e39866c185f26aaa10665d1c04bee52aab9ad2f1e2c4800a524643a4b3f482270c8233ba1feb7cad4caa760b4fa1387d04f1d06f0080743eaa14f2ae83a956
7
+ data.tar.gz: 930aca00dbd18f693f94c12eb2c583afeba7a7aebcd4509f09fb6c6fa9daa168fd256bc1bf4860d221972c4e21cb49c6c0c23f65892d77d8f817283116b226a4
@@ -0,0 +1,46 @@
1
+ require 'ruby-progressbar'
2
+ require 'net/http'
3
+
4
+ module Neo4j
5
+ module RakeTasks
6
+ class Download
7
+ def initialize(url)
8
+ @url = url
9
+ end
10
+
11
+ def exists?
12
+ status = head(@url).code.to_i
13
+ (200...300).cover?(status)
14
+ end
15
+
16
+ def fetch(message)
17
+ require 'open-uri'
18
+ open(@url,
19
+ content_length_proc: lambda do |total|
20
+ create_progress_bar(message, total) if total && total > 0
21
+ end,
22
+ progress_proc: method(:update_progress_bar)).read
23
+ end
24
+
25
+ private
26
+
27
+ def create_progress_bar(message, total)
28
+ @progress_bar ||= ProgressBar.create title: message,
29
+ total: total
30
+ end
31
+
32
+ def update_progress_bar(value)
33
+ return unless @progress_bar
34
+ value = @progress_bar.total >= value ? value : @progress_bar.total
35
+ @progress_bar.progress = value
36
+ end
37
+
38
+ def head(url)
39
+ parsed_url = URI(url)
40
+ Net::HTTP.start(parsed_url.host, parsed_url.port) do |http|
41
+ return http.head(parsed_url.path)
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -14,10 +14,10 @@ module Neo4j
14
14
 
15
15
  def install(edition_string)
16
16
  version = version_from_edition(edition_string)
17
- puts "Installing neo4j-#{version}"
18
17
 
19
18
  if !neo4j_binary_path.exist?
20
19
  archive_path = download_neo4j(version)
20
+ puts "Installing neo4j-#{version}"
21
21
  extract!(archive_path)
22
22
 
23
23
  FileUtils.rm archive_path
@@ -232,18 +232,16 @@ module Neo4j
232
232
 
233
233
  def download_neo4j(version)
234
234
  tempfile = Tempfile.open('neo4j-download', encoding: 'ASCII-8BIT')
235
-
236
235
  url = download_url(version)
237
236
 
238
- status = HTTParty.head(url).code
239
- unless (200...300).include?(status)
240
- fail "#{version} is not available to download"
241
- end
237
+ download = Download.new(url)
238
+ raise "#{version} is not available to download" unless download.exists?
242
239
 
243
- tempfile << HTTParty.get(url)
240
+ tempfile << download.fetch("Fetching neo4j-#{version}")
244
241
  tempfile.flush
245
-
246
242
  tempfile.path
243
+ ensure
244
+ puts
247
245
  end
248
246
 
249
247
  # POSTs to an endpoint with the form required to change a Neo4j password
@@ -1,5 +1,5 @@
1
1
  module Neo4j
2
2
  module RakeTasks
3
- VERSION = '0.5.6'
3
+ VERSION = '0.6.0'
4
4
  end
5
5
  end
@@ -1,3 +1,4 @@
1
+ require 'neo4j/rake_tasks/download'
1
2
  require 'neo4j/rake_tasks/starnix_server_manager'
2
3
  require 'neo4j/rake_tasks/windows_server_manager'
3
4
  require 'rake'
@@ -37,9 +37,9 @@ DESCRIPTION
37
37
  '--inline-source']
38
38
 
39
39
  s.add_dependency('colored')
40
- s.add_dependency('httparty')
41
40
  s.add_dependency('rake')
42
41
  s.add_dependency('os')
42
+ s.add_dependency('ruby-progressbar')
43
43
  s.add_dependency('rubyzip', '>= 1.1.7')
44
44
 
45
45
  # s.add_development_dependency('vcr')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neo4j-rake_tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Underwood
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-30 00:00:00.000000000 Z
11
+ date: 2016-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colored
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: httparty
28
+ name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake
42
+ name: os
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: os
56
+ name: ruby-progressbar
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -163,6 +163,7 @@ files:
163
163
  - Gemfile
164
164
  - README.md
165
165
  - lib/neo4j/rake_tasks.rb
166
+ - lib/neo4j/rake_tasks/download.rb
166
167
  - lib/neo4j/rake_tasks/neo4j_server.rake
167
168
  - lib/neo4j/rake_tasks/server_manager.rb
168
169
  - lib/neo4j/rake_tasks/starnix_server_manager.rb