fspath-xattr 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /pkg/
2
+
3
+ /doc/
4
+ /rdoc/
5
+ /.yardoc/
6
+ /coverage/
7
+
8
+ Makefile
9
+ *.o
10
+ *.bundle
11
+ /tmp/
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010-2011 Ivan Kuchin
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,21 @@
1
+ # fspath
2
+
3
+ Better than Pathname
4
+
5
+ ### Extended attributes (using xattr gem)
6
+
7
+ Get extended attribute:
8
+
9
+ FSPath('/a/b/c').xattr['com.macromates.caret']
10
+
11
+ Set extended attribute:
12
+
13
+ FSPath('/a/b/c').xattr['good'] = 'bad'
14
+
15
+ Set extended attribute on symlink itself:
16
+
17
+ FSPath('/a/b/c').lxattr['good'] = 'bad'
18
+
19
+ ## Copyright
20
+
21
+ Copyright (c) 2010-2011 Ivan Kuchin. See LICENSE.txt for details.
@@ -0,0 +1,21 @@
1
+ # encoding: UTF-8
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'fspath-xattr'
5
+ s.version = '1.0.0'
6
+ s.summary = %q{FSPath methods xattr and lxattr to work with extended attributes using ffi-xattr gem}
7
+ s.homepage = "http://github.com/toy/#{s.name}"
8
+ s.authors = ['Ivan Kuchin']
9
+ s.license = 'MIT'
10
+
11
+ s.rubyforge_project = s.name
12
+
13
+ s.files = `git ls-files`.split("\n")
14
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
16
+ s.require_paths = %w[lib]
17
+
18
+ s.add_dependency 'fspath', '~> 2.0.0'
19
+ s.add_dependency 'ffi-xattr', '~> 0.0.4'
20
+ s.add_development_dependency 'rspec'
21
+ end
@@ -0,0 +1,18 @@
1
+ require 'fspath'
2
+ require 'ffi-xattr'
3
+
4
+ class FSPath
5
+ module Xattr
6
+ # Xattr instance for path
7
+ def xattr
8
+ ::Xattr.new(@path)
9
+ end
10
+
11
+ # Xattr instance for path which doesn't follow symlinks
12
+ def lxattr
13
+ ::Xattr.new(@path, :no_follow => true)
14
+ end
15
+ end
16
+
17
+ include Xattr
18
+ end
@@ -0,0 +1,54 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+ require 'fspath/xattr'
3
+
4
+ describe FSPath::Xattr do
5
+ let(:path){ 'test.txt' }
6
+ let(:link){ 'link.txt' }
7
+
8
+ before do
9
+ File.open(path, 'w'){ |io| io << 'some content' }
10
+ File.symlink(path, link)
11
+ end
12
+ after do
13
+ File.delete(path)
14
+ File.delete(link)
15
+ end
16
+
17
+ describe "xattr" do
18
+ let(:xattr){ FSPath(link).xattr }
19
+
20
+ it "should return instance of Xattr" do
21
+ xattr.should be_kind_of(Xattr)
22
+ end
23
+
24
+ it "should point to same path" do
25
+ xattr.instance_variable_get(:@path).should == link
26
+ end
27
+
28
+ it "should set xattr on linked path" do
29
+ FSPath(path).xattr['user.hello'].should be_nil
30
+ xattr['user.hello'] = 'foo'
31
+ xattr['user.hello'].should == 'foo'
32
+ FSPath(path).xattr['user.hello'].should == 'foo'
33
+ end
34
+ end
35
+
36
+ describe "lxattr" do
37
+ let(:xattr){ FSPath(link).lxattr }
38
+
39
+ it "should return instance of Xattr" do
40
+ xattr.should be_kind_of(Xattr)
41
+ end
42
+
43
+ it "should point to same path" do
44
+ xattr.instance_variable_get(:@path).should == link
45
+ end
46
+
47
+ it "should set xattr on link itself" do
48
+ FSPath(path).xattr['user.hello'].should be_nil
49
+ xattr['user.hello'] = 'foo'
50
+ xattr['user.hello'].should == 'foo'
51
+ FSPath(path).xattr['user.hello'].should be_nil
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,2 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
2
+ require 'rspec'
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fspath-xattr
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Ivan Kuchin
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-11-20 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: fspath
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 15
29
+ segments:
30
+ - 2
31
+ - 0
32
+ - 0
33
+ version: 2.0.0
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: ffi-xattr
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ hash: 23
45
+ segments:
46
+ - 0
47
+ - 0
48
+ - 4
49
+ version: 0.0.4
50
+ type: :runtime
51
+ version_requirements: *id002
52
+ - !ruby/object:Gem::Dependency
53
+ name: rspec
54
+ prerelease: false
55
+ requirement: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 3
61
+ segments:
62
+ - 0
63
+ version: "0"
64
+ type: :development
65
+ version_requirements: *id003
66
+ description:
67
+ email:
68
+ executables: []
69
+
70
+ extensions: []
71
+
72
+ extra_rdoc_files: []
73
+
74
+ files:
75
+ - .gitignore
76
+ - LICENSE.txt
77
+ - README.markdown
78
+ - fspath-xattr.gemspec
79
+ - lib/fspath/xattr.rb
80
+ - spec/fspath/xattr_spec.rb
81
+ - spec/spec_helper.rb
82
+ homepage: http://github.com/toy/fspath-xattr
83
+ licenses:
84
+ - MIT
85
+ post_install_message:
86
+ rdoc_options: []
87
+
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ hash: 3
96
+ segments:
97
+ - 0
98
+ version: "0"
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ none: false
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ hash: 3
105
+ segments:
106
+ - 0
107
+ version: "0"
108
+ requirements: []
109
+
110
+ rubyforge_project: fspath-xattr
111
+ rubygems_version: 1.8.11
112
+ signing_key:
113
+ specification_version: 3
114
+ summary: FSPath methods xattr and lxattr to work with extended attributes using ffi-xattr gem
115
+ test_files:
116
+ - spec/fspath/xattr_spec.rb
117
+ - spec/spec_helper.rb
118
+ has_rdoc: