media_meta_hash 0.0.1.beta → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 daltonrenaldo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MediaMetaHash
2
2
 
3
- TODO: Write a gem description
3
+ TODO: Given the url to a video (youtube, vimeo, foxnews, foxbusiness), this return a hash for opengraph (og) and twitter cards which can be used with meta-tags gem to create the html tags
4
4
 
5
5
  ## Installation
6
6
 
@@ -27,3 +27,6 @@ TODO: Write usage instructions here
27
27
  3. Commit your changes (`git commit -am 'Add some feature'`)
28
28
  4. Push to the branch (`git push origin my-new-feature`)
29
29
  5. Create new Pull Request
30
+
31
+
32
+
@@ -1,3 +1,3 @@
1
1
  module MediaMetaHash
2
- VERSION = "0.0.1.beta"
2
+ VERSION = "0.0.1"
3
3
  end
@@ -7,10 +7,10 @@ Gem::Specification.new do |spec|
7
7
  spec.name = "media_meta_hash"
8
8
  spec.version = MediaMetaHash::VERSION
9
9
  spec.authors = ["Renaldo Pierre-Louis"]
10
- spec.email = ["rpierrelouis@hedgeye.com"]
10
+ spec.email = ["pirelouisd87@gmail.com"]
11
11
  spec.description = %q{Given the url to a video (youtube, vimeo, foxnews, foxbusiness), this return a hash for opengraph (og) and twitter cards which can be used with meta-tags gem to create the html tags}
12
12
  spec.summary = %q{This gem takes video url (youtube, vimeo, foxnews, foxbusiness) and returns a hash for og and twitter card}
13
- spec.homepage = ""
13
+ spec.homepage = "https://github.com/daltonrenaldo/meta_media_hash"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.add_dependency('video_info')
@@ -0,0 +1,154 @@
1
+ require 'spec_helper'
2
+
3
+ describe MediaMetaHash do
4
+ ARTICLE_URL = "http://google.com"
5
+ YOUTUBE_URL = "http://www.youtube.com/watch?v=ZQCINxTQlN4"
6
+ FOX_URL = "http://video.foxbusiness.com/v/2734961183001/a-breach-of-privacy-between-the-irs-and-white-house/"
7
+ VIMEO_URL = "http://vimeo.com/74868773"
8
+
9
+ def basic_info opts = {}
10
+ OpenStruct.new({:title => "Boats",
11
+ :description => "Something",
12
+ :image => "http://image.com",
13
+ :type => "video",
14
+ :provider => "vimeo",
15
+ :embed_url => "http://embed_link.com",
16
+ :width => "240",
17
+ :height => "100",
18
+ :video_id => "13142"
19
+ }.merge!(opts))
20
+ end
21
+
22
+ describe "#get" do
23
+ context ":article" do
24
+ before do
25
+ @result = MediaMetaHash.for(ARTICLE_URL, :article)
26
+ end
27
+
28
+ it "should return a hash" do
29
+ @result.should be_instance_of Hash
30
+ end
31
+
32
+ it "should contains these keys" do
33
+ @result.should include(:og, :twitter)
34
+ end
35
+ end
36
+
37
+ context ":video" do
38
+ before do
39
+ @result = MediaMetaHash.for(YOUTUBE_URL)
40
+ end
41
+
42
+ it "should return a hash" do
43
+ @result.should be_instance_of Hash
44
+ end
45
+
46
+ it "should contains these keys" do
47
+ @result.should include(:og, :twitter)
48
+ end
49
+ end
50
+ end
51
+
52
+ describe "#video_info" do
53
+ context "for fox videos" do
54
+ it "returns object with correct attributes" do
55
+ info = MediaMetaHash.video_info FOX_URL
56
+ info.methods.should include(:video_id, :embed_url, :title, :image, :description, :provider, :width, :height)
57
+ end
58
+ end
59
+
60
+ context "for youtube videos" do
61
+ before do
62
+ VideoInfo.stub(:get).and_return{ basic_info({:thumbnail_medium => "url"}) }
63
+ end
64
+
65
+ it "returns object with correct attributes" do
66
+ url = "http://www.youtube.com/watch?v=ZQCINxTQlN4"
67
+ info = MediaMetaHash.video_info(url)
68
+ info.methods.should include(:video_id, :embed_url, :title, :description, :provider, :width, :height, :thumbnail_medium, :og_url)
69
+ end
70
+ end
71
+
72
+ context "for other videos (vimeo)" do
73
+ before do
74
+ VideoInfo.stub(:get).and_return{ basic_info }
75
+ end
76
+
77
+ it "returns object with correct attritubes" do
78
+ url = "http://vimeo.com/74868773"
79
+ info = MediaMetaHash.video_info(url)
80
+ info.methods.should_not include(:og_url)
81
+ end
82
+ end
83
+ end
84
+
85
+ describe "#video_hash" do
86
+ it "gets video info" do
87
+ url = "http://vimeo.com/74868773"
88
+ MediaMetaHash.should_receive(:video_info).and_return { basic_info }
89
+ MediaMetaHash.video_hash url, {}
90
+ end
91
+
92
+ context "for youtube videos" do
93
+ before do
94
+ MediaMetaHash.stub(:video_info).and_return{ basic_info({:og_url => "http://og_url.com", :provider => :youtube}) }
95
+ @info_hash = MediaMetaHash.video_hash YOUTUBE_URL, {}
96
+ end
97
+
98
+ it "the :og key" do
99
+ @info_hash[:og].should include(:title, :description, :image, :type, :video)
100
+ end
101
+
102
+ it "the :twitter key" do
103
+ @info_hash[:twitter].should include(:title, :description, :image, :player, :card, :app)
104
+ end
105
+
106
+ it "the :twitter => :player should be an array" do
107
+ @info_hash[:twitter][:player].should be_instance_of Array
108
+ end
109
+
110
+ it "the :twitter => :player url (array.first) should be secure" do
111
+ @info_hash[:twitter][:player].first.should match(/^https/)
112
+ end
113
+
114
+ it "the :twitter => :player array should have hash" do
115
+ @info_hash[:twitter][:player].last.should include(:width, :height)
116
+ end
117
+
118
+ it "the :og => :video key" do
119
+ @info_hash[:og][:video].should == "http://og_url.com"
120
+ end
121
+
122
+ it "the :twitter => :app key" do
123
+ @info_hash[:twitter][:app].should include(:id, :name, :url)
124
+ end
125
+
126
+ it "the :twitter => :app => :id key" do
127
+ @info_hash[:twitter][:app][:id].should include(:iphone, :ipad, :googleplay)
128
+ end
129
+
130
+ it "the :twitter => :app => :name key" do
131
+ @info_hash[:twitter][:app][:name].should include(:iphone, :ipad, :googleplay)
132
+ end
133
+
134
+ it "the :twitter => :app => :url key" do
135
+ @info_hash[:twitter][:app][:url].should include(:iphone, :ipad, :googleplay)
136
+ end
137
+ end
138
+
139
+ context "for fox videos" do
140
+ before do
141
+ MediaMetaHash.stub(:video_info).and_return{ basic_info({:provider => "foxbusiness"}) }
142
+ @info_hash = MediaMetaHash.video_hash FOX_URL, {}
143
+ end
144
+
145
+ it "the :og => :video key" do
146
+ @info_hash[:og][:video].should == "http://embed_link.com"
147
+ end
148
+
149
+ it "the :twitter key" do
150
+ @info_hash[:twitter].should_not include(:app)
151
+ end
152
+ end
153
+ end
154
+ end
@@ -0,0 +1,8 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ require 'media_meta_hash'
5
+
6
+ RSpec.configure do |config|
7
+ # some (optional) config here
8
+ end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: media_meta_hash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.beta
5
- prerelease: 6
4
+ version: 0.0.1
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Renaldo Pierre-Louis
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-11 00:00:00.000000000 Z
12
+ date: 2013-10-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: video_info
@@ -95,20 +95,23 @@ description: Given the url to a video (youtube, vimeo, foxnews, foxbusiness), th
95
95
  return a hash for opengraph (og) and twitter cards which can be used with meta-tags
96
96
  gem to create the html tags
97
97
  email:
98
- - rpierrelouis@hedgeye.com
98
+ - pirelouisd87@gmail.com
99
99
  executables: []
100
100
  extensions: []
101
101
  extra_rdoc_files: []
102
102
  files:
103
103
  - .gitignore
104
104
  - Gemfile
105
+ - LICENSE
105
106
  - LICENSE.txt
106
107
  - README.md
107
108
  - Rakefile
108
109
  - lib/media_meta_hash.rb
109
110
  - lib/media_meta_hash/version.rb
110
111
  - media_meta_hash.gemspec
111
- homepage: ''
112
+ - spec/media_meta_hash_spec.rb
113
+ - spec/spec_helper.rb
114
+ homepage: https://github.com/daltonrenaldo/meta_media_hash
112
115
  licenses:
113
116
  - MIT
114
117
  post_install_message:
@@ -124,9 +127,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
124
127
  required_rubygems_version: !ruby/object:Gem::Requirement
125
128
  none: false
126
129
  requirements:
127
- - - ! '>'
130
+ - - ! '>='
128
131
  - !ruby/object:Gem::Version
129
- version: 1.3.1
132
+ version: '0'
130
133
  requirements: []
131
134
  rubyforge_project:
132
135
  rubygems_version: 1.8.25
@@ -134,4 +137,6 @@ signing_key:
134
137
  specification_version: 3
135
138
  summary: This gem takes video url (youtube, vimeo, foxnews, foxbusiness) and returns
136
139
  a hash for og and twitter card
137
- test_files: []
140
+ test_files:
141
+ - spec/media_meta_hash_spec.rb
142
+ - spec/spec_helper.rb