libgfapi-ruby 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -5
- data/lib/glusterfs.rb +0 -1
- data/lib/glusterfs/version.rb +1 -1
- data/lib/glusterfs/volume.rb +2 -0
- data/spec/glusterfs/directory_spec.rb +2 -1
- data/spec/glusterfs/file_spec.rb +2 -1
- data/spec/glusterfs/volume_spec.rb +35 -0
- metadata +3 -4
- data/lib/glusterfs/client.rb +0 -13
- data/spec/glusterfs/client_spec.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 230aca06d3347c56526f91d602b9f757f595484c
|
4
|
+
data.tar.gz: 51ee11f597681f195d4c72a912e7d9a7030db541
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4dedae2636440ed2b10f2b950f408a84d32c168798a8270606834a52df10c4e1dc4dd4d89811350203bf0eec73e137e0f47c9871daa8d3f528da16eee2ba749
|
7
|
+
data.tar.gz: de709064f41c31e50943949acac787ff21ed2065dcf1d424f6718f100526d466bfbab5402712cf9b5ac3fc94f0d24d8c5f7a068250c4a8340864f395a27f6771
|
data/README.md
CHANGED
@@ -27,20 +27,36 @@ Or install it yourself as:
|
|
27
27
|
require 'glusterfs'
|
28
28
|
|
29
29
|
# Create virtual mount
|
30
|
-
volume =
|
30
|
+
volume = GlusterFS::Volume.new('my_volume')
|
31
|
+
volume.mount('1.2.3.4')
|
31
32
|
|
32
|
-
#
|
33
|
-
GlusterFS.
|
33
|
+
# Create a new directory
|
34
|
+
dir = GlusterFS::Directory.new(volume, '/some_dir')
|
35
|
+
dir.create
|
34
36
|
|
35
|
-
#
|
37
|
+
# Delete a directory
|
38
|
+
dir = GlusterDS::Directory.new(volume, '/some_dir')
|
39
|
+
dir.delete
|
40
|
+
|
41
|
+
# Create a file from string or bytes
|
36
42
|
file = GlusterFS::File.new(volume, '/gfs/file/path')
|
37
43
|
size = file.write(data)
|
38
44
|
puts "Written #{size} bytes"
|
39
45
|
|
46
|
+
# Copy an existing file to gluster
|
47
|
+
existing_file = File.open('/path/to/file')
|
48
|
+
file = GlusterFS::File.new(volume, '/gfs/file/path')
|
49
|
+
size = file.write_file(existing_file)
|
50
|
+
puts "Written #{size} bytes"
|
51
|
+
|
40
52
|
# Read a file
|
41
53
|
file = GlusterFS::File.new(volume, '/gfs/file/path')
|
42
54
|
contents = file.read
|
43
|
-
|
55
|
+
|
56
|
+
# Read a file into a Tempfile
|
57
|
+
file = GlusterFS::File.new(volume, '/gfs/file/path')
|
58
|
+
tempfile = file.read_file
|
59
|
+
puts "Tempfile path: #{tempfile.path}"
|
44
60
|
|
45
61
|
# Delete a file
|
46
62
|
file = GlusterFS::File.new(volume, '/gfs/file/path')
|
data/lib/glusterfs.rb
CHANGED
data/lib/glusterfs/version.rb
CHANGED
data/lib/glusterfs/volume.rb
CHANGED
@@ -4,6 +4,7 @@ class GlusterFS::Volume
|
|
4
4
|
def initialize(name)
|
5
5
|
@name = name
|
6
6
|
@fs = GlusterFS.new(@name)
|
7
|
+
self
|
7
8
|
end
|
8
9
|
|
9
10
|
def mount(host, port = 24007, protocol = 'tcp')
|
@@ -14,6 +15,7 @@ class GlusterFS::Volume
|
|
14
15
|
"Failed to mount volume '#{volume_name}' on #{protocol}://#{host}:#{port}"
|
15
16
|
end
|
16
17
|
@mounted = true
|
18
|
+
self
|
17
19
|
end
|
18
20
|
|
19
21
|
def mounted?
|
@@ -2,7 +2,8 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module GlusterFS
|
4
4
|
describe Directory do
|
5
|
-
let(:volume) {
|
5
|
+
let(:volume) { Volume.new(GFS_VOLUME)
|
6
|
+
.mount(GFS_SERVER_HOST, GFS_SERVER_PORT) }
|
6
7
|
let(:dir_name) { "test-#{Time.now.to_i}" }
|
7
8
|
let(:dir) { Directory.new(volume, dir_name) }
|
8
9
|
|
data/spec/glusterfs/file_spec.rb
CHANGED
@@ -2,7 +2,8 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module GlusterFS
|
4
4
|
describe File do
|
5
|
-
let(:volume) {
|
5
|
+
let(:volume) { Volume.new(GFS_VOLUME)
|
6
|
+
.mount(GFS_SERVER_HOST, GFS_SERVER_PORT) }
|
6
7
|
let(:file_name) { "test-#{Time.now.to_i}" }
|
7
8
|
let(:file) { File.new(volume, file_name) }
|
8
9
|
let(:data) { '123' }
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module GlusterFS
|
4
|
+
describe Volume do
|
5
|
+
let(:volume) { Volume.new(GFS_VOLUME) }
|
6
|
+
|
7
|
+
context '#mount' do
|
8
|
+
before { volume.mount(GFS_SERVER_HOST, GFS_SERVER_PORT) }
|
9
|
+
subject { volume.mounted? }
|
10
|
+
it { should be_true }
|
11
|
+
end
|
12
|
+
|
13
|
+
context '#unmount' do
|
14
|
+
before do
|
15
|
+
volume.mount(GFS_SERVER_HOST, GFS_SERVER_PORT)
|
16
|
+
volume.unmount
|
17
|
+
end
|
18
|
+
subject { volume.mounted? }
|
19
|
+
it { should_not be_true }
|
20
|
+
end
|
21
|
+
|
22
|
+
context '#mounted?' do
|
23
|
+
subject { volume.mounted? }
|
24
|
+
|
25
|
+
context 'on mounted volume' do
|
26
|
+
before { volume.mount(GFS_SERVER_HOST, GFS_SERVER_PORT) }
|
27
|
+
it { should be_true }
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'on unmounted volume' do
|
31
|
+
it { should_not be_true }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libgfapi-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Varaneckas
|
@@ -80,7 +80,6 @@ files:
|
|
80
80
|
- Rakefile
|
81
81
|
- lib/glusterfs.rb
|
82
82
|
- lib/glusterfs/bindings.rb
|
83
|
-
- lib/glusterfs/client.rb
|
84
83
|
- lib/glusterfs/directory.rb
|
85
84
|
- lib/glusterfs/error.rb
|
86
85
|
- lib/glusterfs/file.rb
|
@@ -88,9 +87,9 @@ files:
|
|
88
87
|
- lib/glusterfs/version.rb
|
89
88
|
- lib/glusterfs/volume.rb
|
90
89
|
- libgfapi-ruby.gemspec
|
91
|
-
- spec/glusterfs/client_spec.rb
|
92
90
|
- spec/glusterfs/directory_spec.rb
|
93
91
|
- spec/glusterfs/file_spec.rb
|
92
|
+
- spec/glusterfs/volume_spec.rb
|
94
93
|
- spec/spec_helper.rb
|
95
94
|
homepage: https://github.com/spajus/libgfapi-ruby
|
96
95
|
licenses:
|
@@ -117,8 +116,8 @@ signing_key:
|
|
117
116
|
specification_version: 4
|
118
117
|
summary: Ruby bindings for libgfapi (GlusterFS API)
|
119
118
|
test_files:
|
120
|
-
- spec/glusterfs/client_spec.rb
|
121
119
|
- spec/glusterfs/directory_spec.rb
|
122
120
|
- spec/glusterfs/file_spec.rb
|
121
|
+
- spec/glusterfs/volume_spec.rb
|
123
122
|
- spec/spec_helper.rb
|
124
123
|
has_rdoc:
|
data/lib/glusterfs/client.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
class GlusterFS::Client
|
2
|
-
class << self
|
3
|
-
def mount(volume_name, host, port = 24007, protocol = 'tcp')
|
4
|
-
volume = GlusterFS::Volume.new(volume_name)
|
5
|
-
volume.mount(host, port, protocol)
|
6
|
-
volume
|
7
|
-
end
|
8
|
-
|
9
|
-
def unmount(volume)
|
10
|
-
GlusterFS.fini(volume.fs)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|