wikipedia-client 1.12.0 → 1.13.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.textile +1 -0
- data/lib/wikipedia.rb +0 -2
- data/lib/wikipedia/client.rb +24 -22
- data/lib/wikipedia/url.rb +4 -1
- data/lib/wikipedia/version.rb +1 -1
- data/wikipedia-client.gemspec +0 -21
- metadata +5 -110
- data/.travis.yml +0 -6
- data/Gemfile.lock +0 -109
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5089a0eafa00495327e1d0376c3a9868ed0fe41277e5371717cd7acdc04175b5
|
4
|
+
data.tar.gz: '073885a731ca1cdc1f145e8b67438bf3e781dddc543c970b4a6ad79ea2a0fd43'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a825bbd64b3c51b01a72a402a2919be96e52c4c32f345193105942738f0d580874b3f06f974cd654a64f86409d3e8439e5f20e0dc9c829be2b9376fc56274bc
|
7
|
+
data.tar.gz: 156a18e8075a1289ffdc9875edb01d1a91e07d2354eb5649c704b15b20c233e33ef983ea1666bb8a68d81798da78540c0001b499491926e7aaf6b556e551c357
|
@@ -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.textile
CHANGED
@@ -154,6 +154,7 @@ cdr-data <b_rhettbarber@yahoo.com>
|
|
154
154
|
Christian Hellsten <christian.hellsten@gmail.com>
|
155
155
|
Christopher Quackenbush <christopher@quackenbush.me>
|
156
156
|
Cyril David
|
157
|
+
Danny Ben Shitrit <db@dannyben.com>
|
157
158
|
Francesco Serra <afnecors@gmail.com>
|
158
159
|
Harman Singh
|
159
160
|
ivobenedito <ivobenedito@gmail.com>
|
data/lib/wikipedia.rb
CHANGED
data/lib/wikipedia/client.rb
CHANGED
@@ -1,7 +1,13 @@
|
|
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
|
|
@@ -66,7 +72,6 @@ module Wikipedia
|
|
66
72
|
end
|
67
73
|
|
68
74
|
def request( options )
|
69
|
-
require 'open-uri'
|
70
75
|
URI.parse( url_for( options ) ).read( 'User-Agent' => Configuration[:user_agent] )
|
71
76
|
end
|
72
77
|
|
@@ -80,36 +85,33 @@ module Wikipedia
|
|
80
85
|
}
|
81
86
|
end
|
82
87
|
|
83
|
-
def url_for(
|
84
|
-
url = BASE_URL.dup
|
88
|
+
def url_for(options)
|
85
89
|
options = configuration_options.merge( options )
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
end
|
94
|
-
url
|
90
|
+
|
91
|
+
url_options, query_options = split_hash(options, BASE_URL_OPTIONS)
|
92
|
+
normalized_query_options = query_options.map { |k, v| [k, normalize_value(v)] }
|
93
|
+
|
94
|
+
base_url = BASE_URL_TEMPLATE % url_options
|
95
|
+
query_string = Addressable::URI.form_encode(normalized_query_options)
|
96
|
+
base_url + '&' + query_string
|
95
97
|
end
|
96
98
|
|
97
|
-
def
|
99
|
+
def normalize_value( val )
|
98
100
|
case val
|
99
101
|
when Array
|
100
|
-
|
102
|
+
val.flatten.join( '|' )
|
101
103
|
else
|
102
|
-
|
104
|
+
val
|
103
105
|
end
|
104
106
|
end
|
105
107
|
|
106
|
-
def
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
val
|
108
|
+
def split_hash(hash, keys)
|
109
|
+
h1 = {}
|
110
|
+
h2 = {}
|
111
|
+
hash.each do |k, v|
|
112
|
+
(keys.include?(k) ? h1 : h2).store(k, v)
|
112
113
|
end
|
114
|
+
[h1, h2]
|
113
115
|
end
|
114
116
|
end
|
115
117
|
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/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
|
@@ -24,29 +23,9 @@ Gem::Specification.new do |s|
|
|
24
23
|
s.files = `git ls-files`.split("\n")
|
25
24
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
26
25
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
27
|
-
s.has_rdoc = true
|
28
26
|
s.extra_rdoc_files = ['README.textile']
|
29
27
|
s.bindir = 'bin'
|
30
28
|
|
31
29
|
s.require_paths << 'lib'
|
32
30
|
s.rdoc_options << '--title' << 'wikipedia-client' << '--main' << '-ri'
|
33
|
-
|
34
|
-
s.add_development_dependency('pry', '~> 0.14')
|
35
|
-
s.add_development_dependency('rake', '~> 13.0')
|
36
|
-
s.add_development_dependency('rspec', '~> 3.0')
|
37
|
-
s.add_development_dependency('rdoc', '~> 6.0')
|
38
|
-
s.add_development_dependency('jeweler', '~> 2.0')
|
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
|
52
31
|
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.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril David
|
@@ -13,112 +13,8 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2021-04-
|
17
|
-
dependencies:
|
18
|
-
- !ruby/object:Gem::Dependency
|
19
|
-
name: pry
|
20
|
-
requirement: !ruby/object:Gem::Requirement
|
21
|
-
requirements:
|
22
|
-
- - "~>"
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version: '0.14'
|
25
|
-
type: :development
|
26
|
-
prerelease: false
|
27
|
-
version_requirements: !ruby/object:Gem::Requirement
|
28
|
-
requirements:
|
29
|
-
- - "~>"
|
30
|
-
- !ruby/object:Gem::Version
|
31
|
-
version: '0.14'
|
32
|
-
- !ruby/object:Gem::Dependency
|
33
|
-
name: rake
|
34
|
-
requirement: !ruby/object:Gem::Requirement
|
35
|
-
requirements:
|
36
|
-
- - "~>"
|
37
|
-
- !ruby/object:Gem::Version
|
38
|
-
version: '13.0'
|
39
|
-
type: :development
|
40
|
-
prerelease: false
|
41
|
-
version_requirements: !ruby/object:Gem::Requirement
|
42
|
-
requirements:
|
43
|
-
- - "~>"
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '13.0'
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: rspec
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
requirements:
|
50
|
-
- - "~>"
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version: '3.0'
|
53
|
-
type: :development
|
54
|
-
prerelease: false
|
55
|
-
version_requirements: !ruby/object:Gem::Requirement
|
56
|
-
requirements:
|
57
|
-
- - "~>"
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
version: '3.0'
|
60
|
-
- !ruby/object:Gem::Dependency
|
61
|
-
name: rdoc
|
62
|
-
requirement: !ruby/object:Gem::Requirement
|
63
|
-
requirements:
|
64
|
-
- - "~>"
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: '6.0'
|
67
|
-
type: :development
|
68
|
-
prerelease: false
|
69
|
-
version_requirements: !ruby/object:Gem::Requirement
|
70
|
-
requirements:
|
71
|
-
- - "~>"
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
version: '6.0'
|
74
|
-
- !ruby/object:Gem::Dependency
|
75
|
-
name: jeweler
|
76
|
-
requirement: !ruby/object:Gem::Requirement
|
77
|
-
requirements:
|
78
|
-
- - "~>"
|
79
|
-
- !ruby/object:Gem::Version
|
80
|
-
version: '2.0'
|
81
|
-
type: :development
|
82
|
-
prerelease: false
|
83
|
-
version_requirements: !ruby/object:Gem::Requirement
|
84
|
-
requirements:
|
85
|
-
- - "~>"
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
version: '2.0'
|
88
|
-
- !ruby/object:Gem::Dependency
|
89
|
-
name: rubocop
|
90
|
-
requirement: !ruby/object:Gem::Requirement
|
91
|
-
requirements:
|
92
|
-
- - "~>"
|
93
|
-
- !ruby/object:Gem::Version
|
94
|
-
version: '0.48'
|
95
|
-
type: :development
|
96
|
-
prerelease: false
|
97
|
-
version_requirements: !ruby/object:Gem::Requirement
|
98
|
-
requirements:
|
99
|
-
- - "~>"
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version: '0.48'
|
102
|
-
- !ruby/object:Gem::Dependency
|
103
|
-
name: thoughtbot-shoulda
|
104
|
-
requirement: !ruby/object:Gem::Requirement
|
105
|
-
requirements:
|
106
|
-
- - ">="
|
107
|
-
- !ruby/object:Gem::Version
|
108
|
-
version: '2.11'
|
109
|
-
- - "~>"
|
110
|
-
- !ruby/object:Gem::Version
|
111
|
-
version: '2.11'
|
112
|
-
type: :development
|
113
|
-
prerelease: false
|
114
|
-
version_requirements: !ruby/object:Gem::Requirement
|
115
|
-
requirements:
|
116
|
-
- - ">="
|
117
|
-
- !ruby/object:Gem::Version
|
118
|
-
version: '2.11'
|
119
|
-
- - "~>"
|
120
|
-
- !ruby/object:Gem::Version
|
121
|
-
version: '2.11'
|
16
|
+
date: 2021-04-28 00:00:00.000000000 Z
|
17
|
+
dependencies: []
|
122
18
|
description: Ruby client for the Wikipedia API
|
123
19
|
email: ken@kenpratt.net
|
124
20
|
executables: []
|
@@ -127,11 +23,10 @@ extra_rdoc_files:
|
|
127
23
|
- README.textile
|
128
24
|
files:
|
129
25
|
- ".editorconfig"
|
26
|
+
- ".github/workflows/test.yml"
|
130
27
|
- ".gitignore"
|
131
28
|
- ".rubocop.yml"
|
132
|
-
- ".travis.yml"
|
133
29
|
- Gemfile
|
134
|
-
- Gemfile.lock
|
135
30
|
- MIT-LICENSE
|
136
31
|
- README.textile
|
137
32
|
- Rakefile
|
@@ -211,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
211
106
|
requirements: []
|
212
107
|
rubygems_version: 3.0.3
|
213
108
|
signing_key:
|
214
|
-
specification_version:
|
109
|
+
specification_version: 4
|
215
110
|
summary: Ruby client for the Wikipedia API
|
216
111
|
test_files:
|
217
112
|
- spec/fixtures/Edsger_Dijkstra.json
|
data/.travis.yml
DELETED
data/Gemfile.lock
DELETED
@@ -1,109 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
wikipedia-client (1.12.0)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
addressable (2.4.0)
|
10
|
-
ast (2.3.0)
|
11
|
-
builder (3.2.4)
|
12
|
-
coderay (1.1.3)
|
13
|
-
descendants_tracker (0.0.4)
|
14
|
-
thread_safe (~> 0.3, >= 0.3.1)
|
15
|
-
diff-lcs (1.4.4)
|
16
|
-
faraday (0.9.2)
|
17
|
-
multipart-post (>= 1.2, < 3)
|
18
|
-
git (1.8.1)
|
19
|
-
rchardet (~> 1.8)
|
20
|
-
github_api (0.16.0)
|
21
|
-
addressable (~> 2.4.0)
|
22
|
-
descendants_tracker (~> 0.0.4)
|
23
|
-
faraday (~> 0.8, < 0.10)
|
24
|
-
hashie (>= 3.4)
|
25
|
-
mime-types (>= 1.16, < 3.0)
|
26
|
-
oauth2 (~> 1.0)
|
27
|
-
hashie (4.1.0)
|
28
|
-
highline (2.0.3)
|
29
|
-
jeweler (2.3.9)
|
30
|
-
builder
|
31
|
-
bundler
|
32
|
-
git (>= 1.2.5)
|
33
|
-
github_api (~> 0.16.0)
|
34
|
-
highline (>= 1.6.15)
|
35
|
-
nokogiri (>= 1.5.10)
|
36
|
-
psych
|
37
|
-
rake
|
38
|
-
rdoc
|
39
|
-
semver2
|
40
|
-
jwt (2.2.2)
|
41
|
-
method_source (1.0.0)
|
42
|
-
mime-types (2.99.3)
|
43
|
-
mini_portile2 (2.5.0)
|
44
|
-
multi_json (1.15.0)
|
45
|
-
multi_xml (0.6.0)
|
46
|
-
multipart-post (2.1.1)
|
47
|
-
nokogiri (1.11.2)
|
48
|
-
mini_portile2 (~> 2.5.0)
|
49
|
-
racc (~> 1.4)
|
50
|
-
oauth2 (1.4.7)
|
51
|
-
faraday (>= 0.8, < 2.0)
|
52
|
-
jwt (>= 1.0, < 3.0)
|
53
|
-
multi_json (~> 1.3)
|
54
|
-
multi_xml (~> 0.5)
|
55
|
-
rack (>= 1.2, < 3)
|
56
|
-
parser (2.4.0.0)
|
57
|
-
ast (~> 2.2)
|
58
|
-
powerpack (0.1.1)
|
59
|
-
pry (0.14.0)
|
60
|
-
coderay (~> 1.1)
|
61
|
-
method_source (~> 1.0)
|
62
|
-
psych (3.3.1)
|
63
|
-
racc (1.5.2)
|
64
|
-
rack (2.2.3)
|
65
|
-
rainbow (2.2.2)
|
66
|
-
rake
|
67
|
-
rake (13.0.3)
|
68
|
-
rchardet (1.8.0)
|
69
|
-
rdoc (6.3.0)
|
70
|
-
rspec (3.10.0)
|
71
|
-
rspec-core (~> 3.10.0)
|
72
|
-
rspec-expectations (~> 3.10.0)
|
73
|
-
rspec-mocks (~> 3.10.0)
|
74
|
-
rspec-core (3.10.1)
|
75
|
-
rspec-support (~> 3.10.0)
|
76
|
-
rspec-expectations (3.10.1)
|
77
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
78
|
-
rspec-support (~> 3.10.0)
|
79
|
-
rspec-mocks (3.10.2)
|
80
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
81
|
-
rspec-support (~> 3.10.0)
|
82
|
-
rspec-support (3.10.2)
|
83
|
-
rubocop (0.48.1)
|
84
|
-
parser (>= 2.3.3.1, < 3.0)
|
85
|
-
powerpack (~> 0.1)
|
86
|
-
rainbow (>= 1.99.1, < 3.0)
|
87
|
-
ruby-progressbar (~> 1.7)
|
88
|
-
unicode-display_width (~> 1.0, >= 1.0.1)
|
89
|
-
ruby-progressbar (1.8.1)
|
90
|
-
semver2 (3.4.2)
|
91
|
-
thoughtbot-shoulda (2.11.1)
|
92
|
-
thread_safe (0.3.6)
|
93
|
-
unicode-display_width (1.2.1)
|
94
|
-
|
95
|
-
PLATFORMS
|
96
|
-
ruby
|
97
|
-
|
98
|
-
DEPENDENCIES
|
99
|
-
jeweler (~> 2.0)
|
100
|
-
pry (~> 0.14)
|
101
|
-
rake (~> 13.0)
|
102
|
-
rdoc (~> 6.0)
|
103
|
-
rspec (~> 3.0)
|
104
|
-
rubocop (~> 0.48)
|
105
|
-
thoughtbot-shoulda (~> 2.11, >= 2.11)
|
106
|
-
wikipedia-client!
|
107
|
-
|
108
|
-
BUNDLED WITH
|
109
|
-
2.0.2
|