speakerdeck_api 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coveralls.yml +2 -0
- data/README.md +14 -6
- data/lib/speakerdeck_api/parser.rb +2 -0
- data/lib/speakerdeck_api/speaker.rb +3 -1
- data/lib/speakerdeck_api/version.rb +1 -1
- data/speakerdeck_api.gemspec +4 -3
- data/spec/speakerdeck_api/parser_spec.rb +17 -0
- data/spec/speakerdeck_api/speaker_spec.rb +17 -5
- data/spec/spec_helper.rb +3 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64783ecb5e2ae07f2e41ed298ab90ab16acb2513
|
4
|
+
data.tar.gz: 5b11580580d544528c1c849690e9a3a7e56a8390
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99eea920280c391e6ba8fcbc19f6c29f2e27a8e63080625a40781376b89bd501269e1c1b224ff3c83bc906fe98ecac1ba6181a759da51c17a79d0c2a98ee9501
|
7
|
+
data.tar.gz: 6de5e53771d1267a643da190e9435ce0307f7a939187c1f388b5639b006e7b8ef188cfaf89a7f3048776728fc5803311f8d7b16b284e8170d417246183d09aea
|
data/.coveralls.yml
ADDED
data/README.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/FerPerales/speakerdeck_api.png?branch=master)](https://travis-ci.org/FerPerales/speakerdeck_api)
|
4
4
|
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/speakerdeck_api.png)](http://badge.fury.io/rb/speakerdeck_api)
|
6
|
+
|
7
|
+
[![Coverage Status](https://coveralls.io/repos/FerPerales/speakerdeck_api/badge.png)](https://coveralls.io/r/FerPerales/speakerdeck-api)
|
8
|
+
|
5
9
|
A gem for getting data from speakerdeck.com
|
6
10
|
|
7
11
|
## Installation
|
@@ -28,18 +32,22 @@ First require the gem:
|
|
28
32
|
require 'speakerdeck_api'
|
29
33
|
```
|
30
34
|
|
31
|
-
At the moment, you can get the number of talks
|
35
|
+
At the moment, you can get the number of talks, name and website of a speaker via the
|
32
36
|
SpeakerdeckApi::Speaker class.
|
33
37
|
|
34
38
|
```ruby
|
35
|
-
speaker = SpeakerdeckApi::Speaker.get 'speakerdeck.
|
39
|
+
speaker = SpeakerdeckApi::Speaker.get 'speakerdeck.com_username'
|
36
40
|
```
|
37
41
|
|
38
|
-
This return an object with the
|
42
|
+
This return an object with the *number of talks*, *name*, and *website* attributes:
|
39
43
|
|
40
44
|
```ruby
|
41
45
|
speaker.number_of_talks
|
42
46
|
=> 8
|
47
|
+
speaker.name
|
48
|
+
=> 'Fake Guy'
|
49
|
+
speaker.website
|
50
|
+
=> 'http://fakeg.uy/'
|
43
51
|
```
|
44
52
|
|
45
53
|
You will get a SpeakerNotFound exception in case the provided speaker
|
@@ -47,12 +55,12 @@ name does not correspond to a speackerdeck.com user.
|
|
47
55
|
|
48
56
|
## Upcoming
|
49
57
|
|
50
|
-
|
51
|
-
|
58
|
+
- [x] Retrive more information about the speaker
|
59
|
+
- [ ] Add SpeakerdeckApi::Talk class to retrieve talk details
|
52
60
|
|
53
61
|
## Contributing
|
54
62
|
|
55
|
-
1. Fork it ( https://github.com/
|
63
|
+
1. Fork it ( https://github.com/FerPerales/speakerdeck_api/fork )
|
56
64
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
57
65
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
58
66
|
4. Push to the branch (`git push origin my-new-feature`)
|
@@ -4,6 +4,8 @@ module SpeakerdeckApi
|
|
4
4
|
def get_speaker_details(speaker_html)
|
5
5
|
info = {}
|
6
6
|
info[:number_of_talks] = speaker_html.css('.talk.public').size
|
7
|
+
info[:name] = speaker_html.css('.sidebar > h2').text
|
8
|
+
info[:website] = speaker_html.css('.bio > p > a').attribute('href').value
|
7
9
|
info
|
8
10
|
end
|
9
11
|
end
|
@@ -2,10 +2,12 @@ module SpeakerdeckApi
|
|
2
2
|
|
3
3
|
class Speaker
|
4
4
|
|
5
|
-
attr_reader :number_of_talks
|
5
|
+
attr_reader :number_of_talks, :name, :website
|
6
6
|
|
7
7
|
def initialize(params = {})
|
8
8
|
@number_of_talks = params[:number_of_talks] || 0
|
9
|
+
@name = params[:name] || ''
|
10
|
+
@website = params[:website] || ''
|
9
11
|
end
|
10
12
|
|
11
13
|
def self.get(speaker_name)
|
data/speakerdeck_api.gemspec
CHANGED
@@ -20,8 +20,9 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.add_development_dependency "bundler", "~> 1.7"
|
21
21
|
spec.add_development_dependency "rake", "~> 10.0"
|
22
22
|
spec.add_development_dependency "rspec"
|
23
|
-
spec.add_development_dependency
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
23
|
+
spec.add_development_dependency "nokogiri"
|
24
|
+
spec.add_development_dependency "pry"
|
25
|
+
spec.add_development_dependency "coveralls"
|
26
|
+
spec.add_development_dependency "pry-byebug"
|
26
27
|
|
27
28
|
end
|
@@ -20,6 +20,23 @@ module SpeakerdeckApi
|
|
20
20
|
it 'contains the right value' do
|
21
21
|
expect(subject.get_speaker_details(speaker_profile_page).values_at(:number_of_talks)).to eql([14])
|
22
22
|
end
|
23
|
+
|
24
|
+
it 'contains the "name" key' do
|
25
|
+
expect(subject.get_speaker_details(speaker_profile_page)).to have_key(:name)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'contains the right value' do
|
29
|
+
expect(subject.get_speaker_details(speaker_profile_page).values_at(:name)).to eql(["Fernando Perales"])
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'contains the "website" key' do
|
33
|
+
expect(subject.get_speaker_details(speaker_profile_page)).to have_key(:website)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'contains the right value' do
|
37
|
+
expect(subject.get_speaker_details(speaker_profile_page).values_at(:website)).to eql(["http://ferperales.net/"])
|
38
|
+
end
|
39
|
+
|
23
40
|
end
|
24
41
|
end
|
25
42
|
end
|
@@ -16,24 +16,36 @@ module SpeakerdeckApi
|
|
16
16
|
end
|
17
17
|
|
18
18
|
context 'with a valid username' do
|
19
|
+
|
19
20
|
it 'returns a SpeakerdeckApi::Speaker object' do
|
20
21
|
expect(subject.get('ferperales')).to be_a SpeakerdeckApi::Speaker
|
21
22
|
end
|
22
23
|
|
23
|
-
it 'contains the
|
24
|
+
it 'contains the number_of_talks attribute' do
|
24
25
|
expect(subject.get('ferperales')).to respond_to :number_of_talks
|
25
26
|
end
|
26
27
|
|
27
|
-
it 'contains the number of talks' do
|
28
|
+
it 'contains the correct number of talks' do
|
28
29
|
expect(subject.get('ferperales').number_of_talks).to eql 14
|
29
30
|
end
|
30
31
|
|
32
|
+
it 'contains the name attribute' do
|
33
|
+
expect(subject.get('ferperales')).to respond_to :name
|
34
|
+
end
|
31
35
|
|
36
|
+
it 'contains the correct name number' do
|
37
|
+
expect(subject.get('ferperales').name).to eql 'Fernando Perales'
|
38
|
+
end
|
32
39
|
|
33
|
-
|
40
|
+
it 'contains the website attribute' do
|
41
|
+
expect(subject.get('ferperales')).to respond_to :website
|
42
|
+
end
|
34
43
|
|
35
|
-
|
44
|
+
it 'contains the correct website number' do
|
45
|
+
expect(subject.get('ferperales').website).to eql 'http://ferperales.net/'
|
46
|
+
end
|
36
47
|
|
48
|
+
end
|
49
|
+
end
|
37
50
|
end
|
38
|
-
|
39
51
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: speakerdeck_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fer Perales
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: coveralls
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: pry-byebug
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -101,6 +115,7 @@ executables: []
|
|
101
115
|
extensions: []
|
102
116
|
extra_rdoc_files: []
|
103
117
|
files:
|
118
|
+
- ".coveralls.yml"
|
104
119
|
- ".gitignore"
|
105
120
|
- ".travis.yml"
|
106
121
|
- Gemfile
|