libgfapi-ruby 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 546c1919faf9f84867e79c2cda248df96598aaf0
4
- data.tar.gz: a188c35ef572068a72532948b06bbb337d782414
3
+ metadata.gz: 230aca06d3347c56526f91d602b9f757f595484c
4
+ data.tar.gz: 51ee11f597681f195d4c72a912e7d9a7030db541
5
5
  SHA512:
6
- metadata.gz: 054316ffefaf759aed68126ce68a873358d6a9b26eac92199193f3dc2964cbffacdb489de19cf32609a5510301a17e901facf1c40a366c941d837ba2095d1750
7
- data.tar.gz: 81f0d3aa26bcfb9e54f5d4c5f001f0dd478f68b13dc264c59221b2120ce3f08ae49c0488323e7fc2e0cc683b5e1b8a56cac5dd35fa62f0569544adefd0e440cc
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 = GlusterFS::Client.mount('my_volume', '1.2.3.4')
30
+ volume = GlusterFS::Volume.new('my_volume')
31
+ volume.mount('1.2.3.4')
31
32
 
32
- # Make a new directory (raw)
33
- GlusterFS.mkdir(volume.fs, '/some_dir', 0755)
33
+ # Create a new directory
34
+ dir = GlusterFS::Directory.new(volume, '/some_dir')
35
+ dir.create
34
36
 
35
- # Write a file
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
- contents = file.read
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
@@ -5,7 +5,6 @@ require "glusterfs/error"
5
5
  require "glusterfs/file"
6
6
  require "glusterfs/directory"
7
7
  require "glusterfs/volume"
8
- require "glusterfs/client"
9
8
  require "glusterfs/stat"
10
9
 
11
10
  module GlusterFS
@@ -1,3 +1,3 @@
1
1
  module GlusterFS
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -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) { Client.mount(GFS_VOLUME, GFS_SERVER_HOST) }
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
 
@@ -2,7 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  module GlusterFS
4
4
  describe File do
5
- let(:volume) { Client.mount(GFS_VOLUME, GFS_SERVER_HOST) }
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.5
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:
@@ -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
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module GlusterFS
4
- describe GlusterFS::Client do
5
- it 'mounts volume' do
6
- volume = GlusterFS::Client.mount(GFS_VOLUME, GFS_SERVER_HOST)
7
- volume.name.should == GFS_VOLUME
8
- end
9
- end
10
- end