desktop 1.1.2 → 1.2.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/desktop/cli.rb +1 -0
- data/lib/desktop/osx/osx.rb +16 -1
- data/lib/desktop/version.rb +1 -1
- data/test/desktop/cli_test.rb +9 -3
- data/test/desktop/osx/osx_test.rb +13 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0edc8a47310a6a3dc44c4c2387f1e3c6c3451cbe
|
4
|
+
data.tar.gz: 4dda875071a5100581d8625cf586df8f9df1026e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64e244b09625712a29d64b17e4d65c0563e316b8639461fe74015eae3d8b16c6a7a7333a848e11773f748ef02db7585c27c324308c9b826e0ee32738b612f621
|
7
|
+
data.tar.gz: 3318654aa90393d1352f82ee296d0dc6d8e96885507433b7685cb64ac1e2aec4f258750de061d6a930943760d61bb73ca185b9b08558c2adab5b1f921f1c748a
|
data/CHANGELOG.md
CHANGED
data/lib/desktop/cli.rb
CHANGED
@@ -15,6 +15,7 @@ module Desktop
|
|
15
15
|
> $ desktop set http://url.to/image.jpg
|
16
16
|
LONGDESC
|
17
17
|
option :desktop_image_path, :hide => true
|
18
|
+
option :cached_image_path, :hide => true
|
18
19
|
option :skip_reload, :type => :boolean, :hide => true
|
19
20
|
option :skip_database, :type => :boolean, :hide => true
|
20
21
|
def set(path, already_failed = false)
|
data/lib/desktop/osx/osx.rb
CHANGED
@@ -2,7 +2,6 @@ require 'desktop/osx/database'
|
|
2
2
|
|
3
3
|
module Desktop
|
4
4
|
class OSX
|
5
|
-
attr_reader :desktop_image_path, :skip_reload, :skip_database
|
6
5
|
class DesktopImagePermissionsError < StandardError; end
|
7
6
|
class DesktopImageMissingError < StandardError; end
|
8
7
|
|
@@ -28,12 +27,15 @@ module Desktop
|
|
28
27
|
@skip_database = options[:skip_database]
|
29
28
|
@desktop_image_path = \
|
30
29
|
options[:desktop_image_path] || default_desktop_image_path
|
30
|
+
@cached_image_path = \
|
31
|
+
options[:cached_image_path] || default_cached_image_path
|
31
32
|
end
|
32
33
|
|
33
34
|
def desktop_image=(image)
|
34
35
|
write_default_desktop image
|
35
36
|
clear_custom_desktop_image unless skip_database
|
36
37
|
touch_desktop_image
|
38
|
+
remove_cached_image
|
37
39
|
reload_desktop unless skip_reload
|
38
40
|
rescue Errno::EACCES => e
|
39
41
|
raise DesktopImagePermissionsError.new(e)
|
@@ -59,6 +61,11 @@ module Desktop
|
|
59
61
|
|
60
62
|
private
|
61
63
|
|
64
|
+
attr_reader :desktop_image_path,
|
65
|
+
:cached_image_path,
|
66
|
+
:skip_reload,
|
67
|
+
:skip_database
|
68
|
+
|
62
69
|
def write_default_desktop(image)
|
63
70
|
File.open(desktop_image_path, 'w') do |desktop|
|
64
71
|
desktop.write image.data
|
@@ -77,10 +84,18 @@ module Desktop
|
|
77
84
|
end
|
78
85
|
end
|
79
86
|
|
87
|
+
def remove_cached_image
|
88
|
+
system "rm #{cached_image_path} 2>/dev/null"
|
89
|
+
end
|
90
|
+
|
80
91
|
def reload_desktop
|
81
92
|
system 'killall Dock'
|
82
93
|
end
|
83
94
|
|
95
|
+
def default_cached_image_path
|
96
|
+
'/Library/Caches/com.apple.desktop.admin.png'
|
97
|
+
end
|
98
|
+
|
84
99
|
def default_desktop_image_path
|
85
100
|
'/System/Library/CoreServices/DefaultDesktop.jpg'
|
86
101
|
end
|
data/lib/desktop/version.rb
CHANGED
data/test/desktop/cli_test.rb
CHANGED
@@ -8,31 +8,37 @@ module Desktop
|
|
8
8
|
desktop.write 'Default content'
|
9
9
|
desktop.rewind
|
10
10
|
|
11
|
+
cached = Tempfile.new(%w[cached .jpg])
|
12
|
+
cached.write 'Cached content'
|
13
|
+
cached.rewind
|
14
|
+
|
11
15
|
image = Tempfile.new(%w[image .jpg])
|
12
16
|
image.write 'New content'
|
13
17
|
image.rewind
|
14
18
|
|
15
19
|
defaults = [
|
16
20
|
"--desktop-image-path=#{desktop.path}",
|
21
|
+
"--cached-image-path=#{cached.path}",
|
17
22
|
"--skip-reload",
|
18
23
|
"--skip-database"
|
19
24
|
]
|
20
25
|
|
21
|
-
yield desktop, image, defaults
|
26
|
+
yield desktop, cached, image, defaults
|
22
27
|
ensure
|
23
28
|
desktop.unlink
|
29
|
+
cached.unlink
|
24
30
|
image.unlink
|
25
31
|
end
|
26
32
|
|
27
33
|
it 'sets the desktop when a local image path is provided' do
|
28
|
-
with_defaults do |desktop, image, defaults|
|
34
|
+
with_defaults do |desktop, _, image, defaults|
|
29
35
|
CLI.start ['set', image.path] + defaults
|
30
36
|
assert_equal File.read(desktop), File.read(image)
|
31
37
|
end
|
32
38
|
end
|
33
39
|
|
34
40
|
it 'sets the desktop when a web url is provided' do
|
35
|
-
with_defaults do |desktop, _, defaults|
|
41
|
+
with_defaults do |desktop, _, _, defaults|
|
36
42
|
VCR.use_cassette('web_image_data') do
|
37
43
|
CLI.start ['set', 'http://f.cl.ly/image.jpg'] + defaults
|
38
44
|
refute_equal 'Default content', File.read(desktop)
|
@@ -6,23 +6,33 @@ module Desktop
|
|
6
6
|
describe OSX do
|
7
7
|
def osx
|
8
8
|
desktop = Tempfile.new(%w[desktop .jpg])
|
9
|
+
cached = Tempfile.new(%w[cached .jpg])
|
9
10
|
image = Tempfile.new(%w[image .jpg])
|
10
11
|
|
11
12
|
osx = OSX.new(
|
12
13
|
:desktop_image_path => desktop.path,
|
14
|
+
:cached_image_path => cached.path,
|
13
15
|
:skip_reload => true,
|
14
16
|
:skip_database => true
|
15
17
|
)
|
16
18
|
|
17
|
-
yield osx, desktop, image
|
19
|
+
yield osx, desktop, cached, image
|
18
20
|
ensure
|
19
21
|
desktop.unlink
|
22
|
+
cached.unlink
|
20
23
|
image.unlink
|
21
24
|
end
|
22
25
|
|
23
26
|
describe '#desktop_image=' do
|
27
|
+
it 'removes the cached desktop image' do
|
28
|
+
osx do |osx, _, cached, image|
|
29
|
+
osx.desktop_image = LocalImage.new(image)
|
30
|
+
refute File.exists?(cached.path)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
24
34
|
it 'raises DesktopImagePermissionsError when desktop is readonly' do
|
25
|
-
osx do |osx, desktop, image|
|
35
|
+
osx do |osx, desktop, _, image|
|
26
36
|
FileUtils.chmod 'a-w', desktop
|
27
37
|
|
28
38
|
assert_raises OSX::DesktopImagePermissionsError do
|
@@ -32,7 +42,7 @@ module Desktop
|
|
32
42
|
end
|
33
43
|
|
34
44
|
it 'raises DesktopImageMissingError when new image is missing' do
|
35
|
-
osx do |osx, _, _|
|
45
|
+
osx do |osx, _, _, _|
|
36
46
|
assert_raises OSX::DesktopImageMissingError do
|
37
47
|
osx.desktop_image = LocalImage.new('/invalid/image/path.jpg')
|
38
48
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: desktop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Hunt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|