ffi-xattr 0.1.0 → 0.1.1

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: 03fc82a1353a14b6b48327682f8efb5327f8d4a6
4
- data.tar.gz: dd6a2abd62dd605cb0aae1cb65551e69f4c2d00f
3
+ metadata.gz: b16d449688c3e5d3d08e7384fe28da6b6ba89e60
4
+ data.tar.gz: 2c760c5c08c43942bf191e34634f4add6b5893c7
5
5
  SHA512:
6
- metadata.gz: f9cc1cbaab866ac3a6d89d7066b8621ba66eb36ac45032df2a59b0c92a7d57fc297d3db3ed02bed7d41c05aa00520690f84d182979feca7ec881f5eb0ad7200c
7
- data.tar.gz: 73dc271860f7c541aac07195bdfe4cc3746bee9fa0755917967fe899f90ff91934b2f915230446f19bcbd947bda236a37cf372fb6aeb89d0d84840d02e68b244
6
+ metadata.gz: a0bef783382b40a0f75a85da7f82881058b5db2dccb1c6e4b6bfe6be797f3a54b29af9d0e378a137ab7ec453c3b92cf3a3fb814be6a2c3f1e2f280bdf42b4106
7
+ data.tar.gz: 123dc41cc0783bb3aa06beecf3307f1acdfad8d855a921e1d34c93beaed7364b245e896fd6c73dde53de08d1d1270ea61c7bcac48b855d215fa08744cf2c85ed
data/README.md CHANGED
@@ -3,9 +3,6 @@ ffi-xattr
3
3
 
4
4
  Ruby library to manage extended file attributes.
5
5
 
6
- [![Build Status](https://secure.travis-ci.org/jarib/ffi-xattr.png)](http://travis-ci.org/jarib/ffi-xattr)
7
-
8
-
9
6
  Example
10
7
  -------
11
8
 
@@ -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
- raise Errno::ENOENT, path unless File.exist?(path)
23
- @path = path.to_str
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
 
@@ -0,0 +1,3 @@
1
+ require 'ffi-xattr/extensions/file'
2
+ require 'ffi-xattr/extensions/pathname'
3
+
@@ -0,0 +1,9 @@
1
+ require 'ffi-xattr'
2
+
3
+ class File
4
+
5
+ # Returns an Xattr object for the named file (see Xattr).
6
+ def self.xattr(file_name)
7
+ Xattr.new(file_name)
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ require 'ffi-xattr/extensions/file'
2
+
3
+ class Pathname
4
+ # Returns an Xattr object.
5
+ # See File.xattr.
6
+ def xattr
7
+ File.xattr(self)
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  class Xattr
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -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
@@ -82,20 +82,22 @@ describe Xattr do
82
82
  lambda{ Xattr.new(1) }.should raise_error(TypeError)
83
83
  end
84
84
 
85
- class SuperPath
86
- def initialize(path)
87
- @path = path
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
- def to_str
91
- @path.dup
92
- end
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 directly converted to string" do
96
- super_path = SuperPath.new(path)
97
- Xattr.new(super_path).set('user.foo', 'bar')
98
- Xattr.new(super_path).get('user.foo').should == 'bar'
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.0
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-01-30 00:00:00.000000000 Z
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: