urifetch 0.1.1.rc5 → 0.1.1.rc6

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/lib/urifetch.rb CHANGED
@@ -14,12 +14,12 @@ include ActionView::Helpers::NumberHelper
14
14
 
15
15
  module Urifetch
16
16
 
17
- autoload :Response, 'urifetch/response'
18
- autoload :Strategy, 'urifetch/strategy'
19
- autoload :Router, 'urifetch/router'
20
- autoload :Version, 'urifetch/version'
21
-
22
- autoload :OpenGraph, 'urifetch/ext/opengraph'
17
+ require "#{File.expand_path(File.dirname(__FILE__))}/urifetch/response"
18
+ require "#{File.expand_path(File.dirname(__FILE__))}/urifetch/strategy"
19
+ require "#{File.expand_path(File.dirname(__FILE__))}/urifetch/router"
20
+ require "#{File.expand_path(File.dirname(__FILE__))}/urifetch/version"
21
+
22
+ require "#{File.expand_path(File.dirname(__FILE__))}/urifetch/ext/opengraph"
23
23
 
24
24
  @@router = Router.new()
25
25
 
@@ -2,8 +2,8 @@ module Urifetch
2
2
 
3
3
  module Strategy
4
4
 
5
- autoload :Base, 'urifetch/strategy/base'
6
- autoload :Image, 'urifetch/strategy/image'
5
+ require "#{File.expand_path(File.dirname(__FILE__))}/strategy/base"
6
+ require "#{File.expand_path(File.dirname(__FILE__))}/strategy/image"
7
7
 
8
8
  end
9
9
 
@@ -49,8 +49,8 @@ module Urifetch
49
49
  # Start by setting the URI
50
50
  set :url, uri.to_s.sub(/\/$/,"")
51
51
 
52
- doc = Nokogiri::HTML.parse(@request,false)
53
-
52
+ doc = Nokogiri::HTML.parse(@request)
53
+
54
54
  # Image
55
55
  image = doc.css('img').first
56
56
  image = image.nil? ? nil : image['src'].try(:strip)
@@ -62,7 +62,7 @@ module Urifetch
62
62
  end
63
63
 
64
64
  # Open Auth data
65
- if og = OpenGraph.parse(doc)
65
+ if og = OpenGraph.parse(doc,false)
66
66
  set :url, og.url.to_s.sub(/\/$/,""), override: true
67
67
  set :title, og.title, override: true
68
68
  set :image, og.image, override: true
@@ -97,7 +97,9 @@ module Urifetch
97
97
  end
98
98
 
99
99
  def set(key,value,args={})
100
- response.data[key.to_s] = value if (args[:override] == true) or response.data[key.to_s].nil? unless value.nil?
100
+ if value.present?
101
+ response.data[key.to_s] = value if (args[:override] || !response.data[key.to_s].present?)
102
+ end
101
103
  end
102
104
 
103
105
  def set?(key)
@@ -5,7 +5,7 @@ module Urifetch
5
5
  MAJOR = 0
6
6
  MINOR = 1
7
7
  PATCH = 1
8
- BUILD = 'rc5'
8
+ BUILD = 'rc6'
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
11
11
 
data/urifetch.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "urifetch"
8
- s.version = "0.1.1.rc5"
8
+ s.version = "0.1.1.rc6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Philip Vieira"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: urifetch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1.rc5
4
+ version: 0.1.1.rc6
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -249,7 +249,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
249
249
  version: '0'
250
250
  segments:
251
251
  - 0
252
- hash: -1453431270534021920
252
+ hash: 460218162848213799
253
253
  required_rubygems_version: !ruby/object:Gem::Requirement
254
254
  none: false
255
255
  requirements: