wikipedia-client 1.8.0 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +1 -1
- data/.travis.yml +6 -1
- data/Gemfile.lock +1 -1
- data/README.textile +1 -2
- data/lib/wikipedia/client.rb +3 -2
- data/lib/wikipedia/page.rb +4 -0
- data/lib/wikipedia/version.rb +1 -1
- data/spec/lib/client_spec.rb +16 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 806d743adba4ad0839bbc288a7167e4b15ef7524c0ab9d6dabeaa463cb0960e6
|
4
|
+
data.tar.gz: 9e0a592a25a19f1581ecb2840bffffe17616e2fa01d7ba3ad66a9dc636f9cc8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0aea030eca0258d932a780d0c9608f6e0d0dbdf0f1290b5b9d88e818888c04b06a994c077b30ec3b4d3f8d395f9b40b99df66f01c5e57db24fd9cba055ad1f45
|
7
|
+
data.tar.gz: 1b05e6e5908b44cf5955288c5222fe12716c3955b51ba24d0cec3504c2d9a2a04a65732d5d27ad6043ae6b2b464ab2732b1937544a6f94aaf96e66d6461ede09
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
data/README.textile
CHANGED
@@ -101,8 +101,7 @@ h2. Advanced
|
|
101
101
|
|
102
102
|
See the API spec at "http://en.wikipedia.org/w/api.php":http://en.wikipedia.org/w/api.php
|
103
103
|
|
104
|
-
If you need data that is not already present, you can override
|
105
|
-
parameters.
|
104
|
+
If you need data that is not already present, you can override parameters.
|
106
105
|
|
107
106
|
For example, to retrieve only the page info:
|
108
107
|
|
data/lib/wikipedia/client.rb
CHANGED
@@ -34,9 +34,10 @@ module Wikipedia
|
|
34
34
|
def request_page( title, options = {} )
|
35
35
|
request( {
|
36
36
|
action: 'query',
|
37
|
-
prop: %w[
|
37
|
+
prop: %w[info revisions links extlinks images categories coordinates templates extracts pageimages],
|
38
38
|
rvprop: 'content',
|
39
39
|
inprop: 'url',
|
40
|
+
pithumbsize: 200,
|
40
41
|
explaintext: '',
|
41
42
|
titles: title
|
42
43
|
}.merge( options ) )
|
@@ -104,7 +105,7 @@ module Wikipedia
|
|
104
105
|
def encode( val )
|
105
106
|
case val
|
106
107
|
when String
|
107
|
-
URI.encode( val
|
108
|
+
URI.encode( val, /#{URI::UNSAFE}|[\+&]/ )
|
108
109
|
else
|
109
110
|
val
|
110
111
|
end
|
data/lib/wikipedia/page.rb
CHANGED
@@ -93,6 +93,10 @@ module Wikipedia
|
|
93
93
|
page['thumbnail']['source'].sub(/\/thumb/, '').sub(/\/[^\/]*$/, '') if page['thumbnail']
|
94
94
|
end
|
95
95
|
|
96
|
+
def main_image_thumburl
|
97
|
+
page['thumbnail']['source'] if page['thumbnail']
|
98
|
+
end
|
99
|
+
|
96
100
|
def coordinates
|
97
101
|
page['coordinates'].first.values if page['coordinates']
|
98
102
|
end
|
data/lib/wikipedia/version.rb
CHANGED
data/spec/lib/client_spec.rb
CHANGED
@@ -90,6 +90,15 @@ describe Wikipedia::Client, '.find page with one section (mocked)' do
|
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
+
describe Wikipedia::Client, '.find page with special characters in title' do
|
94
|
+
it 'should properly escaped the special characters' do
|
95
|
+
@client = Wikipedia::Client.new
|
96
|
+
@page = @client.find('A +&%=?:/ B')
|
97
|
+
expect(@page.title).to eq('A +&%=?:/ B')
|
98
|
+
expect(@page.fullurl).to eq('https://en.wikipedia.org/wiki/A_%2B%26%25%3D%3F:/_B')
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
93
102
|
describe Wikipedia::Client, '.find image (mocked)' do
|
94
103
|
before(:each) do
|
95
104
|
@client = Wikipedia::Client.new
|
@@ -182,6 +191,13 @@ describe Wikipedia::Client, '.find page (Edsger_Dijkstra)' do
|
|
182
191
|
expect(@page.image_thumburls(100)).to include('https://upload.wikimedia.org/wikipedia' + image)
|
183
192
|
end
|
184
193
|
end
|
194
|
+
|
195
|
+
it 'should collect the main image thumburl' do
|
196
|
+
@client.follow_redirects = true
|
197
|
+
@page = @client.find('Edsger Dijkstra')
|
198
|
+
image = '/commons/thumb/d/d9/Edsger_Wybe_Dijkstra.jpg/150px-Edsger_Wybe_Dijkstra.jpg'
|
199
|
+
expect(@page.main_image_thumburl).to include('https://upload.wikimedia.org/wikipedia' + image)
|
200
|
+
end
|
185
201
|
end
|
186
202
|
|
187
203
|
describe Wikipedia::Client, '.find page (Rails) at jp' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wikipedia-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril David
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date:
|
16
|
+
date: 2018-02-28 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: rake
|
@@ -195,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
195
|
version: '0'
|
196
196
|
requirements: []
|
197
197
|
rubyforge_project:
|
198
|
-
rubygems_version: 2.
|
198
|
+
rubygems_version: 2.7.3
|
199
199
|
signing_key:
|
200
200
|
specification_version: 3
|
201
201
|
summary: Ruby client for the Wikipedia API
|