rubocop-daemon 0.3.0 → 0.3.1

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
  SHA256:
3
- metadata.gz: d60258fcc9e9afc6e69f83a509ce6af552e8cf2c66ef6fd0553de6e88532b27a
4
- data.tar.gz: be0da846dbb327c3b61b9cdd0a2ce160a327963f270a758ee2f6912f1cc1b32d
3
+ metadata.gz: e34a73d9ee5a5f38b2a531efc3a19103b93ae9eef54faea95751820815c893b4
4
+ data.tar.gz: 9968fd324e630f5ad2d40f9c9895d4dec8a03e016087ba3b95978a126ee045ab
5
5
  SHA512:
6
- metadata.gz: 1fbb5f36a050acaa7848ccd2f3307696d0cef5fc7b940df7d2088057a7128fbbab28270d555ee4998c9fcab7934c149f47c1122886650cbde54d790a1d764ce1
7
- data.tar.gz: eb852d20656a2f41a2de055c6a540d00c96a733ea01a514762e4b7eb4c4d60aba33330bfc1dae06ee494cd5d8e152dfd04ef9d6692e803f3a7a84890e26c20a8
6
+ metadata.gz: 03b61796952aa7762a0a4ecb967e6f0d3da0ad54c45395789255cbd188646d8662f0a2f31a8fd82b7fcfaad184fbed69df641c64ea5904bd7ffaa5d454fb36cf
7
+ data.tar.gz: e1dd9d6eccb027a1f4ddc3316fa488d69983108d5381348f0397ab8f01aa5b270846c3fec43cadeab28e5d5e93e5fd8f56d178c8dd6c3d48390c2228336084bb
@@ -1,6 +1,30 @@
1
1
  #!/bin/bash
2
2
  set -e
3
3
 
4
+ if [[ "$OSTYPE" == "linux-gnu" ]]; then
5
+ NETCAT_CMD="nc -N"
6
+ elif [[ "$OSTYPE" == "darwin"* ]]; then
7
+ NETCAT_CMD="nc"
8
+ elif [[ "$OSTYPE" == "freebsd"* ]]; then
9
+ # https://www.freebsd.org/cgi/man.cgi?query=netcat&manpath=SuSE+Linux/i386+11.3
10
+ NETCAT_CMD="nc"
11
+ else
12
+ echo "Sorry, we're not sure if the rubocop-daemon-wrapper script will work" \
13
+ "on your OS: \"$OSTYPE\"" >&2
14
+ echo "Try to comment out this message in the script, and use one of the following:" >&2
15
+ echo >&2
16
+ echo "NETCAT_CMD=\"nc\"" >&2
17
+ echo "# Or" >&2
18
+ echo "NETCAT_CMD=\"nc -N\"" >&2
19
+ echo >&2
20
+ echo "Then please leave a comment on this GitHub issue and" \
21
+ "let us know which one worked:" >&2
22
+ echo >&2
23
+ echo "* https://github.com/fohte/rubocop-daemon/issues/4" >&2
24
+ echo >&2
25
+ exit 1
26
+ fi
27
+
4
28
  find_project_root() {
5
29
  path=$(pwd -P)
6
30
  while [[ "$path" != "" && ! -f "$path/Gemfile" && ! -f "$path/gems.rb" ]]; do
@@ -39,7 +63,7 @@ run_rubocop_command() {
39
63
  PORT="$(cat "$PORT_PATH")"
40
64
  COMMAND="$TOKEN $PROJECT_ROOT exec $@"
41
65
  rm -f "$STATUS_PATH" # Clear the previous status
42
- if echo -e "$COMMAND${STDIN_CONTENT}" | nc localhost "$PORT"; then
66
+ if echo -e "$COMMAND${STDIN_CONTENT}" | $NETCAT_CMD localhost "$PORT"; then
43
67
  if [ -f "$STATUS_PATH" ]; then
44
68
  exit "$(cat $STATUS_PATH)"
45
69
  else
@@ -59,8 +59,9 @@ module RuboCop
59
59
 
60
60
  def acquire_lock
61
61
  lock_file = File.open(lock_path, File::CREAT)
62
+ # flock returns 0 if successful, and false if not.
62
63
  flock_result = lock_file.flock(File::LOCK_EX | File::LOCK_NB)
63
- yield flock_result.zero?
64
+ yield flock_result != false
64
65
  ensure
65
66
  lock_file.flock(File::LOCK_UN)
66
67
  lock_file.close
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module Daemon
5
- VERSION = '0.3.0'.freeze
5
+ VERSION = '0.3.1'.freeze
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-daemon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hayato Kawai
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-16 00:00:00.000000000 Z
11
+ date: 2018-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop