ffi-xattr 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -3
- data/lib/ffi-xattr.rb +10 -2
- data/lib/ffi-xattr/extensions.rb +3 -0
- data/lib/ffi-xattr/extensions/file.rb +9 -0
- data/lib/ffi-xattr/extensions/pathname.rb +9 -0
- data/lib/ffi-xattr/version.rb +1 -1
- data/spec/extensions_spec.rb +35 -0
- data/spec/xattr_spec.rb +13 -11
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b16d449688c3e5d3d08e7384fe28da6b6ba89e60
|
4
|
+
data.tar.gz: 2c760c5c08c43942bf191e34634f4add6b5893c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0bef783382b40a0f75a85da7f82881058b5db2dccb1c6e4b6bfe6be797f3a54b29af9d0e378a137ab7ec453c3b92cf3a3fb814be6a2c3f1e2f280bdf42b4106
|
7
|
+
data.tar.gz: 123dc41cc0783bb3aa06beecf3307f1acdfad8d855a921e1d34c93beaed7364b245e896fd6c73dde53de08d1d1270ea61c7bcac48b855d215fa08744cf2c85ed
|
data/README.md
CHANGED
data/lib/ffi-xattr.rb
CHANGED
@@ -19,8 +19,16 @@ class Xattr
|
|
19
19
|
# Create a new Xattr instance with path.
|
20
20
|
# Use <tt>:no_follow => true</tt> in options to work on symlink itself instead of following it.
|
21
21
|
def initialize(path, options = {})
|
22
|
-
|
23
|
-
|
22
|
+
@path =
|
23
|
+
if path.respond_to?(:to_path)
|
24
|
+
path.to_path
|
25
|
+
elsif path.respond_to?(:to_str)
|
26
|
+
path.to_str
|
27
|
+
else
|
28
|
+
path
|
29
|
+
end
|
30
|
+
raise Errno::ENOENT, @path unless File.exist?(@path)
|
31
|
+
|
24
32
|
@no_follow = !!options[:no_follow]
|
25
33
|
end
|
26
34
|
|
data/lib/ffi-xattr/version.rb
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'ffi-xattr/extensions'
|
2
|
+
|
3
|
+
describe "Xattr extensions" do
|
4
|
+
let(:path) { "test.txt" }
|
5
|
+
let(:xattr) { Xattr.new(path) }
|
6
|
+
|
7
|
+
before { File.open(path, "w") { |io| io << "some content" } }
|
8
|
+
after { File.delete(path) }
|
9
|
+
|
10
|
+
describe "File.xattr" do
|
11
|
+
it "should return an Xattr for the supplied path" do
|
12
|
+
x = File.xattr(path)
|
13
|
+
|
14
|
+
x.should be_kind_of(Xattr)
|
15
|
+
|
16
|
+
#and operate on the real path
|
17
|
+
x["user.file"] = "foo"
|
18
|
+
Xattr.new(path)["user.file"].should == "foo"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "Pathname#xattr" do
|
23
|
+
it "should return an Xattr for the underlying path" do
|
24
|
+
p = Pathname.new(path)
|
25
|
+
x = p.xattr
|
26
|
+
|
27
|
+
x.should be_kind_of(Xattr)
|
28
|
+
|
29
|
+
#and operate on the real path
|
30
|
+
x["user.path"] = "foo"
|
31
|
+
Xattr.new(path)["user.path"].should == "foo"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
data/spec/xattr_spec.rb
CHANGED
@@ -82,20 +82,22 @@ describe Xattr do
|
|
82
82
|
lambda{ Xattr.new(1) }.should raise_error(TypeError)
|
83
83
|
end
|
84
84
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
end
|
85
|
+
it "should work with object that can be converted to string" do
|
86
|
+
super_path = double("super_path")
|
87
|
+
super_path.should_receive(:to_str).and_return(path)
|
89
88
|
|
90
|
-
|
91
|
-
|
92
|
-
|
89
|
+
Xattr.new(super_path).set('user.foo', 'bar')
|
90
|
+
|
91
|
+
Xattr.new(path).get('user.foo').should == 'bar'
|
93
92
|
end
|
94
93
|
|
95
|
-
it "should work with object that can be
|
96
|
-
|
97
|
-
|
98
|
-
|
94
|
+
it "should work with object that can be coerced to string with #to_path" do
|
95
|
+
to_path_obj = double("to_path")
|
96
|
+
to_path_obj.should_receive(:to_path).and_return(path)
|
97
|
+
|
98
|
+
Xattr.new(to_path_obj).set('user.to_path', 'bar')
|
99
|
+
|
100
|
+
Xattr.new(path).get('user.to_path').should == 'bar'
|
99
101
|
end
|
100
102
|
|
101
103
|
describe "respecting :no_follow option" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-xattr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jari Bakken
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -69,9 +69,13 @@ files:
|
|
69
69
|
- lib/ffi-xattr.rb
|
70
70
|
- lib/ffi-xattr/darwin_lib.rb
|
71
71
|
- lib/ffi-xattr/error.rb
|
72
|
+
- lib/ffi-xattr/extensions.rb
|
73
|
+
- lib/ffi-xattr/extensions/file.rb
|
74
|
+
- lib/ffi-xattr/extensions/pathname.rb
|
72
75
|
- lib/ffi-xattr/linux_lib.rb
|
73
76
|
- lib/ffi-xattr/version.rb
|
74
77
|
- lib/ffi-xattr/windows_lib.rb
|
78
|
+
- spec/extensions_spec.rb
|
75
79
|
- spec/xattr_spec.rb
|
76
80
|
homepage: http://github.com/jarib/ffi-xattr
|
77
81
|
licenses: []
|
@@ -97,5 +101,5 @@ signing_key:
|
|
97
101
|
specification_version: 4
|
98
102
|
summary: Manipulate extended file attributes
|
99
103
|
test_files:
|
104
|
+
- spec/extensions_spec.rb
|
100
105
|
- spec/xattr_spec.rb
|
101
|
-
has_rdoc:
|