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.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/embedify.gemspec +1 -1
  3. data/lib/embedify.rb +7 -1
  4. metadata +2 -2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.4.0
data/embedify.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "embedify"
8
- s.version = "0.3.1"
8
+ s.version = "0.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tristan Gomez"]
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.3.1
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: -400433983158747791
217
+ hash: 1796977382236343391
218
218
  required_rubygems_version: !ruby/object:Gem::Requirement
219
219
  none: false
220
220
  requirements: