flocker 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/LICENSE +20 -0
  2. data/README.md +16 -0
  3. data/flocker.gemspec +13 -0
  4. data/lib/flocker.rb +9 -0
  5. metadata +50 -0
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 chrismetcalfe
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,16 @@
1
+ flocker
2
+ =======
3
+
4
+ Ensure that only one instance of a Ruby script will be run at a time on unix-based systems. For more information on file locking see: [flock(2) manpage](http://linux.die.net/man/2/flock)
5
+
6
+ ## Installation
7
+ ```ruby
8
+ gem install flocker
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ To use flocker simply require it in your script:
14
+ ```ruby
15
+ require 'flocker'
16
+ ```
@@ -0,0 +1,13 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'flocker'
3
+ s.version = '1.0.0'
4
+ s.summary = "Flocker uses a file lock to prevent a Ruby script from running if it's already running."
5
+ s.authors = ["Chris Metcalfe"]
6
+ s.email = 'chrsmtclf@gmail.com'
7
+
8
+ s.files = `git ls-files`.split("\n")
9
+ s.require_paths = ["lib"]
10
+
11
+ s.homepage= 'https://github.com/chrismetcalfe/flocker'
12
+ s.license = 'MIT'
13
+ end
@@ -0,0 +1,9 @@
1
+ class Flocker
2
+ def initialize
3
+ filepath = File.expand_path($PROGRAM_NAME)
4
+ f = File.open(filepath)
5
+ abort "This script is already running." unless f.flock(File::LOCK_EX | File::LOCK_NB)
6
+ end
7
+ end
8
+
9
+ Flocker.new
metadata ADDED
@@ -0,0 +1,50 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: flocker
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Chris Metcalfe
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-11-07 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description:
15
+ email: chrsmtclf@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - LICENSE
21
+ - README.md
22
+ - flocker.gemspec
23
+ - lib/flocker.rb
24
+ homepage: https://github.com/chrismetcalfe/flocker
25
+ licenses:
26
+ - MIT
27
+ post_install_message:
28
+ rdoc_options: []
29
+ require_paths:
30
+ - lib
31
+ required_ruby_version: !ruby/object:Gem::Requirement
32
+ none: false
33
+ requirements:
34
+ - - ! '>='
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ requirements: []
44
+ rubyforge_project:
45
+ rubygems_version: 1.8.24
46
+ signing_key:
47
+ specification_version: 3
48
+ summary: Flocker uses a file lock to prevent a Ruby script from running if it's already
49
+ running.
50
+ test_files: []