ffi-xattr 0.1.1 → 0.1.2

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: b16d449688c3e5d3d08e7384fe28da6b6ba89e60
4
- data.tar.gz: 2c760c5c08c43942bf191e34634f4add6b5893c7
3
+ metadata.gz: e9a5f43304cb60076094f298ec9168a89a9df2ba
4
+ data.tar.gz: f645a4aaf033393e17df324565c195b54bcb7015
5
5
  SHA512:
6
- metadata.gz: a0bef783382b40a0f75a85da7f82881058b5db2dccb1c6e4b6bfe6be797f3a54b29af9d0e378a137ab7ec453c3b92cf3a3fb814be6a2c3f1e2f280bdf42b4106
7
- data.tar.gz: 123dc41cc0783bb3aa06beecf3307f1acdfad8d855a921e1d34c93beaed7364b245e896fd6c73dde53de08d1d1270ea61c7bcac48b855d215fa08744cf2c85ed
6
+ metadata.gz: d5c62fa8db807ef7acefe5d47c2936cb96813c234c4dcad46b322802047a6e482faaf08d5a2152b80d39a042a9ef091c8d46789cf3aacc02067a13d9d4473d15
7
+ data.tar.gz: 513f18a55640e5bc9b72095842a8018ec9665674c7ea85740b810540fbc1d0b834ebec5fc9b08ebbb3baac0c322c657fbf2d36fdb92bc4d46a75064d536c948f
@@ -28,7 +28,7 @@ class Xattr
28
28
  path
29
29
  end
30
30
  raise Errno::ENOENT, @path unless File.exist?(@path)
31
-
31
+
32
32
  @no_follow = !!options[:no_follow]
33
33
  end
34
34
 
@@ -62,11 +62,17 @@ class Xattr
62
62
  end
63
63
 
64
64
  # Returns hash of extended attributes
65
- def as_json(*args)
65
+
66
+ def to_hash
66
67
  res = {}
67
68
  each { |k,v| res[k] = v }
68
69
 
69
70
  res
70
71
  end
71
72
 
73
+ alias_method :to_h, :to_hash
74
+
75
+ def as_json(*args)
76
+ to_hash
77
+ end
72
78
  end
@@ -1,3 +1,3 @@
1
1
  class Xattr
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -67,11 +67,13 @@ describe Xattr do
67
67
  xattr.to_a.should == [['user.foo', 'bar']]
68
68
  end
69
69
 
70
- it "returns a Hash for #as_json" do
70
+ it "returns a Hash for #to_hash, #to_h, #as_json" do
71
71
  xattr['user.foo'] = 'bar'
72
72
  xattr['user.bar'] = 'baz'
73
73
 
74
- xattr.as_json.should == {'user.foo' => 'bar', 'user.bar' => 'baz'}
74
+ xattr.to_hash.should == {'user.foo' => 'bar', 'user.bar' => 'baz'}
75
+ xattr.to_h.should == {'user.foo' => 'bar', 'user.bar' => 'baz'}
76
+ xattr.as_json(foo: 1).should == {'user.foo' => 'bar', 'user.bar' => 'baz'}
75
77
  end
76
78
 
77
79
  it "raises Errno::ENOENT if the file doesn't exist" do
@@ -87,16 +89,16 @@ describe Xattr do
87
89
  super_path.should_receive(:to_str).and_return(path)
88
90
 
89
91
  Xattr.new(super_path).set('user.foo', 'bar')
90
-
92
+
91
93
  Xattr.new(path).get('user.foo').should == 'bar'
92
94
  end
93
95
 
94
96
  it "should work with object that can be coerced to string with #to_path" do
95
97
  to_path_obj = double("to_path")
96
98
  to_path_obj.should_receive(:to_path).and_return(path)
97
-
99
+
98
100
  Xattr.new(to_path_obj).set('user.to_path', 'bar')
99
-
101
+
100
102
  Xattr.new(path).get('user.to_path').should == 'bar'
101
103
  end
102
104
 
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.1
4
+ version: 0.1.2
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-02-07 00:00:00.000000000 Z
11
+ date: 2014-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -103,3 +103,4 @@ summary: Manipulate extended file attributes
103
103
  test_files:
104
104
  - spec/extensions_spec.rb
105
105
  - spec/xattr_spec.rb
106
+ has_rdoc: