slideshare-api 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in slideshare-api.gemspec
4
+ gemspec
@@ -0,0 +1,28 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ slideshare-api (0.0.1)
5
+ httparty
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ crack (0.1.8)
11
+ diff-lcs (1.1.2)
12
+ httparty (0.7.8)
13
+ crack (= 0.1.8)
14
+ rspec (2.4.0)
15
+ rspec-core (~> 2.4.0)
16
+ rspec-expectations (~> 2.4.0)
17
+ rspec-mocks (~> 2.4.0)
18
+ rspec-core (2.4.0)
19
+ rspec-expectations (2.4.0)
20
+ diff-lcs (~> 1.1.2)
21
+ rspec-mocks (2.4.0)
22
+
23
+ PLATFORMS
24
+ ruby
25
+
26
+ DEPENDENCIES
27
+ rspec
28
+ slideshare-api!
@@ -0,0 +1,21 @@
1
+ = Slidehare API
2
+
3
+ This is a simple gem that utilizes HTTParty and the Slide Share API.
4
+
5
+ gem install slideshare-api
6
+
7
+ For more information on the Slide Share API check out http://www.slideshare.net/developers
8
+
9
+ == Set API Key and Shared Key
10
+
11
+ You need an API key and a shared key. You get both when you apply for an API key on Slideshare's website.
12
+
13
+ Slideshare.configure do |config|
14
+ config.api_key = YOUR_API_KEY
15
+ config.api_shared_secret = YOUR_SHARED_SECRET
16
+ end
17
+
18
+ == Get Slideshows by user
19
+
20
+ Slideshare::Api.get_slideshows_by_user(*username*)
21
+
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,7 @@
1
+ require 'slideshare/api'
2
+ require 'slideshare/configuration'
3
+ require 'slideshare/request'
4
+
5
+ module Slideshare extend Configuration
6
+
7
+ end
@@ -0,0 +1,36 @@
1
+ require 'slideshare/configuration'
2
+ require 'slideshare/request'
3
+ require 'digest/sha1'
4
+
5
+ module Slideshare
6
+ module Api
7
+ include Request
8
+
9
+ def self.get_slideshows_by_user(username)
10
+ params = default_parameters
11
+ params[:username_for] = username
12
+ Request.do_get("http://www.slideshare.net/api/2/get_slideshows_by_user", :query => params)
13
+ end
14
+
15
+ def self.get_slideshow(slideshow_id, slideshow_url)
16
+ params = default_parameters
17
+ params[:slideshow_id] = slideshow_id
18
+ params[:slideshow_url] = slideshow_url
19
+ Request.do_get("http://www.slideshare.net/api/2/get_slideshow", :query => params)
20
+ end
21
+
22
+ private
23
+ def self.default_parameters
24
+ params = {}
25
+ params[:api_key] = Slideshare.api_key
26
+
27
+ timestamp = Time.now.to_i
28
+ ss_hash = Digest::SHA1.hexdigest(Slideshare.api_shared_secret + timestamp.to_s)
29
+
30
+ params[:ts] = timestamp
31
+ params[:hash] = ss_hash
32
+ params[:format] = "json"
33
+ return params
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,50 @@
1
+ module Slideshare
2
+ module Configuration
3
+ VALID_OPTIONS_KEYS = [
4
+ :api_version,
5
+ :api_key,
6
+ :api_shared_secret,
7
+ :api_http_endpoint,
8
+ :api_https_endpoint,
9
+ :api_response_format
10
+ ].freeze
11
+
12
+ VALID_FROMATS = [:xml].freeze
13
+
14
+ DEFAULT_API_VERSION = "2".freeze
15
+ DEFAULT_API_KEY = nil
16
+ DEFAULT_API_SHARED_SECRET = nil
17
+ DEFAULT_API_HTTP_ENDPOINT = "http://www.slideshare.net/api/2/".freeze
18
+ DEFAULT_API_HTTPS_ENDPOINT = "https://www.slideshare.net/api/2/".freeze
19
+ DEFAULT_API_RESPONSE_FORMAT = :xml
20
+
21
+ # @private
22
+ attr_accessor *VALID_OPTIONS_KEYS
23
+
24
+ # When this module is extended, set all configuration options to their default values
25
+ def self.extended(base)
26
+ base.reset
27
+ end
28
+
29
+ # Convenience method to allow configuration options to be set in a block
30
+ def configure
31
+ yield self
32
+ end
33
+
34
+ # Create a hash of options and their values
35
+ def options
36
+ Hash[VALID_OPTIONS_KEYS.map {|key| [key, send(key)] }]
37
+ end
38
+
39
+ # Reset all configuration options to defaults
40
+ def reset
41
+ self.api_version = DEFAULT_API_VERSION
42
+ self.api_key = DEFAULT_API_KEY
43
+ self.api_shared_secret = DEFAULT_API_SHARED_SECRET
44
+ self.api_http_endpoint = DEFAULT_API_HTTP_ENDPOINT
45
+ self.api_https_endpoint = DEFAULT_API_HTTPS_ENDPOINT
46
+ self.api_response_format = DEFAULT_API_RESPONSE_FORMAT
47
+ self
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,34 @@
1
+ require 'httparty'
2
+
3
+ module Slideshare
4
+ module Request
5
+ include HTTParty
6
+
7
+ def self.do_get(path, options={})
8
+ request(:get, path, options)
9
+ end
10
+
11
+ # Perform an HTTP POST request
12
+ def self.do_post(path, options={})
13
+ request(:post, path, options)
14
+ end
15
+
16
+ # Perform an HTTP PUT request
17
+ def self.do_put(path, options={})
18
+ request(:put, path, options)
19
+ end
20
+
21
+ # Perform an HTTP DELETE request
22
+ def self.do_delete(path, options={})
23
+ request(:delete, path, options)
24
+ end
25
+
26
+ private
27
+ # Perform an HTTP request
28
+ def self.request(method, path, options)
29
+ #options.merge!(authentication)
30
+ response = HTTParty.send(method, path, options)
31
+ response
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,3 @@
1
+ module Slideshare
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "slideshare/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "slideshare-api"
7
+ s.version = Slideshare::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Umanni"]
10
+ s.email = ["ygor@umanni.com"]
11
+ s.homepage = "http://rubygems.org/gems/slideshare-api"
12
+ s.summary = %q{Gem for Slideshare API using HTTParty based on RookieOne SlideShare}
13
+ s.description = %q{Gem for Slideshare API using HTTParty based on RookieOne SlideShare}
14
+
15
+ s.rubyforge_project = "slideshare-api"
16
+
17
+ s.add_development_dependency "rspec"
18
+ s.add_runtime_dependency "httparty"
19
+
20
+ s.files = `git ls-files`.split("\n")
21
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
23
+ s.require_paths = ["lib"]
24
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe Slideshare do
4
+ before(:each) do
5
+ Slideshare.configure do |config|
6
+ config.api_key = "IUKyhLLC"
7
+ config.api_shared_secret = "PdZ8enD1"
8
+ end
9
+ end
10
+
11
+ describe "get slideshows by user" do
12
+ before(:each) do
13
+ @talks = Slideshare::Api.get_slideshows_by_user("umanni")
14
+ end
15
+
16
+ it { @talks.should_not be_nil }
17
+ it { @talks.should_not be_empty }
18
+ end
19
+
20
+
21
+ end
@@ -0,0 +1,2 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'slideshare-api')
2
+ require 'httparty'
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: slideshare-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Umanni
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-07-11 00:00:00.000000000 -03:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ requirement: &9961820 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: *9961820
26
+ - !ruby/object:Gem::Dependency
27
+ name: httparty
28
+ requirement: &9959660 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: *9959660
37
+ description: Gem for Slideshare API using HTTParty based on RookieOne SlideShare
38
+ email:
39
+ - ygor@umanni.com
40
+ executables: []
41
+ extensions: []
42
+ extra_rdoc_files: []
43
+ files:
44
+ - .gitignore
45
+ - Gemfile
46
+ - Gemfile.lock
47
+ - README.rdoc
48
+ - Rakefile
49
+ - lib/slideshare.rb
50
+ - lib/slideshare/api.rb
51
+ - lib/slideshare/configuration.rb
52
+ - lib/slideshare/request.rb
53
+ - lib/slideshare/version.rb
54
+ - slideshare-api.gemspec
55
+ - spec/slideshare_spec.rb
56
+ - spec/spec_helper.rb
57
+ has_rdoc: true
58
+ homepage: http://rubygems.org/gems/slideshare-api
59
+ licenses: []
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project: slideshare-api
78
+ rubygems_version: 1.6.2
79
+ signing_key:
80
+ specification_version: 3
81
+ summary: Gem for Slideshare API using HTTParty based on RookieOne SlideShare
82
+ test_files: []