fspath 1.2.0 → 2.0.0
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.
- data/.gitignore +11 -0
- data/LICENSE.txt +1 -1
- data/README.markdown +3 -33
- data/fspath.gemspec +13 -58
- metadata +13 -62
- data/.tmignore +0 -1
- data/Rakefile +0 -46
- data/lib/fspath/all.rb +0 -2
- data/lib/fspath/darwin.rb +0 -53
- data/lib/fspath/xattr.rb +0 -14
- data/spec/fspath/darwin_spec.rb +0 -175
- data/spec/fspath/xattr_spec.rb +0 -54
data/.gitignore
ADDED
data/LICENSE.txt
CHANGED
data/README.markdown
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Better than Pathname
|
|
4
4
|
|
|
5
|
+
Check out fspath-mac and fspath-xattr.
|
|
6
|
+
|
|
5
7
|
## Synopsis
|
|
6
8
|
|
|
7
9
|
User dir:
|
|
@@ -48,38 +50,6 @@ Path parts:
|
|
|
48
50
|
|
|
49
51
|
FSPath('/a/b/c').parts # => ['/', 'a', 'b', 'c']
|
|
50
52
|
|
|
51
|
-
### Extended attributes (using xattr gem)
|
|
52
|
-
|
|
53
|
-
Get extended attribute:
|
|
54
|
-
|
|
55
|
-
FSPath('/a/b/c').xattr['com.macromates.caret']
|
|
56
|
-
|
|
57
|
-
Set extended attribute:
|
|
58
|
-
|
|
59
|
-
FSPath('/a/b/c').xattr['good'] = 'bad'
|
|
60
|
-
|
|
61
|
-
### OS X stuff
|
|
62
|
-
|
|
63
|
-
Move to trash:
|
|
64
|
-
|
|
65
|
-
FSPath('a').move_to_trash
|
|
66
|
-
|
|
67
|
-
Get finder label (one of :none, :orange, :red, :yellow, :blue, :purple, :green and :gray):
|
|
68
|
-
|
|
69
|
-
FSPath('a').finder_label
|
|
70
|
-
|
|
71
|
-
Set finder label (:grey is same as :gray, nil or false as :none):
|
|
72
|
-
|
|
73
|
-
FSPath('a').finder_label = :red
|
|
74
|
-
|
|
75
|
-
Get spotlight comment:
|
|
76
|
-
|
|
77
|
-
FSPath('a').spotlight_comment
|
|
78
|
-
|
|
79
|
-
Set spotlight comment:
|
|
80
|
-
|
|
81
|
-
FSPath('a').spotlight_comment = 'a file'
|
|
82
|
-
|
|
83
53
|
## Copyright
|
|
84
54
|
|
|
85
|
-
Copyright (c) 2010 Ivan Kuchin. See LICENSE.txt for details.
|
|
55
|
+
Copyright (c) 2010-2011 Ivan Kuchin. See LICENSE.txt for details.
|
data/fspath.gemspec
CHANGED
|
@@ -1,64 +1,19 @@
|
|
|
1
|
-
#
|
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
|
4
|
-
# -*- encoding: utf-8 -*-
|
|
1
|
+
# encoding: UTF-8
|
|
5
2
|
|
|
6
3
|
Gem::Specification.new do |s|
|
|
7
|
-
s.name
|
|
8
|
-
s.version
|
|
9
|
-
s.
|
|
4
|
+
s.name = 'fspath'
|
|
5
|
+
s.version = '2.0.0'
|
|
6
|
+
s.summary = %q{Better than Pathname}
|
|
7
|
+
s.homepage = "http://github.com/toy/#{s.name}"
|
|
8
|
+
s.authors = ['Ivan Kuchin']
|
|
9
|
+
s.license = 'MIT'
|
|
10
10
|
|
|
11
|
-
s.
|
|
12
|
-
s.authors = ["Ivan Kuchin"]
|
|
13
|
-
s.date = "2011-11-20"
|
|
14
|
-
s.extra_rdoc_files = [
|
|
15
|
-
"LICENSE.txt",
|
|
16
|
-
"README.markdown"
|
|
17
|
-
]
|
|
18
|
-
s.files = [
|
|
19
|
-
".tmignore",
|
|
20
|
-
"LICENSE.txt",
|
|
21
|
-
"README.markdown",
|
|
22
|
-
"Rakefile",
|
|
23
|
-
"VERSION",
|
|
24
|
-
"fspath.gemspec",
|
|
25
|
-
"lib/fspath.rb",
|
|
26
|
-
"lib/fspath/all.rb",
|
|
27
|
-
"lib/fspath/darwin.rb",
|
|
28
|
-
"lib/fspath/xattr.rb",
|
|
29
|
-
"spec/fspath/darwin_spec.rb",
|
|
30
|
-
"spec/fspath/xattr_spec.rb",
|
|
31
|
-
"spec/fspath_spec.rb",
|
|
32
|
-
"spec/spec_helper.rb"
|
|
33
|
-
]
|
|
34
|
-
s.homepage = "http://github.com/toy/fspath"
|
|
35
|
-
s.licenses = ["MIT"]
|
|
36
|
-
s.require_paths = ["lib"]
|
|
37
|
-
s.rubygems_version = "1.8.11"
|
|
38
|
-
s.summary = "Better than Pathname"
|
|
11
|
+
s.rubyforge_project = s.name
|
|
39
12
|
|
|
40
|
-
|
|
41
|
-
|
|
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]
|
|
42
17
|
|
|
43
|
-
|
|
44
|
-
s.add_runtime_dependency(%q<ffi-xattr>, [">= 0"])
|
|
45
|
-
s.add_runtime_dependency(%q<rb-appscript>, [">= 0"])
|
|
46
|
-
s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
|
|
47
|
-
s.add_development_dependency(%q<rake-gem-ghost>, [">= 0"])
|
|
48
|
-
s.add_development_dependency(%q<rspec>, [">= 0"])
|
|
49
|
-
else
|
|
50
|
-
s.add_dependency(%q<ffi-xattr>, [">= 0"])
|
|
51
|
-
s.add_dependency(%q<rb-appscript>, [">= 0"])
|
|
52
|
-
s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
|
|
53
|
-
s.add_dependency(%q<rake-gem-ghost>, [">= 0"])
|
|
54
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
|
55
|
-
end
|
|
56
|
-
else
|
|
57
|
-
s.add_dependency(%q<ffi-xattr>, [">= 0"])
|
|
58
|
-
s.add_dependency(%q<rb-appscript>, [">= 0"])
|
|
59
|
-
s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
|
|
60
|
-
s.add_dependency(%q<rake-gem-ghost>, [">= 0"])
|
|
61
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
|
62
|
-
end
|
|
18
|
+
s.add_development_dependency 'rspec'
|
|
63
19
|
end
|
|
64
|
-
|
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:
|
|
4
|
+
hash: 15
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
|
-
- 1
|
|
8
7
|
- 2
|
|
9
8
|
- 0
|
|
10
|
-
|
|
9
|
+
- 0
|
|
10
|
+
version: 2.0.0
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Ivan Kuchin
|
|
@@ -17,54 +17,10 @@ cert_chain: []
|
|
|
17
17
|
|
|
18
18
|
date: 2011-11-20 00:00:00 Z
|
|
19
19
|
dependencies:
|
|
20
|
-
- !ruby/object:Gem::Dependency
|
|
21
|
-
name: ffi-xattr
|
|
22
|
-
prerelease: false
|
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
|
24
|
-
none: false
|
|
25
|
-
requirements:
|
|
26
|
-
- - ">="
|
|
27
|
-
- !ruby/object:Gem::Version
|
|
28
|
-
hash: 3
|
|
29
|
-
segments:
|
|
30
|
-
- 0
|
|
31
|
-
version: "0"
|
|
32
|
-
type: :runtime
|
|
33
|
-
version_requirements: *id001
|
|
34
|
-
- !ruby/object:Gem::Dependency
|
|
35
|
-
name: jeweler
|
|
36
|
-
prerelease: false
|
|
37
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
|
38
|
-
none: false
|
|
39
|
-
requirements:
|
|
40
|
-
- - ~>
|
|
41
|
-
- !ruby/object:Gem::Version
|
|
42
|
-
hash: 1
|
|
43
|
-
segments:
|
|
44
|
-
- 1
|
|
45
|
-
- 5
|
|
46
|
-
- 1
|
|
47
|
-
version: 1.5.1
|
|
48
|
-
type: :development
|
|
49
|
-
version_requirements: *id002
|
|
50
|
-
- !ruby/object:Gem::Dependency
|
|
51
|
-
name: rake-gem-ghost
|
|
52
|
-
prerelease: false
|
|
53
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
|
54
|
-
none: false
|
|
55
|
-
requirements:
|
|
56
|
-
- - ">="
|
|
57
|
-
- !ruby/object:Gem::Version
|
|
58
|
-
hash: 3
|
|
59
|
-
segments:
|
|
60
|
-
- 0
|
|
61
|
-
version: "0"
|
|
62
|
-
type: :development
|
|
63
|
-
version_requirements: *id003
|
|
64
20
|
- !ruby/object:Gem::Dependency
|
|
65
21
|
name: rspec
|
|
66
22
|
prerelease: false
|
|
67
|
-
requirement: &
|
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
|
68
24
|
none: false
|
|
69
25
|
requirements:
|
|
70
26
|
- - ">="
|
|
@@ -74,29 +30,22 @@ dependencies:
|
|
|
74
30
|
- 0
|
|
75
31
|
version: "0"
|
|
76
32
|
type: :development
|
|
77
|
-
version_requirements: *
|
|
33
|
+
version_requirements: *id001
|
|
78
34
|
description:
|
|
79
35
|
email:
|
|
80
36
|
executables: []
|
|
81
37
|
|
|
82
38
|
extensions: []
|
|
83
39
|
|
|
84
|
-
extra_rdoc_files:
|
|
85
|
-
|
|
86
|
-
- README.markdown
|
|
40
|
+
extra_rdoc_files: []
|
|
41
|
+
|
|
87
42
|
files:
|
|
88
|
-
- .
|
|
43
|
+
- .gitignore
|
|
89
44
|
- LICENSE.txt
|
|
90
45
|
- README.markdown
|
|
91
|
-
- Rakefile
|
|
92
46
|
- VERSION
|
|
93
47
|
- fspath.gemspec
|
|
94
48
|
- lib/fspath.rb
|
|
95
|
-
- lib/fspath/all.rb
|
|
96
|
-
- lib/fspath/darwin.rb
|
|
97
|
-
- lib/fspath/xattr.rb
|
|
98
|
-
- spec/fspath/darwin_spec.rb
|
|
99
|
-
- spec/fspath/xattr_spec.rb
|
|
100
49
|
- spec/fspath_spec.rb
|
|
101
50
|
- spec/spec_helper.rb
|
|
102
51
|
homepage: http://github.com/toy/fspath
|
|
@@ -127,10 +76,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
127
76
|
version: "0"
|
|
128
77
|
requirements: []
|
|
129
78
|
|
|
130
|
-
rubyforge_project:
|
|
79
|
+
rubyforge_project: fspath
|
|
131
80
|
rubygems_version: 1.8.11
|
|
132
81
|
signing_key:
|
|
133
82
|
specification_version: 3
|
|
134
83
|
summary: Better than Pathname
|
|
135
|
-
test_files:
|
|
136
|
-
|
|
84
|
+
test_files:
|
|
85
|
+
- spec/fspath_spec.rb
|
|
86
|
+
- spec/spec_helper.rb
|
|
87
|
+
has_rdoc:
|
data/.tmignore
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/*.gemspec
|
data/Rakefile
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
require 'rake'
|
|
2
|
-
require 'jeweler'
|
|
3
|
-
require 'rake/gem_ghost_task'
|
|
4
|
-
require 'rspec/core/rake_task'
|
|
5
|
-
|
|
6
|
-
name = 'fspath'
|
|
7
|
-
|
|
8
|
-
[nil, 'darwin'].each do |platform|
|
|
9
|
-
spec = Gem::Specification.new do |gem|
|
|
10
|
-
gem.name = name
|
|
11
|
-
gem.summary = %Q{Better than Pathname}
|
|
12
|
-
gem.homepage = "http://github.com/toy/#{name}"
|
|
13
|
-
gem.license = 'MIT'
|
|
14
|
-
gem.authors = ['Ivan Kuchin']
|
|
15
|
-
gem.platform = platform
|
|
16
|
-
gem.add_dependency 'ffi-xattr'
|
|
17
|
-
if platform == 'darwin'
|
|
18
|
-
gem.add_dependency 'rb-appscript'
|
|
19
|
-
end
|
|
20
|
-
gem.add_development_dependency 'jeweler', '~> 1.5.1'
|
|
21
|
-
gem.add_development_dependency 'rake-gem-ghost'
|
|
22
|
-
gem.add_development_dependency 'rspec'
|
|
23
|
-
end
|
|
24
|
-
Jeweler::RubygemsDotOrgTasks.new do |rubygems_tasks|
|
|
25
|
-
rubygems_tasks.jeweler = Jeweler::Tasks.new(spec).jeweler
|
|
26
|
-
end
|
|
27
|
-
Rake::GemGhostTask.new
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
RSpec::Core::RakeTask.new(:spec) do |spec|
|
|
31
|
-
spec.rspec_opts = ['--colour --format progress']
|
|
32
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
|
36
|
-
spec.rspec_opts = ['--colour --format progress']
|
|
37
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
|
38
|
-
spec.rcov = true
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
task :spec_with_rcov_and_open => :rcov do
|
|
42
|
-
`open coverage/index.html`
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
desc 'Default: run specs.'
|
|
46
|
-
task :default => :spec_with_rcov_and_open
|
data/lib/fspath/all.rb
DELETED
data/lib/fspath/darwin.rb
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
require 'fspath'
|
|
2
|
-
require 'appscript'
|
|
3
|
-
|
|
4
|
-
class FSPath < Pathname
|
|
5
|
-
# Move to trash using finder
|
|
6
|
-
def move_to_trash
|
|
7
|
-
mac_finder_alias.delete
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
FINDER_LABEL_COLORS = [:none, :orange, :red, :yellow, :blue, :purple, :green, :gray].freeze
|
|
11
|
-
FINDER_LABEL_COLOR_ALIASES = {:grey => :gray}.freeze
|
|
12
|
-
# Get finder label (one of :none, :orange, :red, :yellow, :blue, :purple, :green and :gray)
|
|
13
|
-
def finder_label
|
|
14
|
-
FINDER_LABEL_COLORS[mac_finder_alias.label_index.get]
|
|
15
|
-
end
|
|
16
|
-
# Set finder label (:grey is same as :gray, nil or false as :none)
|
|
17
|
-
def finder_label=(color)
|
|
18
|
-
color = FINDER_LABEL_COLOR_ALIASES[color] || color || :none
|
|
19
|
-
index = FINDER_LABEL_COLORS.index(color)
|
|
20
|
-
raise "Unknown label #{color.inspect}" unless index
|
|
21
|
-
mac_finder_alias.label_index.set(index)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
# Get spotlight comment
|
|
25
|
-
def spotlight_comment
|
|
26
|
-
mac_finder_alias.comment.get
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# Set spotlight comment
|
|
30
|
-
def spotlight_comment=(comment)
|
|
31
|
-
mac_finder_alias.comment.set(comment.to_s)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
# MacTypes::Alias for path
|
|
35
|
-
def mac_alias
|
|
36
|
-
MacTypes::Alias.path(@path)
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
# MacTypes::FileURL for path
|
|
40
|
-
def mac_file_url
|
|
41
|
-
MacTypes::FileURL.path(@path)
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
# Finder item for path through mac_alias
|
|
45
|
-
def mac_finder_alias
|
|
46
|
-
Appscript.app('Finder').items[mac_alias]
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
# Finder item for path through mac_alias
|
|
50
|
-
def mac_finder_file_url
|
|
51
|
-
Appscript.app('Finder').items[mac_file_url]
|
|
52
|
-
end
|
|
53
|
-
end
|
data/lib/fspath/xattr.rb
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
require 'fspath'
|
|
2
|
-
require 'ffi-xattr'
|
|
3
|
-
|
|
4
|
-
class FSPath < Pathname
|
|
5
|
-
# Xattr instance for path
|
|
6
|
-
def xattr
|
|
7
|
-
Xattr.new(@path)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
# Xattr instance for path which doesn't follow symlinks
|
|
11
|
-
def lxattr
|
|
12
|
-
Xattr.new(@path, :no_follow => true)
|
|
13
|
-
end
|
|
14
|
-
end
|
data/spec/fspath/darwin_spec.rb
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
|
-
require 'fspath/darwin'
|
|
3
|
-
|
|
4
|
-
describe FSPath do
|
|
5
|
-
if RUBY_PLATFORM.downcase.include?('darwin')
|
|
6
|
-
describe "mac related" do
|
|
7
|
-
describe "move_to_trash" do
|
|
8
|
-
it "should call delete on mac_finder_alias" do
|
|
9
|
-
@path = FSPath('to_delete')
|
|
10
|
-
@finder_alias = mock(:finder_alias)
|
|
11
|
-
|
|
12
|
-
@path.should_receive(:mac_finder_alias).and_return(@finder_alias)
|
|
13
|
-
@finder_alias.should_receive(:delete)
|
|
14
|
-
|
|
15
|
-
@path.move_to_trash
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
describe "finder labels" do
|
|
20
|
-
describe "getting" do
|
|
21
|
-
it "should call label_index.get on mac_finder_alias" do
|
|
22
|
-
@path = FSPath('to_label')
|
|
23
|
-
@finder_alias = mock(:finder_alias)
|
|
24
|
-
@label_index = mock(:label_index)
|
|
25
|
-
|
|
26
|
-
@path.should_receive(:mac_finder_alias).and_return(@finder_alias)
|
|
27
|
-
@finder_alias.should_receive(:label_index).and_return(@label_index)
|
|
28
|
-
@label_index.should_receive(:get).and_return(0)
|
|
29
|
-
|
|
30
|
-
@path.finder_label
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
it "should return apporitate label" do
|
|
34
|
-
@path = FSPath('to_label')
|
|
35
|
-
@finder_alias = mock(:finder_alias)
|
|
36
|
-
@label_index = mock(:label_index)
|
|
37
|
-
|
|
38
|
-
@path.stub!(:mac_finder_alias).and_return(@finder_alias)
|
|
39
|
-
@finder_alias.stub!(:label_index).and_return(@label_index)
|
|
40
|
-
|
|
41
|
-
FSPath::FINDER_LABEL_COLORS.each_with_index do |label, index|
|
|
42
|
-
@label_index.stub!(:get).and_return(index)
|
|
43
|
-
@path.finder_label.should == label
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
describe "setting" do
|
|
49
|
-
it "should call label_index.set on mac_finder_alias" do
|
|
50
|
-
@path = FSPath('to_label')
|
|
51
|
-
@finder_alias = mock(:finder_alias)
|
|
52
|
-
@label_index = mock(:label_index)
|
|
53
|
-
|
|
54
|
-
@path.should_receive(:mac_finder_alias).and_return(@finder_alias)
|
|
55
|
-
@finder_alias.should_receive(:label_index).and_return(@label_index)
|
|
56
|
-
@label_index.should_receive(:set)
|
|
57
|
-
|
|
58
|
-
@path.finder_label = nil
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
describe "index" do
|
|
62
|
-
before do
|
|
63
|
-
@path = FSPath('to_label')
|
|
64
|
-
@finder_alias = mock(:finder_alias)
|
|
65
|
-
@label_index = mock(:label_index)
|
|
66
|
-
|
|
67
|
-
@path.stub!(:mac_finder_alias).and_return(@finder_alias)
|
|
68
|
-
@finder_alias.stub!(:label_index).and_return(@label_index)
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
it "should call label_index.set with apporitate index" do
|
|
72
|
-
FSPath::FINDER_LABEL_COLORS.each_with_index do |label, index|
|
|
73
|
-
@label_index.should_receive(:set).with(index).ordered
|
|
74
|
-
@path.finder_label = label
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
it "should accept aliases" do
|
|
79
|
-
FSPath::FINDER_LABEL_COLOR_ALIASES.each do |label_alias, label|
|
|
80
|
-
index = FSPath::FINDER_LABEL_COLORS.index(label)
|
|
81
|
-
@label_index.should_receive(:set).with(index).ordered
|
|
82
|
-
@path.finder_label = label_alias
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
it "should set to none when called with nil or false" do
|
|
87
|
-
[nil, false].each do |label|
|
|
88
|
-
@label_index.should_receive(:set).with(0).ordered
|
|
89
|
-
@path.finder_label = label
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
it "should raise when called with something else" do
|
|
94
|
-
[true, :shitty, 'hello'].each do |label|
|
|
95
|
-
proc do
|
|
96
|
-
@path.finder_label = label
|
|
97
|
-
end.should raise_error("Unknown label #{label.inspect}")
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
describe "spotlight comments" do
|
|
105
|
-
describe "getting" do
|
|
106
|
-
it "should call comment.get on mac_finder_alias" do
|
|
107
|
-
@path = FSPath(__FILE__)
|
|
108
|
-
@finder_alias = mock(:finder_alias)
|
|
109
|
-
@comment = mock(:comment)
|
|
110
|
-
@comment_text = mock(:comment_text)
|
|
111
|
-
|
|
112
|
-
@path.should_receive(:mac_finder_alias).and_return(@finder_alias)
|
|
113
|
-
@finder_alias.should_receive(:comment).and_return(@comment)
|
|
114
|
-
@comment.should_receive(:get).and_return(@comment_text)
|
|
115
|
-
|
|
116
|
-
@path.spotlight_comment.should == @comment_text
|
|
117
|
-
end
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
describe "setting" do
|
|
121
|
-
it "should call comment.set on mac_finder_alias" do
|
|
122
|
-
@path = FSPath(__FILE__)
|
|
123
|
-
@finder_alias = mock(:finder_alias)
|
|
124
|
-
@comment = mock(:comment)
|
|
125
|
-
@comment_text = mock(:comment_text)
|
|
126
|
-
|
|
127
|
-
@path.should_receive(:mac_finder_alias).and_return(@finder_alias)
|
|
128
|
-
@finder_alias.should_receive(:comment).and_return(@comment)
|
|
129
|
-
@comment.should_receive(:set).with(@comment_text.to_s)
|
|
130
|
-
|
|
131
|
-
@path.spotlight_comment = @comment_text
|
|
132
|
-
end
|
|
133
|
-
end
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
describe "appscript objects" do
|
|
137
|
-
before do
|
|
138
|
-
@file_path = File.expand_path(__FILE__)
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
describe "mac_alias" do
|
|
142
|
-
it "should return instance of MacTypes::Alias" do
|
|
143
|
-
FSPath(@file_path).mac_alias.should be_kind_of(MacTypes::Alias)
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
it "should point to same path" do
|
|
147
|
-
FSPath(@file_path).mac_alias.path.should == @file_path
|
|
148
|
-
end
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
describe "mac_file_url" do
|
|
152
|
-
it "should return instance of MacTypes::FileURL" do
|
|
153
|
-
FSPath(@file_path).mac_file_url.should be_kind_of(MacTypes::FileURL)
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
it "should point to same path" do
|
|
157
|
-
FSPath(@file_path).mac_file_url.path.should == @file_path
|
|
158
|
-
end
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
describe "mac_finder_alias" do
|
|
162
|
-
it "should return same ref" do
|
|
163
|
-
FSPath(@file_path).mac_finder_alias.should == Appscript.app('Finder').items[FSPath(@file_path).mac_alias]
|
|
164
|
-
end
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
describe "mac_finder_file_url" do
|
|
168
|
-
it "should return same ref" do
|
|
169
|
-
FSPath(@file_path).mac_finder_file_url.should == Appscript.app('Finder').items[FSPath(@file_path).mac_file_url]
|
|
170
|
-
end
|
|
171
|
-
end
|
|
172
|
-
end
|
|
173
|
-
end
|
|
174
|
-
end
|
|
175
|
-
end
|
data/spec/fspath/xattr_spec.rb
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
|
-
require 'fspath/xattr'
|
|
3
|
-
|
|
4
|
-
describe FSPath 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
|