slideshare_api 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3dfc38449a88509d40a09ba46e053bd1b257c743
4
+ data.tar.gz: 3e104b627fdc62fd994d7f4fd03695b15462918a
5
+ SHA512:
6
+ metadata.gz: ef3f6868c4ecf3b9361688f1159ec0b562637cafbfee98605b1f0801e917b0c341f75550dc8918302072b6f6dd06f9f6dbdc88765bb24de48c9eb96d0a7d070e
7
+ data.tar.gz: 443fe4c6cc43de6ae5c720dbea4812a939751f727d34d779756a945914edc59846266e8a1391d886f19662bdd130497fa2111fdfcc295981c1554a0b901d1367
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ .idea
@@ -0,0 +1,33 @@
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0" is_locked="false">
3
+ <option name="myName" value="Project Default" />
4
+ <option name="myLocal" value="false" />
5
+ <inspection_tool class="RubyClassMethodNamingConvention" enabled="true" level="WARNING" enabled_by_default="true">
6
+ <option name="m_maxLength" value="90" />
7
+ </inspection_tool>
8
+ <inspection_tool class="RubyClassModuleNamingConvention" enabled="true" level="WARNING" enabled_by_default="true">
9
+ <option name="m_maxLength" value="90" />
10
+ </inspection_tool>
11
+ <inspection_tool class="RubyClassVariableNamingConvention" enabled="true" level="WARNING" enabled_by_default="true">
12
+ <option name="m_maxLength" value="90" />
13
+ </inspection_tool>
14
+ <inspection_tool class="RubyConstantNamingConvention" enabled="true" level="WARNING" enabled_by_default="true">
15
+ <option name="m_maxLength" value="90" />
16
+ </inspection_tool>
17
+ <inspection_tool class="RubyGlobalVariableNamingConvention" enabled="true" level="WARNING" enabled_by_default="true">
18
+ <option name="m_maxLength" value="90" />
19
+ </inspection_tool>
20
+ <inspection_tool class="RubyInstanceMethodNamingConvention" enabled="true" level="WARNING" enabled_by_default="true">
21
+ <option name="m_maxLength" value="90" />
22
+ </inspection_tool>
23
+ <inspection_tool class="RubyInstanceVariableNamingConvention" enabled="true" level="WARNING" enabled_by_default="true">
24
+ <option name="m_maxLength" value="90" />
25
+ </inspection_tool>
26
+ <inspection_tool class="RubyLocalVariableNamingConvention" enabled="true" level="WARNING" enabled_by_default="true">
27
+ <option name="m_maxLength" value="90" />
28
+ </inspection_tool>
29
+ <inspection_tool class="RubyParameterNamingConvention" enabled="true" level="WARNING" enabled_by_default="true">
30
+ <option name="m_maxLength" value="90" />
31
+ </inspection_tool>
32
+ </profile>
33
+ </component>
@@ -0,0 +1,7 @@
1
+ <component name="InspectionProjectProfileManager">
2
+ <settings>
3
+ <option name="PROJECT_PROFILE" value="Project Default" />
4
+ <option name="USE_PROJECT_PROFILE" value="true" />
5
+ <version value="1.0" />
6
+ </settings>
7
+ </component>
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in slideshare_api.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Jeremy Venezia
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.
data/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # SlideshareApi
2
+ [![Build](https://travis-ci.org/jvenezia/slideshare_api.svg?branch=master)](https://travis-ci.org/jvenezia/slideshare_api)
3
+
4
+ Slideshare ruby wrapper for the Slideshare API.
5
+
6
+ **Warning**: SlideshareApi is currently under heavy development.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'slideshare_api'
14
+ ```
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install slideshare_api
19
+
20
+ ## Usage
21
+
22
+ Get your **API Key** and **Shared Secret** from Slideshare [here](http://fr.slideshare.net/developers/applyforapi).
23
+
24
+ ```ruby
25
+ api_key = 'your api key'
26
+ shared_secret = 'shared secret'
27
+
28
+ client = SlideshareApi::Client.new api_key, shared_secret
29
+ ```
30
+
31
+ Get a slideshow:
32
+ ```ruby
33
+ slideshow_url = 'http://fr.slideshare.net/awesome_slideshow'
34
+ slideshow = client.slideshow(slideshow_url) #=> returns a SlideshareApi::Model::Slideshow
35
+ slideshow.id
36
+ slideshow.title
37
+ slideshow.description
38
+ slideshow.username
39
+ slideshow.url
40
+ slideshow.embed
41
+ slideshow.language
42
+ ```
43
+
44
+ ## Contributing
45
+ Feel free to contribute!
46
+
47
+ 1. Fork it ( https://github.com/jvenezia/slideshare_api/fork )
48
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
49
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
50
+ 4. Push to the branch (`git push origin my-new-feature`)
51
+ 5. Create a new Pull Request
52
+
53
+ ## License
54
+ Released under the MIT License, which can be found in `LICENSE.txt`.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'rspec/core/rake_task'
2
+ require 'bundler/gem_tasks'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1 @@
1
+ Gem.find_files('slideshare_api/**/*.rb').each { |file| require file }
@@ -0,0 +1,37 @@
1
+ require 'faraday'
2
+ require 'faraday_middleware'
3
+ require 'digest/sha1'
4
+ require 'nokogiri'
5
+
6
+ module SlideshareApi
7
+ class Client
8
+ SLIDESHARE_API_URL = 'https://www.slideshare.net/api/2'
9
+
10
+ attr_accessor :connection, :api_key, :shared_secret
11
+
12
+ def initialize(api_key, shared_secret)
13
+ @api_key = api_key
14
+ @shared_secret = shared_secret
15
+ build_connection
16
+ end
17
+
18
+ def slideshow(slideshow_url)
19
+ SlideshareApi::Model::Slideshow.new Nokogiri::XML(@connection.get('get_slideshow', api_validation_params.merge({slideshow_url: slideshow_url})).body)
20
+ end
21
+
22
+ private
23
+
24
+ def build_connection
25
+ @connection = Faraday.new(url: SLIDESHARE_API_URL) do |faraday|
26
+ faraday.request :json
27
+ faraday.adapter Faraday.default_adapter
28
+ end
29
+ end
30
+
31
+ def api_validation_params
32
+ timestamp = Time.now.to_i
33
+ hash = Digest::SHA1.hexdigest "#{@shared_secret}#{timestamp}"
34
+ {api_key: @api_key, ts: timestamp, hash: hash}
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,17 @@
1
+ module SlideshareApi
2
+ module Model
3
+ class Slideshow
4
+ attr_accessor :id, :title, :description, :username, :url, :embed, :language
5
+
6
+ def initialize(slideshow_xml)
7
+ @id = slideshow_xml.search('ID').text
8
+ @title = slideshow_xml.search('Title').text
9
+ @description = slideshow_xml.search('Description').text
10
+ @username = slideshow_xml.search('Username').text
11
+ @url = slideshow_xml.search('URL').text
12
+ @embed = slideshow_xml.search('Embed').text
13
+ @language = slideshow_xml.search('Language').text
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module SlideshareApi
2
+ VERSION = "0.0.1"
3
+ end
@@ -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 'slideshare_api/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'slideshare_api'
8
+ spec.version = SlideshareApi::VERSION
9
+ spec.authors = ['Jeremy Venezia']
10
+ spec.email = ['veneziajeremy@gmail.com']
11
+ spec.summary = %q{Slideshare ruby wrapper for the Slideshare API.}
12
+ spec.description = %q{Slideshare ruby wrapper for the Slideshare API.}
13
+ spec.homepage = 'https://github.com/jvenezia/slideshare_api'
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{^(spec|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.7'
22
+ spec.add_development_dependency 'rake', '~> 10.0'
23
+ spec.add_development_dependency 'rspec', '~> 3.0'
24
+
25
+ spec.add_dependency 'faraday', '~> 0'
26
+ spec.add_dependency 'faraday_middleware', '~> 0'
27
+ spec.add_dependency 'nokogiri', '~> 1.6'
28
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe SlideshareApi::Client do
4
+ let(:api_key) { 'api key' }
5
+ let(:shared_secret) { 'shared secret' }
6
+ let(:slideshare_client) { SlideshareApi::Client.new api_key, shared_secret }
7
+ let(:connection) { slideshare_client.connection }
8
+ let(:api_validation_params) { slideshare_client.send(:api_validation_params) }
9
+
10
+ describe '.connection' do
11
+ it { expect(connection).to be_a(Faraday::Connection) }
12
+ it { expect("#{connection.url_prefix.scheme}://#{connection.url_prefix.host}#{connection.url_prefix.path}").to eq(SlideshareApi::Client::SLIDESHARE_API_URL) }
13
+ end
14
+
15
+ describe '.api_validation_params' do
16
+ subject { slideshare_client.send(:api_validation_params) }
17
+ it { should eq({api_key: api_key, ts: Time.now.to_i, hash: Digest::SHA1.hexdigest("#{shared_secret}#{Time.now.to_i}")}) }
18
+ end
19
+
20
+ describe '.slideshow' do
21
+ let(:slideshow_raw_xml) { open('spec/fixtures/slideshow.xml').read }
22
+ let(:slideshow_url) { 'http://fr.slideshare.net/jeremyvenezia/prerequis-pour-appliquer-le-lean-startup-en-entreprise' }
23
+
24
+ before { expect(connection).to receive(:get).with('get_slideshow', api_validation_params.merge({slideshow_url: slideshow_url})).and_return(connection) }
25
+ before { expect(connection).to receive(:body).and_return(slideshow_raw_xml) }
26
+
27
+ subject { slideshare_client.slideshow slideshow_url }
28
+
29
+ it { should eql? SlideshareApi::Model::Slideshow.new(Nokogiri::XML(slideshow_raw_xml)) }
30
+ end
31
+ end
@@ -0,0 +1,32 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Slideshow>
3
+ <ID>34187090</ID>
4
+ <Title>Prerequis pour appliquer le Lean Startup en entreprise</Title>
5
+ <Description></Description>
6
+ <Status>2</Status>
7
+ <Username>jeremyvenezia</Username>
8
+ <URL>http://www.slideshare.net/jeremyvenezia/prerequis-pour-appliquer-le-lean-startup-en-entreprise</URL>
9
+ <ThumbnailURL>
10
+ //cdn.slidesharecdn.com/ss_thumbnails/prerequispourappliquerleleanstartupdanslentreprise-140430023146-phpapp02-140501195007-phpapp01-thumbnail.jpg?cb=1398991939
11
+ </ThumbnailURL>
12
+ <ThumbnailSize>[170,130]</ThumbnailSize>
13
+ <ThumbnailSmallURL>
14
+ //cdn.slidesharecdn.com/ss_thumbnails/prerequispourappliquerleleanstartupdanslentreprise-140430023146-phpapp02-140501195007-phpapp01-thumbnail-2.jpg?cb=1398991939
15
+ </ThumbnailSmallURL>
16
+ <Embed>
17
+ &lt;iframe src=&quot;https://www.slideshare.net/slideshow/embed_code/34187090&quot; width=&quot;427&quot;
18
+ height=&quot;356&quot; frameborder=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; scrolling=&quot;no&quot;
19
+ style=&quot;border:1px solid #CCC; border-width:1px; margin-bottom:5px; max-width: 100%;&quot; allowfullscreen&gt;
20
+ &lt;/iframe&gt; &lt;div style=&quot;margin-bottom:5px&quot;&gt; &lt;strong&gt; &lt;a href=&quot;https://www.slideshare.net/jeremyvenezia/prerequis-pour-appliquer-le-lean-startup-en-entreprise&quot;
21
+ title=&quot;Prerequis pour appliquer le Lean Startup en entreprise&quot; target=&quot;_blank&quot;&gt;Prerequis pour
22
+ appliquer le Lean Startup en entreprise&lt;/a&gt; &lt;/strong&gt; from &lt;strong&gt;&lt;a href=&quot;http://www.slideshare.net/jeremyvenezia&quot;
23
+ target=&quot;_blank&quot;&gt;Jeremy Venezia&lt;/a&gt;&lt;/strong&gt; &lt;/div&gt;
24
+ </Embed>
25
+ <Created>2014-05-02 00:50:06 UTC</Created>
26
+ <Updated>2014-05-02 00:52:19 UTC</Updated>
27
+ <Language>fr</Language>
28
+ <Format>pptx</Format>
29
+ <Download>0</Download>
30
+ <SlideshowType>0</SlideshowType>
31
+ <InContest>0</InContest>
32
+ </Slideshow>
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe SlideshareApi::Model::Slideshow do
4
+ describe 'attributes' do
5
+ let(:slideshow_xml) { Nokogiri::XML(open('spec/fixtures/slideshow.xml').read) }
6
+
7
+ subject { SlideshareApi::Model::Slideshow.new slideshow_xml }
8
+
9
+ it { expect(subject.id).to eq slideshow_xml.search('ID').text }
10
+ it { expect(subject.title).to eq slideshow_xml.search('Title').text }
11
+ it { expect(subject.description).to eq slideshow_xml.search('Description').text }
12
+ it { expect(subject.username).to eq slideshow_xml.search('Username').text }
13
+ it { expect(subject.url).to eq slideshow_xml.search('URL').text }
14
+ it { expect(subject.embed).to eq slideshow_xml.search('Embed').text }
15
+ it { expect(subject.language).to eq slideshow_xml.search('Language').text }
16
+ end
17
+ end
@@ -0,0 +1,7 @@
1
+ require 'bundler/setup'
2
+ Bundler.setup
3
+
4
+ require 'slideshare_api'
5
+
6
+ RSpec.configure do |config|
7
+ end
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: slideshare_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jeremy Venezia
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: faraday
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
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: faraday_middleware
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: nokogiri
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.6'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.6'
97
+ description: Slideshare ruby wrapper for the Slideshare API.
98
+ email:
99
+ - veneziajeremy@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".idea/inspectionProfiles/Project_Default.xml"
106
+ - ".idea/inspectionProfiles/profiles_settings.xml"
107
+ - ".travis.yml"
108
+ - Gemfile
109
+ - LICENSE.txt
110
+ - README.md
111
+ - Rakefile
112
+ - lib/slideshare_api.rb
113
+ - lib/slideshare_api/client.rb
114
+ - lib/slideshare_api/model/slideshow.rb
115
+ - lib/slideshare_api/version.rb
116
+ - slideshare_api.gemspec
117
+ - spec/client_spec.rb
118
+ - spec/fixtures/slideshow.xml
119
+ - spec/model/slideshow_spec.rb
120
+ - spec/spec_helper.rb
121
+ homepage: https://github.com/jvenezia/slideshare_api
122
+ licenses:
123
+ - MIT
124
+ metadata: {}
125
+ post_install_message:
126
+ rdoc_options: []
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ requirements: []
140
+ rubyforge_project:
141
+ rubygems_version: 2.2.2
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: Slideshare ruby wrapper for the Slideshare API.
145
+ test_files:
146
+ - spec/client_spec.rb
147
+ - spec/fixtures/slideshow.xml
148
+ - spec/model/slideshow_spec.rb
149
+ - spec/spec_helper.rb