wikipedia-client 1.8.0 → 1.9.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 67327f1838111f1bed4ca3182d8cc835ea4e90a1
4
- data.tar.gz: f8d7f4f997ea1e8e75dcf218722e75bccc05943c
2
+ SHA256:
3
+ metadata.gz: 806d743adba4ad0839bbc288a7167e4b15ef7524c0ab9d6dabeaa463cb0960e6
4
+ data.tar.gz: 9e0a592a25a19f1581ecb2840bffffe17616e2fa01d7ba3ad66a9dc636f9cc8e
5
5
  SHA512:
6
- metadata.gz: 233353d769eb80065b44c2e18f109431d471f84b93daf5257f3de460a6d21f0deb581764cfc949c7431f89ec6e6db77b75a8d8f988ace6f8f1d26305a591f0f4
7
- data.tar.gz: 95cbac02fbe073e72b0ec9a2f6b8cd1874279492f83842c8ae1e166e9d000018f63fe02749be704fce9b3ab0a6c9455dbf31254bc1f79a9ef5a202ac7d5f4845
6
+ metadata.gz: 0aea030eca0258d932a780d0c9608f6e0d0dbdf0f1290b5b9d88e818888c04b06a994c077b30ec3b4d3f8d395f9b40b99df66f01c5e57db24fd9cba055ad1f45
7
+ data.tar.gz: 1b05e6e5908b44cf5955288c5222fe12716c3955b51ba24d0cec3504c2d9a2a04a65732d5d27ad6043ae6b2b464ab2732b1937544a6f94aaf96e66d6461ede09
@@ -24,4 +24,4 @@ Style/SymbolArray:
24
24
  Enabled: false
25
25
 
26
26
  Metrics/ClassLength:
27
- Max: 125
27
+ Max: 130
@@ -1,3 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.2
3
+ - 2.0
4
+ - 2.1
5
+ - 2.2
6
+ - 2.3
7
+ - 2.4
8
+ - 2.5
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- wikipedia-client (1.8.0)
4
+ wikipedia-client (1.9.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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
 
@@ -34,9 +34,10 @@ module Wikipedia
34
34
  def request_page( title, options = {} )
35
35
  request( {
36
36
  action: 'query',
37
- prop: %w[ info revisions links extlinks images categories coordinates templates extracts pageimages],
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 ).gsub( '&', '%26' )
108
+ URI.encode( val, /#{URI::UNSAFE}|[\+&]/ )
108
109
  else
109
110
  val
110
111
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Wikipedia
2
- VERSION = '1.8.0'.freeze
2
+ VERSION = '1.9.0'.freeze
3
3
  end
@@ -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.8.0
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: 2017-12-01 00:00:00.000000000 Z
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.6.13
198
+ rubygems_version: 2.7.3
199
199
  signing_key:
200
200
  specification_version: 3
201
201
  summary: Ruby client for the Wikipedia API