fspath 1.1.0-darwin → 1.2.0-darwin

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -13,7 +13,7 @@ name = 'fspath'
13
13
  gem.license = 'MIT'
14
14
  gem.authors = ['Ivan Kuchin']
15
15
  gem.platform = platform
16
- gem.add_dependency 'xattr'
16
+ gem.add_dependency 'ffi-xattr'
17
17
  if platform == 'darwin'
18
18
  gem.add_dependency 'rb-appscript'
19
19
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.2.0
data/fspath.gemspec CHANGED
@@ -5,12 +5,12 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "fspath"
8
- s.version = "1.1.0"
8
+ s.version = "1.2.0"
9
9
  s.platform = "darwin"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.authors = ["Ivan Kuchin"]
13
- s.date = "2011-10-31"
13
+ s.date = "2011-11-20"
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE.txt",
16
16
  "README.markdown"
@@ -41,20 +41,20 @@ Gem::Specification.new do |s|
41
41
  s.specification_version = 3
42
42
 
43
43
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
44
- s.add_runtime_dependency(%q<xattr>, [">= 0"])
44
+ s.add_runtime_dependency(%q<ffi-xattr>, [">= 0"])
45
45
  s.add_runtime_dependency(%q<rb-appscript>, [">= 0"])
46
46
  s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
47
47
  s.add_development_dependency(%q<rake-gem-ghost>, [">= 0"])
48
48
  s.add_development_dependency(%q<rspec>, [">= 0"])
49
49
  else
50
- s.add_dependency(%q<xattr>, [">= 0"])
50
+ s.add_dependency(%q<ffi-xattr>, [">= 0"])
51
51
  s.add_dependency(%q<rb-appscript>, [">= 0"])
52
52
  s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
53
53
  s.add_dependency(%q<rake-gem-ghost>, [">= 0"])
54
54
  s.add_dependency(%q<rspec>, [">= 0"])
55
55
  end
56
56
  else
57
- s.add_dependency(%q<xattr>, [">= 0"])
57
+ s.add_dependency(%q<ffi-xattr>, [">= 0"])
58
58
  s.add_dependency(%q<rb-appscript>, [">= 0"])
59
59
  s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
60
60
  s.add_dependency(%q<rake-gem-ghost>, [">= 0"])
data/lib/fspath/xattr.rb CHANGED
@@ -1,15 +1,5 @@
1
1
  require 'fspath'
2
- require 'xattr'
3
-
4
- Xattr.class_eval do
5
- # Accept follow_symlinks as second attribute
6
- def initialize(path, follow_symlinks = true)
7
- @path = path
8
- @follow_symlinks = follow_symlinks
9
- end
10
- alias_method :[], :get
11
- alias_method :[]=, :set
12
- end
2
+ require 'ffi-xattr'
13
3
 
14
4
  class FSPath < Pathname
15
5
  # Xattr instance for path
@@ -19,6 +9,6 @@ class FSPath < Pathname
19
9
 
20
10
  # Xattr instance for path which doesn't follow symlinks
21
11
  def lxattr
22
- Xattr.new(@path, false)
12
+ Xattr.new(@path, :no_follow => true)
23
13
  end
24
14
  end
@@ -1,58 +1,54 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
  require 'fspath/xattr'
3
3
 
4
- describe Xattr do
5
- describe "new" do
6
- it "should accept follow_symlinks as second attribute" do
7
- Xattr.new('a', true).follow_symlinks.should == true
8
- Xattr.new('a', false).follow_symlinks.should == false
9
- end
10
-
11
- it "should alias get/set as []" do
12
- Xattr.instance_method(:[]).should == Xattr.instance_method(:get)
13
- Xattr.instance_method(:[]=).should == Xattr.instance_method(:set)
14
- end
15
- end
16
- end
17
-
18
4
  describe FSPath do
5
+ let(:path){ 'test.txt' }
6
+ let(:link){ 'link.txt' }
7
+
19
8
  before do
20
- @file_path = 'with_xattr'
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)
21
15
  end
22
16
 
23
17
  describe "xattr" do
24
- before do
25
- @xattr = FSPath(@file_path).xattr
26
- end
18
+ let(:xattr){ FSPath(link).xattr }
27
19
 
28
20
  it "should return instance of Xattr" do
29
- @xattr.should be_kind_of(Xattr)
21
+ xattr.should be_kind_of(Xattr)
30
22
  end
31
23
 
32
- it "should follow_symlinks" do
33
- @xattr.follow_symlinks.should be_true
24
+ it "should point to same path" do
25
+ xattr.instance_variable_get(:@path).should == link
34
26
  end
35
27
 
36
- it "should point to same path" do
37
- @xattr.instance_variable_get(:@path).should == @file_path
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'
38
33
  end
39
34
  end
40
35
 
41
36
  describe "lxattr" do
42
- before do
43
- @lxattr = FSPath(@file_path).lxattr
44
- end
37
+ let(:xattr){ FSPath(link).lxattr }
45
38
 
46
39
  it "should return instance of Xattr" do
47
- @lxattr.should be_kind_of(Xattr)
40
+ xattr.should be_kind_of(Xattr)
48
41
  end
49
42
 
50
- it "should not follow_symlinks" do
51
- @lxattr.follow_symlinks.should be_false
43
+ it "should point to same path" do
44
+ xattr.instance_variable_get(:@path).should == link
52
45
  end
53
46
 
54
- it "should point to same path" do
55
- @lxattr.instance_variable_get(:@path).should == @file_path
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
56
52
  end
57
53
  end
58
54
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fspath
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 1.1.0
10
+ version: 1.2.0
11
11
  platform: darwin
12
12
  authors:
13
13
  - Ivan Kuchin
@@ -15,10 +15,10 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-31 00:00:00 Z
18
+ date: 2011-11-20 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- name: xattr
21
+ name: ffi-xattr
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
24
  none: false