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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8bb5dcc8886d22d589e2f3d9dfef5ab42bc6adb8
4
- data.tar.gz: f72571f07afcfc2f9693dbf94c7030cce7bfb321
3
+ metadata.gz: 581820b108b7f7ec7bbb5a4ff10e1f1e32219d3a
4
+ data.tar.gz: c98a9550f44ffed18439928169760d874af665cb
5
5
  SHA512:
6
- metadata.gz: ead6ae9ac27815133dd6a219cdcebb44d527f43dc5451e0739d49fc945613b6beb4648ae9132d2e1807b0808d9cc0645ee299671611775c9019773ae9fe4953a
7
- data.tar.gz: bd4875fd569db49ab0cebada2a67e9608ec0536dca7b91e5698add2be1bbb3617ad29baf66febdb9592daa173e53ab221b33861e66f204bcd31bbce57e3e523d
6
+ metadata.gz: 7192353c8f85c0c2ba22ce1d09ebf6514ad32a6ecf4c90a307c96edc2790f9fa49ecccdb2752a68d3ce567128d4570e04055345f9af0d8ec7c833527fb26e6c7
7
+ data.tar.gz: e265acba7c61d0c9ecda8098f16ac2733a7aa25ab02c382c0f846738228a6d77b64122eb8d66f79a4af64a46a476f1d8e2e2e2fef84e43365229f2c4579e117d
data/bin/ficon ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'ficon'
4
+
5
+ puts Ficon.from_uri ARGV[0]
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
- uri = URI(_uri)
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
@@ -1,3 +1,3 @@
1
1
  module Ficon
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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.1
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-06 00:00:00.000000000 Z
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