unsavory 1.1 → 1.2
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/README.rdoc +26 -0
- data/bin/unsavory +18 -9
- data/lib/utilities.rb +21 -1
- metadata +12 -12
- data/LICENSE +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6003a2ee811476e80f9203f4064fb5479e9447ae
|
4
|
+
data.tar.gz: 6b92d8fd928058d879b4d2fe77a82bcc53895f75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2a74acb97b11f5367ec363a32909c0c98bf556543ad6cd1640263992738b43b313c832cd84e5052993dddcac3aaf057680e369d0cf242b67234a0036a9f9632
|
7
|
+
data.tar.gz: 420bcb560f56f9093d3349bc4ec1319dd2c9f2bb7949f96a99efea211047e19495d1928735dfa8472ac0980fb7c947956e56bb390a65a9462142f81e2f23b33b
|
data/README.rdoc
CHANGED
@@ -38,6 +38,32 @@ Any link that returns an HTTP status code of 404 will be deleted without warning
|
|
38
38
|
# Use tests to clean up code.
|
39
39
|
# Add option to replace links with Archive.org links
|
40
40
|
|
41
|
+
== Thanks
|
42
|
+
|
43
|
+
# thelibrarian[https://github.com/thelibrarian]: for implementing HTTPS support and the '--dry-run' option
|
44
|
+
|
41
45
|
== Author
|
42
46
|
|
43
47
|
Michael Kohl <citizen428[at]gmail[dot]com>
|
48
|
+
|
49
|
+
== License
|
50
|
+
|
51
|
+
Copyright (c) 2009-2014 Michael Kohl
|
52
|
+
|
53
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
54
|
+
of this software and associated documentation files (the "Software"), to deal
|
55
|
+
in the Software without restriction, including without limitation the rights
|
56
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
57
|
+
copies of the Software, and to permit persons to whom the Software is
|
58
|
+
furnished to do so, subject to the following conditions:
|
59
|
+
|
60
|
+
The above copyright notice and this permission notice shall be included in
|
61
|
+
all copies or substantial portions of the Software.
|
62
|
+
|
63
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
64
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
65
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
66
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
67
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
68
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
69
|
+
THE SOFTWARE.
|
data/bin/unsavory
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
|
-
# Copyright (c) 2009-
|
2
|
+
# Copyright (c) 2009-2014 Michael Kohl
|
3
3
|
|
4
4
|
require "rubygems" # for the 1.8 users
|
5
5
|
require "logger"
|
@@ -8,8 +8,8 @@ require "progressbar"
|
|
8
8
|
require_relative "../lib/pinboard_client.rb"
|
9
9
|
require_relative "../lib/utilities.rb"
|
10
10
|
|
11
|
-
|
12
|
-
pinboard_client = PinboardClient.new(user, pass)
|
11
|
+
opts = Utilities.get_options
|
12
|
+
pinboard_client = PinboardClient.new(opts[:user], opts[:pass])
|
13
13
|
logger = Logger.new('unsavory.log')
|
14
14
|
|
15
15
|
logger.info "Unsavory started: #{Time.now.strftime('%Y-%m-%d %H:%M')}"
|
@@ -20,7 +20,8 @@ unless urls
|
|
20
20
|
puts "\nCould not retrieve URLs!\nPlease check your login credentials."
|
21
21
|
exit 1
|
22
22
|
end
|
23
|
-
puts "\n#{user} has #{urls.length} bookmarks."
|
23
|
+
puts "\n#{opts[:user]} has #{urls.length} bookmarks."
|
24
|
+
puts "You are using dry run mode. No links will be deleted!\n\n" if opts[:dry_run]
|
24
25
|
|
25
26
|
pbar = ProgressBar.new("URLs", urls.size)
|
26
27
|
moved = 0
|
@@ -28,12 +29,16 @@ moved = 0
|
|
28
29
|
urls.each_with_index do |url, idx|
|
29
30
|
pbar.inc
|
30
31
|
delete = false
|
32
|
+
use_ssl = false
|
31
33
|
|
32
34
|
# Hackety fix for issue #1
|
33
35
|
uri = URI.parse(url) rescue next
|
36
|
+
if uri.scheme == "https"
|
37
|
+
use_ssl = true
|
38
|
+
end
|
34
39
|
|
35
40
|
begin
|
36
|
-
Net::HTTP.start(uri.host, uri.port) do |http|
|
41
|
+
Net::HTTP.start(uri.host, uri.port, :use_ssl => use_ssl) do |http|
|
37
42
|
response = http.head(uri.path.empty? ? '/' : uri.path)
|
38
43
|
|
39
44
|
# handle redirects
|
@@ -43,17 +48,21 @@ urls.each_with_index do |url, idx|
|
|
43
48
|
next
|
44
49
|
end
|
45
50
|
|
46
|
-
if response.code == '404'
|
51
|
+
if response.code == '404' && !opts[:dry_run]
|
47
52
|
delete = true
|
48
53
|
elsif response.code != '200'
|
49
54
|
logger.info "#{response.code}: #{url}"
|
50
55
|
end
|
51
56
|
end
|
52
|
-
rescue Errno::ENOENT
|
53
|
-
|
57
|
+
rescue Errno::ENOENT => e
|
58
|
+
if opts[:dry_run]
|
59
|
+
logger.info "#{e.message}: #{url}"
|
60
|
+
else
|
61
|
+
delete = true
|
62
|
+
end
|
54
63
|
# In 1.8, TimeoutError does not inherit from StandardError
|
55
64
|
rescue StandardError, Timeout::Error => e
|
56
|
-
logger.error "#{e.message}
|
65
|
+
logger.error "#{e.message}: #{url}"
|
57
66
|
end
|
58
67
|
|
59
68
|
if delete
|
data/lib/utilities.rb
CHANGED
@@ -1,7 +1,14 @@
|
|
1
|
+
require 'getoptlong'
|
2
|
+
|
1
3
|
module Utilities
|
2
4
|
class << self
|
3
5
|
CFG_FILE = File.join(ENV['HOME'], ".#{File.basename($0)}")
|
4
6
|
|
7
|
+
def get_options
|
8
|
+
get_credentials.merge(parse_options)
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
5
12
|
def get_credentials
|
6
13
|
if File.exists?(CFG_FILE)
|
7
14
|
puts "Using config file '#{CFG_FILE}'"
|
@@ -17,7 +24,20 @@ module Utilities
|
|
17
24
|
exit 1
|
18
25
|
end
|
19
26
|
end
|
20
|
-
|
27
|
+
{:user => user, :pass => pass}
|
28
|
+
end
|
29
|
+
|
30
|
+
def parse_options
|
31
|
+
options = {}
|
32
|
+
opts = GetoptLong.new(['--dry-run', '-n', GetoptLong::NO_ARGUMENT])
|
33
|
+
|
34
|
+
opts.each do |opt, _|
|
35
|
+
case opt
|
36
|
+
when '--dry-run'
|
37
|
+
options[:dry_run] = true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
options
|
21
41
|
end
|
22
42
|
end
|
23
43
|
end
|
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unsavory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Kohl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.4.3
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.4.3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: progressbar
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.9.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.9.0
|
41
41
|
description: unsavory is a little Ruby script which checks your Pinboard bookmarks
|
@@ -47,11 +47,10 @@ executables:
|
|
47
47
|
extensions: []
|
48
48
|
extra_rdoc_files: []
|
49
49
|
files:
|
50
|
+
- "./README.rdoc"
|
51
|
+
- bin/unsavory
|
50
52
|
- lib/pinboard_client.rb
|
51
53
|
- lib/utilities.rb
|
52
|
-
- bin/unsavory
|
53
|
-
- ./LICENSE
|
54
|
-
- ./README.rdoc
|
55
54
|
homepage: http://github.com/citizen428/unsavory
|
56
55
|
licenses:
|
57
56
|
- MIT
|
@@ -62,18 +61,19 @@ require_paths:
|
|
62
61
|
- lib
|
63
62
|
required_ruby_version: !ruby/object:Gem::Requirement
|
64
63
|
requirements:
|
65
|
-
- -
|
64
|
+
- - ">="
|
66
65
|
- !ruby/object:Gem::Version
|
67
66
|
version: '0'
|
68
67
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
68
|
requirements:
|
70
|
-
- -
|
69
|
+
- - ">="
|
71
70
|
- !ruby/object:Gem::Version
|
72
71
|
version: '0'
|
73
72
|
requirements: []
|
74
73
|
rubyforge_project:
|
75
|
-
rubygems_version: 2.0
|
74
|
+
rubygems_version: 2.2.0
|
76
75
|
signing_key:
|
77
76
|
specification_version: 4
|
78
77
|
summary: Removes outdated links from your Pinboard bookmarks
|
79
78
|
test_files: []
|
79
|
+
has_rdoc: false
|
data/LICENSE
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
Copyright (c) 2009-2013 Michael Kohl
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
of this software and associated documentation files (the "Software"), to deal
|
5
|
-
in the Software without restriction, including without limitation the rights
|
6
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
copies of the Software, and to permit persons to whom the Software is
|
8
|
-
furnished to do so, subject to the following conditions:
|
9
|
-
|
10
|
-
The above copyright notice and this permission notice shall be included in
|
11
|
-
all copies or substantial portions of the Software.
|
12
|
-
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
THE SOFTWARE.
|