embedly 0.3.2 → 0.3.3
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/ChangeLog +4 -0
- data/README.rdoc +6 -5
- data/VERSION +1 -1
- data/features/oembed.feature +1 -1
- data/lib/embedly/api.rb +8 -3
- data/lib/embedly/model.rb +1 -1
- metadata +3 -3
data/ChangeLog
CHANGED
data/README.rdoc
CHANGED
@@ -12,7 +12,7 @@ To install the official latest stable version, please use rubygems.
|
|
12
12
|
|
13
13
|
If you would like cutting edge, then you can clone and install HEAD.
|
14
14
|
|
15
|
-
git clone git
|
15
|
+
git clone git://github.com/embedly/embedly-ruby.git
|
16
16
|
cd embedly-ruby
|
17
17
|
rake install
|
18
18
|
|
@@ -23,17 +23,17 @@ You can find rdocs at http://rubydoc.info/github/embedly/embedly-ruby/master/fra
|
|
23
23
|
require 'embedly'
|
24
24
|
require 'json'
|
25
25
|
|
26
|
-
embedly_api = Embedly::API.new
|
26
|
+
embedly_api = Embedly::API.new :user_agent => 'Mozilla/5.0 (compatible; mytestapp/1.0; my@email.com)'
|
27
27
|
|
28
28
|
# single url
|
29
|
-
obj = embedly_api.oembed :url => 'http://
|
29
|
+
obj = embedly_api.oembed :url => 'http://www.youtube.com/watch?v=sPbJ4Z5D-n4&feature=topvideos'
|
30
30
|
puts obj[0].marshal_dump
|
31
31
|
json_obj = JSON.pretty_generate(obj[0].marshal_dump)
|
32
32
|
puts json_obj
|
33
33
|
|
34
34
|
# multiple urls with opts
|
35
35
|
objs = embedly_api.oembed(
|
36
|
-
:urls => ['http://
|
36
|
+
:urls => ['http://www.youtube.com/watch?v=sPbJ4Z5D-n4&feature=topvideos', 'http://twitpic.com/3yr7hk'],
|
37
37
|
:maxWidth => 450,
|
38
38
|
:wmode => 'transparent',
|
39
39
|
:method => 'after'
|
@@ -42,7 +42,8 @@ You can find rdocs at http://rubydoc.info/github/embedly/embedly-ruby/master/fra
|
|
42
42
|
puts json_obj
|
43
43
|
|
44
44
|
# call pro with key (you'll need a real key)
|
45
|
-
embedly_pro = Embedly::API.new :key => 'xxxxxxxxxxxxxxxxxxxxxxxxxx'
|
45
|
+
embedly_pro = Embedly::API.new :key => 'xxxxxxxxxxxxxxxxxxxxxxxxxx',
|
46
|
+
:user_agent => 'Mozilla/5.0 (compatible; mytestapp/1.0; my@email.com)'
|
46
47
|
url = 'http://www.guardian.co.uk/media/2011/jan/21/andy-coulson-phone-hacking-statement'
|
47
48
|
obj = embedly_pro.preview :url => url
|
48
49
|
puts JSON.pretty_generate(obj[0].marshal_dump)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.3
|
data/features/oembed.feature
CHANGED
@@ -74,7 +74,7 @@ Feature: OEmbed
|
|
74
74
|
| url |
|
75
75
|
| http://www.youtube.com/watch/is/a/bad/url |
|
76
76
|
| http://www.scribd.com/doc/zfldsf/asdfkljlas/klajsdlfkasdf |
|
77
|
-
| http://
|
77
|
+
| http://fav.me/alsfsdf |
|
78
78
|
|
79
79
|
|
80
80
|
Scenario Outline: Attempt multi get 404 URLs
|
data/lib/embedly/api.rb
CHANGED
@@ -3,7 +3,6 @@ require 'json'
|
|
3
3
|
require 'ostruct'
|
4
4
|
require 'embedly/model'
|
5
5
|
|
6
|
-
include ::Embedly
|
7
6
|
|
8
7
|
# Performs api calls to embedly.
|
9
8
|
#
|
@@ -36,6 +35,10 @@ include ::Embedly
|
|
36
35
|
class Embedly::API
|
37
36
|
attr_reader :key, :endpoint, :api_version, :user_agent
|
38
37
|
|
38
|
+
def logger *args
|
39
|
+
Embedly.logger *args
|
40
|
+
end
|
41
|
+
|
39
42
|
# === Options
|
40
43
|
#
|
41
44
|
# [:+endpoint+] Hostname of embedly server. Defaults to api.embed.ly if no key is provided, pro.embed.ly if key is provided.
|
@@ -80,7 +83,7 @@ class Embedly::API
|
|
80
83
|
params[:urls].reject!.with_index do |url, i|
|
81
84
|
if url !~ services_regex
|
82
85
|
rejects << [i,
|
83
|
-
EmbedlyObject.new(
|
86
|
+
Embedly::EmbedlyObject.new(
|
84
87
|
:type => 'error',
|
85
88
|
:error_code => 401,
|
86
89
|
:error_message => 'This service requires an Embedly Pro account'
|
@@ -108,7 +111,9 @@ class Embedly::API
|
|
108
111
|
if response.code.to_i == 200
|
109
112
|
logger.debug { response.body }
|
110
113
|
# [].flatten is to be sure we have an array
|
111
|
-
objs = [JSON.parse(response.body)].flatten.collect
|
114
|
+
objs = [JSON.parse(response.body)].flatten.collect do |o|
|
115
|
+
Embedly::EmbedlyObject.new(o)
|
116
|
+
end
|
112
117
|
else
|
113
118
|
logger.error { response.inspect }
|
114
119
|
raise 'An unexpected error occurred'
|
data/lib/embedly/model.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 3
|
9
|
+
version: 0.3.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Bob Corsaro
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-02-
|
17
|
+
date: 2011-02-20 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|