simpledesktops 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +38 -0
- data/Rakefile +1 -0
- data/lib/simpledesktops.rb +3 -0
- data/lib/simpledesktops/feed.rb +48 -0
- data/lib/simpledesktops/version.rb +3 -0
- data/lib/simpledesktops/wallpaper.rb +10 -0
- data/simpledesktops.gemspec +25 -0
- data/spec/simpledesktops/feed_spec.rb +28 -0
- data/spec/simpledesktops/wallpaper_spec.rb +8 -0
- metadata +131 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Teo Ljungberg
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# Simpledesktops
|
2
|
+
|
3
|
+
`simpledesktops` lists wallpapers from the [site](http://simpledesktops.com)
|
4
|
+
with the same name.
|
5
|
+
I hacked this together because...well I had nothing else to do :sad_panda:
|
6
|
+
|
7
|
+
NOTE: It currently only fetches the latest 5 wallpapers
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
gem 'simpledesktops'
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install simpledesktops
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
require 'simpledesktops'
|
27
|
+
|
28
|
+
f = SimpleDesktops::Feed.new
|
29
|
+
f.list_wallpapers # f.wallpapers work aswell
|
30
|
+
```
|
31
|
+
|
32
|
+
## Contributing
|
33
|
+
|
34
|
+
1. Fork it
|
35
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
36
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
37
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
38
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'simpledesktops/wallpaper'
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'open-uri'
|
4
|
+
|
5
|
+
module SimpleDesktops
|
6
|
+
class Feed
|
7
|
+
|
8
|
+
attr_reader :url
|
9
|
+
|
10
|
+
def initialize url = default_feed
|
11
|
+
@url = url
|
12
|
+
end
|
13
|
+
|
14
|
+
def list_wallpapers
|
15
|
+
get_wallpapers
|
16
|
+
end
|
17
|
+
alias_method :wallpapers, :list_wallpapers
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def default_feed
|
22
|
+
"http://feeds.feedburner.com/simpledesktops?xml"
|
23
|
+
end
|
24
|
+
|
25
|
+
def base_url
|
26
|
+
"http://simpledesktops.com"
|
27
|
+
end
|
28
|
+
|
29
|
+
def feed
|
30
|
+
@feed ||= Nokogiri::XML open(url)
|
31
|
+
end
|
32
|
+
|
33
|
+
def get_wallpapers
|
34
|
+
all_wallpapers.map do |el|
|
35
|
+
SimpleDesktops::Wallpaper.new(base_url + download_link(el)).url
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def all_wallpapers
|
40
|
+
@all_wallpapers ||= feed.xpath('//item/link').map &:text
|
41
|
+
end
|
42
|
+
|
43
|
+
def download_link(pic)
|
44
|
+
html = Nokogiri::HTML(open(pic))
|
45
|
+
html.at_css('div.desktop').elements[1].children.first.attr 'href'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'simpledesktops/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "simpledesktops"
|
8
|
+
spec.version = Simpledesktops::VERSION
|
9
|
+
spec.authors = ["Teo Ljungberg"]
|
10
|
+
spec.email = ["teo.ljungberg@gmail.com"]
|
11
|
+
spec.description = %q{simpledesktops.com wallpaper fetcher}
|
12
|
+
spec.summary = %q{Wallpapers from simpledesktops.com}
|
13
|
+
spec.homepage = "https://github.com/metamorfos/simpledesktops"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "nokogiri", "~> 1.5.6"
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0.3"
|
24
|
+
spec.add_development_dependency "rspec", "~> 2.12.0"
|
25
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'simpledesktops/feed'
|
2
|
+
|
3
|
+
describe SimpleDesktops::Feed do
|
4
|
+
describe '#new' do
|
5
|
+
context 'with a provided feed' do
|
6
|
+
let(:feed_with_url) { SimpleDesktops::Feed.new "http://feeds.feedburner.com/simpledesktops?xml" }
|
7
|
+
its(:url) { should eq 'http://feeds.feedburner.com/simpledesktops?xml' }
|
8
|
+
end
|
9
|
+
|
10
|
+
context 'with a fallback feed' do
|
11
|
+
let(:feed_with_fallback) { SimpleDesktops::Feed.new }
|
12
|
+
its(:url) { should eq 'http://feeds.feedburner.com/simpledesktops?xml' }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#list_wallpapers' do
|
17
|
+
context 'fetches wallpapers' do
|
18
|
+
let(:feed) { double('feed') }
|
19
|
+
it { should respond_to(:wallpapers, :list_wallpapers) }
|
20
|
+
|
21
|
+
it 'fetches the latest 5 wallpapers' do
|
22
|
+
feed.stub_chain(:wallpapers, :size).and_return 5
|
23
|
+
feed.wallpapers.size.should eq 5
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'simpledesktops/wallpaper'
|
2
|
+
|
3
|
+
describe SimpleDesktops::Wallpaper do
|
4
|
+
let(:pic) { SimpleDesktops::Wallpaper.new "http://simpledesktops.com/download/?desktop=5071" }
|
5
|
+
subject { pic }
|
6
|
+
|
7
|
+
its(:url) { should eq "http://simpledesktops.com/download/?desktop=5071" }
|
8
|
+
end
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: simpledesktops
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Teo Ljungberg
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-16 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: nokogiri
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.5.6
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.5.6
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: bundler
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '1.3'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '1.3'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 10.0.3
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 10.0.3
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 2.12.0
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 2.12.0
|
78
|
+
description: simpledesktops.com wallpaper fetcher
|
79
|
+
email:
|
80
|
+
- teo.ljungberg@gmail.com
|
81
|
+
executables: []
|
82
|
+
extensions: []
|
83
|
+
extra_rdoc_files: []
|
84
|
+
files:
|
85
|
+
- .gitignore
|
86
|
+
- .rspec
|
87
|
+
- Gemfile
|
88
|
+
- LICENSE.txt
|
89
|
+
- README.md
|
90
|
+
- Rakefile
|
91
|
+
- lib/simpledesktops.rb
|
92
|
+
- lib/simpledesktops/feed.rb
|
93
|
+
- lib/simpledesktops/version.rb
|
94
|
+
- lib/simpledesktops/wallpaper.rb
|
95
|
+
- simpledesktops.gemspec
|
96
|
+
- spec/simpledesktops/feed_spec.rb
|
97
|
+
- spec/simpledesktops/wallpaper_spec.rb
|
98
|
+
homepage: https://github.com/metamorfos/simpledesktops
|
99
|
+
licenses:
|
100
|
+
- MIT
|
101
|
+
post_install_message:
|
102
|
+
rdoc_options: []
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
segments:
|
112
|
+
- 0
|
113
|
+
hash: -3614486721383950381
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
none: false
|
116
|
+
requirements:
|
117
|
+
- - ! '>='
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
segments:
|
121
|
+
- 0
|
122
|
+
hash: -3614486721383950381
|
123
|
+
requirements: []
|
124
|
+
rubyforge_project:
|
125
|
+
rubygems_version: 1.8.23
|
126
|
+
signing_key:
|
127
|
+
specification_version: 3
|
128
|
+
summary: Wallpapers from simpledesktops.com
|
129
|
+
test_files:
|
130
|
+
- spec/simpledesktops/feed_spec.rb
|
131
|
+
- spec/simpledesktops/wallpaper_spec.rb
|