revenc 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -24
- data/.yardopts +6 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +54 -0
- data/HISTORY.markdown +16 -0
- data/{README.rdoc → README.markdown} +41 -35
- data/Rakefile +34 -43
- data/TODO.markdown +3 -0
- data/VERSION +1 -1
- data/bin/revenc +1 -1
- data/config/cucumber.yml +1 -1
- data/features/app.feature +7 -7
- data/features/bin.feature +3 -3
- data/features/configuration.feature +5 -5
- data/features/copy.feature +10 -10
- data/features/mount.feature +11 -11
- data/features/step_definitions/revenc_steps.rb +3 -2
- data/features/support/aruba.rb +2 -2
- data/features/unmount.feature +3 -3
- data/lib/revenc/io.rb +3 -1
- data/lib/revenc.rb +13 -11
- data/revenc.gemspec +42 -0
- data/spec/basic_gem/basic_gem_spec.rb +13 -0
- data/spec/spec_helper.rb +7 -4
- data/spec/watchr.rb +8 -5
- metadata +147 -48
- data/.document +0 -5
- data/CLONING.rdoc +0 -108
- data/lib/revenc/lockfile.rb +0 -66
- data/spec/revenc/lockfile_spec.rb +0 -44
data/CLONING.rdoc
DELETED
@@ -1,108 +0,0 @@
|
|
1
|
-
= Cloning from BasicApp
|
2
|
-
|
3
|
-
BasicApp provides no stand-alone functionality. It purpose is to
|
4
|
-
provide a repository for jump-starting a new RubyGem based CLI
|
5
|
-
application and provide a point to cloned applications to facilitate
|
6
|
-
pulling in future enhancements and fixes.
|
7
|
-
|
8
|
-
== Features/Dependencies
|
9
|
-
|
10
|
-
* Jeweler for RubyGem management http://github.com/technicalpickles/jeweler
|
11
|
-
* Rspec for unit testing http://github.com/dchelimsky/rspec
|
12
|
-
* Cucumber for functional testing http://github.com/tpope/vim-cucumber
|
13
|
-
* Aruba for CLI testing http://github.com/aslakhellesoy/aruba
|
14
|
-
|
15
|
-
== Jump-starting a new project with BasicApp
|
16
|
-
|
17
|
-
The following steps illustrate creating a new application called "oct." Oct
|
18
|
-
is a simple command line utility that prints file listing permissions in octal
|
19
|
-
notation.
|
20
|
-
|
21
|
-
cd ~/workspace
|
22
|
-
git clone git://github.com/robertwahler/basic_app.git oct
|
23
|
-
cd oct
|
24
|
-
|
25
|
-
=== Setup repository for cloned project
|
26
|
-
|
27
|
-
We are going to change the origin URL to our own server and setup a remote
|
28
|
-
for pulling in future BasicApp changes. If our own repo is setup at
|
29
|
-
git@red:oct.git, change the URL with sed:
|
30
|
-
|
31
|
-
sed -i 's/url =.*\.git$/url = git@red:oct.git/' .git/config
|
32
|
-
|
33
|
-
Push it up
|
34
|
-
|
35
|
-
git push origin master:refs/heads/master
|
36
|
-
|
37
|
-
Add BasicApp as remote
|
38
|
-
|
39
|
-
git remote add basic_app git://github.com/robertwahler/basic_app.git
|
40
|
-
|
41
|
-
=== Rename your application
|
42
|
-
|
43
|
-
We need to change the name of the application from basic_app to oct
|
44
|
-
|
45
|
-
git mv bin/basic_app bin/oct
|
46
|
-
git mv lib/basic_app.rb lib/oct.rb
|
47
|
-
git mv lib/basic_app lib/oct
|
48
|
-
|
49
|
-
# BasicApp => Oct
|
50
|
-
find ./bin -type f -exec sed -i 's/BasicApp/Oct/' '{}' +
|
51
|
-
find . -name *.rb -exec sed -i 's/BasicApp/Oct/' '{}' +
|
52
|
-
find . -name Rakefile -exec sed -i 's/BasicApp/Oct/' '{}' +
|
53
|
-
# basic_app => oct
|
54
|
-
find ./bin -type f -exec sed -i 's/basic_app/oct/' '{}' +
|
55
|
-
find ./spec -type f -exec sed -i 's/basic_app/oct/' '{}' +
|
56
|
-
find . -name *.rb -exec sed -i 's/basic_app/oct/' '{}' +
|
57
|
-
find . -name *.feature -exec sed -i 's/basic_app/oct/' '{}' +
|
58
|
-
find . -name Rakefile -exec sed -i 's/basic_app/oct/' '{}' +
|
59
|
-
|
60
|
-
Replace TODO's and update documentation
|
61
|
-
|
62
|
-
* Replace README.rdoc
|
63
|
-
* Replace LICENSE
|
64
|
-
* (OPTIONAL) git rm CLONING.rdoc
|
65
|
-
* Replace the TODO's in Rakefile and bin
|
66
|
-
|
67
|
-
Application should now be functional, lets test it
|
68
|
-
|
69
|
-
cucumber
|
70
|
-
|
71
|
-
Looks OK, commit it
|
72
|
-
|
73
|
-
git commit -a -m "renamed basic_app to oct"
|
74
|
-
|
75
|
-
== Merging of future BasicApp changes
|
76
|
-
|
77
|
-
Cherry picking method
|
78
|
-
|
79
|
-
git fetch basic_app
|
80
|
-
git cherry-pick a0f9745
|
81
|
-
|
82
|
-
Merge 2-step method
|
83
|
-
|
84
|
-
git fetch basic_app
|
85
|
-
git merge basic_app/master
|
86
|
-
|
87
|
-
Trusting pull of HEAD
|
88
|
-
|
89
|
-
git pull basic_app HEAD
|
90
|
-
|
91
|
-
Conflicted?
|
92
|
-
|
93
|
-
git mergetool
|
94
|
-
git commit
|
95
|
-
|
96
|
-
== Note on Patches/Pull Requests
|
97
|
-
|
98
|
-
* Fork the project.
|
99
|
-
* Make your feature addition or bug fix.
|
100
|
-
* Add tests for it. This is important so I don't break it in a
|
101
|
-
future version unintentionally.
|
102
|
-
* Commit, do not mess with rakefile, version, or history.
|
103
|
-
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
104
|
-
* Send me a pull request. Bonus points for topic branches.
|
105
|
-
|
106
|
-
== Copyright
|
107
|
-
|
108
|
-
Copyright (c) 2010 GearheadForHire, LLC. See LICENSE for details.
|
data/lib/revenc/lockfile.rb
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
module Revenc
|
2
|
-
|
3
|
-
class Lockfile
|
4
|
-
attr_accessor :lockfile
|
5
|
-
|
6
|
-
def initialize(lockfile=nil)
|
7
|
-
raise ArgumentError, "lockfile not specified" unless lockfile
|
8
|
-
@lockfile = lockfile
|
9
|
-
end
|
10
|
-
|
11
|
-
def locked?
|
12
|
-
return false unless File.exists?(lockfile)
|
13
|
-
result = false
|
14
|
-
open(lockfile, 'w') do |f|
|
15
|
-
# exclusive non-blocking lock
|
16
|
-
result = !lock(f, File::LOCK_EX | File::LOCK_NB)
|
17
|
-
end
|
18
|
-
result
|
19
|
-
end
|
20
|
-
|
21
|
-
# flock, get a file lock
|
22
|
-
#
|
23
|
-
# Typical usage:
|
24
|
-
#
|
25
|
-
# open('output', 'w') do |f|
|
26
|
-
# flock(f, File::LOCK_EX) do |f|
|
27
|
-
# f << "write to file"
|
28
|
-
# end
|
29
|
-
# end
|
30
|
-
def lock(file, mode)
|
31
|
-
result = file.flock(mode)
|
32
|
-
if result
|
33
|
-
begin
|
34
|
-
yield file if block_given?
|
35
|
-
ensure
|
36
|
-
file.flock(File::LOCK_UN)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
return result
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
class Mutex < Lockfile
|
44
|
-
|
45
|
-
def initialize(lockfile='revenc.lck')
|
46
|
-
super lockfile
|
47
|
-
end
|
48
|
-
|
49
|
-
def execute
|
50
|
-
result = false
|
51
|
-
begin
|
52
|
-
open(@lockfile, 'w') do |f|
|
53
|
-
# exclusive non-blocking lock
|
54
|
-
result = lock(f, File::LOCK_EX | File::LOCK_NB) do |f|
|
55
|
-
yield if block_given?
|
56
|
-
end
|
57
|
-
end
|
58
|
-
ensure
|
59
|
-
# clean up but only if we have a positive result meaning we wrote the lockfile
|
60
|
-
FileUtils.rm(@lockfile) if (result && File.exists?(@lockfile))
|
61
|
-
end
|
62
|
-
result
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
|
3
|
-
describe Revenc::Mutex do
|
4
|
-
|
5
|
-
before(:each) do
|
6
|
-
FileUtils.rm_rf(current_dir)
|
7
|
-
end
|
8
|
-
|
9
|
-
describe 'mutex' do
|
10
|
-
|
11
|
-
it "should create a mutex, yield, and clean up" do
|
12
|
-
in_current_dir do
|
13
|
-
mutex = Revenc::Mutex.new
|
14
|
-
result = mutex.execute do
|
15
|
-
File.should be_file('revenc.lck')
|
16
|
-
mutex.should be_locked
|
17
|
-
end
|
18
|
-
result.should be_true
|
19
|
-
mutex.should_not be_locked
|
20
|
-
File.should_not be_file('revenc.lck')
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should prevent recursion but not block" do
|
25
|
-
in_current_dir do
|
26
|
-
Revenc::Mutex.new.execute do
|
27
|
-
File.should be_file('revenc.lck')
|
28
|
-
|
29
|
-
mutext = Revenc::Mutex.new
|
30
|
-
result = mutext.execute do
|
31
|
-
# This block is protected, should not be here
|
32
|
-
true.should be(false)
|
33
|
-
end
|
34
|
-
result.should be_false
|
35
|
-
mutext.should be_locked
|
36
|
-
end
|
37
|
-
File.should_not be_file('revenc.lck')
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
|