embedit_gem 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README.rdoc +29 -0
- data/Rakefile +50 -0
- data/VERSION +1 -0
- data/embedit_gem.gemspec +56 -0
- data/lib/embedit_gem.rb +42 -0
- data/spec/embedit_gem_spec.rb +47 -0
- data/spec/spec_helper.rb +9 -0
- metadata +85 -0
data/.document
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 reddavis
|
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.
|
data/README.rdoc
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
= Embedit Gem
|
2
|
+
|
3
|
+
This is a wrapper that interacts with http://embedit.me
|
4
|
+
|
5
|
+
== Installation
|
6
|
+
|
7
|
+
gem sources -a http://gemcutter.org
|
8
|
+
gem install embedit_gem
|
9
|
+
|
10
|
+
== Example
|
11
|
+
|
12
|
+
require 'rubygems'
|
13
|
+
require 'embedit_gem'
|
14
|
+
|
15
|
+
request = EmbeditGem.new('http://www.youtube.com/watch?v=qRuNxHqwazs')
|
16
|
+
request.title
|
17
|
+
#=> "Some title"
|
18
|
+
request.html
|
19
|
+
#=> "Some html"
|
20
|
+
request.fbml
|
21
|
+
#=> "Some fbml"
|
22
|
+
request.valid?
|
23
|
+
#=> true
|
24
|
+
request.format
|
25
|
+
#=> "video"
|
26
|
+
|
27
|
+
== Copyright
|
28
|
+
|
29
|
+
Copyright (c) 2009 reddavis. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "embedit_gem"
|
8
|
+
gem.summary = %Q{Wrapper for http://embedit.me}
|
9
|
+
gem.description = %Q{Wrapper for http://embedit.me}
|
10
|
+
gem.email = "reddavis@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/reddavis/embedit_gem"
|
12
|
+
gem.authors = ["reddavis"]
|
13
|
+
gem.add_development_dependency "rspec"
|
14
|
+
gem.add_dependency "httparty"
|
15
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
|
+
end
|
17
|
+
Jeweler::GemcutterTasks.new
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'spec/rake/spectask'
|
23
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
24
|
+
spec.libs << 'lib' << 'spec'
|
25
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
26
|
+
end
|
27
|
+
|
28
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
29
|
+
spec.libs << 'lib' << 'spec'
|
30
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
31
|
+
spec.rcov = true
|
32
|
+
end
|
33
|
+
|
34
|
+
task :spec => :check_dependencies
|
35
|
+
|
36
|
+
task :default => :spec
|
37
|
+
|
38
|
+
require 'rake/rdoctask'
|
39
|
+
Rake::RDocTask.new do |rdoc|
|
40
|
+
if File.exist?('VERSION')
|
41
|
+
version = File.read('VERSION')
|
42
|
+
else
|
43
|
+
version = ""
|
44
|
+
end
|
45
|
+
|
46
|
+
rdoc.rdoc_dir = 'rdoc'
|
47
|
+
rdoc.title = "embedit_gem #{version}"
|
48
|
+
rdoc.rdoc_files.include('README*')
|
49
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
50
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/embedit_gem.gemspec
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
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{embedit_gem}
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["reddavis"]
|
12
|
+
s.date = %q{2009-10-28}
|
13
|
+
s.description = %q{Wrapper for http://embedit.me}
|
14
|
+
s.email = %q{reddavis@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"embedit_gem.gemspec",
|
27
|
+
"lib/embedit_gem.rb",
|
28
|
+
"spec/embedit_gem_spec.rb",
|
29
|
+
"spec/spec_helper.rb"
|
30
|
+
]
|
31
|
+
s.homepage = %q{http://github.com/reddavis/embedit_gem}
|
32
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
33
|
+
s.require_paths = ["lib"]
|
34
|
+
s.rubygems_version = %q{1.3.5}
|
35
|
+
s.summary = %q{Wrapper for http://embedit.me}
|
36
|
+
s.test_files = [
|
37
|
+
"spec/embedit_gem_spec.rb",
|
38
|
+
"spec/spec_helper.rb"
|
39
|
+
]
|
40
|
+
|
41
|
+
if s.respond_to? :specification_version then
|
42
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
43
|
+
s.specification_version = 3
|
44
|
+
|
45
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
46
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
47
|
+
s.add_runtime_dependency(%q<httparty>, [">= 0"])
|
48
|
+
else
|
49
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
50
|
+
s.add_dependency(%q<httparty>, [">= 0"])
|
51
|
+
end
|
52
|
+
else
|
53
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
54
|
+
s.add_dependency(%q<httparty>, [">= 0"])
|
55
|
+
end
|
56
|
+
end
|
data/lib/embedit_gem.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'httparty'
|
3
|
+
|
4
|
+
class EmbeditGem
|
5
|
+
include HTTParty
|
6
|
+
base_uri 'http://embedit.me/embedit'
|
7
|
+
headers 'Content-Type' => 'application/json'
|
8
|
+
|
9
|
+
def initialize(url, options={})
|
10
|
+
api_key, frog_key = options[:api_key], options[:frog_key]
|
11
|
+
height, width = options[:height], options[:width]
|
12
|
+
@data = EmbeditGem.get("/", :query => {
|
13
|
+
:url => url,
|
14
|
+
:height => height,
|
15
|
+
:width => width,
|
16
|
+
:api_key => api_key,
|
17
|
+
:frog_key => frog_key
|
18
|
+
}
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
def html
|
23
|
+
@data['html']
|
24
|
+
end
|
25
|
+
|
26
|
+
def title
|
27
|
+
@data['title']
|
28
|
+
end
|
29
|
+
|
30
|
+
def valid?
|
31
|
+
@data['valid'] == 'true' ? true : false
|
32
|
+
end
|
33
|
+
|
34
|
+
def format
|
35
|
+
@data['format']
|
36
|
+
end
|
37
|
+
|
38
|
+
def fbml
|
39
|
+
@data['fbml']
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "EmbeditGem" do
|
4
|
+
|
5
|
+
describe "Good Params" do
|
6
|
+
before(:all) do
|
7
|
+
mock_request
|
8
|
+
@request = EmbeditGem.new('http://www.youtube.com/watch?v=qRuNxHqwazs')
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should set title" do
|
12
|
+
@request.title.should_not be_blank
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should set format" do
|
16
|
+
@request.format.should_not be_blank
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should set valid to true" do
|
20
|
+
@request.valid?.should be_true
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should set fbml" do
|
24
|
+
@request.fbml.should_not be_blank
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "Bad Params" do
|
29
|
+
before(:all) do
|
30
|
+
mock_request('valid' => 'false')
|
31
|
+
@request = EmbeditGem.new('http://www.youtube.com/watch?v=qRuNxHqwazs')
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should set valid to true" do
|
35
|
+
@request.valid?.should be_false
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def mock_request(options={})
|
43
|
+
json = {'title' => 'title', 'format' => 'format', 'html' => 'html',
|
44
|
+
'valid' => 'true', 'fbml' => 'fbml'}.merge(options)
|
45
|
+
EmbeditGem.stub!(:get).and_return(json)
|
46
|
+
end
|
47
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: embedit_gem
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- reddavis
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-10-28 00:00:00 +00:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: httparty
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
description: Wrapper for http://embedit.me
|
36
|
+
email: reddavis@gmail.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- LICENSE
|
43
|
+
- README.rdoc
|
44
|
+
files:
|
45
|
+
- .document
|
46
|
+
- .gitignore
|
47
|
+
- LICENSE
|
48
|
+
- README.rdoc
|
49
|
+
- Rakefile
|
50
|
+
- VERSION
|
51
|
+
- embedit_gem.gemspec
|
52
|
+
- lib/embedit_gem.rb
|
53
|
+
- spec/embedit_gem_spec.rb
|
54
|
+
- spec/spec_helper.rb
|
55
|
+
has_rdoc: true
|
56
|
+
homepage: http://github.com/reddavis/embedit_gem
|
57
|
+
licenses: []
|
58
|
+
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options:
|
61
|
+
- --charset=UTF-8
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
69
|
+
version:
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: "0"
|
75
|
+
version:
|
76
|
+
requirements: []
|
77
|
+
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 1.3.5
|
80
|
+
signing_key:
|
81
|
+
specification_version: 3
|
82
|
+
summary: Wrapper for http://embedit.me
|
83
|
+
test_files:
|
84
|
+
- spec/embedit_gem_spec.rb
|
85
|
+
- spec/spec_helper.rb
|