embedify 0.3.1 → 0.4.0
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/VERSION +1 -1
- data/embedify.gemspec +1 -1
- data/lib/embedify.rb +7 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/embedify.gemspec
CHANGED
data/lib/embedify.rb
CHANGED
@@ -38,7 +38,7 @@ module Embedify
|
|
38
38
|
def self.get_with_redirects(uri, iterations = 0)
|
39
39
|
html = Faraday.get(uri)
|
40
40
|
#raise html.env[:response_headers]['Location']
|
41
|
-
puts "#{iterations.inspect} #{html.env[:response_headers]['Location']}"
|
41
|
+
#puts "#{iterations.inspect} #{html.env[:response_headers]['Location']}"
|
42
42
|
case html.status
|
43
43
|
when 301..307
|
44
44
|
html = get_with_redirects(html.env[:response_headers]['Location'], iterations + 1)
|
@@ -50,11 +50,17 @@ module Embedify
|
|
50
50
|
def self.parse(html)
|
51
51
|
doc = Nokogiri::HTML.parse(html)
|
52
52
|
page = Embedify::Object.new
|
53
|
+
|
54
|
+
# capture all og: meta tags
|
53
55
|
doc.css('meta').each do |m|
|
54
56
|
if m.attribute('property') && m.attribute('property').to_s.match(/^og:(.+)$/i)
|
55
57
|
page[$1.gsub('-','_')] = m.attribute('content').to_s
|
56
58
|
end
|
57
59
|
end
|
60
|
+
|
61
|
+
# transform the og:image tag into an array
|
62
|
+
page.image = [url: page.image] unless(page.image.nil? || page.image.respond_to?(:each))
|
63
|
+
|
58
64
|
page[:nokogiri_parsed_document] = doc
|
59
65
|
page
|
60
66
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embedify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -214,7 +214,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
214
214
|
version: '0'
|
215
215
|
segments:
|
216
216
|
- 0
|
217
|
-
hash:
|
217
|
+
hash: 1796977382236343391
|
218
218
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
219
219
|
none: false
|
220
220
|
requirements:
|