ficon 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/ficon +5 -0
- data/lib/ficon.rb +21 -2
- data/lib/ficon/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 581820b108b7f7ec7bbb5a4ff10e1f1e32219d3a
|
4
|
+
data.tar.gz: c98a9550f44ffed18439928169760d874af665cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7192353c8f85c0c2ba22ce1d09ebf6514ad32a6ecf4c90a307c96edc2790f9fa49ecccdb2752a68d3ce567128d4570e04055345f9af0d8ec7c833527fb26e6c7
|
7
|
+
data.tar.gz: e265acba7c61d0c9ecda8098f16ac2733a7aa25ab02c382c0f846738228a6d77b64122eb8d66f79a4af64a46a476f1d8e2e2e2fef84e43365229f2c4579e117d
|
data/bin/ficon
ADDED
data/lib/ficon.rb
CHANGED
@@ -7,9 +7,17 @@ require 'net/http'
|
|
7
7
|
|
8
8
|
module Ficon
|
9
9
|
def self.from_uri(_uri)
|
10
|
-
|
10
|
+
|
11
|
+
uri = nil
|
11
12
|
doc = nil
|
12
13
|
|
14
|
+
begin
|
15
|
+
require 'addressable/uri'
|
16
|
+
uri = Addressable::URI.heuristic_parse(_uri)
|
17
|
+
rescue LoadError
|
18
|
+
uri = URI(_uri)
|
19
|
+
end
|
20
|
+
|
13
21
|
begin
|
14
22
|
data = open(uri)
|
15
23
|
doc = Nokogiri::HTML(data)
|
@@ -17,7 +25,18 @@ module Ficon
|
|
17
25
|
uri = data.base_uri
|
18
26
|
|
19
27
|
rescue OpenURI::HTTPError, SocketError => e
|
20
|
-
puts e.inspect
|
28
|
+
puts "OpenURI: #{e.inspect}"
|
29
|
+
return nil
|
30
|
+
rescue TypeError => e
|
31
|
+
if uri.to_s =~ /^http/
|
32
|
+
puts "#{e.inspect}"
|
33
|
+
puts "#{e.backtrace.join('\n')}"
|
34
|
+
else
|
35
|
+
puts "Please prepend http:// or https:// to the URL"
|
36
|
+
end
|
37
|
+
return nil
|
38
|
+
rescue RuntimeError => e
|
39
|
+
puts "#{e.message}"
|
21
40
|
return nil
|
22
41
|
end
|
23
42
|
|
data/lib/ficon/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ficon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Milne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -55,7 +55,8 @@ dependencies:
|
|
55
55
|
description: Ficon finds icons for websites and optionally, the best icon
|
56
56
|
email:
|
57
57
|
- d@nmilne.com
|
58
|
-
executables:
|
58
|
+
executables:
|
59
|
+
- ficon
|
59
60
|
extensions: []
|
60
61
|
extra_rdoc_files: []
|
61
62
|
files:
|
@@ -64,6 +65,7 @@ files:
|
|
64
65
|
- LICENSE.txt
|
65
66
|
- README.md
|
66
67
|
- Rakefile
|
68
|
+
- bin/ficon
|
67
69
|
- ficon.gemspec
|
68
70
|
- lib/ficon.rb
|
69
71
|
- lib/ficon/version.rb
|