oh-my-embed 1.0.0 → 1.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e9b3c0abc85a8a6452fe5b72c9ec7b09584cd6b
4
- data.tar.gz: 352afe1e30344a73c37a8e4158c98187cc48d271
3
+ metadata.gz: ebc9fdd71585f31eadeae70930224680ff2d7030
4
+ data.tar.gz: 1d3e73bc091acbcf845e4912ab3982d96d0b25b0
5
5
  SHA512:
6
- metadata.gz: f9b7bd55bb85ea38c46bce13e3e86759477b0dc753175aa7a9f2d3d434eac911d3b55157a5e2bdc10d325482dfd40080516bd334272badc761a2eeae9e85fb41
7
- data.tar.gz: 2966e93abe6f4ceba68a8f78922b792c2cb85324bcbc8e13a3be0066785f8746d7e78c85e093bfd0403ea5de77d6aded02c21eee1ad4624b84345095179ef337
6
+ metadata.gz: a2159a9328a5782f1723db6ab0537a07f96de5f659955bd4d4f2d0343180344557f72d8ecaf37eeceffdb567031cc4f960a2f3b21511c2e086658d9f5ae1fe1b
7
+ data.tar.gz: c2c999a481588d788947bdbb743837d654f2487e9a566f082efdd75e65352cc1a4d7304bf25f6c5a761cc02088d7d4be53f2bc9c45fd88590450c9700695a90c
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  OhMyEmbed
2
2
  =================
3
- VERSION BADGE
3
+ [![Gem Version](https://badge.fury.io/rb/oh-my-embed.svg)](https://badge.fury.io/rb/oh-my-embed)
4
4
  [![Build Status](https://travis-ci.org/dino115/oh-my-embed.svg?branch=master)](https://travis-ci.org/dino115/oh-my-embed)
5
5
  [![Code Climate](https://codeclimate.com/github/dino115/oh-my-embed/badges/gpa.svg)](https://codeclimate.com/github/dino115/oh-my-embed)
6
6
  [![Test Coverage](https://codeclimate.com/github/dino115/oh-my-embed/badges/coverage.svg)](https://codeclimate.com/github/dino115/oh-my-embed/coverage)
@@ -8,8 +8,6 @@ VERSION BADGE
8
8
 
9
9
  Simple gem to interact with oembed providers. Read specs at http://www.oembed.com
10
10
 
11
- ** WORK IN PROGRESS, not finshed yet **
12
-
13
11
  ## Installation
14
12
 
15
13
  Add this line to your application's Gemfile:
@@ -157,8 +155,6 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
157
155
 
158
156
  Bug reports and pull requests are welcome on GitHub at https://github.com/dino115/oh-my-embed. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
159
157
 
160
-
161
158
  ## License
162
159
 
163
160
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
164
-
data/lib/oh_my_embed.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'active_support/all'
2
2
 
3
3
  Dir.glob(File.join(__dir__, 'oh_my_embed', '*.rb'), &method(:require))
4
- Dir.glob(File.join(__dir__, 'oh_my_embed', '{providers}', '*.rb'), &method(:require))
4
+ Dir.glob(File.join(__dir__, 'oh_my_embed', 'providers', '*.rb'), &method(:require))
5
5
 
6
6
  module OhMyEmbed
7
7
  # All OhMyEmbed errors inherits from a generic OhMyEmbed::Error class
@@ -106,5 +106,14 @@ module OhMyEmbed
106
106
  height: attribute(mapping['embed.height']),
107
107
  }.compact
108
108
  end
109
+
110
+ # Return the Hash representation of this response
111
+ #
112
+ # @return [Hash] :type, :provider_name, :provider_url, :url, :author, :thumbnail, :embed
113
+ def to_h
114
+ %i{ type provider_name provider_url url title author thumbnail embed }.map do |key|
115
+ [key, self.send(key)]
116
+ end.to_h
117
+ end
109
118
  end
110
119
  end
@@ -1,3 +1,3 @@
1
1
  module OhMyEmbed
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'
3
3
  end
@@ -171,4 +171,36 @@ describe OhMyEmbed::Response do
171
171
  expect(response.embed[:url]).to eq 'http://www.example.com/my/content'
172
172
  end
173
173
  end
174
+
175
+ describe '#to_h' do
176
+ it 'returns a hash' do
177
+ expect(response.to_h).to be_a Hash
178
+ end
179
+
180
+ it 'includes the required fields' do
181
+ hash = response.to_h
182
+
183
+ expect(hash).to eq({
184
+ type: :rich,
185
+ provider_name: 'My awesome example provider',
186
+ provider_url: 'http://www.example.com',
187
+ url: 'http://www.example.com/my/content',
188
+ title: 'My content',
189
+ author: {
190
+ name: 'John Doe',
191
+ url: 'http://www.example.com/users/john.doe',
192
+ },
193
+ thumbnail: {
194
+ url: 'http://www.example.com/images/my-content.png',
195
+ width: 200,
196
+ height: 200,
197
+ },
198
+ embed: {
199
+ html: '<iframe src="http://www.example.com/embed/my-content" />',
200
+ width: 640,
201
+ height: 480,
202
+ },
203
+ })
204
+ end
205
+ end
174
206
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oh-my-embed
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Axel Wahlen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-08 00:00:00.000000000 Z
11
+ date: 2016-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport