libgfapi-ruby 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/glusterfs/directory.rb +23 -0
- data/lib/glusterfs/file.rb +1 -1
- data/lib/glusterfs/version.rb +1 -1
- data/libgfapi-ruby.gemspec +0 -1
- data/spec/glusterfs/directory_spec.rb +89 -0
- data/spec/glusterfs/file_spec.rb +7 -7
- data/spec/spec_helper.rb +3 -5
- metadata +3 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 546c1919faf9f84867e79c2cda248df96598aaf0
|
4
|
+
data.tar.gz: a188c35ef572068a72532948b06bbb337d782414
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 054316ffefaf759aed68126ce68a873358d6a9b26eac92199193f3dc2964cbffacdb489de19cf32609a5510301a17e901facf1c40a366c941d837ba2095d1750
|
7
|
+
data.tar.gz: 81f0d3aa26bcfb9e54f5d4c5f001f0dd478f68b13dc264c59221b2120ce3f08ae49c0488323e7fc2e0cc683b5e1b8a56cac5dd35fa62f0569544adefd0e440cc
|
data/lib/glusterfs/directory.rb
CHANGED
@@ -1,2 +1,25 @@
|
|
1
1
|
class GlusterFS::Directory
|
2
|
+
attr_reader :volume, :path
|
3
|
+
def initialize(volume, path)
|
4
|
+
@volume = volume
|
5
|
+
@path = path
|
6
|
+
end
|
7
|
+
|
8
|
+
def create(perms = 0755)
|
9
|
+
GlusterFS.mkdir(@volume.fs, @path, perms)
|
10
|
+
end
|
11
|
+
|
12
|
+
def delete
|
13
|
+
GlusterFS.rmdir(@volume.fs, @path)
|
14
|
+
end
|
15
|
+
|
16
|
+
def lstat
|
17
|
+
data = GlusterFS::Stat.new
|
18
|
+
GlusterFS.lstat(@volume.fs, @path, data)
|
19
|
+
data
|
20
|
+
end
|
21
|
+
|
22
|
+
def exists?
|
23
|
+
lstat[:st_blocks] > 0
|
24
|
+
end
|
2
25
|
end
|
data/lib/glusterfs/file.rb
CHANGED
data/lib/glusterfs/version.rb
CHANGED
data/libgfapi-ruby.gemspec
CHANGED
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module GlusterFS
|
4
|
+
describe Directory do
|
5
|
+
let(:volume) { Client.mount(GFS_VOLUME, GFS_SERVER_HOST) }
|
6
|
+
let(:dir_name) { "test-#{Time.now.to_i}" }
|
7
|
+
let(:dir) { Directory.new(volume, dir_name) }
|
8
|
+
|
9
|
+
after do
|
10
|
+
dir.delete
|
11
|
+
volume.unmount
|
12
|
+
end
|
13
|
+
|
14
|
+
context '#create' do
|
15
|
+
before { dir.create }
|
16
|
+
subject { dir.exists? }
|
17
|
+
it { should be_true }
|
18
|
+
end
|
19
|
+
|
20
|
+
context '#delete' do
|
21
|
+
before do
|
22
|
+
dir.create
|
23
|
+
dir.delete
|
24
|
+
end
|
25
|
+
subject { dir.exists? }
|
26
|
+
it { should_not be_true }
|
27
|
+
end
|
28
|
+
|
29
|
+
context '#exist?' do
|
30
|
+
subject { dir.exists? }
|
31
|
+
|
32
|
+
context 'on existing dir' do
|
33
|
+
before { dir.create }
|
34
|
+
it { should be_true }
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'on non-existing file' do
|
38
|
+
it { should_not be_true }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context '#lstat' do
|
43
|
+
context 'on existing dir' do
|
44
|
+
before { dir.create }
|
45
|
+
let(:lstat) { dir.lstat }
|
46
|
+
specify 'lstat response is as expected' do
|
47
|
+
lstat[:st_dev].should_not == 0
|
48
|
+
lstat[:st_ino].should_not == 0
|
49
|
+
lstat[:st_nlink].should_not == 0
|
50
|
+
lstat[:st_mode].should_not == 0
|
51
|
+
lstat[:st_uid].should == 0
|
52
|
+
lstat[:st_gid].should == 0
|
53
|
+
lstat[:st_rdev].should == 0
|
54
|
+
lstat[:st_size].should_not == 0
|
55
|
+
lstat[:st_blksize].should == 0
|
56
|
+
lstat[:st_blocks].should be > 1
|
57
|
+
lstat[:st_atime].should_not == 0
|
58
|
+
lstat[:st_mtime].should_not == 0
|
59
|
+
lstat[:st_ctime].should_not == 0
|
60
|
+
lstat[:st_atimesec].should_not == 0
|
61
|
+
lstat[:st_mtimesec].should_not == 0
|
62
|
+
lstat[:st_ctimesec].should_not == 0
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'on non-existing dir' do
|
67
|
+
let(:lstat) { dir.lstat }
|
68
|
+
specify 'lstat response is as expected' do
|
69
|
+
lstat[:st_dev].should == 0
|
70
|
+
lstat[:st_ino].should == 0
|
71
|
+
lstat[:st_nlink].should == 0
|
72
|
+
lstat[:st_mode].should == 0
|
73
|
+
lstat[:st_uid].should == 0
|
74
|
+
lstat[:st_gid].should == 0
|
75
|
+
lstat[:st_rdev].should == 0
|
76
|
+
lstat[:st_size].should == 0
|
77
|
+
lstat[:st_blksize].should == 0
|
78
|
+
lstat[:st_blocks].should == 0
|
79
|
+
lstat[:st_atime].should == 0
|
80
|
+
lstat[:st_mtime].should == 0
|
81
|
+
lstat[:st_ctime].should == 0
|
82
|
+
lstat[:st_atimesec].should == 0
|
83
|
+
lstat[:st_mtimesec].should == 0
|
84
|
+
lstat[:st_ctimesec].should == 0
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
data/spec/glusterfs/file_spec.rb
CHANGED
@@ -8,7 +8,7 @@ module GlusterFS
|
|
8
8
|
let(:data) { '123' }
|
9
9
|
|
10
10
|
after do
|
11
|
-
file.
|
11
|
+
file.delete
|
12
12
|
volume.unmount
|
13
13
|
end
|
14
14
|
|
@@ -39,7 +39,7 @@ module GlusterFS
|
|
39
39
|
let(:data2) { '1234' }
|
40
40
|
|
41
41
|
before { file.write(data) }
|
42
|
-
after { file2.
|
42
|
+
after { file2.delete }
|
43
43
|
|
44
44
|
subject { file2.write(data2) }
|
45
45
|
it('returns bytes written') { should == data2.length }
|
@@ -71,7 +71,7 @@ module GlusterFS
|
|
71
71
|
|
72
72
|
before { file.write_file(data) }
|
73
73
|
after do
|
74
|
-
file2.
|
74
|
+
file2.delete
|
75
75
|
data2.close
|
76
76
|
end
|
77
77
|
|
@@ -80,24 +80,24 @@ module GlusterFS
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
-
context '#
|
83
|
+
context '#delete' do
|
84
84
|
before do
|
85
85
|
file.write(data)
|
86
|
-
file.
|
86
|
+
file.delete
|
87
87
|
end
|
88
88
|
subject { file.exists? }
|
89
89
|
it('deletes the file') { should_not be_true }
|
90
90
|
end
|
91
91
|
|
92
92
|
context '#exist?' do
|
93
|
+
subject { file.exists? }
|
94
|
+
|
93
95
|
context 'on existing file' do
|
94
96
|
before { file.write(data) }
|
95
|
-
subject { file.exists? }
|
96
97
|
it { should be_true }
|
97
98
|
end
|
98
99
|
|
99
100
|
context 'on non-existing file' do
|
100
|
-
subject { file.exists? }
|
101
101
|
it { should_not be_true }
|
102
102
|
end
|
103
103
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
require 'rspec'
|
2
2
|
require 'glusterfs'
|
3
|
-
require 'pry'
|
4
|
-
require 'pry-nav'
|
5
3
|
|
6
|
-
GFS_SERVER_HOST = '127.0.0.1'
|
7
|
-
GFS_SERVER_PORT = 24007
|
8
|
-
GFS_VOLUME = 'dist-volume'
|
4
|
+
GFS_SERVER_HOST = ENV['GFS_SERVER_HOST'] || '127.0.0.1'
|
5
|
+
GFS_SERVER_PORT = (ENV['GFS_SERVER_PORT'] || 24007).to_i
|
6
|
+
GFS_VOLUME = ENV['GFS_VOLUME_NAME'] || 'dist-volume'
|
9
7
|
|
10
8
|
RSpec.configure do |config|
|
11
9
|
config.color_enabled = true
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Varaneckas
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: pry-nav
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - '>='
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: rspec
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -103,6 +89,7 @@ files:
|
|
103
89
|
- lib/glusterfs/volume.rb
|
104
90
|
- libgfapi-ruby.gemspec
|
105
91
|
- spec/glusterfs/client_spec.rb
|
92
|
+
- spec/glusterfs/directory_spec.rb
|
106
93
|
- spec/glusterfs/file_spec.rb
|
107
94
|
- spec/spec_helper.rb
|
108
95
|
homepage: https://github.com/spajus/libgfapi-ruby
|
@@ -131,6 +118,7 @@ specification_version: 4
|
|
131
118
|
summary: Ruby bindings for libgfapi (GlusterFS API)
|
132
119
|
test_files:
|
133
120
|
- spec/glusterfs/client_spec.rb
|
121
|
+
- spec/glusterfs/directory_spec.rb
|
134
122
|
- spec/glusterfs/file_spec.rb
|
135
123
|
- spec/spec_helper.rb
|
136
124
|
has_rdoc:
|