anideo-embedly 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 1.9.2@embedly-ruby
@@ -0,0 +1,56 @@
1
+ *embedly-1.3.0 (12 Sep 2011)
2
+
3
+ 12 Sep 2011: Russ Bradberry, Bob Corsaro <bob@embed.ly>
4
+ Adds Typhoeus support
5
+
6
+ 12 Sep 2011: Russ Bradberry
7
+ Adds timeout support
8
+
9
+ *embedly-1.2.0 (12 Sep 2011)
10
+
11
+ 12 Sep 2011: Felipe Elias Philipp <j@felipeelias.info>
12
+ Adds Configuration class to make configuration Embedly simpler
13
+
14
+ *embedly-1.1.0 (7 Sep 2011)
15
+
16
+ 7 Sep 2011: Felipe Elias Philipp <j@felipeelias.info>
17
+ Improves CLI
18
+
19
+ 7 Sep 2011: Bob Corsaro <bob@embed.ly>
20
+ Support OAuth
21
+
22
+ 7 Sep 2011: Bob Corsaro <bob@embed.ly>
23
+ Update specs
24
+
25
+
26
+ *embedly-1.0.0 (22 Jun 2011)
27
+
28
+ 22 Jun 2011: Bob Corsaro <bob@embed.ly>
29
+ Support changes to API
30
+
31
+ 22 Jun 2011: Bob Corsaro <bob@embed.ly>
32
+ Adds header, host and no-key CLI args
33
+
34
+ 22 Jun 2011: Bob Corsaro <bob@embed.ly>
35
+ Better exception handling
36
+
37
+ *embedly-0.4.0 (20 May 2011)
38
+
39
+ 20 May 2011: Bob Corsaro <bob@embed.ly>
40
+ Support hostnames without tlds
41
+
42
+ 20 May 2011: Bob Corsaro <bob@embed.ly>
43
+ Bug fixes
44
+
45
+ *embedly-0.3.3 (20 Feb 2011)
46
+
47
+ 20 Feb 2011: Bob Corsaro <bob@embed.ly>
48
+ Fixes namespace issue
49
+
50
+ *embedly-0.3.0 (04 Feb 2011)
51
+
52
+ 04 Feb 2011: Bob Corsaro <bob@embed.ly>
53
+ Services methods always return an array, even for a single URL
54
+
55
+ 04 Feb 2011: Bob Corsaro <bob@embed.ly>
56
+ URLs are checked against the services regex for non-Pro calls
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source :rubygems
2
+
3
+ gem "querystring"
4
+ gem "oauth"
5
+ gem "typhoeus"
6
+
7
+ group :development do
8
+ gem "jeweler"
9
+ gem "cucumber"
10
+ gem "rake"
11
+ gem "rspec"
12
+ gem "yard"
13
+ gem "aruba"
14
+ end
15
+
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Embed.ly, Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,105 @@
1
+ = embedly
2
+
3
+ Embedly ruby client library. To find out what Embedly is all about, please
4
+ visit http://embed.ly. To see our api documentation, visit
5
+ http://api.embed.ly/docs.
6
+
7
+ == Installing
8
+
9
+ To install the official latest stable version, please use rubygems.
10
+
11
+ gem install embedly
12
+
13
+ If you would like cutting edge, then you can clone and install HEAD.
14
+
15
+ git clone git://github.com/embedly/embedly-ruby.git
16
+ cd embedly-ruby
17
+ rake install
18
+
19
+ == Requirements
20
+
21
+ * querystring <https://github/dokipen/querystring>
22
+
23
+ == Getting Started
24
+
25
+ You can find rdocs at http://rubydoc.info/github/embedly/embedly-ruby/master/frames
26
+
27
+ require 'embedly'
28
+ require 'json'
29
+
30
+ embedly_api = Embedly::API.new :user_agent => 'Mozilla/5.0 (compatible; mytestapp/1.0; my@email.com)'
31
+
32
+ # single url
33
+ obj = embedly_api.oembed :url => 'http://www.youtube.com/watch?v=sPbJ4Z5D-n4&feature=topvideos'
34
+ puts obj[0].marshal_dump
35
+ json_obj = JSON.pretty_generate(obj[0].marshal_dump)
36
+ puts json_obj
37
+
38
+ # multiple urls with opts
39
+ objs = embedly_api.oembed(
40
+ :urls => ['http://www.youtube.com/watch?v=sPbJ4Z5D-n4&feature=topvideos', 'http://twitpic.com/3yr7hk'],
41
+ :maxWidth => 450,
42
+ :wmode => 'transparent',
43
+ :method => 'after'
44
+ )
45
+ json_obj = JSON.pretty_generate(objs.collect{|o| o.marshal_dump})
46
+ puts json_obj
47
+
48
+ # call api with key (you'll need a real key)
49
+ embedly_api = Embedly::API.new :key => 'xxxxxxxxxxxxxxxxxxxxxxxxxx',
50
+ :user_agent => 'Mozilla/5.0 (compatible; mytestapp/1.0; my@email.com)'
51
+ url = 'http://www.guardian.co.uk/media/2011/jan/21/andy-coulson-phone-hacking-statement'
52
+ obj = embedly_api.preview :url => url
53
+ puts JSON.pretty_generate(obj[0].marshal_dump)
54
+
55
+ == Configuration options
56
+
57
+ You can configure some parameters in the api:
58
+
59
+ Embedly.configure do |config|
60
+ # prints debug messages to the logger
61
+ config.debug = true
62
+
63
+ # use a custom logger
64
+ config.logger = MyAwesomeLogger.new(STDERR)
65
+
66
+ # disable typhoeus and use Net::HTTP instead
67
+ config.typhoeus = false
68
+ end
69
+
70
+ == Testing
71
+
72
+ gem install jeweler
73
+ rake rspec
74
+ rake features # if it complains of missing deps install them
75
+
76
+ Some tests will fail due to missing api key. Set the EMBEDLY_KEY environmental
77
+ variable with your key to get them to pass.
78
+
79
+ EMBEDLY_KEY=xxxxxxxxxxxxx rake features
80
+
81
+ To turn on debugging, set the EMBEDLY_VERBOSE environmental variable.
82
+
83
+ EMBEDLY_VERBOSE=1 EMBEDLY_KEY=xxxxxxxxxxx rake features
84
+
85
+ We have provided some commandline tools to test the Embedly interface.
86
+
87
+ * embedly_oembed
88
+ * embedly_objectify
89
+ * embedly_preview
90
+
91
+ Using --help with the commands should give you a good idea of how to use them.
92
+
93
+ == Note on Patches/Pull Requests
94
+
95
+ * Fork the project.
96
+ * Make your feature addition or bug fix.
97
+ * Add tests for it. This is important so I don't break it in a
98
+ future version unintentionally.
99
+ * Commit, do not mess with rakefile, version, or history.
100
+ (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)
101
+ * Send me a pull request. Bonus points for topic branches.
102
+
103
+ == Copyright
104
+
105
+ Copyright (c) 2011 Embed.ly, Inc. See MIT-LICENSE for details.
@@ -0,0 +1,54 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+
4
+ begin
5
+ Bundler.setup(:default, :development)
6
+ rescue Bundler::BundlerError => e
7
+ $stderr.puts e.message
8
+ $stderr.puts "Run `bundle install` to install missing gems"
9
+ exit e.status_code
10
+ end
11
+
12
+ require 'rake'
13
+ require 'jeweler'
14
+
15
+ Jeweler::Tasks.new do |gem|
16
+ gem.name = "anideo-embedly"
17
+ gem.summary = %Q{Ruby Embedly client library}
18
+ gem.description = %Q{Ruby Embedly client library}
19
+ gem.email = "bob@embed.ly"
20
+ gem.homepage = "http://github.com/embedly/embedly-ruby"
21
+ gem.authors = ["Bob Corsaro"]
22
+ gem.license = "MIT"
23
+
24
+ # in Gemfile
25
+ end
26
+ Jeweler::GemcutterTasks.new
27
+
28
+ require 'cucumber/rake/task'
29
+ Cucumber::Rake::Task.new(:features)
30
+
31
+ require "rspec/core/rake_task"
32
+ RSpec::Core::RakeTask.new(:spec) do |t|
33
+ t.rspec_opts = %w[--color]
34
+ t.verbose = false
35
+ end
36
+
37
+ require 'yard'
38
+ YARD::Rake::YardocTask.new do |t|
39
+ t.files = FileList['lib/**/*.rb'].exclude('lib/jeweler/templates/**/*.rb')
40
+ end
41
+
42
+ require 'rake/rdoctask'
43
+ Rake::RDocTask.new do |rdoc|
44
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
45
+
46
+ rdoc.rdoc_dir = 'rdoc'
47
+ rdoc.title = "embedly #{version}"
48
+ rdoc.rdoc_files.include('README*')
49
+ rdoc.rdoc_files.include('lib/**/*.rb')
50
+ end
51
+
52
+ task :all_specs => [:spec, :features]
53
+
54
+ task :default => :all_specs
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.3.0
@@ -0,0 +1,91 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{anideo-embedly}
8
+ s.version = "1.3.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = [%q{Bob Corsaro}]
12
+ s.date = %q{2011-10-18}
13
+ s.description = %q{Ruby Embedly client library}
14
+ s.email = %q{bob@embed.ly}
15
+ s.executables = [%q{embedly_objectify}, %q{embedly_oembed}, %q{embedly_preview}]
16
+ s.extra_rdoc_files = [
17
+ "ChangeLog",
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ ".rvmrc",
22
+ "ChangeLog",
23
+ "Gemfile",
24
+ "MIT-LICENSE",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "anideo-embedly.gemspec",
29
+ "bin/embedly_objectify",
30
+ "bin/embedly_oembed",
31
+ "bin/embedly_preview",
32
+ "cucumber.yml",
33
+ "features/command_line.feature",
34
+ "features/objectify.feature",
35
+ "features/oembed.feature",
36
+ "features/steps/api_steps.rb",
37
+ "features/steps/env.rb",
38
+ "lib/embedly.rb",
39
+ "lib/embedly/api.rb",
40
+ "lib/embedly/command_line.rb",
41
+ "lib/embedly/configuration.rb",
42
+ "lib/embedly/exceptions.rb",
43
+ "lib/embedly/model.rb",
44
+ "spec/embedly/api_spec.rb",
45
+ "spec/embedly/command_line_spec.rb",
46
+ "spec/embedly/configuration_spec.rb",
47
+ "spec/spec_helper.rb"
48
+ ]
49
+ s.homepage = %q{http://github.com/embedly/embedly-ruby}
50
+ s.licenses = [%q{MIT}]
51
+ s.require_paths = [%q{lib}]
52
+ s.rubygems_version = %q{1.8.6}
53
+ s.summary = %q{Ruby Embedly client library}
54
+
55
+ if s.respond_to? :specification_version then
56
+ s.specification_version = 3
57
+
58
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
59
+ s.add_runtime_dependency(%q<querystring>, [">= 0"])
60
+ s.add_runtime_dependency(%q<oauth>, [">= 0"])
61
+ s.add_runtime_dependency(%q<typhoeus>, [">= 0"])
62
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
63
+ s.add_development_dependency(%q<cucumber>, [">= 0"])
64
+ s.add_development_dependency(%q<rake>, [">= 0"])
65
+ s.add_development_dependency(%q<rspec>, [">= 0"])
66
+ s.add_development_dependency(%q<yard>, [">= 0"])
67
+ s.add_development_dependency(%q<aruba>, [">= 0"])
68
+ else
69
+ s.add_dependency(%q<querystring>, [">= 0"])
70
+ s.add_dependency(%q<oauth>, [">= 0"])
71
+ s.add_dependency(%q<typhoeus>, [">= 0"])
72
+ s.add_dependency(%q<jeweler>, [">= 0"])
73
+ s.add_dependency(%q<cucumber>, [">= 0"])
74
+ s.add_dependency(%q<rake>, [">= 0"])
75
+ s.add_dependency(%q<rspec>, [">= 0"])
76
+ s.add_dependency(%q<yard>, [">= 0"])
77
+ s.add_dependency(%q<aruba>, [">= 0"])
78
+ end
79
+ else
80
+ s.add_dependency(%q<querystring>, [">= 0"])
81
+ s.add_dependency(%q<oauth>, [">= 0"])
82
+ s.add_dependency(%q<typhoeus>, [">= 0"])
83
+ s.add_dependency(%q<jeweler>, [">= 0"])
84
+ s.add_dependency(%q<cucumber>, [">= 0"])
85
+ s.add_dependency(%q<rake>, [">= 0"])
86
+ s.add_dependency(%q<rspec>, [">= 0"])
87
+ s.add_dependency(%q<yard>, [">= 0"])
88
+ s.add_dependency(%q<aruba>, [">= 0"])
89
+ end
90
+ end
91
+
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.expand_path('../../lib', __FILE__))
3
+ %w{embedly embedly/command_line json optparse ostruct}.each {|l| require l}
4
+
5
+ api = Embedly::CommandLine.run!(:objectify, ARGV)
6
+
7
+ begin
8
+ data = api.flatten.collect { |o| o.marshal_dump }
9
+ puts JSON.pretty_generate(data)
10
+ rescue Embedly::BadResponseException => e
11
+ puts "#{e.response.code} :: #{e.response.message}"
12
+ end
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.expand_path('../../lib', __FILE__))
3
+ %w{embedly embedly/command_line json optparse ostruct}.each {|l| require l}
4
+
5
+ api = Embedly::CommandLine.run!(:oembed, ARGV)
6
+
7
+ begin
8
+ data = api.flatten.collect { |o| o.marshal_dump }
9
+ puts JSON.pretty_generate(data)
10
+ rescue Embedly::BadResponseException => e
11
+ puts "#{e.response.code} :: #{e.response.message}"
12
+ end
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.expand_path('../../lib', __FILE__))
3
+ %w{embedly embedly/command_line json optparse ostruct}.each {|l| require l}
4
+
5
+ api = Embedly::CommandLine.run!(:preview, ARGV)
6
+
7
+ begin
8
+ data = api.flatten.collect { |o| o.marshal_dump }
9
+ puts JSON.pretty_generate(data)
10
+ rescue Embedly::BadResponseException => e
11
+ puts "#{e.response.code} :: #{e.response.message}"
12
+ end
@@ -0,0 +1 @@
1
+ default: features
@@ -0,0 +1,17 @@
1
+ Feature: Command line runner
2
+ As an embedly user
3
+ I want to call the the embedly api via command line
4
+
5
+ Scenario: Run oembed command
6
+ When I run `embedly_oembed http://lockerz.com/s/136425091`
7
+ Then the output should contain:
8
+ """
9
+ "provider_url": "http://lockerz.com"
10
+ """
11
+
12
+ Scenario: Run oembed command verbosely
13
+ When I run `embedly_oembed -v http://lockerz.com/s/136425091`
14
+ Then the output should contain:
15
+ """
16
+ DEBUG -- : calling http://api.embed.ly/1/oembed
17
+ """
@@ -0,0 +1,15 @@
1
+ Feature: Objectify
2
+
3
+ As an embedly user
4
+ I want to call the the embedly api
5
+ Because I want to objectify a url
6
+
7
+ Scenario Outline: Get the meta description with pro
8
+ Given an embedly api with key
9
+ When objectify is called with the <url> URL
10
+ Then the meta.description should start with <metadesc>
11
+ And objectify api_version is 2
12
+
13
+ Examples:
14
+ | url | metadesc |
15
+ | http://lockerz.com/s/136425091 | Quentin Richardson's Photo on Lockerz.com |
@@ -0,0 +1,80 @@
1
+ Feature: OEmbed
2
+
3
+ As an embedly user
4
+ I want to call the the embedly api
5
+ Because I want and oembed for a specific url
6
+
7
+ Scenario Outline: Get the provider_url
8
+ Given an embedly api with key
9
+ When oembed is called with the <url> URL
10
+ Then the provider_url should be <provider_url>
11
+
12
+ Examples:
13
+ | url | provider_url |
14
+ | http://www.scribd.com/doc/13994900/Easter | http://www.scribd.com/ |
15
+ | http://www.scribd.com/doc/28452730/Easter-Cards | http://www.scribd.com/ |
16
+ | http://www.youtube.com/watch?v=Zk7dDekYej0 | http://www.youtube.com/ |
17
+ | http://yfrog.com/h7qqespj | http://yfrog.com |
18
+ | http://blog.embed.ly/bob | http://posterous.com |
19
+ | http://blog.doki-pen.org/cassandra-rules | http://posterous.com |
20
+ | http://www.guardian.co.uk/media/2011/jan/21/andy-coulson-phone-hacking-statement | http://www.guardian.co.uk/ |
21
+
22
+
23
+ Scenario Outline: Get the types
24
+ Given an embedly api with key
25
+ When oembed is called with the <url> URL
26
+ Then the type should be <type>
27
+
28
+ Examples:
29
+ | url | type |
30
+ | http://www.scribd.com/doc/13994900/Easter | rich |
31
+ | http://www.scribd.com/doc/28452730/Easter-Cards | rich |
32
+ | http://www.youtube.com/watch?v=Zk7dDekYej0 | video |
33
+ | http://yfrog.com/h7qqespj | photo |
34
+
35
+
36
+ Scenario Outline: Get the provider_url with force flag
37
+ Given an embedly api with key
38
+ When oembed is called with the <url> URL and force flag
39
+ Then the provider_url should be <provider_url>
40
+
41
+ Examples:
42
+ | url | provider_url |
43
+ | http://www.youtube.com/watch?v=Zk7dDekYej0 | http://www.youtube.com/ |
44
+
45
+
46
+ Scenario Outline: Get multiple provider_urls
47
+ Given an embedly api with key
48
+ When oembed is called with the <urls> URLs
49
+ Then provider_url should be <provider_urls>
50
+
51
+ Examples:
52
+ | urls | provider_urls |
53
+ | http://www.scribd.com/doc/13994900/Easter,http://www.scribd.com/doc/28452730/Easter-Cards | http://www.scribd.com/,http://www.scribd.com/ |
54
+ | http://www.youtube.com/watch?v=Zk7dDekYej0,http://yfrog.com/h7qqespj | http://www.youtube.com/,http://yfrog.com |
55
+
56
+
57
+ Scenario Outline: Attempt to get 404 URL
58
+ Given an embedly api with key
59
+ When oembed is called with the <url> URL
60
+ Then type should be error
61
+ And error_code should be 404
62
+ And type should be error
63
+
64
+ Examples:
65
+ | url |
66
+ | http://www.youtube.com/watch/is/a/bad/url |
67
+ | http://fav.me/alsfsdf |
68
+
69
+
70
+ Scenario Outline: Attempt multi get 404 URLs
71
+ Given an embedly api with key
72
+ When oembed is called with the <urls> URLs
73
+ Then error_code should be <errcode>
74
+ And type should be <types>
75
+
76
+ Examples:
77
+ | urls | errcode | types |
78
+ | http://www.youtube.com/watch/a/bassd/url,http://www.youtube.com/watch/ldf/asdlfj | 404,404 | error,error |
79
+ | 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 |