iframely 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 91587997c33a71850459d7c564055faa00320ec7
4
+ data.tar.gz: c8bc80f9a894d87612160adff95ba36b514e27e8
5
+ SHA512:
6
+ metadata.gz: e20e699477de580cd8dc67c5341889920bf1519318d81dac8e7e15a19b0ae543993754d43f0be1a22213b5beb42e9f0a693b140e9bac29465fa49ba0bbced4e2
7
+ data.tar.gz: bf65427d99ac61c66163afb5db3aad7fa261f66ad559af83e845e7c0720265f6725731a7b74470a2e731b95c3dbde01f2e30964829afeb821daeaed5fc902f79
@@ -0,0 +1,54 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /lib/bundler/man/
26
+
27
+ # for a library or gem, you might want to ignore these files since the code is
28
+ # intended to run in multiple environments; otherwise, check them in:
29
+ # Gemfile.lock
30
+ # .ruby-version
31
+ # .ruby-gemset
32
+
33
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
34
+ .rvmrc
35
+ .bundle
36
+ .config
37
+ .yardoc
38
+ Gemfile.lock
39
+ InstalledFiles
40
+ _yardoc
41
+ coverage
42
+ doc/
43
+ lib/bundler/man
44
+ pkg
45
+ rdoc
46
+ spec/reports
47
+ test/tmp
48
+ test/version_tmp
49
+ tmp
50
+ *.bundle
51
+ *.so
52
+ *.o
53
+ *.a
54
+ mkmf.log
@@ -0,0 +1 @@
1
+ 2.1.2
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in iframely.gemspec
4
+ gemspec
5
+
6
+ gem 'faraday'
7
+ gem 'hashie'
8
+
9
+ #group :development do
10
+ #gem 'minitest'
11
+ #gem 'webmock'
12
+ #end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Danil Pismenny
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,43 @@
1
+ # iframe.ly ruby client
2
+ [![Build Status](https://travis-ci.org/BrandyMint/iframely.svg?branch=master)](https://travis-ci.org/BrandyMint/iframely)
3
+ [![Dependency Status](https://gemnasium.com/BrandyMint/iframely.svg)](https://gemnasium.com/BrandyMint/iframely) [![Code Climate](https://codeclimate.com/github/BrandyMint/iframely.png)](https://codeclimate.com/github/BrandyMint/iframely)
4
+
5
+
6
+ Get http://iframe.ly in Ruby world!
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ gem 'iframely'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install iframely
21
+
22
+ ## Usage
23
+
24
+
25
+ iframely = Iframely::Requester.new api_key: 'you_api_key'
26
+
27
+ iframely.get_json 'http://www.youtube.com/watch?v=wVVjOd_Ooys'
28
+ # returns iframely json
29
+
30
+ iframely.get_iframely 'http://www.youtube.com/watch?v=wVVjOd_Ooys'
31
+ # returns Iframely::Model from iframely json
32
+
33
+ iframely.get_oembed 'http://www.youtube.com/watch?v=wVVjOd_Ooys'
34
+ # returns oembed json
35
+
36
+
37
+ ## Contributing
38
+
39
+ 1. Fork it ( https://github.com/[my-github-username]/iframely/fork )
40
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
41
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
42
+ 4. Push to the branch (`git push origin my-new-feature`)
43
+ 5. Create a new Pull Request
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.pattern = "test/*_test.rb"
6
+ end
7
+
8
+ task default: :test
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'iframely/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "iframely"
8
+ spec.version = Iframely::VERSION
9
+ spec.authors = ["Danil Pismenny"]
10
+ spec.email = ["danil@brandymint.ru"]
11
+ spec.summary = %q{iframe.ly ruby client}
12
+ #spec.description = %q{TODO: Write a longer description. Optional.}
13
+ spec.homepage = "http://iframe.ly"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'hashie'
22
+ spec.add_dependency 'faraday'
23
+
24
+ spec.add_development_dependency "minitest"
25
+ spec.add_development_dependency "webmock"
26
+ spec.add_development_dependency "bundler", "~> 1.6"
27
+ spec.add_development_dependency "rake"
28
+ end
@@ -0,0 +1,10 @@
1
+ require "iframely/version"
2
+
3
+ module Iframely
4
+ IFRAMELY_API_URL = 'http://iframe.ly/api/iframely'
5
+ OEMBED_API_URL = 'http://iframe.ly/api/oembed'
6
+ end
7
+
8
+ require 'iframely/requester'
9
+ require 'iframely/model'
10
+ require 'iframely/error'
@@ -0,0 +1,2 @@
1
+ class Iframely::Error < StandardError; end
2
+
@@ -0,0 +1,13 @@
1
+ require 'hashie'
2
+
3
+ module Iframely
4
+ class Model < Hashie::Dash
5
+ property :id, required: true
6
+ property :url, required: true
7
+
8
+ property :meta
9
+ property :links
10
+
11
+ property :html, required: true
12
+ end
13
+ end
@@ -0,0 +1,61 @@
1
+ require 'iframely'
2
+ require 'json'
3
+
4
+ module Iframely
5
+ class Requester
6
+ def initialize api_key: nil, iframely_url: IFRAMELY_API_URL, oembed_url: OEMBED_API_URL
7
+ @iframely_url = iframely_url or raise "No iframely_url specified"
8
+ @oembed_url = oembed_url or raise "No oembed_url specified"
9
+ @api_key = api_key or raise "No api_key specified"
10
+ end
11
+
12
+ def get_json embed_url
13
+ response = iframely_connection.get do |req|
14
+ req.params['api_key'] = api_key
15
+ req.params['url'] = embed_url
16
+ end
17
+
18
+ return JSON.parse response.body
19
+ end
20
+
21
+ def get_iframely embed_url
22
+ json = get_json embed_url
23
+ if json.has_key? 'error'
24
+ raise Iframely::Error, json['error']
25
+ else
26
+ Iframely::Model.new json
27
+ end
28
+ end
29
+
30
+ def get_oembed embed_url
31
+ response = oembed_connection.get do |req|
32
+ req.params['api_key'] = api_key
33
+ req.params['url'] = embed_url
34
+ end
35
+
36
+ return JSON.parse response.body
37
+ end
38
+
39
+ private
40
+
41
+ attr_reader :iframely_url, :oembed_url, :api_key
42
+
43
+ def oembed_connection
44
+ @oembed_connection ||= Faraday.new(:url => oembed_url) do |faraday|
45
+ faraday.request :url_encoded # form-encode POST params
46
+ #faraday.response :logger # log requests to STDOUT
47
+ faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
48
+ end
49
+ end
50
+
51
+ def iframely_connection
52
+ @iframely_connection ||= Faraday.new(:url => iframely_url) do |faraday|
53
+ faraday.request :url_encoded # form-encode POST params
54
+ #faraday.response :logger # log requests to STDOUT
55
+ faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
56
+ end
57
+ end
58
+
59
+ end
60
+ end
61
+
@@ -0,0 +1,3 @@
1
+ module Iframely
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,25 @@
1
+ require './test/test_helper'
2
+
3
+ class IframelyRequesterTers < Minitest::Test
4
+ API_KEY = 'some_key'
5
+ EMBED_URL = 'some_url'
6
+
7
+ def setup
8
+ @iframely = Iframely::Requester.new api_key: API_KEY
9
+ end
10
+
11
+ def test_request_json
12
+ stub_request(:get, Iframely::IFRAMELY_API_URL + "?api_key=some_key&url=some_url").
13
+ to_return(:status => 200, :body => "{}")
14
+
15
+ @iframely.get_json EMBED_URL
16
+ end
17
+
18
+ def test_request_oembed
19
+ stub_request(:get, Iframely::OEMBED_API_URL + "?api_key=some_key&url=some_url").
20
+ to_return(:status => 200, :body => "{}")
21
+
22
+ @iframely.get_oembed EMBED_URL
23
+ end
24
+
25
+ end
@@ -0,0 +1,11 @@
1
+
2
+ Bundler.require :default
3
+
4
+ Hashie::Dash
5
+
6
+ require 'minitest'
7
+ require "minitest/autorun"
8
+ require 'webmock/minitest'
9
+
10
+ require './lib/iframely'
11
+
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: iframely
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Danil Pismenny
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: hashie
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: webmock
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.6'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.6'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description:
98
+ email:
99
+ - danil@brandymint.ru
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".ruby-version"
106
+ - ".travis.yml"
107
+ - Gemfile
108
+ - LICENSE.txt
109
+ - README.md
110
+ - Rakefile
111
+ - iframely.gemspec
112
+ - lib/iframely.rb
113
+ - lib/iframely/error.rb
114
+ - lib/iframely/model.rb
115
+ - lib/iframely/requester.rb
116
+ - lib/iframely/version.rb
117
+ - test/iframely_requester_test.rb
118
+ - test/test_helper.rb
119
+ homepage: http://iframe.ly
120
+ licenses:
121
+ - MIT
122
+ metadata: {}
123
+ post_install_message:
124
+ rdoc_options: []
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubyforge_project:
139
+ rubygems_version: 2.2.2
140
+ signing_key:
141
+ specification_version: 4
142
+ summary: iframe.ly ruby client
143
+ test_files:
144
+ - test/iframely_requester_test.rb
145
+ - test/test_helper.rb