embedly 1.8.0 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,9 @@
1
+ *embedly-1.9.0 (21 Jan 2014)
2
+ 15 Jan 2014: Roman Shterenzon <romanbsd@yahoo.com>
3
+ Adds a Faraday request adapter
4
+ Remove Typhoeus as dependency, if it is installed manually, it will be
5
+ used by default
6
+
1
7
  *embedly-1.8.0 (17 Jun 2013)
2
8
 
3
9
  17 Jun 2013: Felipe Elias Philipp <felipeelias@gmail.com>
data/Gemfile CHANGED
@@ -4,16 +4,13 @@ gem "querystring"
4
4
  gem "oauth"
5
5
  gem "json"
6
6
 
7
- platforms :mri do
8
- gem "typhoeus"
9
- end
10
-
11
7
  group :development do
8
+ gem "typhoeus"
12
9
  gem "jeweler"
13
10
  gem "cucumber"
14
11
  gem "rake"
15
12
  gem "rspec"
16
13
  gem "yard"
17
14
  gem "aruba"
15
+ gem "faraday"
18
16
  end
19
-
@@ -0,0 +1,114 @@
1
+ # embedly
2
+
3
+ embedly is the Embedly Ruby client library and commandline tool. It allows
4
+ you to integrate Embedly into your Ruby applications, as well as use
5
+ Embedly's API from the commandline.
6
+
7
+ To find out what Embedly is all about, please visit http://embed.ly. To see
8
+ our api documentation, visit http://api.embed.ly/docs.
9
+
10
+ ## Installing
11
+
12
+ To install the official latest stable version, please use rubygems.
13
+
14
+ gem install embedly
15
+
16
+ If you would like cutting edge, then you can clone and install HEAD.
17
+
18
+ git clone git://github.com/embedly/embedly-ruby.git
19
+ cd embedly-ruby
20
+ rake install
21
+
22
+ ## Requirements
23
+
24
+ * querystring <https://github/dokipen/querystring>
25
+
26
+ ## Getting Started
27
+
28
+ You can find rdocs at http://rubydoc.info/github/embedly/embedly-ruby/master/frames
29
+
30
+ ```ruby
31
+ require 'embedly'
32
+ require 'json'
33
+
34
+ embedly_api =
35
+ Embedly::API.new :user_agent => 'Mozilla/5.0 (compatible; mytestapp/1.0; my@email.com)'
36
+
37
+ # single url
38
+ obj = embedly_api.oembed :url => 'http://www.youtube.com/watch?v=sPbJ4Z5D-n4&feature=topvideos'
39
+ puts obj[0].marshal_dump
40
+ json_obj = JSON.pretty_generate(obj[0].marshal_dump)
41
+ puts json_obj
42
+
43
+ # multiple urls with opts
44
+ objs = embedly_api.oembed(
45
+ :urls => ['http://www.youtube.com/watch?v=sPbJ4Z5D-n4&feature=topvideos',
46
+ 'http://twitpic.com/3yr7hk'],
47
+ :maxwidth => 450,
48
+ :wmode => 'transparent',
49
+ :method => 'after'
50
+ )
51
+ json_obj = JSON.pretty_generate(objs.collect{|o| o.marshal_dump})
52
+ puts json_obj
53
+
54
+ # call api with key (you'll need a real key)
55
+ embedly_api = Embedly::API.new :key => 'xxxxxxxxxxxxxxxxxxxxxxxxxx',
56
+ :user_agent => 'Mozilla/5.0 (compatible; mytestapp/1.0; my@email.com)'
57
+ url = 'http://www.guardian.co.uk/media/2011/jan/21/andy-coulson-phone-hacking-statement'
58
+ obj = embedly_api.extract :url => url
59
+ puts JSON.pretty_generate(obj[0].marshal_dump)
60
+ ```
61
+
62
+ ## Configuration options
63
+
64
+ You can configure some parameters in the api:
65
+
66
+ ```ruby
67
+ Embedly.configure do |config|
68
+ # prints debug messages to the logger
69
+ config.debug = true
70
+
71
+ # use a custom logger
72
+ config.logger = MyAwesomeLogger.new(STDERR)
73
+
74
+ # Choose a request adatper (net_http, typhoeus or faraday)
75
+ config.request_with :faraday
76
+ end
77
+ ```
78
+
79
+ ## Testing
80
+
81
+ gem install jeweler
82
+ rake spec
83
+ rake features # if it complains of missing deps install them
84
+
85
+ Some tests will fail due to missing api key. Set the `EMBEDLY_KEY` environmental
86
+ variable with your key to get them to pass.
87
+
88
+ EMBEDLY_KEY=xxxxxxxxxxxxx rake features
89
+
90
+ To turn on debugging, set the `EMBEDLY_VERBOSE` environmental variable.
91
+
92
+ EMBEDLY_VERBOSE=1 EMBEDLY_KEY=xxxxxxxxxxx rake features
93
+
94
+ We have provided some commandline tools to test the Embedly interface.
95
+
96
+ * embedly_oembed
97
+ * embedly_objectify
98
+ * embedly_preview
99
+
100
+ Using `--help` with the commands should give you a good idea of how to use them.
101
+
102
+ ## Note on Patches/Pull Requests
103
+
104
+ * Fork the project.
105
+ * Make your feature addition or bug fix.
106
+ * Add tests for it. This is important so I don't break it in a
107
+ future version unintentionally.
108
+ * Commit, do not mess with rakefile, version, or history.
109
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
110
+ * Send me a pull request. Bonus points for topic branches.
111
+
112
+ ## Copyright
113
+
114
+ Copyright (c) 2011 Embed.ly, Inc. See MIT-LICENSE for details.
data/Rakefile CHANGED
@@ -19,12 +19,13 @@ Jeweler::Tasks.new do |gem|
19
19
  gem.email = "bob@embed.ly"
20
20
  gem.homepage = "http://github.com/embedly/embedly-ruby"
21
21
  gem.authors = [
22
- "Bob Corsaro",
22
+ "Bob Corsaro",
23
23
  "Felipe Elias Philipp",
24
- "Russ Bradberry",
24
+ "Russ Bradberry",
25
25
  "Arun Thampi",
26
26
  "Anton Dieterle",
27
- "Nitesh"
27
+ "Nitesh",
28
+ "Roman Shterenzon",
28
29
  ]
29
30
  gem.license = "MIT"
30
31
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.8.0
1
+ 1.9.0
@@ -5,23 +5,23 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "embedly"
8
- s.version = "1.8.0"
8
+ s.version = "1.9.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Bob Corsaro", "Felipe Elias Philipp", "Russ Bradberry", "Arun Thampi", "Anton Dieterle", "Nitesh"]
12
- s.date = "2013-06-17"
11
+ s.authors = ["Bob Corsaro", "Felipe Elias Philipp", "Russ Bradberry", "Arun Thampi", "Anton Dieterle", "Nitesh", "Roman Shterenzon"]
12
+ s.date = "2014-01-21"
13
13
  s.description = "Ruby Embedly client library"
14
14
  s.email = "bob@embed.ly"
15
15
  s.executables = ["embedly_extract", "embedly_objectify", "embedly_oembed", "embedly_preview"]
16
16
  s.extra_rdoc_files = [
17
17
  "ChangeLog",
18
- "README.rdoc"
18
+ "README.md"
19
19
  ]
20
20
  s.files = [
21
21
  "ChangeLog",
22
22
  "Gemfile",
23
23
  "MIT-LICENSE",
24
- "README.rdoc",
24
+ "README.md",
25
25
  "Rakefile",
26
26
  "VERSION",
27
27
  "bin/embedly_extract",
@@ -43,6 +43,7 @@ Gem::Specification.new do |s|
43
43
  "lib/embedly/model.rb",
44
44
  "lib/embedly/request.rb",
45
45
  "lib/embedly/request/base.rb",
46
+ "lib/embedly/request/faraday.rb",
46
47
  "lib/embedly/request/net_http.rb",
47
48
  "lib/embedly/request/typhoeus.rb",
48
49
  "spec/embedly/api_spec.rb",
@@ -53,7 +54,7 @@ Gem::Specification.new do |s|
53
54
  s.homepage = "http://github.com/embedly/embedly-ruby"
54
55
  s.licenses = ["MIT"]
55
56
  s.require_paths = ["lib"]
56
- s.rubygems_version = "1.8.25"
57
+ s.rubygems_version = "1.8.24"
57
58
  s.summary = "Ruby Embedly client library"
58
59
 
59
60
  if s.respond_to? :specification_version then
@@ -63,13 +64,14 @@ Gem::Specification.new do |s|
63
64
  s.add_runtime_dependency(%q<querystring>, [">= 0"])
64
65
  s.add_runtime_dependency(%q<oauth>, [">= 0"])
65
66
  s.add_runtime_dependency(%q<json>, [">= 0"])
66
- s.add_runtime_dependency(%q<typhoeus>, [">= 0"])
67
+ s.add_development_dependency(%q<typhoeus>, [">= 0"])
67
68
  s.add_development_dependency(%q<jeweler>, [">= 0"])
68
69
  s.add_development_dependency(%q<cucumber>, [">= 0"])
69
70
  s.add_development_dependency(%q<rake>, [">= 0"])
70
71
  s.add_development_dependency(%q<rspec>, [">= 0"])
71
72
  s.add_development_dependency(%q<yard>, [">= 0"])
72
73
  s.add_development_dependency(%q<aruba>, [">= 0"])
74
+ s.add_development_dependency(%q<faraday>, [">= 0"])
73
75
  else
74
76
  s.add_dependency(%q<querystring>, [">= 0"])
75
77
  s.add_dependency(%q<oauth>, [">= 0"])
@@ -81,6 +83,7 @@ Gem::Specification.new do |s|
81
83
  s.add_dependency(%q<rspec>, [">= 0"])
82
84
  s.add_dependency(%q<yard>, [">= 0"])
83
85
  s.add_dependency(%q<aruba>, [">= 0"])
86
+ s.add_dependency(%q<faraday>, [">= 0"])
84
87
  end
85
88
  else
86
89
  s.add_dependency(%q<querystring>, [">= 0"])
@@ -93,6 +96,7 @@ Gem::Specification.new do |s|
93
96
  s.add_dependency(%q<rspec>, [">= 0"])
94
97
  s.add_dependency(%q<yard>, [">= 0"])
95
98
  s.add_dependency(%q<aruba>, [">= 0"])
99
+ s.add_dependency(%q<faraday>, [">= 0"])
96
100
  end
97
101
  end
98
102
 
@@ -6,7 +6,7 @@ Feature: Command line runner
6
6
  When I run `embedly_oembed http://lockerz.com/s/136425091`
7
7
  Then the output should contain:
8
8
  """
9
- "provider_url": "http://lockerz.com"
9
+ "provider_url": "http://pics.lockerz.com"
10
10
  """
11
11
 
12
12
  Scenario: Run oembed command verbosely
@@ -12,4 +12,4 @@ Feature: Objectify
12
12
 
13
13
  Examples:
14
14
  | url | metadesc |
15
- | http://lockerz.com/s/136425091 | Top finds from friends & celebrities. Get |
15
+ | http://lockerz.com/s/136425091 | Collect the things you love. Earn |
@@ -16,8 +16,6 @@ Feature: OEmbed
16
16
  | http://www.youtube.com/watch?v=Zk7dDekYej0 | http://www.youtube.com/ |
17
17
  | http://yfrog.com/h7qqespj | http://yfrog.com |
18
18
  | http://blog.embed.ly/bob | http://tumblr.com |
19
- | http://blog.doki-pen.org/cassandra-rules | http://blog.doki-pen.org |
20
- | http://www.guardian.co.uk/media/2011/jan/21/andy-coulson-phone-hacking-statement | http://www.guardian.co.uk |
21
19
 
22
20
 
23
21
  Scenario Outline: Get the types
@@ -65,7 +63,7 @@ Feature: OEmbed
65
63
  | url |
66
64
  | http://www.youtube.com/watch/is/a/bad/url |
67
65
  | http://fav.me/alsfsdf |
68
-
66
+
69
67
 
70
68
  Scenario Outline: Attempt multi get 404 URLs
71
69
  Given an embedly api with key
@@ -77,8 +75,8 @@ Feature: OEmbed
77
75
  | urls | errcode | types |
78
76
  | http://www.youtube.com/watch/a/bassd/url,http://www.youtube.com/watch/ldf/asdlfj | 404,404 | error,error |
79
77
  | http://www.youtube.com/watch/zzzzasdf/kl,http://yfrog.com/h7qqespj | 404, | error,photo |
80
- | http://yfrog.com/h7qqespj,http://www.youtube.com/watch/asdfasdfasdf | ,404 | photo,error |
81
-
78
+ | http://yfrog.com/h7qqespj,http://www.youtube.com/watch/asdfasdf/asdf | ,404 | photo,error |
79
+
82
80
  Scenario Outline: Attempt to get 414 URL
83
81
  Given an embedly api with key
84
82
  When oembed is called with the <url> URL
@@ -85,7 +85,7 @@ class Embedly::Configuration
85
85
  def reset
86
86
  self.logger = default_logger
87
87
  self.debug = false
88
- self.request_with :typhoeus
88
+ self.request_with :net_http
89
89
  end
90
90
 
91
91
  private
@@ -1,3 +1,4 @@
1
1
  require "embedly/request/base"
2
2
  require "embedly/request/net_http"
3
3
  require "embedly/request/typhoeus"
4
+ require "embedly/request/faraday"
@@ -0,0 +1,22 @@
1
+ require 'faraday'
2
+
3
+ # Patch Faraday::Response to provide a status code
4
+ module Faraday
5
+ class Response
6
+ alias_method :code, :status unless method_defined?(:code)
7
+ end
8
+ end
9
+
10
+ module Embedly
11
+ module Request
12
+ class Faraday < Base
13
+ def get(uri, options = {})
14
+ ::Faraday.get(uri.to_s, nil, options[:headers])
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ Embedly.configuration.add_requester :faraday do |api|
21
+ Embedly::Request::Faraday.new(api)
22
+ end
@@ -19,7 +19,4 @@ begin
19
19
  Embedly::Typhoeus::Request.new(api)
20
20
  end
21
21
  rescue LoadError
22
- require "logger"
23
- logger = Logger.new(STDERR)
24
- logger.warn { "typhoeus failed to load" }
25
22
  end
@@ -41,6 +41,23 @@ module Embedly
41
41
  api.request.should be_a(Embedly::Typhoeus::Request)
42
42
  end
43
43
  end
44
+
45
+ describe "faraday" do
46
+ before do
47
+ Embedly.configure { |c| c.request_with :faraday }
48
+ end
49
+
50
+ it "sets the correct request adapter" do
51
+ api.request.should be_a(Embedly::Request::Faraday)
52
+ end
53
+
54
+ it "calls faraday" do
55
+ url = 'http://example.com'
56
+ headers = {'User-Agent'=>'spec'}
57
+ Faraday.should_receive(:get).with(url, nil, headers)
58
+ api.request.get(URI.parse(url), headers: headers)
59
+ end
60
+ end
44
61
  end
45
62
  end
46
63
  end
@@ -10,7 +10,7 @@ module Embedly
10
10
 
11
11
  describe "::run!" do
12
12
  let(:arguments) { ['-k', 'MY_KEY', '--no-secret', 'http://yfrog.com/h7qqespj', '-o', 'maxwidth=10'] }
13
- let(:api) { mock(API) }
13
+ let(:api) { double(API) }
14
14
 
15
15
  it "calls api with options" do
16
16
  API.should_receive(:new).with(:key => 'MY_KEY', :headers => {}) { api }
@@ -49,8 +49,8 @@ module Embedly
49
49
  config.key.should == 'my_api_key'
50
50
  end
51
51
 
52
- it "requests typhoeus by default" do
53
- config.requester.should == :typhoeus
52
+ it "requests using Net::HTTP by default" do
53
+ config.requester.should == :net_http
54
54
  end
55
55
  end
56
56
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embedly
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.9.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,10 +11,11 @@ authors:
11
11
  - Arun Thampi
12
12
  - Anton Dieterle
13
13
  - Nitesh
14
+ - Roman Shterenzon
14
15
  autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
- date: 2013-06-17 00:00:00.000000000 Z
18
+ date: 2014-01-21 00:00:00.000000000 Z
18
19
  dependencies:
19
20
  - !ruby/object:Gem::Dependency
20
21
  name: querystring
@@ -72,7 +73,7 @@ dependencies:
72
73
  - - ! '>='
73
74
  - !ruby/object:Gem::Version
74
75
  version: '0'
75
- type: :runtime
76
+ type: :development
76
77
  prerelease: false
77
78
  version_requirements: !ruby/object:Gem::Requirement
78
79
  none: false
@@ -176,6 +177,22 @@ dependencies:
176
177
  - - ! '>='
177
178
  - !ruby/object:Gem::Version
178
179
  version: '0'
180
+ - !ruby/object:Gem::Dependency
181
+ name: faraday
182
+ requirement: !ruby/object:Gem::Requirement
183
+ none: false
184
+ requirements:
185
+ - - ! '>='
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ none: false
192
+ requirements:
193
+ - - ! '>='
194
+ - !ruby/object:Gem::Version
195
+ version: '0'
179
196
  description: Ruby Embedly client library
180
197
  email: bob@embed.ly
181
198
  executables:
@@ -186,12 +203,12 @@ executables:
186
203
  extensions: []
187
204
  extra_rdoc_files:
188
205
  - ChangeLog
189
- - README.rdoc
206
+ - README.md
190
207
  files:
191
208
  - ChangeLog
192
209
  - Gemfile
193
210
  - MIT-LICENSE
194
- - README.rdoc
211
+ - README.md
195
212
  - Rakefile
196
213
  - VERSION
197
214
  - bin/embedly_extract
@@ -213,6 +230,7 @@ files:
213
230
  - lib/embedly/model.rb
214
231
  - lib/embedly/request.rb
215
232
  - lib/embedly/request/base.rb
233
+ - lib/embedly/request/faraday.rb
216
234
  - lib/embedly/request/net_http.rb
217
235
  - lib/embedly/request/typhoeus.rb
218
236
  - spec/embedly/api_spec.rb
@@ -234,7 +252,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
234
252
  version: '0'
235
253
  segments:
236
254
  - 0
237
- hash: 1864796039289790567
255
+ hash: -3010721165708634299
238
256
  required_rubygems_version: !ruby/object:Gem::Requirement
239
257
  none: false
240
258
  requirements:
@@ -243,7 +261,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
243
261
  version: '0'
244
262
  requirements: []
245
263
  rubyforge_project:
246
- rubygems_version: 1.8.25
264
+ rubygems_version: 1.8.24
247
265
  signing_key:
248
266
  specification_version: 3
249
267
  summary: Ruby Embedly client library
@@ -1,108 +0,0 @@
1
- = embedly
2
-
3
- embedly is the Embedly Ruby client library and commandline tool. It allows
4
- you to integrate Embedly into your Ruby applications, as well as use
5
- Embedly's API from the commandline.
6
-
7
- To find out what Embedly is all about, please visit http://embed.ly. To see
8
- our api documentation, visit http://api.embed.ly/docs.
9
-
10
- == Installing
11
-
12
- To install the official latest stable version, please use rubygems.
13
-
14
- gem install embedly
15
-
16
- If you would like cutting edge, then you can clone and install HEAD.
17
-
18
- git clone git://github.com/embedly/embedly-ruby.git
19
- cd embedly-ruby
20
- rake install
21
-
22
- == Requirements
23
-
24
- * querystring <https://github/dokipen/querystring>
25
-
26
- == Getting Started
27
-
28
- You can find rdocs at http://rubydoc.info/github/embedly/embedly-ruby/master/frames
29
-
30
- require 'embedly'
31
- require 'json'
32
-
33
- embedly_api = Embedly::API.new :user_agent => 'Mozilla/5.0 (compatible; mytestapp/1.0; my@email.com)'
34
-
35
- # single url
36
- obj = embedly_api.oembed :url => 'http://www.youtube.com/watch?v=sPbJ4Z5D-n4&feature=topvideos'
37
- puts obj[0].marshal_dump
38
- json_obj = JSON.pretty_generate(obj[0].marshal_dump)
39
- puts json_obj
40
-
41
- # multiple urls with opts
42
- objs = embedly_api.oembed(
43
- :urls => ['http://www.youtube.com/watch?v=sPbJ4Z5D-n4&feature=topvideos', 'http://twitpic.com/3yr7hk'],
44
- :maxwidth => 450,
45
- :wmode => 'transparent',
46
- :method => 'after'
47
- )
48
- json_obj = JSON.pretty_generate(objs.collect{|o| o.marshal_dump})
49
- puts json_obj
50
-
51
- # call api with key (you'll need a real key)
52
- embedly_api = Embedly::API.new :key => 'xxxxxxxxxxxxxxxxxxxxxxxxxx',
53
- :user_agent => 'Mozilla/5.0 (compatible; mytestapp/1.0; my@email.com)'
54
- url = 'http://www.guardian.co.uk/media/2011/jan/21/andy-coulson-phone-hacking-statement'
55
- obj = embedly_api.preview :url => url
56
- puts JSON.pretty_generate(obj[0].marshal_dump)
57
-
58
- == Configuration options
59
-
60
- You can configure some parameters in the api:
61
-
62
- Embedly.configure do |config|
63
- # prints debug messages to the logger
64
- config.debug = true
65
-
66
- # use a custom logger
67
- config.logger = MyAwesomeLogger.new(STDERR)
68
-
69
- # disable typhoeus and use Net::HTTP instead
70
- config.request_with :net_http
71
- end
72
-
73
- == Testing
74
-
75
- gem install jeweler
76
- rake spec
77
- rake features # if it complains of missing deps install them
78
-
79
- Some tests will fail due to missing api key. Set the EMBEDLY_KEY environmental
80
- variable with your key to get them to pass.
81
-
82
- EMBEDLY_KEY=xxxxxxxxxxxxx rake features
83
-
84
- To turn on debugging, set the EMBEDLY_VERBOSE environmental variable.
85
-
86
- EMBEDLY_VERBOSE=1 EMBEDLY_KEY=xxxxxxxxxxx rake features
87
-
88
- We have provided some commandline tools to test the Embedly interface.
89
-
90
- * embedly_oembed
91
- * embedly_objectify
92
- * embedly_preview
93
-
94
- Using --help with the commands should give you a good idea of how to use them.
95
-
96
- == Note on Patches/Pull Requests
97
-
98
- * Fork the project.
99
- * Make your feature addition or bug fix.
100
- * Add tests for it. This is important so I don't break it in a
101
- future version unintentionally.
102
- * Commit, do not mess with rakefile, version, or history.
103
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
104
- * Send me a pull request. Bonus points for topic branches.
105
-
106
- == Copyright
107
-
108
- Copyright (c) 2011 Embed.ly, Inc. See MIT-LICENSE for details.