desktop 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: baf8e2c8fe943e00600976c2e9ac1f92117ee140
4
- data.tar.gz: 1069ee0d452addac29c11031b22f10bcc7662702
3
+ metadata.gz: 3de2a50f1f1510ad2cb1fd5fe695ba1698221cae
4
+ data.tar.gz: f4515e4418728f240c2a73c01bc638b03d5fa7f5
5
5
  SHA512:
6
- metadata.gz: 45a7c8f948a881470f18cd6fb9e1d16a0b0ac1cb1b0916545e74e34732e531f532fb1b75a9d455f532fbe247e98a59baa8066fdb223a58913451b3781853af04
7
- data.tar.gz: 3d6725d98c997d0ee5181115c0efce22fce51b1e6f94100aeb6feef4ac6e38f670de2505e8e76ae131f42d11d69a6e085dfe6cb7da5afaa434669128922b36d0
6
+ metadata.gz: b7cb135b3c2c2769f52a056c9d24863303cf6c8c578c10c9944dfb3ee839c753256b38d3bf137eda9cd404b11f5bfda593df2d89fcf146b004cdba8d020ee9d7
7
+ data.tar.gz: a3e7f4f5b6cc5375d3b8030b355d64c6c546810b3f0b4acf39a724f453de2922a24c8edd701d3c822c6e2e42719fc805375c8dd6e588acbfb5a375062fd59181
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ##v1.1.1
4
+ *2014-06-06*
5
+
6
+ - [Don't blow up if OSX is missing data table](https://github.com/chrishunt/desktop/pull/8)
7
+
3
8
  ##v1.1.0
4
9
  *2014-06-01*
5
10
 
data/README.md CHANGED
@@ -73,6 +73,19 @@ And use the same CLI interface that you already know:
73
73
  Desktop::CLI.start %w[set path/to/image.jpg]
74
74
  ```
75
75
 
76
+ ## Where can I get desktops?
77
+
78
+ [**Simple Desktops**](http://simpledesktops.com) - A collection of wallpapers
79
+ curated by [Tom Watson](http://tmwtsn.com) designed to make your computer
80
+ beautiful without distraction.
81
+
82
+ [![](img/simple-desktops.jpg)](http://simpledesktops.com)
83
+
84
+ [**Vladstudio**](http://www.vladstudio.com/wallpapers) - The project of Russian
85
+ digital artist [Vlad Gerasimov](http://www.vladstudio.com/blog). He creates
86
+ wallpapers for computers and mobile devices.
87
+
88
+ [![](img/vladstudio.jpg)](http://www.vladstudio.com/wallpapers)
76
89
 
77
90
  ## Contributing
78
91
  Please see the [Contributing
Binary file
Binary file
@@ -1,5 +1,6 @@
1
1
  require 'desktop/cli'
2
2
  require 'desktop/local_image'
3
- require 'desktop/osx'
4
3
  require 'desktop/version'
5
4
  require 'desktop/web_image'
5
+
6
+ require 'desktop/osx/osx'
@@ -0,0 +1,42 @@
1
+ require 'sqlite3'
2
+
3
+ module Desktop
4
+ class OSX
5
+ class Database
6
+ attr_reader :connection
7
+
8
+ def initialize(connection = nil)
9
+ @connection = connection || default_connection
10
+ end
11
+
12
+ def clear_desktop_image
13
+ clear_data if data?
14
+ end
15
+
16
+ def close
17
+ connection.close
18
+ end
19
+
20
+ private
21
+
22
+ def data?
23
+ connection.execute(
24
+ "SELECT name FROM sqlite_master WHERE type='table' AND name='data'"
25
+ ).any?
26
+ end
27
+
28
+ def clear_data
29
+ connection.execute 'DELETE FROM data'
30
+ connection.execute 'VACUUM data'
31
+ end
32
+
33
+ def default_connection
34
+ SQLite3::Database.new path
35
+ end
36
+
37
+ def path
38
+ File.expand_path '~/Library/Application Support/Dock/desktoppicture.db'
39
+ end
40
+ end
41
+ end
42
+ end
@@ -1,4 +1,4 @@
1
- require 'sqlite3'
1
+ require 'desktop/osx/database'
2
2
 
3
3
  module Desktop
4
4
  class OSX
@@ -58,9 +58,8 @@ module Desktop
58
58
  end
59
59
 
60
60
  def clear_custom_desktop_image
61
- db = SQLite3::Database.new(desktop_image_db_path)
62
- db.execute 'DELETE FROM data'
63
- db.execute 'VACUUM data'
61
+ db = Database.new
62
+ db.clear_desktop_image
64
63
  db.close
65
64
  end
66
65
 
@@ -71,9 +70,5 @@ module Desktop
71
70
  def default_desktop_image_path
72
71
  '/System/Library/CoreServices/DefaultDesktop.jpg'
73
72
  end
74
-
75
- def desktop_image_db_path
76
- File.expand_path '~/Library/Application Support/Dock/desktoppicture.db'
77
- end
78
73
  end
79
74
  end
@@ -1,3 +1,3 @@
1
1
  module Desktop
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1'
3
3
  end
@@ -0,0 +1,38 @@
1
+ require 'test_helper'
2
+ require 'desktop/osx/database'
3
+
4
+ module Desktop
5
+ describe OSX::Database do
6
+ def with_connection
7
+ connection = SQLite3::Database.new ':memory:'
8
+ yield connection
9
+ ensure
10
+ connection.close
11
+ end
12
+
13
+ describe '#clear_desktop_image' do
14
+ it 'clears contents of data table' do
15
+ with_connection do |connection|
16
+ connection.execute("CREATE TABLE data (FileName STRING)")
17
+ connection.execute("INSERT INTO data VALUES ('mydesktop.png')")
18
+
19
+ refute_empty connection.execute("SELECT * FROM data")
20
+
21
+ OSX::Database.new(connection).clear_desktop_image
22
+
23
+ assert_empty connection.execute("SELECT * FROM data")
24
+ end
25
+ end
26
+
27
+ it 'does not blow up if data table does not exist' do
28
+ with_connection do |connection|
29
+ assert_empty connection.execute(
30
+ "SELECT name FROM sqlite_master WHERE type='table' AND name='data'"
31
+ )
32
+
33
+ OSX::Database.new(connection).clear_desktop_image
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -1,5 +1,5 @@
1
1
  require 'test_helper'
2
- require 'desktop/osx'
2
+ require 'desktop/osx/osx'
3
3
  require 'desktop/local_image'
4
4
 
5
5
  module Desktop
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.1.0
4
+ version: 1.1.1
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-06-01 00:00:00.000000000 Z
11
+ date: 2014-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -154,19 +154,23 @@ files:
154
154
  - bin/desktop
155
155
  - desktop.gemspec
156
156
  - img/example.gif
157
+ - img/simple-desktops.jpg
158
+ - img/vladstudio.jpg
157
159
  - lib/desktop.rb
158
160
  - lib/desktop/cli.rb
159
161
  - lib/desktop/http.rb
160
162
  - lib/desktop/image.rb
161
163
  - lib/desktop/local_image.rb
162
- - lib/desktop/osx.rb
164
+ - lib/desktop/osx/database.rb
165
+ - lib/desktop/osx/osx.rb
163
166
  - lib/desktop/version.rb
164
167
  - lib/desktop/web_image.rb
165
168
  - test/desktop/cli_test.rb
166
169
  - test/desktop/http_test.rb
167
170
  - test/desktop/image_test.rb
168
171
  - test/desktop/local_image_test.rb
169
- - test/desktop/osx_test.rb
172
+ - test/desktop/osx/database_test.rb
173
+ - test/desktop/osx/osx_test.rb
170
174
  - test/desktop/web_image_test.rb
171
175
  - test/fixtures/web_image_data.yml
172
176
  - test/test_helper.rb
@@ -199,7 +203,8 @@ test_files:
199
203
  - test/desktop/http_test.rb
200
204
  - test/desktop/image_test.rb
201
205
  - test/desktop/local_image_test.rb
202
- - test/desktop/osx_test.rb
206
+ - test/desktop/osx/database_test.rb
207
+ - test/desktop/osx/osx_test.rb
203
208
  - test/desktop/web_image_test.rb
204
209
  - test/fixtures/web_image_data.yml
205
210
  - test/test_helper.rb