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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 07e7dbcd9e8fd92afb079f75a87a928740dbb2427ec6a26e115cb67473f6dba9
4
- data.tar.gz: 64a2a3cd7bf9d74b1496af48d8a2aa73366ccf4339c79d3297813d6fdb282d45
3
+ metadata.gz: 5089a0eafa00495327e1d0376c3a9868ed0fe41277e5371717cd7acdc04175b5
4
+ data.tar.gz: '073885a731ca1cdc1f145e8b67438bf3e781dddc543c970b4a6ad79ea2a0fd43'
5
5
  SHA512:
6
- metadata.gz: 8c98ab9206724951d38d97b56bc2ef9890179971c6abcf816ae7f1a89264681b3b73d76e4d2ff1bb9ce186eb9392a6a8220e63fe6a90bbb951e803020b68a064
7
- data.tar.gz: 4f7dc758853e41b3ea56542fa66ec4e5fc4ad013a9a75f91a6292ca790e7bda64abc020537e599245433b3f57a91c28b98783515695e771e509337935f5a9320
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
@@ -7,3 +7,4 @@
7
7
  pkg/*
8
8
  coverage/
9
9
  rdoc/
10
+ Gemfile.lock
data/Gemfile CHANGED
@@ -1,2 +1,12 @@
1
1
  source 'https://rubygems.org'
2
+
3
+ gem 'jeweler'
4
+ gem 'pry'
5
+ gem 'rake'
6
+ gem 'rdoc'
7
+ gem 'rspec'
8
+ # FIXME: Remove rubocop version restriction and fix or disable cops
9
+ gem 'rubocop', '= 0.48.1'
10
+ gem 'thoughtbot-shoulda'
11
+
2
12
  gemspec
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
@@ -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')
@@ -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
- BASE_URL = ':protocol://:domain/:path?action=:action&format=json'.freeze
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( options )
84
- url = BASE_URL.dup
88
+ def url_for(options)
85
89
  options = configuration_options.merge( options )
86
- options.each do |key, val|
87
- value = urlify_value( val )
88
- if url.include?( ":#{key}" )
89
- url.sub! ":#{key}", value
90
- else
91
- url << "&#{key}=#{value}"
92
- end
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 urlify_value( val )
99
+ def normalize_value( val )
98
100
  case val
99
101
  when Array
100
- encode( val.flatten.join( '|' ) )
102
+ val.flatten.join( '|' )
101
103
  else
102
- encode( val )
104
+ val
103
105
  end
104
106
  end
105
107
 
106
- def encode( val )
107
- case val
108
- when String
109
- URI.encode( val, /#{URI::UNSAFE}|[\+&]/ )
110
- else
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.decode( uri.path.sub(/\/wiki\//, '') )
14
+ @title = Addressable::URI.unencode( uri.path.sub(/\/wiki\//, '') )
12
15
  end
13
16
  end
14
17
  end
@@ -1,3 +1,3 @@
1
1
  module Wikipedia
2
- VERSION = '1.12.0'.freeze
2
+ VERSION = '1.13.0'.freeze
3
3
  end
@@ -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.12.0
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-03 00:00:00.000000000 Z
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: 3
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
@@ -1,6 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.5
4
- - 2.6
5
- - 2.7
6
- - 3.0
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