bingwallpaper 0.5.2 → 0.5.3
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 +8 -8
- data/README.md +4 -2
- data/bin/bingwallpaper +28 -5
- data/lib/bingwallpaper/image.rb +10 -29
- data/lib/bingwallpaper/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZWM1OWI4MWQ0MmEwMTY4YTY1ZDNhMTYwMWFkOWUwZjExN2I4NWZhMw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NGY0NDFjOTdmMTMwMTAxMzc3N2JiMTFkYzkyMDczNmM5YWJkYjIwNw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MDc3NTQ5OTVjZGVmMGZiYzViM2JlMzkyZTYzNWVmNzUyODViZmVjY2QxOGIx
|
10
|
+
NzMxNjc0NDEzMjVjOTRiOWJkZmZkOTViM2QwYjAwNjBhNTAxNzBkZTQzOTRi
|
11
|
+
ZTFmYTQxMTI3MjAxMjdjZDBiNjk3NzViZDlhMDQ2ZTQ3MGZmYTE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZTdiODE1ZjVkMDNjMzFkYmUxMjNhMGQyM2E1MzAxNDE3ODI5OGE1Y2VjY2Ew
|
14
|
+
OGIwMDc3NjNlYmU5NjVmYmY5ZTU0MTJlM2EwYTE3NGZiYjdlZjFmZTQ5OWVi
|
15
|
+
OGQ4ZTdjMzQ5YWYzMGZkMGQxZTgwZmYyMTBiNDllODk4YTlmNTA=
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[](http://badge.fury.io/rb/bingwallpaper)
|
2
|
+
|
1
3
|
# Bing Wallpaper
|
2
4
|
|
3
5
|
This project provides a simple Ruby script that will download the
|
@@ -20,10 +22,10 @@ Just install the gem...
|
|
20
22
|
|
21
23
|
And then invoke the script.
|
22
24
|
|
23
|
-
|
25
|
+
bingwallpaper
|
24
26
|
|
25
27
|
|
26
28
|
***
|
27
|
-
[0]: https://www
|
29
|
+
[0]: https://www.bing.com
|
28
30
|
[1]: http://feh.finalrewind.org/
|
29
31
|
[2]: http://i3wm.org/
|
data/bin/bingwallpaper
CHANGED
@@ -5,17 +5,40 @@
|
|
5
5
|
# Sets the desktop wallpaper to the current "image of the day" from the Bing
|
6
6
|
# search engine.
|
7
7
|
#
|
8
|
-
|
9
8
|
require "bingwallpaper"
|
9
|
+
require "logger"
|
10
|
+
|
11
|
+
# setup a logger
|
12
|
+
logger = Logger.new(STDOUT)
|
13
|
+
logger.formatter = proc do |severity, time, progname, msg|
|
14
|
+
"%-6s %s\n" % [severity, msg]
|
15
|
+
end
|
10
16
|
|
11
17
|
# create an instance and set the wallpaper
|
12
18
|
bingImage = Bingwallpaper::Image.new
|
13
19
|
|
14
|
-
# set the wallpaper
|
15
20
|
begin
|
16
|
-
|
21
|
+
|
22
|
+
# compute the URL for the image of the data data
|
23
|
+
data_url = bingImage.get_data_url
|
24
|
+
|
25
|
+
# parse image of the day data
|
26
|
+
image_data = bingImage.parse_xml data_url
|
27
|
+
|
28
|
+
# decide where we'll save today's image
|
29
|
+
image_path = bingImage.image_storage_path image_data[0]
|
30
|
+
|
31
|
+
# only download the wallpaper once
|
32
|
+
if !image_path.exist?
|
33
|
+
|
34
|
+
# download the image and set the wallpaper
|
35
|
+
bingImage.download_image image_data[0]
|
36
|
+
`feh --bg-fill #{image_path}`
|
37
|
+
else
|
38
|
+
logger.info "Today's wallpaper already downloaded. ;-)"
|
39
|
+
end
|
17
40
|
rescue Exception => exception
|
18
|
-
|
19
|
-
|
41
|
+
logger.info "Sorry, I couldn't set today's Bing Image of the Day Wallpaper. :'("
|
42
|
+
logger.error "The problems was: " + exception.message
|
20
43
|
exit 1
|
21
44
|
end
|
data/lib/bingwallpaper/image.rb
CHANGED
@@ -90,12 +90,12 @@ module Bingwallpaper
|
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
-
# Returns
|
94
|
-
# hash will be stored.
|
93
|
+
# Returns a Pathname with location where the image from the
|
94
|
+
# provided Bing image hash will be stored.
|
95
95
|
#
|
96
96
|
# image_data:: Hash of Bing image data
|
97
97
|
def image_storage_path(image_data)
|
98
|
-
@storage_path + "/" + image_data[:file_name]
|
98
|
+
Pathname.new @storage_path + "/" + image_data[:file_name]
|
99
99
|
end
|
100
100
|
|
101
101
|
# Downloads the Bing image from the provided image hash.
|
@@ -103,32 +103,13 @@ module Bingwallpaper
|
|
103
103
|
# image_date:: Hash of Bing image data
|
104
104
|
def download_image(image_data)
|
105
105
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
#
|
114
|
-
# file:: File instance with wallpaper data
|
115
|
-
def set_wallpaper(file)
|
116
|
-
|
117
|
-
puts "Setting wallpaper to " + file.path
|
118
|
-
`feh --bg-fill #{file.path}`
|
119
|
-
end
|
120
|
-
|
121
|
-
# Sets the wallpaper to Bing's "image of the day".
|
122
|
-
def set_today_wallpaper
|
123
|
-
|
124
|
-
image_data = parse_xml(get_data_url)
|
125
|
-
image_path = Pathname.new(image_storage_path(image_data[0]))
|
126
|
-
|
127
|
-
# only download the wallpaper once
|
128
|
-
if !image_path.exist?
|
129
|
-
set_wallpaper(download_image(image_data[0]))
|
130
|
-
else
|
131
|
-
puts "Today's wallpaper already downloaded. ;-)"
|
106
|
+
begin
|
107
|
+
open(image_storage_path(image_data), 'wb') do |file|
|
108
|
+
file << open(image_data[:links][:url]).read
|
109
|
+
end
|
110
|
+
rescue Exception => exception
|
111
|
+
FileUtils.rm(image_storage_path(image_data))
|
112
|
+
raise exception
|
132
113
|
end
|
133
114
|
end
|
134
115
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bingwallpaper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cmiles74
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|