neo4j-rake_tasks 0.3.0 → 0.4.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: f49243dad640d3474b999e8c645c9bd9c60c2cba
4
- data.tar.gz: 78738a943de6f3a0974f16deb5cc08570a9d1d1b
3
+ metadata.gz: 1ed87f21ff7a5a5242dbfc8ace41b95adc1d40dd
4
+ data.tar.gz: 406737a27d011b728f870ad4202dc81c9f2ee9a0
5
5
  SHA512:
6
- metadata.gz: b45237730eab1a69e1a7b3663ac21d12176caf07032c9975325be5c8d3f4eec53d2eec7c906e9fa79addcaadb0039b9298559c1826f6ef098d90907b4abbd0a3
7
- data.tar.gz: 90c39ca72851a2a687af9b9b5d1f93969f15281432e85106f3c54c14baf7914aafdc3d559ecf3a8843614330c4f5a0bde3187af433b9a6dfa2194dc78c54aacf
6
+ metadata.gz: 971cdcb5bf88dac5ede1a21119b2155e0045551a02387743a1bb17501d5f2e6e3d888de82356c628347ea6c1a68818c715074e192b7ccc708366b08361645b31
7
+ data.tar.gz: 817864aef547aa9c372f39da3e2fde8c59b3b8854ed194c0d1f6ed12e9bea39afe43f4ee3a06dc7b7797d3dca6500bef62753f84afaee0532e9247ad172a10c7
@@ -27,13 +27,20 @@ module Neo4j
27
27
  end
28
28
 
29
29
  def start(wait = true)
30
- system_or_fail(neo4j_command_path(start_argument(wait)))
30
+ system_or_fail(neo4j_command_path(start_argument(wait))).tap do
31
+ @pid = pid_path.read.to_i
32
+ end
31
33
  end
32
34
 
33
- def stop
35
+ def stop(timeout = nil)
34
36
  validate_is_system_admin!
35
37
 
36
- system_or_fail(neo4j_command_path(:stop))
38
+ Timeout.timeout(timeout) do
39
+ system_or_fail(neo4j_command_path(:stop))
40
+ end
41
+ rescue Timeout::Error
42
+ puts 'Shutdown timeout reached, killing process...'
43
+ Process.kill('KILL', @pid) if @pid
37
44
  end
38
45
 
39
46
  def console
@@ -41,7 +48,7 @@ module Neo4j
41
48
  end
42
49
 
43
50
  def shell
44
- not_started = !@path.join('data/neo4j-service.pid').exist?
51
+ not_started = !pid_path.exist?
45
52
 
46
53
  start if not_started
47
54
 
@@ -164,19 +171,36 @@ module Neo4j
164
171
  fail("Unable to run: #{command}")
165
172
  end
166
173
 
167
- NEO4J_LATEST_URL = 'https://api.github.com/repos/neo4j/neo4j/releases/latest'
168
174
  def version_from_edition(edition_string)
169
- edition_string.gsub(/-latest$/) do
170
- require 'open-uri'
171
- puts 'Retrieving latest version...'
172
- latest_version = JSON.parse(open(NEO4J_LATEST_URL).read)['tag_name']
173
- puts "Latest version is: #{latest_version}"
174
- "-#{latest_version}"
175
+ edition_string.downcase.gsub(/-([a-z\-]+)$/) do
176
+ puts "Retrieving #{$1} version..."
177
+
178
+ version = neo4j_versions[$1]
179
+
180
+ fail "Invalid version identifier: #{$1}" if !neo4j_versions.key?($1)
181
+ fail "There is not currently a version for #{$1}" if version.nil?
182
+
183
+ puts "#{$1.capitalize} version is: #{version}"
184
+
185
+ "-#{version}"
175
186
  end
176
187
  end
177
188
 
189
+ def pid_path
190
+ @path.join('data/neo4j-service.pid')
191
+ end
192
+
178
193
  private
179
194
 
195
+ NEO4J_VERSIONS_URL = 'https://raw.githubusercontent.com/neo4jrb/neo4j-rake_tasks/master/neo4j_versions.yml'
196
+
197
+ def neo4j_versions
198
+ require 'open-uri'
199
+ require 'yaml'
200
+
201
+ YAML.load(open(NEO4J_VERSIONS_URL).read)
202
+ end
203
+
180
204
  def download_neo4j(version)
181
205
  tempfile = Tempfile.open('neo4j-download', encoding: 'ASCII-8BIT')
182
206
 
@@ -1,5 +1,5 @@
1
1
  module Neo4j
2
2
  module RakeTasks
3
- VERSION = '0.3.0'
3
+ VERSION = '0.4.0'
4
4
  end
5
5
  end
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.3.0
4
+ version: 0.4.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: 2015-10-14 00:00:00.000000000 Z
11
+ date: 2016-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colored
@@ -200,4 +200,3 @@ signing_key:
200
200
  specification_version: 4
201
201
  summary: Rake tasks for managing Neo4j
202
202
  test_files: []
203
- has_rdoc: true