frontkick 0.3.3 → 0.3.4

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: afbcaf599563d9ebb1395512e65ce021d9f314e6
4
- data.tar.gz: 203a79a478f3bc6acccb641160ca2ba73af1049d
3
+ metadata.gz: 5cb9b445262c3f7b278593b0bbb6bf54a14664e6
4
+ data.tar.gz: 6f557263aa916e8b293334da3e594931b552b721
5
5
  SHA512:
6
- metadata.gz: 7a42da35a826093ba55a28d1494531f52a727b7d8f0b4af13d3faf607a7426f02c58bf8fad3e49b0305e2d5ce656b0eb08737620ce3cf33c50962f39456e4e6d
7
- data.tar.gz: 79a39227fbf5051c94afd63cdf50c3852c1ac218b626028b34004715d6b7bf8d191355d586cfc333726402ae466f6776a3d7b0ef4da72c4b65b1aac61fcf2342
6
+ metadata.gz: f28fa5899334a518182cbce05bf4628001bc97c0cbe5e0997ecbbd2ccee374d5f4822a74ad22bce5fb09cd2e4e333bbe41181f118a24444dd3b3d5d68968228b
7
+ data.tar.gz: 4284c8e05039f6b3e478b3dc75959b715546a52efc82c9c5fbab27c03fc691f13a5b640e29bff07155d8f28ffa4cf7ec6970e9d169be83b20b7aec2416be776e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 0.3.4 (2014/07/30)
2
+
3
+ Enhancements:
4
+
5
+ - Add `exclusive_blocking` option
6
+
1
7
  # 0.3.3 (2014/06/04)
2
8
 
3
9
  Changes:
data/Gemfile CHANGED
@@ -2,4 +2,3 @@
2
2
  source 'https://rubygems.org'
3
3
 
4
4
  gemspec
5
- gem 'frontkick', path: '.'
data/README.md CHANGED
@@ -39,6 +39,10 @@ Prohibit another process to run a command concurrently
39
39
 
40
40
  Frontkick.exec("sleep 2 && ls /hoge", :exclusive => "/tmp/frontkick.lock") # raises Fontkick::Locked if locked
41
41
 
42
+ If you prefer to be blocked:
43
+
44
+ Frontkick.exec("sleep 2 && ls /hoge", :exclusive => "/tmp/frontkick.lock", :exclusive_blocking => true)
45
+
42
46
  ## Contributing
43
47
 
44
48
  1. Fork it
@@ -8,7 +8,7 @@ module Frontkick
8
8
  stdin, out, err, wait_thr, pid = nil
9
9
 
10
10
  cmd_array = cmd.kind_of?(Array) ? cmd : [cmd]
11
- lock_fd = file_lock(opts[:exclusive]) if opts[:exclusive]
11
+ lock_fd = file_lock(opts[:exclusive], opts[:exclusive_blocking]) if opts[:exclusive]
12
12
  begin
13
13
  timeout(opts[:timeout]) do # nil is for no timeout
14
14
  duration = Benchmark.realtime do
@@ -50,14 +50,19 @@ module Frontkick
50
50
  # Use file lock to perfome exclusive operation
51
51
  #
52
52
  # @param lock_file file path used to lock
53
+ # @param blocking blocking or non-blocking. default is nil (false)
53
54
  # @return file descriptor
54
55
  # @raise Fontkick::Locked if locked
55
- def self.file_lock(lock_file)
56
+ def self.file_lock(lock_file, blocking = nil)
56
57
  lock_fd = File.open(lock_file, File::RDWR|File::CREAT, 0644)
57
- success = lock_fd.flock(File::LOCK_EX|File::LOCK_NB)
58
- unless success
59
- lock_fd.flock(File::LOCK_UN)
60
- raise Frontkick::Locked
58
+ if blocking
59
+ lock_fd.flock(File::LOCK_EX)
60
+ else
61
+ success = lock_fd.flock(File::LOCK_EX|File::LOCK_NB)
62
+ unless success
63
+ lock_fd.flock(File::LOCK_UN)
64
+ raise Frontkick::Locked
65
+ end
61
66
  end
62
67
  lock_fd
63
68
  end
@@ -1,3 +1,3 @@
1
1
  module Frontkick
2
- VERSION = "0.3.3"
2
+ VERSION = "0.3.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frontkick
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-03 00:00:00.000000000 Z
11
+ date: 2014-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  version: '0'
94
94
  requirements: []
95
95
  rubyforge_project:
96
- rubygems_version: 2.2.2
96
+ rubygems_version: 2.2.0
97
97
  signing_key:
98
98
  specification_version: 4
99
99
  summary: Execute a command simply!