wikipedia-client 1.10.0 → 1.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +27 -0
- data/.gitignore +1 -0
- data/Gemfile +10 -0
- data/README.md +191 -0
- data/lib/wikipedia.rb +3 -13
- data/lib/wikipedia/client.rb +30 -27
- data/lib/wikipedia/configuration.rb +14 -7
- data/lib/wikipedia/url.rb +4 -1
- data/lib/wikipedia/version.rb +1 -1
- data/spec/lib/client_spec.rb +21 -14
- data/wikipedia-client.gemspec +2 -21
- metadata +14 -92
- data/.travis.yml +0 -8
- data/Gemfile.lock +0 -93
- data/README.textile +0 -168
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af50d4fda3d70e5bd837bde17b2ca86ec4c653c92891a5088246772da4ca45b5
|
4
|
+
data.tar.gz: 6366ad0bf999ed51533fd49963b4fa6d36e7181d49fc9bab227407cc3f76300f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0f6e70ee49591fb4fb1238cd35ede198ff14e6efd89ddfbc972e4c7b03ff3aeabc2770c80f7981af5ec30d820ffbd5ca4a4870da944686d612134d34dacde87
|
7
|
+
data.tar.gz: 701089ac1c06f95ea5b67afba9b7d6754c967d0d4411f7b95b3f8a8f456b9adabc4ab67036be5024c70a1d21022144a5e88d4693c76d719ab3ad4bff0cd01e9d
|
@@ -0,0 +1,27 @@
|
|
1
|
+
name: Test
|
2
|
+
on:
|
3
|
+
pull_request:
|
4
|
+
push: { branches: master }
|
5
|
+
|
6
|
+
jobs:
|
7
|
+
test:
|
8
|
+
name: Ruby ${{ matrix.ruby }}
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
strategy:
|
11
|
+
matrix: { ruby: ['2.5', '2.6', '2.7', '3.0'] }
|
12
|
+
|
13
|
+
steps:
|
14
|
+
- name: Checkout code
|
15
|
+
uses: actions/checkout@v2
|
16
|
+
|
17
|
+
- name: Setup Ruby
|
18
|
+
uses: ruby/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
ruby-version: '${{ matrix.ruby }}'
|
21
|
+
bundler-cache: true
|
22
|
+
|
23
|
+
- name: Run tests
|
24
|
+
run: bundle exec rspec
|
25
|
+
|
26
|
+
- name: Run rubocop
|
27
|
+
run: bundle exec rubocop
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.md
ADDED
@@ -0,0 +1,191 @@
|
|
1
|
+
# Wikipedia API Client
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/wikipedia-client.svg)](https://badge.fury.io/rb/wikipedia-client)
|
4
|
+
[![Build Status](https://github.com/kenpratt/wikipedia-client/workflows/Test/badge.svg)](https://github.com/kenpratt/wikipedia-client/actions?query=workflow%3ATest)
|
5
|
+
|
6
|
+
Allows you to get wikipedia content through their API. This uses the
|
7
|
+
alpha API, not the deprecated query.php API type.
|
8
|
+
|
9
|
+
Wikipedia API reference: <http://en.wikipedia.org/w/api.php>
|
10
|
+
|
11
|
+
Adopted from: <http://code.google.com/p/wikipedia-client/>
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
```
|
16
|
+
gem install wikipedia-client
|
17
|
+
```
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
require 'wikipedia'
|
23
|
+
page = Wikipedia.find( 'Getting Things Done' )
|
24
|
+
#=> #<Wikipedia:Page>
|
25
|
+
|
26
|
+
page.title
|
27
|
+
#=> 'Getting Things Done'
|
28
|
+
|
29
|
+
page.fullurl
|
30
|
+
#=> 'http://en.wikipedia.org/wiki/Getting_Things_Done'
|
31
|
+
|
32
|
+
page.text
|
33
|
+
#=> 'Getting Things Done is a time-management method...'
|
34
|
+
|
35
|
+
page.content
|
36
|
+
#=> all the wiki markup appears here...
|
37
|
+
|
38
|
+
page.summary
|
39
|
+
#=> only the wiki summary appears here...
|
40
|
+
|
41
|
+
page.categories
|
42
|
+
#=> [..., "Category:Self-help books", ...]
|
43
|
+
|
44
|
+
page.links
|
45
|
+
#=> [..., "Business", "Cult following", ...]
|
46
|
+
|
47
|
+
page.extlinks
|
48
|
+
# => [..., "http://www.example.com/", ...]
|
49
|
+
|
50
|
+
page.images
|
51
|
+
#=> ["File:Getting Things Done.jpg", ...]
|
52
|
+
|
53
|
+
page.image_urls
|
54
|
+
#=> ["http://upload.wikimedia.org/wikipedia/en/e/e1/Getting_Things_Done.jpg"]
|
55
|
+
|
56
|
+
page.image_thumburls
|
57
|
+
#=> ["https://upload.wikimedia.org/wikipedia/en/thumb/e/e1/Getting_Things_Done.jpg/200px-Getting_Things_Done.jpg"]
|
58
|
+
|
59
|
+
# or with custom width argument:
|
60
|
+
page.image_thumburls(100)
|
61
|
+
#=> ["https://upload.wikimedia.org/wikipedia/en/thumb/e/e1/Getting_Things_Done.jpg/100px-Getting_Things_Done.jpg"]
|
62
|
+
|
63
|
+
page.image_descriptionurls
|
64
|
+
#=> ["http://en.wikipedia.org/wiki/File:Getting_Things_Done.jpg"]
|
65
|
+
|
66
|
+
page.main_image_url
|
67
|
+
#=> "https://upload.wikimedia.org/wikipedia/en/e/e1/Getting_Things_Done.jpg"
|
68
|
+
|
69
|
+
page.coordinates
|
70
|
+
#=> [48.853, 2.3498, "", "earth"]
|
71
|
+
|
72
|
+
page.templates
|
73
|
+
#=> [..., "Template:About", ...]
|
74
|
+
|
75
|
+
page.langlinks
|
76
|
+
#=> {..., "de"=>"Getting Things Done", "eo"=>"Igi aferojn finitaj", "zh"=>"尽管去做", ...}
|
77
|
+
```
|
78
|
+
|
79
|
+
## Configuration
|
80
|
+
|
81
|
+
### Global
|
82
|
+
|
83
|
+
This is by default configured like this:
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
Wikipedia.configure {
|
87
|
+
domain 'en.wikipedia.org'
|
88
|
+
path 'w/api.php'
|
89
|
+
}
|
90
|
+
```
|
91
|
+
|
92
|
+
### Local
|
93
|
+
|
94
|
+
If you need to query multiple wikis indiviual clients with individual configurations can be
|
95
|
+
used:
|
96
|
+
|
97
|
+
```ruby
|
98
|
+
config_en = Wikipedia::Configuration.new(domain: 'en.wikipedia.org')
|
99
|
+
config_de = Wikipedia::Configuration.new(domain: 'de.wikipedia.org')
|
100
|
+
|
101
|
+
client_en = Wikipedia::Client.new(config_en)
|
102
|
+
client_de = Wikipedia::Client.new(config_de)
|
103
|
+
client_en.find( 'Getting Things Done' )
|
104
|
+
client_de.find( 'Buch' )
|
105
|
+
```
|
106
|
+
|
107
|
+
## Advanced
|
108
|
+
|
109
|
+
See the API spec at <http://en.wikipedia.org/w/api.php>.
|
110
|
+
|
111
|
+
If you need data that is not already present, you can override parameters.
|
112
|
+
|
113
|
+
For example, to retrieve only the page info:
|
114
|
+
|
115
|
+
```ruby
|
116
|
+
page = Wikipedia.find( 'Getting Things Done', :prop => "info" )
|
117
|
+
|
118
|
+
page.title
|
119
|
+
#=> "Getting Things Done"
|
120
|
+
|
121
|
+
page.raw_data
|
122
|
+
#=> {"query"=>{"pages"=>{"959928"=>{"pageid"=>959928, "ns"=>0,
|
123
|
+
"title"=>"Getting Things Done", "touched"=>"2010-03-10T00:04:09Z",
|
124
|
+
"lastrevid"=>348481810, "counter"=>0, "length"=>7891}}}}
|
125
|
+
```
|
126
|
+
|
127
|
+
## Contributing
|
128
|
+
|
129
|
+
### Getting the code, and running the tests
|
130
|
+
|
131
|
+
```
|
132
|
+
git clone git@github.com:kenpratt/wikipedia-client.git
|
133
|
+
cd wikipedia-client
|
134
|
+
bundle install
|
135
|
+
bundle exec rspec
|
136
|
+
```
|
137
|
+
|
138
|
+
### Pushing a new release of the Gem
|
139
|
+
|
140
|
+
1. Edit `lib/wikipedia/version.rb`, changing `VERSION`.
|
141
|
+
2. Test that the current branch will work as a gem, by testing in an external directory:
|
142
|
+
3. Make a test directory.
|
143
|
+
4. Add a `Gemfile` with:
|
144
|
+
|
145
|
+
```
|
146
|
+
source 'https://rubygems.org'
|
147
|
+
|
148
|
+
gem 'wikipedia-client', :path => '/path/to/local/wikipedia-client'
|
149
|
+
```
|
150
|
+
|
151
|
+
5. And a `test.rb` file with:
|
152
|
+
|
153
|
+
```
|
154
|
+
require 'wikipedia'
|
155
|
+
|
156
|
+
page = Wikipedia.find('Ruby')
|
157
|
+
puts page.title
|
158
|
+
```
|
159
|
+
|
160
|
+
6. And then run `bundle install && bundle exec ruby test.rb`
|
161
|
+
7. Build the gem: `bundle exec gem build wikipedia-client.gemspec`.
|
162
|
+
8. Commit the changes: `git commit -a -m 'Version bump to 1.4.0' && git tag v1.4.0 && git push && git push --tag`
|
163
|
+
9. Publish the result to RubyGems: `bundle exec gem push wikipedia-client-1.4.0.gem`.
|
164
|
+
10. Test the released gem in an external directory:
|
165
|
+
11. Make a test directory.
|
166
|
+
12. Add a `Gemfile` with:
|
167
|
+
|
168
|
+
```
|
169
|
+
source 'https://rubygems.org'
|
170
|
+
|
171
|
+
gem 'wikipedia-client'
|
172
|
+
```
|
173
|
+
|
174
|
+
13. And a `test.rb` file with:
|
175
|
+
|
176
|
+
```
|
177
|
+
require 'wikipedia'
|
178
|
+
|
179
|
+
page = Wikipedia.find('Ruby')
|
180
|
+
puts page.title
|
181
|
+
```
|
182
|
+
|
183
|
+
14. And then run `bundle install && bundle exec ruby test.rb`
|
184
|
+
|
185
|
+
## Thanks!
|
186
|
+
|
187
|
+
Copyright (c) 2008 Cyril David, released under the MIT license
|
188
|
+
|
189
|
+
Adopted by Ken Pratt (ken@kenpratt.net) in 2010/03
|
190
|
+
|
191
|
+
Thanks to all the [Contributors](https://github.com/kenpratt/wikipedia-client/graphs/contributors).
|
data/lib/wikipedia.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
Dir[File.dirname(__FILE__) + '/wikipedia/**/*.rb'].each { |f| require f }
|
2
2
|
|
3
|
-
require 'uri'
|
4
|
-
|
5
3
|
module Wikipedia
|
6
4
|
# Examples :
|
7
5
|
# page = Wikipedia.find('Rails')
|
@@ -26,7 +24,7 @@ module Wikipedia
|
|
26
24
|
end
|
27
25
|
|
28
26
|
def self.configure(&block)
|
29
|
-
|
27
|
+
@configuration.instance_eval(&block)
|
30
28
|
end
|
31
29
|
|
32
30
|
# rubocop:disable Style/MethodName
|
@@ -34,20 +32,12 @@ module Wikipedia
|
|
34
32
|
configure(&block)
|
35
33
|
end
|
36
34
|
|
37
|
-
configure do
|
38
|
-
protocol 'https'
|
39
|
-
domain 'en.wikipedia.org'
|
40
|
-
path 'w/api.php'
|
41
|
-
user_agent(
|
42
|
-
'wikipedia-client/1.7 (https://github.com/kenpratt/wikipedia-client)'
|
43
|
-
)
|
44
|
-
end
|
45
|
-
|
46
35
|
class << self
|
47
36
|
private
|
48
37
|
|
49
38
|
def client
|
50
|
-
@
|
39
|
+
@configuration ||= Wikipedia::Configuration.new
|
40
|
+
@client ||= Wikipedia::Client.new @configuration
|
51
41
|
end
|
52
42
|
end
|
53
43
|
end
|
data/lib/wikipedia/client.rb
CHANGED
@@ -1,11 +1,18 @@
|
|
1
|
+
require 'addressable'
|
2
|
+
require 'cgi'
|
3
|
+
require 'open-uri'
|
4
|
+
require 'set'
|
5
|
+
|
1
6
|
module Wikipedia
|
2
7
|
class Client
|
3
8
|
# see http://en.wikipedia.org/w/api.php
|
4
|
-
|
9
|
+
BASE_URL_TEMPLATE = '%{protocol}://%{domain}/%{path}?action=%{action}&format=json'.freeze
|
10
|
+
BASE_URL_OPTIONS = Set.new([:protocol, :domain, :path, :action])
|
5
11
|
|
6
12
|
attr_accessor :follow_redirects
|
7
13
|
|
8
|
-
def initialize
|
14
|
+
def initialize(configuration = Wikipedia::Configuration.new)
|
15
|
+
@configuration = configuration
|
9
16
|
self.follow_redirects = true
|
10
17
|
end
|
11
18
|
|
@@ -66,50 +73,46 @@ module Wikipedia
|
|
66
73
|
end
|
67
74
|
|
68
75
|
def request( options )
|
69
|
-
|
70
|
-
URI.parse( url_for( options ) ).read( 'User-Agent' => Configuration[:user_agent] )
|
76
|
+
URI.parse( url_for( options ) ).read( 'User-Agent' => @configuration[:user_agent] )
|
71
77
|
end
|
72
78
|
|
73
79
|
protected
|
74
80
|
|
75
81
|
def configuration_options
|
76
82
|
{
|
77
|
-
protocol:
|
78
|
-
domain:
|
79
|
-
path:
|
83
|
+
protocol: @configuration[:protocol],
|
84
|
+
domain: @configuration[:domain],
|
85
|
+
path: @configuration[:path]
|
80
86
|
}
|
81
87
|
end
|
82
88
|
|
83
|
-
def url_for(
|
84
|
-
url = BASE_URL.dup
|
89
|
+
def url_for(options)
|
85
90
|
options = configuration_options.merge( options )
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
end
|
94
|
-
url
|
91
|
+
|
92
|
+
url_options, query_options = split_hash(options, BASE_URL_OPTIONS)
|
93
|
+
normalized_query_options = query_options.map { |k, v| [k, normalize_value(v)] }
|
94
|
+
|
95
|
+
base_url = BASE_URL_TEMPLATE % url_options
|
96
|
+
query_string = Addressable::URI.form_encode(normalized_query_options)
|
97
|
+
base_url + '&' + query_string
|
95
98
|
end
|
96
99
|
|
97
|
-
def
|
100
|
+
def normalize_value( val )
|
98
101
|
case val
|
99
102
|
when Array
|
100
|
-
|
103
|
+
val.flatten.join( '|' )
|
101
104
|
else
|
102
|
-
|
105
|
+
val
|
103
106
|
end
|
104
107
|
end
|
105
108
|
|
106
|
-
def
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
val
|
109
|
+
def split_hash(hash, keys)
|
110
|
+
h1 = {}
|
111
|
+
h2 = {}
|
112
|
+
hash.each do |k, v|
|
113
|
+
(keys.include?(k) ? h1 : h2).store(k, v)
|
112
114
|
end
|
115
|
+
[h1, h2]
|
113
116
|
end
|
114
117
|
end
|
115
118
|
end
|
@@ -1,8 +1,19 @@
|
|
1
|
-
require 'singleton'
|
2
|
-
|
3
1
|
module Wikipedia
|
4
2
|
class Configuration
|
5
|
-
|
3
|
+
DEFAULT = {
|
4
|
+
protocol: 'https',
|
5
|
+
domain: 'en.wikipedia.org',
|
6
|
+
path: 'w/api.php',
|
7
|
+
user_agent: 'wikipedia-client/1.7 (https://github.com/kenpratt/wikipedia-client)'
|
8
|
+
}.freeze
|
9
|
+
|
10
|
+
def initialize(configuration = DEFAULT)
|
11
|
+
DEFAULT.merge(configuration).each { |args| send(*args) }
|
12
|
+
end
|
13
|
+
|
14
|
+
def [](directive)
|
15
|
+
send(directive)
|
16
|
+
end
|
6
17
|
|
7
18
|
def self.directives(*directives)
|
8
19
|
directives.each do |directive|
|
@@ -14,10 +25,6 @@ module Wikipedia
|
|
14
25
|
end
|
15
26
|
end
|
16
27
|
|
17
|
-
def self.[](directive)
|
18
|
-
instance.send(directive)
|
19
|
-
end
|
20
|
-
|
21
28
|
directives :protocol, :domain, :path, :user_agent
|
22
29
|
end
|
23
30
|
end
|
data/lib/wikipedia/url.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'addressable'
|
3
|
+
|
1
4
|
module Wikipedia
|
2
5
|
class Url
|
3
6
|
def initialize(wiki_url)
|
@@ -8,7 +11,7 @@ module Wikipedia
|
|
8
11
|
return @title if @title
|
9
12
|
|
10
13
|
uri = URI.parse( @wiki_url )
|
11
|
-
@title = URI.
|
14
|
+
@title = Addressable::URI.unencode( uri.path.sub(/\/wiki\//, '') )
|
12
15
|
end
|
13
16
|
end
|
14
17
|
end
|
data/lib/wikipedia/version.rb
CHANGED
data/spec/lib/client_spec.rb
CHANGED
@@ -161,14 +161,9 @@ describe Wikipedia::Client, '.find page (Edsger_Dijkstra)' do
|
|
161
161
|
@client.follow_redirects = true
|
162
162
|
@page = @client.find('Edsger Dijkstra')
|
163
163
|
[
|
164
|
-
'/en/4/4a/Commons-logo.svg',
|
165
|
-
'/en/4/48/Folder_Hexagonal_Icon.svg',
|
166
164
|
'/commons/5/57/Dijkstra_Animation.gif',
|
167
165
|
'/commons/c/c9/Edsger_Dijkstra_1994.jpg',
|
168
|
-
'/commons/d/d9/Edsger_Wybe_Dijkstra.jpg'
|
169
|
-
'/en/4/4d/Centrum-wiskunde-informatica-logo.png',
|
170
|
-
'/commons/7/7b/An_illustration_of_the_dining_philosophers_problem.png',
|
171
|
-
'/commons/3/37/Detail_of_a_1Kb_ferrite_core_RAM-module_of_an_1960s_Electrologica_X1_computer.jpg'
|
166
|
+
'/commons/d/d9/Edsger_Wybe_Dijkstra.jpg'
|
172
167
|
].each do |image|
|
173
168
|
expect(@page.image_urls).to include('https://upload.wikimedia.org/wikipedia' + image)
|
174
169
|
end
|
@@ -178,12 +173,9 @@ describe Wikipedia::Client, '.find page (Edsger_Dijkstra)' do
|
|
178
173
|
@client.follow_redirects = true
|
179
174
|
@page = @client.find('Edsger Dijkstra')
|
180
175
|
[
|
181
|
-
'/en/thumb/4/4a/Commons-logo.svg/200px-Commons-logo.svg.png',
|
182
|
-
'/en/thumb/4/48/Folder_Hexagonal_Icon.svg/200px-Folder_Hexagonal_Icon.svg.png',
|
183
176
|
'/commons/thumb/5/57/Dijkstra_Animation.gif/200px-Dijkstra_Animation.gif',
|
184
177
|
'/commons/thumb/c/c9/Edsger_Dijkstra_1994.jpg/200px-Edsger_Dijkstra_1994.jpg',
|
185
|
-
'/commons/thumb/d/d9/Edsger_Wybe_Dijkstra.jpg/200px-Edsger_Wybe_Dijkstra.jpg'
|
186
|
-
'/en/thumb/4/4d/Centrum-wiskunde-informatica-logo.png/200px-Centrum-wiskunde-informatica-logo.png'
|
178
|
+
'/commons/thumb/d/d9/Edsger_Wybe_Dijkstra.jpg/200px-Edsger_Wybe_Dijkstra.jpg'
|
187
179
|
].each do |image|
|
188
180
|
expect(@page.image_thumburls).to include('https://upload.wikimedia.org/wikipedia' + image)
|
189
181
|
end
|
@@ -193,12 +185,9 @@ describe Wikipedia::Client, '.find page (Edsger_Dijkstra)' do
|
|
193
185
|
@client.follow_redirects = true
|
194
186
|
@page = @client.find('Edsger Dijkstra')
|
195
187
|
[
|
196
|
-
'/en/thumb/4/4a/Commons-logo.svg/100px-Commons-logo.svg.png',
|
197
|
-
'/en/thumb/4/48/Folder_Hexagonal_Icon.svg/100px-Folder_Hexagonal_Icon.svg.png',
|
198
188
|
'/commons/thumb/5/57/Dijkstra_Animation.gif/100px-Dijkstra_Animation.gif',
|
199
189
|
'/commons/thumb/c/c9/Edsger_Dijkstra_1994.jpg/100px-Edsger_Dijkstra_1994.jpg',
|
200
|
-
'/commons/thumb/d/d9/Edsger_Wybe_Dijkstra.jpg/100px-Edsger_Wybe_Dijkstra.jpg'
|
201
|
-
'/en/thumb/4/4d/Centrum-wiskunde-informatica-logo.png/100px-Centrum-wiskunde-informatica-logo.png'
|
190
|
+
'/commons/thumb/d/d9/Edsger_Wybe_Dijkstra.jpg/100px-Edsger_Wybe_Dijkstra.jpg'
|
202
191
|
].each do |image|
|
203
192
|
expect(@page.image_thumburls(100)).to include('https://upload.wikimedia.org/wikipedia' + image)
|
204
193
|
end
|
@@ -296,3 +285,21 @@ describe Wikipedia::Client, 'page.langlinks' do
|
|
296
285
|
)
|
297
286
|
end
|
298
287
|
end
|
288
|
+
|
289
|
+
describe Wikipedia::Client, 'multiple configs' do
|
290
|
+
before(:each) do
|
291
|
+
config_en = Wikipedia::Configuration.new(domain: 'en.wikipedia.org')
|
292
|
+
config_de = Wikipedia::Configuration.new(domain: 'de.wikipedia.org')
|
293
|
+
|
294
|
+
@client_en = Wikipedia::Client.new(config_en)
|
295
|
+
@client_de = Wikipedia::Client.new(config_de)
|
296
|
+
end
|
297
|
+
|
298
|
+
it 'should return a page with the correct URL' do
|
299
|
+
@page_en = @client_en.find('Edsger_Dijkstra')
|
300
|
+
expect(@page_en.fullurl).to eq('https://en.wikipedia.org/wiki/Edsger_W._Dijkstra')
|
301
|
+
|
302
|
+
@page_de = @client_de.find('Edsger_Dijkstra')
|
303
|
+
expect(@page_de.fullurl).to eq('https://de.wikipedia.org/wiki/Edsger_W._Dijkstra')
|
304
|
+
end
|
305
|
+
end
|
data/wikipedia-client.gemspec
CHANGED
@@ -4,7 +4,6 @@ $LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
|
4
4
|
require 'wikipedia/version'
|
5
5
|
require 'date'
|
6
6
|
|
7
|
-
# rubocop:disable Metrics/BlockLength
|
8
7
|
Gem::Specification.new do |s|
|
9
8
|
s.name = 'wikipedia-client'
|
10
9
|
s.version = Wikipedia::VERSION
|
@@ -19,34 +18,16 @@ Gem::Specification.new do |s|
|
|
19
18
|
s.email = 'ken@kenpratt.net'
|
20
19
|
|
21
20
|
s.homepage = 'http://github.com/kenpratt/wikipedia-client'
|
22
|
-
s.rubygems_version = '1.8.23'
|
23
21
|
s.summary = 'Ruby client for the Wikipedia API'
|
24
22
|
s.platform = Gem::Platform::RUBY
|
25
23
|
s.files = `git ls-files`.split("\n")
|
26
24
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
27
25
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
28
|
-
s.
|
29
|
-
s.extra_rdoc_files = ['README.textile']
|
26
|
+
s.extra_rdoc_files = ['README.md']
|
30
27
|
s.bindir = 'bin'
|
31
28
|
|
32
29
|
s.require_paths << 'lib'
|
33
30
|
s.rdoc_options << '--title' << 'wikipedia-client' << '--main' << '-ri'
|
34
31
|
|
35
|
-
s.
|
36
|
-
s.add_development_dependency('rspec', '~> 3.0')
|
37
|
-
s.add_development_dependency('rdoc', '~> 4.0')
|
38
|
-
s.add_development_dependency('jeweler', '~> 1.8')
|
39
|
-
s.add_development_dependency('rubocop', '~> 0.48')
|
40
|
-
|
41
|
-
if s.respond_to? :specification_version
|
42
|
-
s.specification_version = 3
|
43
|
-
|
44
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0')
|
45
|
-
s.add_development_dependency('thoughtbot-shoulda', '~> 2.11', ['>= 2.11'])
|
46
|
-
else
|
47
|
-
s.add_dependency('thoughtbot-shoulda', ['>= 0'])
|
48
|
-
end
|
49
|
-
else
|
50
|
-
s.add_dependency('thoughtbot-shoulda', ['>= 0'])
|
51
|
-
end
|
32
|
+
s.add_runtime_dependency 'addressable', '~> 2.7'
|
52
33
|
end
|
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.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril David
|
@@ -10,116 +10,39 @@ authors:
|
|
10
10
|
- Aishwarya Subramanian
|
11
11
|
- Pietro Menna
|
12
12
|
- Sophie Rapoport
|
13
|
-
autorequire:
|
13
|
+
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date:
|
16
|
+
date: 2021-07-06 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
|
-
name:
|
19
|
+
name: addressable
|
20
20
|
requirement: !ruby/object:Gem::Requirement
|
21
21
|
requirements:
|
22
22
|
- - "~>"
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: '
|
25
|
-
type: :
|
24
|
+
version: '2.7'
|
25
|
+
type: :runtime
|
26
26
|
prerelease: false
|
27
27
|
version_requirements: !ruby/object:Gem::Requirement
|
28
28
|
requirements:
|
29
29
|
- - "~>"
|
30
30
|
- !ruby/object:Gem::Version
|
31
|
-
version: '
|
32
|
-
- !ruby/object:Gem::Dependency
|
33
|
-
name: rspec
|
34
|
-
requirement: !ruby/object:Gem::Requirement
|
35
|
-
requirements:
|
36
|
-
- - "~>"
|
37
|
-
- !ruby/object:Gem::Version
|
38
|
-
version: '3.0'
|
39
|
-
type: :development
|
40
|
-
prerelease: false
|
41
|
-
version_requirements: !ruby/object:Gem::Requirement
|
42
|
-
requirements:
|
43
|
-
- - "~>"
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '3.0'
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: rdoc
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
requirements:
|
50
|
-
- - "~>"
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version: '4.0'
|
53
|
-
type: :development
|
54
|
-
prerelease: false
|
55
|
-
version_requirements: !ruby/object:Gem::Requirement
|
56
|
-
requirements:
|
57
|
-
- - "~>"
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
version: '4.0'
|
60
|
-
- !ruby/object:Gem::Dependency
|
61
|
-
name: jeweler
|
62
|
-
requirement: !ruby/object:Gem::Requirement
|
63
|
-
requirements:
|
64
|
-
- - "~>"
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: '1.8'
|
67
|
-
type: :development
|
68
|
-
prerelease: false
|
69
|
-
version_requirements: !ruby/object:Gem::Requirement
|
70
|
-
requirements:
|
71
|
-
- - "~>"
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
version: '1.8'
|
74
|
-
- !ruby/object:Gem::Dependency
|
75
|
-
name: rubocop
|
76
|
-
requirement: !ruby/object:Gem::Requirement
|
77
|
-
requirements:
|
78
|
-
- - "~>"
|
79
|
-
- !ruby/object:Gem::Version
|
80
|
-
version: '0.48'
|
81
|
-
type: :development
|
82
|
-
prerelease: false
|
83
|
-
version_requirements: !ruby/object:Gem::Requirement
|
84
|
-
requirements:
|
85
|
-
- - "~>"
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
version: '0.48'
|
88
|
-
- !ruby/object:Gem::Dependency
|
89
|
-
name: thoughtbot-shoulda
|
90
|
-
requirement: !ruby/object:Gem::Requirement
|
91
|
-
requirements:
|
92
|
-
- - "~>"
|
93
|
-
- !ruby/object:Gem::Version
|
94
|
-
version: '2.11'
|
95
|
-
- - ">="
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
version: '2.11'
|
98
|
-
type: :development
|
99
|
-
prerelease: false
|
100
|
-
version_requirements: !ruby/object:Gem::Requirement
|
101
|
-
requirements:
|
102
|
-
- - "~>"
|
103
|
-
- !ruby/object:Gem::Version
|
104
|
-
version: '2.11'
|
105
|
-
- - ">="
|
106
|
-
- !ruby/object:Gem::Version
|
107
|
-
version: '2.11'
|
31
|
+
version: '2.7'
|
108
32
|
description: Ruby client for the Wikipedia API
|
109
33
|
email: ken@kenpratt.net
|
110
34
|
executables: []
|
111
35
|
extensions: []
|
112
36
|
extra_rdoc_files:
|
113
|
-
- README.
|
37
|
+
- README.md
|
114
38
|
files:
|
115
39
|
- ".editorconfig"
|
40
|
+
- ".github/workflows/test.yml"
|
116
41
|
- ".gitignore"
|
117
42
|
- ".rubocop.yml"
|
118
|
-
- ".travis.yml"
|
119
43
|
- Gemfile
|
120
|
-
- Gemfile.lock
|
121
44
|
- MIT-LICENSE
|
122
|
-
- README.
|
45
|
+
- README.md
|
123
46
|
- Rakefile
|
124
47
|
- init.rb
|
125
48
|
- install.rb
|
@@ -175,7 +98,7 @@ homepage: http://github.com/kenpratt/wikipedia-client
|
|
175
98
|
licenses:
|
176
99
|
- MIT
|
177
100
|
metadata: {}
|
178
|
-
post_install_message:
|
101
|
+
post_install_message:
|
179
102
|
rdoc_options:
|
180
103
|
- "--title"
|
181
104
|
- wikipedia-client
|
@@ -195,10 +118,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
118
|
- !ruby/object:Gem::Version
|
196
119
|
version: '0'
|
197
120
|
requirements: []
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
specification_version: 3
|
121
|
+
rubygems_version: 3.0.3
|
122
|
+
signing_key:
|
123
|
+
specification_version: 4
|
202
124
|
summary: Ruby client for the Wikipedia API
|
203
125
|
test_files:
|
204
126
|
- spec/fixtures/Edsger_Dijkstra.json
|
data/.travis.yml
DELETED
data/Gemfile.lock
DELETED
@@ -1,93 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
wikipedia-client (1.10.0)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
addressable (2.3.5)
|
10
|
-
ast (2.3.0)
|
11
|
-
builder (3.2.2)
|
12
|
-
diff-lcs (1.3)
|
13
|
-
faraday (0.8.8)
|
14
|
-
multipart-post (~> 1.2.0)
|
15
|
-
git (1.2.6)
|
16
|
-
github_api (0.10.1)
|
17
|
-
addressable
|
18
|
-
faraday (~> 0.8.1)
|
19
|
-
hashie (>= 1.2)
|
20
|
-
multi_json (~> 1.4)
|
21
|
-
nokogiri (~> 1.5.2)
|
22
|
-
oauth2
|
23
|
-
hashie (2.0.5)
|
24
|
-
highline (1.6.19)
|
25
|
-
httpauth (0.2.0)
|
26
|
-
jeweler (1.8.8)
|
27
|
-
builder
|
28
|
-
bundler (~> 1.0)
|
29
|
-
git (>= 1.2.5)
|
30
|
-
github_api (= 0.10.1)
|
31
|
-
highline (>= 1.6.15)
|
32
|
-
nokogiri (= 1.5.10)
|
33
|
-
rake
|
34
|
-
rdoc
|
35
|
-
json (1.8.6)
|
36
|
-
jwt (0.1.8)
|
37
|
-
multi_json (>= 1.5)
|
38
|
-
multi_json (1.8.1)
|
39
|
-
multi_xml (0.5.5)
|
40
|
-
multipart-post (1.2.0)
|
41
|
-
nokogiri (1.5.10)
|
42
|
-
oauth2 (0.9.2)
|
43
|
-
faraday (~> 0.8)
|
44
|
-
httpauth (~> 0.2)
|
45
|
-
jwt (~> 0.1.4)
|
46
|
-
multi_json (~> 1.0)
|
47
|
-
multi_xml (~> 0.5)
|
48
|
-
rack (~> 1.2)
|
49
|
-
parser (2.4.0.0)
|
50
|
-
ast (~> 2.2)
|
51
|
-
powerpack (0.1.1)
|
52
|
-
rack (1.5.2)
|
53
|
-
rainbow (2.2.2)
|
54
|
-
rake
|
55
|
-
rake (10.1.0)
|
56
|
-
rdoc (4.0.1)
|
57
|
-
json (~> 1.4)
|
58
|
-
rspec (3.0.0)
|
59
|
-
rspec-core (~> 3.0.0)
|
60
|
-
rspec-expectations (~> 3.0.0)
|
61
|
-
rspec-mocks (~> 3.0.0)
|
62
|
-
rspec-core (3.0.4)
|
63
|
-
rspec-support (~> 3.0.0)
|
64
|
-
rspec-expectations (3.0.4)
|
65
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
66
|
-
rspec-support (~> 3.0.0)
|
67
|
-
rspec-mocks (3.0.4)
|
68
|
-
rspec-support (~> 3.0.0)
|
69
|
-
rspec-support (3.0.4)
|
70
|
-
rubocop (0.48.1)
|
71
|
-
parser (>= 2.3.3.1, < 3.0)
|
72
|
-
powerpack (~> 0.1)
|
73
|
-
rainbow (>= 1.99.1, < 3.0)
|
74
|
-
ruby-progressbar (~> 1.7)
|
75
|
-
unicode-display_width (~> 1.0, >= 1.0.1)
|
76
|
-
ruby-progressbar (1.8.1)
|
77
|
-
thoughtbot-shoulda (2.11.1)
|
78
|
-
unicode-display_width (1.2.1)
|
79
|
-
|
80
|
-
PLATFORMS
|
81
|
-
ruby
|
82
|
-
|
83
|
-
DEPENDENCIES
|
84
|
-
jeweler (~> 1.8)
|
85
|
-
rake (~> 10.1)
|
86
|
-
rdoc (~> 4.0)
|
87
|
-
rspec (~> 3.0)
|
88
|
-
rubocop (~> 0.48)
|
89
|
-
thoughtbot-shoulda (~> 2.11, >= 2.11)
|
90
|
-
wikipedia-client!
|
91
|
-
|
92
|
-
BUNDLED WITH
|
93
|
-
1.15.1
|
data/README.textile
DELETED
@@ -1,168 +0,0 @@
|
|
1
|
-
h1. Wikipedia
|
2
|
-
|
3
|
-
!https://badge.fury.io/rb/wikipedia-client.svg!:https://badge.fury.io/rb/wikipedia-client !https://travis-ci.org/kenpratt/wikipedia-client.svg?branch=master!:https://travis-ci.org/kenpratt/wikipedia-client
|
4
|
-
|
5
|
-
Allows you to get wikipedia content through their API. This uses the
|
6
|
-
alpha API, not the deprecated query.php API type
|
7
|
-
|
8
|
-
Wikipedia API reference: "http://en.wikipedia.org/w/api.php":http://en.wikipedia.org/w/api.php
|
9
|
-
|
10
|
-
Adopted from: "http://code.google.com/p/wikipedia-client/":http://code.google.com/p/wikipedia-client/
|
11
|
-
|
12
|
-
h2. Installation
|
13
|
-
|
14
|
-
<pre><code>gem install wikipedia-client</code></pre>
|
15
|
-
|
16
|
-
h2. Examples
|
17
|
-
|
18
|
-
<pre><code>require 'wikipedia'
|
19
|
-
page = Wikipedia.find( 'Getting Things Done' )
|
20
|
-
|
21
|
-
=> #<Wikipedia:Page>
|
22
|
-
|
23
|
-
page.title
|
24
|
-
|
25
|
-
=> 'Getting Things Done'
|
26
|
-
|
27
|
-
page.fullurl
|
28
|
-
|
29
|
-
=> 'http://en.wikipedia.org/wiki/Getting_Things_Done'
|
30
|
-
|
31
|
-
page.text
|
32
|
-
|
33
|
-
=> 'Getting Things Done is a time-management method...'
|
34
|
-
|
35
|
-
page.content
|
36
|
-
|
37
|
-
=> # all the wiki markup appears here...
|
38
|
-
|
39
|
-
page.summary
|
40
|
-
|
41
|
-
=> # only the wiki summary appears here...
|
42
|
-
|
43
|
-
page.categories
|
44
|
-
|
45
|
-
=> [..., "Category:Self-help books", ...]
|
46
|
-
|
47
|
-
page.links
|
48
|
-
|
49
|
-
=> [..., "Business", "Cult following", ...]
|
50
|
-
|
51
|
-
page.extlinks
|
52
|
-
|
53
|
-
=> [..., "http://www.example.com/", ...]
|
54
|
-
|
55
|
-
page.images
|
56
|
-
|
57
|
-
=> ["File:Getting Things Done.jpg", ...]
|
58
|
-
|
59
|
-
page.image_urls
|
60
|
-
|
61
|
-
=> ["http://upload.wikimedia.org/wikipedia/en/e/e1/Getting_Things_Done.jpg"]
|
62
|
-
|
63
|
-
default width: 200
|
64
|
-
|
65
|
-
page.image_thumburls
|
66
|
-
|
67
|
-
=> ["https://upload.wikimedia.org/wikipedia/en/thumb/e/e1/Getting_Things_Done.jpg/200px-Getting_Things_Done.jpg"]
|
68
|
-
|
69
|
-
or with custom width argument:
|
70
|
-
|
71
|
-
page.image_thumburls(100)
|
72
|
-
|
73
|
-
=> ["https://upload.wikimedia.org/wikipedia/en/thumb/e/e1/Getting_Things_Done.jpg/100px-Getting_Things_Done.jpg"]
|
74
|
-
|
75
|
-
page.image_descriptionurls
|
76
|
-
|
77
|
-
=> ["http://en.wikipedia.org/wiki/File:Getting_Things_Done.jpg"]
|
78
|
-
|
79
|
-
page.main_image_url
|
80
|
-
|
81
|
-
=> "https://upload.wikimedia.org/wikipedia/en/e/e1/Getting_Things_Done.jpg"
|
82
|
-
|
83
|
-
page.coordinates
|
84
|
-
|
85
|
-
=> [48.853, 2.3498, "", "earth"]
|
86
|
-
|
87
|
-
page.templates
|
88
|
-
|
89
|
-
=> [..., "Template:About", ...]
|
90
|
-
|
91
|
-
page.langlinks
|
92
|
-
|
93
|
-
=> {..., "de"=>"Getting Things Done", "eo"=>"Igi aferojn finitaj", "zh"=>"尽管去做", ...}</code></pre>
|
94
|
-
|
95
|
-
h2. Configuration
|
96
|
-
|
97
|
-
This is by default configured like this:
|
98
|
-
|
99
|
-
<pre><code>Wikipedia.configure {
|
100
|
-
domain 'en.wikipedia.org'
|
101
|
-
path 'w/api.php'
|
102
|
-
}</code></pre>
|
103
|
-
|
104
|
-
h2. Advanced
|
105
|
-
|
106
|
-
See the API spec at "http://en.wikipedia.org/w/api.php":http://en.wikipedia.org/w/api.php
|
107
|
-
|
108
|
-
If you need data that is not already present, you can override parameters.
|
109
|
-
|
110
|
-
For example, to retrieve only the page info:
|
111
|
-
|
112
|
-
<pre><code>page = Wikipedia.find( 'Getting Things Done', :prop => "info" )
|
113
|
-
|
114
|
-
page.title
|
115
|
-
|
116
|
-
=> "Getting Things Done"
|
117
|
-
|
118
|
-
page.raw_data
|
119
|
-
|
120
|
-
=> {"query"=>{"pages"=>{"959928"=>{"pageid"=>959928, "ns"=>0,
|
121
|
-
"title"=>"Getting Things Done", "touched"=>"2010-03-10T00:04:09Z",
|
122
|
-
"lastrevid"=>348481810, "counter"=>0, "length"=>7891}}}}</code></pre>
|
123
|
-
|
124
|
-
h2. Contributing
|
125
|
-
|
126
|
-
h3. Getting the code, and running the tests
|
127
|
-
|
128
|
-
<pre><code>git clone git@github.com:kenpratt/wikipedia-client.git
|
129
|
-
cd wikipedia-client
|
130
|
-
gem install bundler
|
131
|
-
bundle exec rake spec</code></pre>
|
132
|
-
|
133
|
-
h3. Pushing a new release of the Gem
|
134
|
-
|
135
|
-
Edit <code>lib/wikipedia/version.rb</code>, changing <code>VERSION</code>.
|
136
|
-
|
137
|
-
Build the gem: <code>bundle exec gem build wikipedia-client.gemspec</code>
|
138
|
-
|
139
|
-
Commit the changes: <code>git commit -a -m 'Version bump to 1.4.0' && git push</code>
|
140
|
-
|
141
|
-
Publish the result to RubyGems: <code>bundle exec gem push wikipedia-client-1.4.0.gem</code>
|
142
|
-
|
143
|
-
h2. Thanks!
|
144
|
-
|
145
|
-
Copyright (c) 2008 [Cyril David], released under the MIT license
|
146
|
-
|
147
|
-
Adopted by Ken Pratt (ken@kenpratt.net) in 2010/03
|
148
|
-
|
149
|
-
h3. Contributors
|
150
|
-
|
151
|
-
Aishwarya Subramanian <aishwarya923@gmail.com>
|
152
|
-
Bryce <brycedneal@gmail.com>
|
153
|
-
cdr-data <b_rhettbarber@yahoo.com>
|
154
|
-
Christian Hellsten <christian.hellsten@gmail.com>
|
155
|
-
Christopher Quackenbush <christopher@quackenbush.me>
|
156
|
-
Cyril David
|
157
|
-
Francesco Serra <afnecors@gmail.com>
|
158
|
-
Harman Singh
|
159
|
-
ivobenedito <ivobenedito@gmail.com>
|
160
|
-
Justin Harrison <justin@matthin.com>
|
161
|
-
Ken Pratt <ken@kenpratt.net>
|
162
|
-
Manu Manu <manuisfunny@gmail.com>
|
163
|
-
Mike Haugland <mike.haugland@bravenet.com>
|
164
|
-
Pietro F. Menna <pietromenna@yahoo.com>
|
165
|
-
Sophie Rapoport <sfrapoport@gmail.com>
|
166
|
-
tsukasaoishi <tsukasa.oishi@gmail.com>
|
167
|
-
V <thevalentino@gmail.com>
|
168
|
-
Ilgiz Mustafin <ilgimustafin@gmail.com>
|