couch-quilt 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,43 +14,53 @@
14
14
  # limitations under the License.
15
15
  #
16
16
  # usage:
17
- # couchquilt ~/quilt http://localhost:5984
18
-
19
- QUILT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), ".."))
20
- require File.join(QUILT_ROOT, "lib/couchquilt")
17
+ # couchquilt http://localhost:5984 ~/quilt
21
18
 
22
19
  DEBUG = ARGV.delete("--debug")
23
- require File.join(File.dirname(__FILE__), '../lib/couchquilt/debugged_fs') if DEBUG
24
20
 
25
- if ARGV.empty?
21
+ require File.expand_path("../../lib/couchquilt", __FILE__)
22
+ require File.expand_path("../../lib/couchquilt/debugged_fs", __FILE__) if DEBUG
23
+
24
+ # database server url defaults to http://127.0.0.1:5984
25
+ ARGV.unshift "http://127.0.0.1:5984" if !ARGV[1] && ARGV[0] !~ /^-/
26
+
27
+ server, mountpoint = ARGV
28
+
29
+ unless server && mountpoint
26
30
  puts "usage:"
27
31
  puts "couchquilt [server] mountpoint [--debug]"
28
32
  exit
29
33
  end
30
34
 
31
- # database server url defaults to http://127.0.0.1:5984
32
- ARGV.unshift "http://127.0.0.1:5984" if ARGV.size < 2
33
-
34
- server = ARGV[0]
35
- mountpoint = ARGV[1]
36
35
 
37
36
  # create mount point if needed
38
37
  Dir.mkdir(mountpoint) unless File.directory?(mountpoint)
39
38
 
40
- # init quilt fs
41
- quilt_fs_class = DEBUG ? Couchquilt::DebuggedFS : Couchquilt::FS
42
- FuseFS.set_root quilt_fs_class.new(server)
43
- FuseFS.mount_under mountpoint
44
-
45
- # listen for exit signals and unmount fuse
46
- trap("INT") do
47
- puts "ancelling..."
48
- FuseFS.unmount
49
- FuseFS.exit
50
- puts "Bye."
39
+ def maybe_fork
40
+ if DEBUG
41
+ yield
42
+ else
43
+ p = fork { yield }
44
+ Process.detach p
45
+ end
46
+ end
47
+
48
+ # on debug mode we do not run in background
49
+ maybe_fork do
50
+ # listen for exit signals and unmount fuse
51
+ trap("EXIT") do
52
+ FuseFS.unmount
53
+ FuseFS.exit
54
+ end
55
+
56
+ # init quilt fs
57
+ quilt_fs_class = DEBUG ? Couchquilt::DebuggedFS : Couchquilt::FS
58
+ FuseFS.set_root quilt_fs_class.new(server)
59
+ FuseFS.mount_under mountpoint
60
+
61
+ # actually do the Fuse mount
62
+ puts "Quilt maps #{server} to #{mountpoint}" if DEBUG
63
+
64
+ FuseFS.run
51
65
  end
52
66
 
53
- # actually do the Fuse mount
54
- puts "Quilt maps #{server} to #{mountpoint}"
55
- puts "Debug mode" if DEBUG
56
- FuseFS.run
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{couch-quilt}
8
- s.version = "0.4.0"
8
+ s.version = "0.4.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Johannes J\303\266rg Schmidt"]
12
- s.date = %q{2010-03-22}
12
+ s.date = %q{2010-03-23}
13
13
  s.default_executable = %q{couchquilt}
14
14
  s.description = %q{Access CouchDB JSON documents from filesystem.}
15
15
  s.email = %q{schmidt@netzmerk.com}
@@ -1,3 +1,3 @@
1
1
  module Couchquilt
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.1'
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- - 0
9
- version: 0.4.0
8
+ - 1
9
+ version: 0.4.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - "Johannes J\xC3\xB6rg Schmidt"
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-22 00:00:00 +01:00
17
+ date: 2010-03-23 00:00:00 +01:00
18
18
  default_executable: couchquilt
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency