unsavory 0.3.2 → 0.3.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.
- data/README.rdoc +3 -3
- data/bin/unsavory +7 -7
- data/lib/{delicious.rb → pinboard.rb} +13 -12
- metadata +25 -11
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= unsavory -- get rid of those stale bookmarks!
|
2
2
|
|
3
|
-
unsavory is a little Ruby script which checks your
|
3
|
+
unsavory is a little Ruby script which checks your Pinboard bookmarks for dead links (HTTP status code 404) and removes them. Additionally it will also inform you about links which return a status code other than 200 (OK).
|
4
4
|
|
5
5
|
== Usage
|
6
6
|
|
@@ -20,8 +20,8 @@ In case this file doesn't exist, HighLine will be used to prompt for login crede
|
|
20
20
|
|
21
21
|
When run, unsavory will generate output similar to this (the real code does show the URLs):
|
22
22
|
|
23
|
-
Enter
|
24
|
-
Enter
|
23
|
+
Enter Pinboard username: username
|
24
|
+
Enter Pinboard password: *********
|
25
25
|
|
26
26
|
username has 664 bookmarks.
|
27
27
|
Processing URL #0001: OK
|
data/bin/unsavory
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# Copyright (c) 2009 Michael Kohl
|
3
3
|
|
4
4
|
$:.unshift File.join(File.dirname(__FILE__), '../lib')
|
5
|
-
%w{rubygems net/http
|
5
|
+
%w{rubygems net/http pinboard}.each { |x| require x }
|
6
6
|
highline = true
|
7
7
|
begin
|
8
8
|
require 'highline'
|
@@ -17,8 +17,8 @@ if File.exists?(CFG_FILE)
|
|
17
17
|
user, pass = File.new(CFG_FILE).gets.chomp.split(':')
|
18
18
|
elsif highline
|
19
19
|
hl = HighLine.new
|
20
|
-
user = hl.ask('Enter
|
21
|
-
pass = hl.ask('Enter
|
20
|
+
user = hl.ask('Enter Pinboard username: ')
|
21
|
+
pass = hl.ask('Enter Pinboard password: ') { |q| q.echo = "*" }
|
22
22
|
else
|
23
23
|
puts %{
|
24
24
|
Can't find config file '#{CFG_FILE}' and you
|
@@ -27,14 +27,14 @@ else
|
|
27
27
|
exit 1
|
28
28
|
end
|
29
29
|
|
30
|
-
|
30
|
+
pinboard = Pinboard.new(user, pass)
|
31
31
|
moved = 0
|
32
32
|
|
33
33
|
begin
|
34
|
-
urls =
|
34
|
+
urls = pinboard.get_all_urls
|
35
35
|
rescue => e
|
36
36
|
puts %{
|
37
|
-
I couldn't get your posts from
|
37
|
+
I couldn't get your posts from Pinboard!
|
38
38
|
|
39
39
|
Either you entered your username/password wrong,
|
40
40
|
or the site is temporarily unreachable.
|
@@ -69,7 +69,7 @@ urls.each_with_index do |url, idx|
|
|
69
69
|
puts case response.code
|
70
70
|
when '200' then 'OK'
|
71
71
|
when '404' then
|
72
|
-
|
72
|
+
pinboard.delete(url)
|
73
73
|
"Deleted #{url}"
|
74
74
|
else "#{response.code}: #{url}"
|
75
75
|
end
|
@@ -1,18 +1,18 @@
|
|
1
1
|
require 'httparty'
|
2
2
|
|
3
|
-
class
|
3
|
+
class Pinboard
|
4
4
|
include HTTParty
|
5
|
-
base_uri 'https://api.
|
5
|
+
base_uri 'https://api.pinboard.in/v1/'
|
6
6
|
headers "User-Agent" => "Unsavory"
|
7
|
-
|
8
|
-
API_METHODS = {
|
9
|
-
:all => '/posts/all',
|
10
|
-
:delete => '/posts/delete?url='}
|
11
|
-
|
7
|
+
|
8
|
+
API_METHODS = {
|
9
|
+
:all => '/posts/all',
|
10
|
+
:delete => '/posts/delete?url='}
|
11
|
+
|
12
12
|
def initialize(user, password)
|
13
13
|
@options = {:basic_auth => {:username => user, :password => password}}
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
# get_all returns a nested hash, but we want an array of URLs
|
17
17
|
def get_all_urls
|
18
18
|
get_all['posts']['post'].inject([]) { |urls, post| urls << post['href'] }
|
@@ -21,10 +21,11 @@ class Delicious
|
|
21
21
|
def delete(url)
|
22
22
|
self.class.get(API_METHODS[:delete]+url, @options)
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
private
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
def get_all
|
27
|
+
self.class.get(API_METHODS[:all], @options)
|
28
|
+
end
|
29
29
|
end
|
30
30
|
|
31
|
+
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unsavory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 3
|
8
|
+
- 3
|
9
|
+
version: 0.3.3
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Michael Kohl
|
@@ -9,19 +14,24 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date:
|
17
|
+
date: 2010-12-24 00:00:00 +01:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: httparty
|
17
|
-
|
18
|
-
|
19
|
-
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
20
25
|
requirements:
|
21
26
|
- - ">="
|
22
27
|
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
- 4
|
31
|
+
- 3
|
23
32
|
version: 0.4.3
|
24
|
-
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
25
35
|
description:
|
26
36
|
email: citizen428@gmail.com
|
27
37
|
executables:
|
@@ -31,7 +41,7 @@ extensions: []
|
|
31
41
|
extra_rdoc_files: []
|
32
42
|
|
33
43
|
files:
|
34
|
-
- lib/
|
44
|
+
- lib/pinboard.rb
|
35
45
|
- bin/unsavory
|
36
46
|
- ./LICENSE
|
37
47
|
- ./README.rdoc
|
@@ -45,23 +55,27 @@ rdoc_options: []
|
|
45
55
|
require_paths:
|
46
56
|
- lib
|
47
57
|
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
48
59
|
requirements:
|
49
60
|
- - ">="
|
50
61
|
- !ruby/object:Gem::Version
|
62
|
+
segments:
|
63
|
+
- 0
|
51
64
|
version: "0"
|
52
|
-
version:
|
53
65
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
54
67
|
requirements:
|
55
68
|
- - ">="
|
56
69
|
- !ruby/object:Gem::Version
|
70
|
+
segments:
|
71
|
+
- 0
|
57
72
|
version: "0"
|
58
|
-
version:
|
59
73
|
requirements: []
|
60
74
|
|
61
75
|
rubyforge_project:
|
62
|
-
rubygems_version: 1.3.
|
76
|
+
rubygems_version: 1.3.7
|
63
77
|
signing_key:
|
64
78
|
specification_version: 3
|
65
|
-
summary: Removes outdated links from your
|
79
|
+
summary: Removes outdated links from your Pinboard bookmarks
|
66
80
|
test_files: []
|
67
81
|
|