slideshare_api 0.0.5 → 0.0.6
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/lib/slideshare_api/client.rb +8 -1
- data/lib/slideshare_api/error.rb +4 -0
- data/lib/slideshare_api/version.rb +1 -1
- data/spec/client_spec.rb +31 -21
- data/spec/fixtures/error.xml +5 -0
- metadata +4 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b51beff1edd1f7d82c4f023e91cd22714089ea4f
|
|
4
|
+
data.tar.gz: 5ffdd7a0aeb502c4b4ac764bafa77493c1455711
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2871d54d5b029544b65f345325ce70be8cce55d0ab9bfc3559a4b9b7a4f690aaebac64f0fd0186b72a0536f0bd66e5480cf379a4c2940ee5c39fa5172b7543d4
|
|
7
|
+
data.tar.gz: 94d549cc830f334a7f32a5e6f76658cc0b49a9fc55574ff22dd9df4c9db1a8dda0646c93fd0293cdec35763a9b92ef1bb000fb031b223879e8e69c3737fdab2b
|
|
@@ -20,7 +20,9 @@ module SlideshareApi
|
|
|
20
20
|
params.merge!({slideshow_url: cleaned_url(options[:slideshow_url])}) if options[:slideshow_url]
|
|
21
21
|
params.merge!({slideshow_id: options[:slideshow_id]}) if options[:slideshow_id]
|
|
22
22
|
params.merge!({detailed: 1}) if options[:detailed]
|
|
23
|
-
|
|
23
|
+
xml_response = Nokogiri::XML(@connection.get('get_slideshow', api_validation_params.merge(params)).body)
|
|
24
|
+
check_error xml_response
|
|
25
|
+
SlideshareApi::Model::Slideshow.new xml_response
|
|
24
26
|
end
|
|
25
27
|
|
|
26
28
|
private
|
|
@@ -29,6 +31,11 @@ module SlideshareApi
|
|
|
29
31
|
url.split('?')[0]
|
|
30
32
|
end
|
|
31
33
|
|
|
34
|
+
def check_error(xml_response)
|
|
35
|
+
error = xml_response.search('SlideShareServiceError')
|
|
36
|
+
raise SlideshareApi::Error, xml_response.search('Message').text unless error.empty?
|
|
37
|
+
end
|
|
38
|
+
|
|
32
39
|
def build_connection
|
|
33
40
|
@connection = Faraday.new(url: SLIDESHARE_API_URL) do |faraday|
|
|
34
41
|
faraday.request :json
|
data/spec/client_spec.rb
CHANGED
|
@@ -18,41 +18,51 @@ describe SlideshareApi::Client do
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
describe '.slideshow' do
|
|
21
|
-
|
|
21
|
+
context 'there is an error' do
|
|
22
|
+
let(:error_xml) { open('spec/fixtures/error.xml').read }
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
before { expect(connection).to receive(:get).and_return(connection) }
|
|
25
|
+
before { expect(connection).to receive(:body).and_return(error_xml) }
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
let(:slideshow_url_with_params) { 'http://fr.slideshare.net/jeremyvenezia/prerequis-pour-appliquer-le-lean-startup-en-entreprise?ref=http://fr.slideshare.net/?ss' }
|
|
28
|
-
let(:slideshow_url) { 'http://fr.slideshare.net/jeremyvenezia/prerequis-pour-appliquer-le-lean-startup-en-entreprise' }
|
|
27
|
+
it { expect(-> { slideshare_client.slideshow }).to raise_error(SlideshareApi::Error) }
|
|
28
|
+
end
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
context 'there is no error' do
|
|
31
|
+
let(:slideshow_raw_xml) { open('spec/fixtures/slideshow.xml').read }
|
|
32
|
+
before { expect(connection).to receive(:body).and_return(slideshow_raw_xml) }
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
context 'get from slideshow url' do
|
|
35
|
+
context 'url has params' do
|
|
36
|
+
let(:slideshow_url_with_params) { 'http://fr.slideshare.net/jeremyvenezia/prerequis-pour-appliquer-le-lean-startup-en-entreprise?ref=http://fr.slideshare.net/?ss' }
|
|
37
|
+
let(:slideshow_url) { 'http://fr.slideshare.net/jeremyvenezia/prerequis-pour-appliquer-le-lean-startup-en-entreprise' }
|
|
33
38
|
|
|
34
|
-
|
|
35
|
-
end
|
|
39
|
+
before { expect(connection).to receive(:get).with('get_slideshow', api_validation_params.merge({slideshow_url: slideshow_url})).and_return(connection) }
|
|
36
40
|
|
|
37
|
-
|
|
38
|
-
let(:slideshow_url) { 'http://fr.slideshare.net/jeremyvenezia/prerequis-pour-appliquer-le-lean-startup-en-entreprise' }
|
|
41
|
+
subject { slideshare_client.slideshow slideshow_url: slideshow_url_with_params }
|
|
39
42
|
|
|
40
|
-
|
|
43
|
+
it { should eql? SlideshareApi::Model::Slideshow.new(Nokogiri::XML(slideshow_raw_xml)) }
|
|
44
|
+
end
|
|
41
45
|
|
|
42
|
-
|
|
46
|
+
context 'url has no params' do
|
|
47
|
+
let(:slideshow_url) { 'http://fr.slideshare.net/jeremyvenezia/prerequis-pour-appliquer-le-lean-startup-en-entreprise' }
|
|
43
48
|
|
|
44
|
-
|
|
49
|
+
before { expect(connection).to receive(:get).with('get_slideshow', api_validation_params.merge({slideshow_url: slideshow_url})).and_return(connection) }
|
|
50
|
+
|
|
51
|
+
subject { slideshare_client.slideshow slideshow_url: slideshow_url }
|
|
52
|
+
|
|
53
|
+
it { should eql? SlideshareApi::Model::Slideshow.new(Nokogiri::XML(slideshow_raw_xml)) }
|
|
54
|
+
end
|
|
45
55
|
end
|
|
46
|
-
end
|
|
47
56
|
|
|
48
|
-
|
|
49
|
-
|
|
57
|
+
context 'get from slideshow id' do
|
|
58
|
+
let(:slideshow_id) { '1234' }
|
|
50
59
|
|
|
51
|
-
|
|
60
|
+
before { expect(connection).to receive(:get).with('get_slideshow', api_validation_params.merge({slideshow_id: slideshow_id})).and_return(connection) }
|
|
52
61
|
|
|
53
|
-
|
|
62
|
+
subject { slideshare_client.slideshow slideshow_id: slideshow_id }
|
|
54
63
|
|
|
55
|
-
|
|
64
|
+
it { should eql? SlideshareApi::Model::Slideshow.new(Nokogiri::XML(slideshow_raw_xml)) }
|
|
65
|
+
end
|
|
56
66
|
end
|
|
57
67
|
end
|
|
58
68
|
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.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jeremy Venezia
|
|
@@ -123,10 +123,12 @@ files:
|
|
|
123
123
|
- Rakefile
|
|
124
124
|
- lib/slideshare_api.rb
|
|
125
125
|
- lib/slideshare_api/client.rb
|
|
126
|
+
- lib/slideshare_api/error.rb
|
|
126
127
|
- lib/slideshare_api/model/slideshow.rb
|
|
127
128
|
- lib/slideshare_api/version.rb
|
|
128
129
|
- slideshare_api.gemspec
|
|
129
130
|
- spec/client_spec.rb
|
|
131
|
+
- spec/fixtures/error.xml
|
|
130
132
|
- spec/fixtures/slideshow.xml
|
|
131
133
|
- spec/fixtures/slideshow_detailed.xml
|
|
132
134
|
- spec/model/slideshow_spec.rb
|
|
@@ -157,6 +159,7 @@ specification_version: 4
|
|
|
157
159
|
summary: Ruby wrapper for the Slideshare API.
|
|
158
160
|
test_files:
|
|
159
161
|
- spec/client_spec.rb
|
|
162
|
+
- spec/fixtures/error.xml
|
|
160
163
|
- spec/fixtures/slideshow.xml
|
|
161
164
|
- spec/fixtures/slideshow_detailed.xml
|
|
162
165
|
- spec/model/slideshow_spec.rb
|