sambal 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sambal/version.rb +1 -1
- data/lib/sambal.rb +10 -0
- data/spec/sambal/client_spec.rb +13 -1
- metadata +3 -3
data/lib/sambal/version.rb
CHANGED
data/lib/sambal.rb
CHANGED
@@ -123,6 +123,12 @@ module Sambal
|
|
123
123
|
end
|
124
124
|
|
125
125
|
def del(file)
|
126
|
+
if (path_parts = file.split('/')).length>1
|
127
|
+
file = path_parts.pop
|
128
|
+
subdirs = path_parts.length
|
129
|
+
dir = path_parts.join('/')
|
130
|
+
cd dir
|
131
|
+
end
|
126
132
|
response = ask "del #{file}"
|
127
133
|
next_line = response.split("\n")[1]
|
128
134
|
if next_line =~ /^smb:.*\\>/
|
@@ -136,6 +142,10 @@ module Sambal
|
|
136
142
|
end
|
137
143
|
rescue InternalError => e
|
138
144
|
Response.new(e.message, false)
|
145
|
+
ensure
|
146
|
+
unless subdirs.nil?
|
147
|
+
subdirs.times { cd '..' }
|
148
|
+
end
|
139
149
|
end
|
140
150
|
|
141
151
|
def close
|
data/spec/sambal/client_spec.rb
CHANGED
@@ -6,13 +6,16 @@ require 'tempfile'
|
|
6
6
|
describe Sambal::Client do
|
7
7
|
|
8
8
|
before(:all) do
|
9
|
+
@sambal_client = described_class.new(host: test_server.host, share: test_server.share_name, port: test_server.port)
|
10
|
+
end
|
11
|
+
|
12
|
+
before(:each) do
|
9
13
|
File.open("#{test_server.share_path}/#{testfile}", 'w') do |f|
|
10
14
|
f << "Hello"
|
11
15
|
end
|
12
16
|
FileUtils.mkdir_p "#{test_server.share_path}/#{test_directory}"
|
13
17
|
FileUtils.chmod 0775, "#{test_server.share_path}/#{test_directory}"
|
14
18
|
FileUtils.chmod 0777, "#{test_server.share_path}/#{testfile}"
|
15
|
-
@sambal_client = described_class.new(host: test_server.host, share: test_server.share_name, port: test_server.port)
|
16
19
|
end
|
17
20
|
|
18
21
|
after(:all) do
|
@@ -89,6 +92,15 @@ describe Sambal::Client do
|
|
89
92
|
@sambal_client.ls.should have_key('dirtest.txt')
|
90
93
|
end
|
91
94
|
|
95
|
+
it "should delete files in subdirectory while in a higher level directory" do
|
96
|
+
@sambal_client.cd('/')
|
97
|
+
@sambal_client.cd(test_directory)
|
98
|
+
@sambal_client.put_content("some content", "file_to_delete").should be_successful
|
99
|
+
@sambal_client.cd('/')
|
100
|
+
@sambal_client.del("#{test_directory}/file_to_delete").should be_successful
|
101
|
+
@sambal_client.ls.should have_key(testfile)
|
102
|
+
end
|
103
|
+
|
92
104
|
it "should not be successful when command fails" do
|
93
105
|
result = @sambal_client.put("jhfahsf iasifasifh", "jsfijsf ijidjag")
|
94
106
|
result.should_not be_successful
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sambal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-04-23 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70313268575020 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: 2.6.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70313268575020
|
25
25
|
description: Ruby Samba Client using the cmdline smbclient
|
26
26
|
email:
|
27
27
|
- john@insane.se
|