slideshare_ruby 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.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +2 -0
- data/lib/slideshare_ruby/version.rb +3 -0
- data/lib/slideshare_ruby.rb +73 -0
- data/slideshare_ruby.gemspec +24 -0
- metadata +83 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
#require 'open-uri'
|
2
|
+
require 'digest/sha1'
|
3
|
+
begin
|
4
|
+
require 'cgi'
|
5
|
+
end
|
6
|
+
require 'httparty'
|
7
|
+
|
8
|
+
module SlideshareRuby
|
9
|
+
|
10
|
+
|
11
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
12
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
13
|
+
|
14
|
+
class SlideshareRuby
|
15
|
+
include HTTParty
|
16
|
+
|
17
|
+
VERSION = '0.0.1'
|
18
|
+
|
19
|
+
@@base_uri = "http://www.slideshare.net/api"
|
20
|
+
@@api_version = "2"
|
21
|
+
|
22
|
+
@@api_key = ""
|
23
|
+
@@api_secret = ""
|
24
|
+
|
25
|
+
#default_params :api_key => @@api_key, @ts => Time.now.to_i.to_s, :hash = calculate_hash
|
26
|
+
format :xml
|
27
|
+
|
28
|
+
def initialize(api_key, api_secret)
|
29
|
+
@@api_key = api_key
|
30
|
+
@@api_secret = api_secret
|
31
|
+
end
|
32
|
+
|
33
|
+
def api_key=(api_key)
|
34
|
+
@@api_key = api_key
|
35
|
+
end
|
36
|
+
|
37
|
+
def api_key
|
38
|
+
@@api_key
|
39
|
+
end
|
40
|
+
|
41
|
+
def api_secret=(api_secret)
|
42
|
+
@@api_secret = api_secret
|
43
|
+
end
|
44
|
+
|
45
|
+
def api_secret
|
46
|
+
@@api_secret
|
47
|
+
end
|
48
|
+
|
49
|
+
# api_key: Set this to the API Key that SlideShare has provided for you.
|
50
|
+
# ts: Set this to the current time in Unix TimeStamp format, to the nearest second(?).
|
51
|
+
# hash: Set this to the SHA1 hash of the concatenation of the shared secret and the timestamp (ts). i.e. SHA1 (sharedsecret + timestamp). The order of the terms in the concatenation is important.
|
52
|
+
def prepare_call
|
53
|
+
@ts = Time.now.to_i.to_s
|
54
|
+
@hash = Digest::SHA1.hexdigest(@@api_secret + @ts)
|
55
|
+
"?api_key=#{@@api_key}&ts=#{@ts}&hash=#{@hash}"
|
56
|
+
end
|
57
|
+
|
58
|
+
def calculate_hash
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
def get_slideshow(slideshow_url)
|
63
|
+
# http://www.slideshare.net/api/2/get_slideshow
|
64
|
+
@required_params = self.prepare_call
|
65
|
+
@request_uri = "/#{@@api_version}/get_slideshow#{@required_params}&slideshow_url=#{CGI.escape(slideshow_url)}&detailed=1"
|
66
|
+
result = self.class.get(@@base_uri + @request_uri)
|
67
|
+
Crack::XML.parse(result.body)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "slideshare_ruby/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "slideshare_ruby"
|
7
|
+
s.version = SlideshareRuby::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Edd Parris"]
|
10
|
+
s.email = ["eddy@nixonmcinnes.co.uk"]
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = %q{Wrapper for the Slideshare API}
|
13
|
+
s.description = %q{Wrapper for the Slideshare API}
|
14
|
+
|
15
|
+
s.rubyforge_project = "slideshare_ruby"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_dependency('httparty')
|
23
|
+
s.add_dependency('nokogiri')
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: slideshare_ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Edd Parris
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-04-01 00:00:00 +01:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: httparty
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: nokogiri
|
29
|
+
prerelease: false
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: "0"
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id002
|
38
|
+
description: Wrapper for the Slideshare API
|
39
|
+
email:
|
40
|
+
- eddy@nixonmcinnes.co.uk
|
41
|
+
executables: []
|
42
|
+
|
43
|
+
extensions: []
|
44
|
+
|
45
|
+
extra_rdoc_files: []
|
46
|
+
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- Rakefile
|
51
|
+
- lib/slideshare_ruby.rb
|
52
|
+
- lib/slideshare_ruby/version.rb
|
53
|
+
- slideshare_ruby.gemspec
|
54
|
+
has_rdoc: true
|
55
|
+
homepage: ""
|
56
|
+
licenses: []
|
57
|
+
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options: []
|
60
|
+
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: "0"
|
75
|
+
requirements: []
|
76
|
+
|
77
|
+
rubyforge_project: slideshare_ruby
|
78
|
+
rubygems_version: 1.6.1
|
79
|
+
signing_key:
|
80
|
+
specification_version: 3
|
81
|
+
summary: Wrapper for the Slideshare API
|
82
|
+
test_files: []
|
83
|
+
|