embedly 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,7 +18,7 @@ If you would like cutting edge, then you can clone and install HEAD.
18
18
 
19
19
  == Getting Started
20
20
 
21
- You can find rdocs at http://embedly.github.com/embedly-ruby.
21
+ You can find rdocs at http://rubydoc.info/github/embedly/embedly-ruby/master/frames
22
22
 
23
23
  require 'embedly'
24
24
  require 'json'
@@ -38,7 +38,6 @@ You can find rdocs at http://embedly.github.com/embedly-ruby.
38
38
  :wmode => 'transparent',
39
39
  :method => 'after'
40
40
  )
41
- puts obj.marshal_dump
42
41
  json_obj = JSON.pretty_generate(objs.collect{|o| o.marshal_dump})
43
42
  puts json_obj
44
43
 
data/Rakefile CHANGED
@@ -13,10 +13,9 @@ begin
13
13
  gem.add_development_dependency "cucumber", ">= 0"
14
14
  gem.add_development_dependency "jeweler", ">= 0"
15
15
  gem.add_development_dependency "rspec", ">= 0"
16
- gem.add_development_dependency "grancher", ">= 0"
17
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
18
16
  end
19
17
  Jeweler::GemcutterTasks.new
18
+
20
19
  rescue LoadError
21
20
  puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
22
21
  end
@@ -31,22 +30,19 @@ rescue LoadError
31
30
  end
32
31
 
33
32
  begin
34
- require 'grancher/task'
35
- Grancher::Task.new do |g|
36
- g.branch = 'gh-pages'
37
- g.push_to = 'origin'
38
- g.message = 'Updated website'
39
- g.directory 'rdoc'
33
+ require 'yard'
34
+ YARD::Rake::YardocTask.new do |t|
35
+ t.files = FileList['lib/**/*.rb'].exclude('lib/jeweler/templates/**/*.rb')
40
36
  end
41
37
  rescue LoadError
42
- task :publish do
43
- abort "Grancher is not installed"
38
+ task :yard do
39
+ abort "Yard is not installed"
44
40
  end
45
41
  end
46
42
 
47
43
  task :features => :check_dependencies
48
44
 
49
- task :default => :test
45
+ task :default => :features
50
46
 
51
47
  require 'rake/rdoctask'
52
48
  Rake::RDocTask.new do |rdoc|
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -0,0 +1,14 @@
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
8
+ Given an embedly endpoint
9
+ When objectify is called with the <url> URL
10
+ Then the meta.description should start with <metadesc>
11
+
12
+ Examples:
13
+ | url | metadesc |
14
+ | http://tweetphoto.com/14784358 | Plixi allows user to ins |
@@ -17,6 +17,19 @@ Feature: OEmbed
17
17
  | http://tweetphoto.com/14784358 | http://plixi.com |
18
18
 
19
19
 
20
+ Scenario Outline: Get the types
21
+ Given an embedly endpoint
22
+ When oembed is called with the <url> URL
23
+ Then the type should be <type>
24
+
25
+ Examples:
26
+ | url | type |
27
+ | http://www.scribd.com/doc/13994900/Easter | rich |
28
+ | http://www.scribd.com/doc/28452730/Easter-Cards | rich |
29
+ | http://www.youtube.com/watch?v=Zk7dDekYej0 | video |
30
+ | http://tweetphoto.com/14784358 | photo |
31
+
32
+
20
33
  Scenario Outline: Get the provider_url with force flag
21
34
  Given an embedly endpoint
22
35
  When oembed is called with the <url> URL and force flag
@@ -36,3 +36,10 @@ Then /([^\s]+) should be ([^\s]+)/ do |key, value|
36
36
  end
37
37
  end
38
38
 
39
+ Then /([^\s]+) should start with ([^\s]+)/ do |key, value|
40
+ logger = Embedly.logger('api_steps')
41
+ logger.debug { "result: #{@result.marshal_dump}"}
42
+ v = key.split('.').inject(@result){|o,c| o.send(c)}.to_s
43
+ v.to_s.should match(/^#{value}/)
44
+ end
45
+
@@ -1,6 +1,9 @@
1
1
  require 'net/http'
2
2
  require 'json'
3
3
  require 'ostruct'
4
+ require 'embedly/model'
5
+
6
+ include ::Embedly
4
7
 
5
8
  # Performs api calls to embedly.
6
9
  #
@@ -98,9 +101,9 @@ class Embedly::API
98
101
  if response.code.to_i == 200
99
102
  logger.debug { response.body }
100
103
  # [].flatten is to be sure we have an array
101
- objs = [JSON.parse(response.body)].flatten.collect {|o| OpenStruct.new(o)}
104
+ objs = [JSON.parse(response.body)].flatten.collect {|o| EmbedlyObject.new(o)}
102
105
  else
103
- objs = OpenStruct.new :type => 'error', :error_code => response.code.to_i
106
+ objs = EmbedlyObject.new :type => 'error', :error_code => response.code.to_i
104
107
  end
105
108
 
106
109
  if objs.size == 1
@@ -0,0 +1,32 @@
1
+ require 'ostruct'
2
+
3
+ class Embedly::EmbedlyObject < OpenStruct
4
+
5
+ # Resursively make ostruct
6
+ def initialize obj
7
+ o = obj.clone
8
+ o.each do |k,v|
9
+ if v.is_a?Hash
10
+ o[k] = Embedly::EmbedlyObject.new v
11
+ end
12
+ end
13
+ super o
14
+ end
15
+
16
+ # for ruby 1.8.x, type should return @table[:type], not the
17
+ # class.
18
+ def type
19
+ method_missing :type
20
+ end
21
+
22
+ def marshal_dump
23
+ o = @table.clone
24
+ o.each do |k,v|
25
+ if v.is_a?EmbedlyObject
26
+ o[k] = v.marshal_dump
27
+ end
28
+ end
29
+ return o
30
+ end
31
+
32
+ end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
7
+ - 2
8
8
  - 0
9
- version: 0.1.0
9
+ version: 0.2.0
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-01-21 00:00:00 -05:00
17
+ date: 2011-01-26 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -56,19 +56,6 @@ dependencies:
56
56
  version: "0"
57
57
  type: :development
58
58
  version_requirements: *id003
59
- - !ruby/object:Gem::Dependency
60
- name: grancher
61
- prerelease: false
62
- requirement: &id004 !ruby/object:Gem::Requirement
63
- none: false
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- segments:
68
- - 0
69
- version: "0"
70
- type: :development
71
- version_requirements: *id004
72
59
  description: Ruby Embedly client library
73
60
  email: bob@embed.ly
74
61
  executables:
@@ -89,11 +76,13 @@ files:
89
76
  - bin/embedly_oembed
90
77
  - bin/embedly_preview
91
78
  - cucumber.yml
79
+ - features/objectify.feature
92
80
  - features/oembed.feature
93
81
  - features/steps/api_steps.rb
94
82
  - features/steps/env.rb
95
83
  - lib/embedly.rb
96
84
  - lib/embedly/api.rb
85
+ - lib/embedly/model.rb
97
86
  has_rdoc: true
98
87
  homepage: http://github.com/embedly/embedly-ruby
99
88
  licenses: []