slideshare_api 0.0.1 → 0.0.2
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 +4 -4
- data/README.md +10 -8
- data/lib/slideshare_api/client.rb +6 -2
- data/lib/slideshare_api/model/slideshow.rb +62 -8
- data/lib/slideshare_api/version.rb +1 -1
- data/slideshare_api-0.0.1.gem +0 -0
- data/spec/client_spec.rb +18 -4
- data/spec/fixtures/slideshow.xml +35 -0
- data/spec/model/slideshow_spec.rb +92 -0
- metadata +2 -3
- data/.idea/inspectionProfiles/Project_Default.xml +0 -33
- data/.idea/inspectionProfiles/profiles_settings.xml +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee401e264b32416a6e53fa0895bcffb4971f13d5
|
4
|
+
data.tar.gz: d1a1b14f379f4f067d3f2460598cbfad593b6c63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1e576034d37c5948921c1146da3fe840227e87af7e26b4074dbbaa120aafdefb245a4e6f22e5a6372530e07a61bdf39e8e43435803322b8b00b1fbb14d82b43
|
7
|
+
data.tar.gz: 6e8280de36391a0fbb387d9601dbb7f89d9f6f273e0ff6d0dc5fbfc91d2c8026331d15b58b855e79814355600b3d95ccf40a424c2db44bd7c995048d0a4f2d12
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# SlideshareApi
|
2
2
|
[](https://travis-ci.org/jvenezia/slideshare_api)
|
3
|
+
[](http://badge.fury.io/rb/slideshare_api)
|
3
4
|
|
4
5
|
Slideshare ruby wrapper for the Slideshare API.
|
5
6
|
|
@@ -30,15 +31,16 @@ client = SlideshareApi::Client.new api_key, shared_secret
|
|
30
31
|
|
31
32
|
Get a slideshow:
|
32
33
|
```ruby
|
34
|
+
# from url...
|
33
35
|
slideshow_url = 'http://fr.slideshare.net/awesome_slideshow'
|
34
|
-
slideshow = client.slideshow(slideshow_url) #=> returns a SlideshareApi::Model::Slideshow
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
slideshow.
|
39
|
-
|
40
|
-
|
41
|
-
slideshow.
|
36
|
+
slideshow = client.slideshow(slideshow_url: slideshow_url) #=> returns a SlideshareApi::Model::Slideshow
|
37
|
+
|
38
|
+
# from id...
|
39
|
+
slideshow_id = '1234'
|
40
|
+
slideshow = client.slideshow(slideshow_id: slideshow_id) #=> returns a SlideshareApi::Model::Slideshow
|
41
|
+
|
42
|
+
# with optional informations...
|
43
|
+
slideshow = client.slideshow(slideshow_id: slideshow_id, detailed: true) #=> returns a SlideshareApi::Model::Slideshow
|
42
44
|
```
|
43
45
|
|
44
46
|
## Contributing
|
@@ -15,8 +15,12 @@ module SlideshareApi
|
|
15
15
|
build_connection
|
16
16
|
end
|
17
17
|
|
18
|
-
def slideshow(
|
19
|
-
|
18
|
+
def slideshow(options = {})
|
19
|
+
params = {}
|
20
|
+
params.merge!({slideshow_url: options[:slideshow_url]}) if options[:slideshow_url]
|
21
|
+
params.merge!({slideshow_id: options[:slideshow_id]}) if options[:slideshow_id]
|
22
|
+
params.merge!({detailed: 1}) if options[:detailed]
|
23
|
+
SlideshareApi::Model::Slideshow.new Nokogiri::XML(@connection.get('get_slideshow', api_validation_params.merge(params)).body)
|
20
24
|
end
|
21
25
|
|
22
26
|
private
|
@@ -1,16 +1,70 @@
|
|
1
1
|
module SlideshareApi
|
2
2
|
module Model
|
3
3
|
class Slideshow
|
4
|
-
attr_accessor :
|
4
|
+
attr_accessor :original_slideshow_xml,
|
5
|
+
:id, :title, :stripped_title, :description, :status,
|
6
|
+
:created_at, :updated_at,
|
7
|
+
:username, :user_id,
|
8
|
+
:url, :thumbnail_url, :thumbnail_size, :thumbnail_small_url, :embed,
|
9
|
+
:language, :format, :slideshow_type,
|
10
|
+
:is_downloadable, :is_in_contest,
|
11
|
+
:ppt_location,
|
12
|
+
:tags,
|
13
|
+
:download_count, :view_count, :comment_count, :favorite_count,
|
14
|
+
:slide_count,
|
15
|
+
:related_slideshow_ids,
|
16
|
+
:privacy_level, :is_flagged, :url_is_secret, :is_embaddable, :is_visible, :is_visible_by_contacts
|
5
17
|
|
6
18
|
def initialize(slideshow_xml)
|
7
|
-
@
|
8
|
-
|
9
|
-
@
|
10
|
-
@
|
11
|
-
@
|
12
|
-
@
|
13
|
-
@
|
19
|
+
@original_slideshow_xml = slideshow_xml
|
20
|
+
|
21
|
+
@id = text_from_xml('ID')
|
22
|
+
@title = text_from_xml('Title')
|
23
|
+
@description = text_from_xml('Description')
|
24
|
+
@status = text_from_xml('Status')
|
25
|
+
@username = text_from_xml('Username')
|
26
|
+
@url = text_from_xml('URL')
|
27
|
+
@thumbnail_url = text_from_xml('ThumbnailURL')
|
28
|
+
@thumbnail_size = text_from_xml('ThumbnailSize')
|
29
|
+
@thumbnail_small_url = text_from_xml('ThumbnailSmallURL')
|
30
|
+
@embed = text_from_xml('Embed')
|
31
|
+
@created_at = Time.parse text_from_xml('Created')
|
32
|
+
@updated_at = Time.parse text_from_xml('Updated')
|
33
|
+
@language = text_from_xml('Language')
|
34
|
+
@format = text_from_xml('Format')
|
35
|
+
@is_downloadable = boolean_from_xml('Download')
|
36
|
+
@slideshow_type = text_from_xml('SlideshowType')
|
37
|
+
@is_in_contest = boolean_from_xml('InContest')
|
38
|
+
@user_id = text_from_xml('UserID')
|
39
|
+
@ppt_location = text_from_xml('PPTLocation')
|
40
|
+
@stripped_title = text_from_xml('StrippedTitle')
|
41
|
+
@tags = text_list_from_xml('Tag')
|
42
|
+
@download_count = text_from_xml('NumDownloads')
|
43
|
+
@view_count = text_from_xml('NumViews')
|
44
|
+
@comment_count = text_from_xml('NumComments')
|
45
|
+
@favorite_count = text_from_xml('NumFavorites')
|
46
|
+
@slide_count = text_from_xml('NumSlides')
|
47
|
+
@related_slideshow_ids = text_list_from_xml('RelatedSlideshowID')
|
48
|
+
@privacy_level = text_from_xml('PrivacyLevel')
|
49
|
+
@is_flagged = boolean_from_xml('FlagVisible')
|
50
|
+
@is_visible = boolean_from_xml('ShowOnSS')
|
51
|
+
@url_is_secret = boolean_from_xml('SecretURL')
|
52
|
+
@is_embaddable = boolean_from_xml('AllowEmbed')
|
53
|
+
@is_visible_by_contacts = boolean_from_xml('ShareWithContacts')
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def boolean_from_xml(attribute_name)
|
59
|
+
@original_slideshow_xml.search(attribute_name).first.content == '1'
|
60
|
+
end
|
61
|
+
|
62
|
+
def text_from_xml(attribute_name)
|
63
|
+
@original_slideshow_xml.search(attribute_name).text
|
64
|
+
end
|
65
|
+
|
66
|
+
def text_list_from_xml(attribute_name)
|
67
|
+
@original_slideshow_xml.search(attribute_name).map(&:text)
|
14
68
|
end
|
15
69
|
end
|
16
70
|
end
|
Binary file
|
data/spec/client_spec.rb
CHANGED
@@ -19,13 +19,27 @@ describe SlideshareApi::Client do
|
|
19
19
|
|
20
20
|
describe '.slideshow' do
|
21
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
22
|
|
24
|
-
before { expect(connection).to receive(:get).with('get_slideshow', api_validation_params.merge({slideshow_url: slideshow_url})).and_return(connection) }
|
25
23
|
before { expect(connection).to receive(:body).and_return(slideshow_raw_xml) }
|
26
24
|
|
27
|
-
|
25
|
+
context 'get from slideshow url' do
|
26
|
+
let(:slideshow_url) { 'http://fr.slideshare.net/jeremyvenezia/prerequis-pour-appliquer-le-lean-startup-en-entreprise' }
|
28
27
|
|
29
|
-
|
28
|
+
before { expect(connection).to receive(:get).with('get_slideshow', api_validation_params.merge({slideshow_url: slideshow_url})).and_return(connection) }
|
29
|
+
|
30
|
+
subject { slideshare_client.slideshow slideshow_url: slideshow_url }
|
31
|
+
|
32
|
+
it { should eql? SlideshareApi::Model::Slideshow.new(Nokogiri::XML(slideshow_raw_xml)) }
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'get from slideshow id' do
|
36
|
+
let(:slideshow_id) { '1234' }
|
37
|
+
|
38
|
+
before { expect(connection).to receive(:get).with('get_slideshow', api_validation_params.merge({slideshow_id: slideshow_id})).and_return(connection) }
|
39
|
+
|
40
|
+
subject { slideshare_client.slideshow slideshow_id: slideshow_id }
|
41
|
+
|
42
|
+
it { should eql? SlideshareApi::Model::Slideshow.new(Nokogiri::XML(slideshow_raw_xml)) }
|
43
|
+
end
|
30
44
|
end
|
31
45
|
end
|
data/spec/fixtures/slideshow.xml
CHANGED
@@ -29,4 +29,39 @@
|
|
29
29
|
<Download>0</Download>
|
30
30
|
<SlideshowType>0</SlideshowType>
|
31
31
|
<InContest>0</InContest>
|
32
|
+
<UserID>62691692</UserID>
|
33
|
+
<PPTLocation>
|
34
|
+
prerequispourappliquerleleanstartupdanslentreprise-140430023146-phpapp02-140501195007-phpapp01
|
35
|
+
</PPTLocation>
|
36
|
+
<StrippedTitle>prerequis-pour-appliquer-le-lean-startup-en-entreprise</StrippedTitle>
|
37
|
+
<Tags>
|
38
|
+
<Tag Count="1" Owner="1">leanstartup</Tag>
|
39
|
+
<Tag Count="1" Owner="1">entrepreneur</Tag>
|
40
|
+
<Tag Count="1" Owner="1">startup</Tag>
|
41
|
+
<Tag Count="1" Owner="1">entrepreneurship</Tag>
|
42
|
+
<Tag Count="1" Owner="1">business</Tag>
|
43
|
+
</Tags>
|
44
|
+
<NumDownloads>0</NumDownloads>
|
45
|
+
<NumViews>223</NumViews>
|
46
|
+
<NumComments>0</NumComments>
|
47
|
+
<NumFavorites>0</NumFavorites>
|
48
|
+
<NumSlides>28</NumSlides>
|
49
|
+
<RelatedSlideshows>
|
50
|
+
<RelatedSlideshowID rank="1">34115565</RelatedSlideshowID>
|
51
|
+
<RelatedSlideshowID rank="2">34120112</RelatedSlideshowID>
|
52
|
+
<RelatedSlideshowID rank="3">33133758</RelatedSlideshowID>
|
53
|
+
<RelatedSlideshowID rank="4">27569567</RelatedSlideshowID>
|
54
|
+
<RelatedSlideshowID rank="5">28375042</RelatedSlideshowID>
|
55
|
+
<RelatedSlideshowID rank="6">30302539</RelatedSlideshowID>
|
56
|
+
<RelatedSlideshowID rank="7">28193782</RelatedSlideshowID>
|
57
|
+
<RelatedSlideshowID rank="8">22861393</RelatedSlideshowID>
|
58
|
+
<RelatedSlideshowID rank="9">16138475</RelatedSlideshowID>
|
59
|
+
<RelatedSlideshowID rank="10">19583592</RelatedSlideshowID>
|
60
|
+
</RelatedSlideshows>
|
61
|
+
<PrivacyLevel>0</PrivacyLevel>
|
62
|
+
<FlagVisible>1</FlagVisible>
|
63
|
+
<ShowOnSS>0</ShowOnSS>
|
64
|
+
<SecretURL>0</SecretURL>
|
65
|
+
<AllowEmbed>0</AllowEmbed>
|
66
|
+
<ShareWithContacts>0</ShareWithContacts>
|
32
67
|
</Slideshow>
|
@@ -6,12 +6,104 @@ describe SlideshareApi::Model::Slideshow do
|
|
6
6
|
|
7
7
|
subject { SlideshareApi::Model::Slideshow.new slideshow_xml }
|
8
8
|
|
9
|
+
it { expect(subject.original_slideshow_xml).to eq slideshow_xml }
|
9
10
|
it { expect(subject.id).to eq slideshow_xml.search('ID').text }
|
10
11
|
it { expect(subject.title).to eq slideshow_xml.search('Title').text }
|
11
12
|
it { expect(subject.description).to eq slideshow_xml.search('Description').text }
|
13
|
+
it { expect(subject.status).to eq slideshow_xml.search('Status').text }
|
12
14
|
it { expect(subject.username).to eq slideshow_xml.search('Username').text }
|
13
15
|
it { expect(subject.url).to eq slideshow_xml.search('URL').text }
|
16
|
+
it { expect(subject.thumbnail_url).to eq slideshow_xml.search('ThumbnailURL').text }
|
17
|
+
it { expect(subject.thumbnail_size).to eq slideshow_xml.search('ThumbnailSize').text }
|
18
|
+
it { expect(subject.thumbnail_small_url).to eq slideshow_xml.search('ThumbnailSmallURL').text }
|
14
19
|
it { expect(subject.embed).to eq slideshow_xml.search('Embed').text }
|
20
|
+
it { expect(subject.created_at).to eq Time.parse slideshow_xml.search('Created').text }
|
21
|
+
it { expect(subject.updated_at).to eq Time.parse slideshow_xml.search('Updated').text }
|
15
22
|
it { expect(subject.language).to eq slideshow_xml.search('Language').text }
|
23
|
+
it { expect(subject.format).to eq slideshow_xml.search('Format').text }
|
24
|
+
|
25
|
+
context 'it is downloadable' do
|
26
|
+
before { slideshow_xml.search('Download').first.content = 1 }
|
27
|
+
it { expect(subject.is_downloadable).to eq true }
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'it is not downloadable' do
|
31
|
+
before { slideshow_xml.search('Download').first.content = 0 }
|
32
|
+
it { expect(subject.is_downloadable).to eq false }
|
33
|
+
end
|
34
|
+
|
35
|
+
it { expect(subject.slideshow_type).to eq slideshow_xml.search('SlideshowType').text }
|
36
|
+
|
37
|
+
context 'it is in contest' do
|
38
|
+
before { slideshow_xml.search('InContest').first.content = 1 }
|
39
|
+
it { expect(subject.is_in_contest).to eq true }
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'it is not in contest' do
|
43
|
+
before { slideshow_xml.search('InContest').first.content = 0 }
|
44
|
+
it { expect(subject.is_in_contest).to eq false }
|
45
|
+
end
|
46
|
+
|
47
|
+
it { expect(subject.user_id).to eq slideshow_xml.search('UserID').text }
|
48
|
+
it { expect(subject.ppt_location).to eq slideshow_xml.search('PPTLocation').text }
|
49
|
+
it { expect(subject.stripped_title).to eq slideshow_xml.search('StrippedTitle').text }
|
50
|
+
it { expect(subject.tags).to eq slideshow_xml.search('Tag').map(&:text) }
|
51
|
+
it { expect(subject.download_count).to eq slideshow_xml.search('NumDownloads').text }
|
52
|
+
it { expect(subject.view_count).to eq slideshow_xml.search('NumViews').text }
|
53
|
+
it { expect(subject.comment_count).to eq slideshow_xml.search('NumComments').text }
|
54
|
+
it { expect(subject.favorite_count).to eq slideshow_xml.search('NumFavorites').text }
|
55
|
+
it { expect(subject.slide_count).to eq slideshow_xml.search('NumSlides').text }
|
56
|
+
it { expect(subject.related_slideshow_ids).to eq slideshow_xml.search('RelatedSlideshowID').map(&:text) }
|
57
|
+
it { expect(subject.privacy_level).to eq slideshow_xml.search('PrivacyLevel').text }
|
58
|
+
|
59
|
+
context 'it is flagged' do
|
60
|
+
before { slideshow_xml.search('FlagVisible').first.content = 1 }
|
61
|
+
it { expect(subject.is_flagged).to eq true }
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'it is not flagged' do
|
65
|
+
before { slideshow_xml.search('FlagVisible').first.content = 0 }
|
66
|
+
it { expect(subject.is_flagged).to eq false }
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'it is visible' do
|
70
|
+
before { slideshow_xml.search('ShowOnSS').first.content = 1 }
|
71
|
+
it { expect(subject.is_visible).to eq true }
|
72
|
+
end
|
73
|
+
|
74
|
+
context 'it is not visible' do
|
75
|
+
before { slideshow_xml.search('ShowOnSS').first.content = 0 }
|
76
|
+
it { expect(subject.is_visible).to eq false }
|
77
|
+
end
|
78
|
+
|
79
|
+
context 'url is secret' do
|
80
|
+
before { slideshow_xml.search('SecretURL').first.content = 1 }
|
81
|
+
it { expect(subject.url_is_secret).to eq true }
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'url is not secret' do
|
85
|
+
before { slideshow_xml.search('SecretURL').first.content = 0 }
|
86
|
+
it { expect(subject.url_is_secret).to eq false }
|
87
|
+
end
|
88
|
+
|
89
|
+
context 'it is embaddable' do
|
90
|
+
before { slideshow_xml.search('AllowEmbed').first.content = 1 }
|
91
|
+
it { expect(subject.is_embaddable).to eq true }
|
92
|
+
end
|
93
|
+
|
94
|
+
context 'url is not embaddable' do
|
95
|
+
before { slideshow_xml.search('AllowEmbed').first.content = 0 }
|
96
|
+
it { expect(subject.is_embaddable).to eq false }
|
97
|
+
end
|
98
|
+
|
99
|
+
context 'it is visible by contacts' do
|
100
|
+
before { slideshow_xml.search('ShareWithContacts').first.content = 1 }
|
101
|
+
it { expect(subject.is_visible_by_contacts).to eq true }
|
102
|
+
end
|
103
|
+
|
104
|
+
context 'url is not visible by contacts' do
|
105
|
+
before { slideshow_xml.search('ShareWithContacts').first.content = 0 }
|
106
|
+
it { expect(subject.is_visible_by_contacts).to eq false }
|
107
|
+
end
|
16
108
|
end
|
17
109
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slideshare_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Venezia
|
@@ -102,8 +102,6 @@ extensions: []
|
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
104
|
- ".gitignore"
|
105
|
-
- ".idea/inspectionProfiles/Project_Default.xml"
|
106
|
-
- ".idea/inspectionProfiles/profiles_settings.xml"
|
107
105
|
- ".travis.yml"
|
108
106
|
- Gemfile
|
109
107
|
- LICENSE.txt
|
@@ -113,6 +111,7 @@ files:
|
|
113
111
|
- lib/slideshare_api/client.rb
|
114
112
|
- lib/slideshare_api/model/slideshow.rb
|
115
113
|
- lib/slideshare_api/version.rb
|
114
|
+
- slideshare_api-0.0.1.gem
|
116
115
|
- slideshare_api.gemspec
|
117
116
|
- spec/client_spec.rb
|
118
117
|
- spec/fixtures/slideshow.xml
|
@@ -1,33 +0,0 @@
|
|
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>
|