infoboxer 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +32 -0
  3. data/CHANGELOG.md +13 -0
  4. data/Gemfile.lock +97 -75
  5. data/README.md +1 -1
  6. data/lib/infoboxer.rb +7 -5
  7. data/lib/infoboxer/core_ext.rb +2 -0
  8. data/lib/infoboxer/definitions/en.wikipedia.org.rb +2 -0
  9. data/lib/infoboxer/media_wiki.rb +3 -1
  10. data/lib/infoboxer/media_wiki/page.rb +2 -0
  11. data/lib/infoboxer/media_wiki/traits.rb +4 -1
  12. data/lib/infoboxer/navigation.rb +2 -0
  13. data/lib/infoboxer/navigation/lookup.rb +5 -5
  14. data/lib/infoboxer/navigation/sections.rb +5 -1
  15. data/lib/infoboxer/navigation/selector.rb +3 -1
  16. data/lib/infoboxer/navigation/shortcuts.rb +2 -0
  17. data/lib/infoboxer/navigation/wikipath.rb +2 -0
  18. data/lib/infoboxer/parser.rb +3 -1
  19. data/lib/infoboxer/parser/context.rb +10 -6
  20. data/lib/infoboxer/parser/html.rb +2 -0
  21. data/lib/infoboxer/parser/image.rb +3 -1
  22. data/lib/infoboxer/parser/inline.rb +8 -4
  23. data/lib/infoboxer/parser/paragraphs.rb +3 -1
  24. data/lib/infoboxer/parser/table.rb +23 -15
  25. data/lib/infoboxer/parser/template.rb +3 -0
  26. data/lib/infoboxer/parser/util.rb +2 -0
  27. data/lib/infoboxer/templates.rb +2 -0
  28. data/lib/infoboxer/templates/base.rb +2 -0
  29. data/lib/infoboxer/templates/set.rb +2 -0
  30. data/lib/infoboxer/tree.rb +2 -0
  31. data/lib/infoboxer/tree/compound.rb +3 -1
  32. data/lib/infoboxer/tree/document.rb +2 -0
  33. data/lib/infoboxer/tree/gallery.rb +2 -0
  34. data/lib/infoboxer/tree/html.rb +4 -2
  35. data/lib/infoboxer/tree/image.rb +3 -1
  36. data/lib/infoboxer/tree/inline.rb +2 -0
  37. data/lib/infoboxer/tree/linkable.rb +2 -0
  38. data/lib/infoboxer/tree/list.rb +4 -2
  39. data/lib/infoboxer/tree/math.rb +2 -0
  40. data/lib/infoboxer/tree/node.rb +3 -1
  41. data/lib/infoboxer/tree/nodes.rb +16 -4
  42. data/lib/infoboxer/tree/paragraphs.rb +2 -0
  43. data/lib/infoboxer/tree/ref.rb +2 -0
  44. data/lib/infoboxer/tree/table.rb +5 -3
  45. data/lib/infoboxer/tree/template.rb +3 -1
  46. data/lib/infoboxer/tree/text.rb +11 -9
  47. data/lib/infoboxer/tree/wikilink.rb +3 -0
  48. data/lib/infoboxer/version.rb +4 -2
  49. data/lib/infoboxer/wiki_path.rb +2 -0
  50. data/regression/pages/2012_bdo_world_darts_championship.wiki +941 -0
  51. data/regression/pages/progress_wrestling.wiki +1308 -0
  52. metadata +6 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36fa882706af5f4b483c3723a179934eb906842f4de8c5118a9cf5b0dd91fec1
4
- data.tar.gz: 0e11e6635fab15e01a2b4cf53eb8fa209938121f582bf1e925cbeeb841dd7478
3
+ metadata.gz: 755e1283e896d2c2b363983a9b04ac92cb14870cfa2ab67fd62777684bac1352
4
+ data.tar.gz: c5443d788fc06a2310c65b80bc16531b820bb7142f611f5d063af8992cee7525
5
5
  SHA512:
6
- metadata.gz: 35825da3980f77f9fbaaa91e3cde9d3c2e40c02249577a6a2f337dd5077c247cfbeef97c6e714d1c529cd109f91bf7555e4d8e67f7c4d32a226508d004a2e86b
7
- data.tar.gz: df6abe08b07cf597bc0c196900ddffbeff023cbdfa8ec5b185c343c6fa4dd2e9cd924c92ed1deb793e96f285b287360a6c27c32489d3a970e046dbedc481529b
6
+ metadata.gz: 1443ecf7dbb485555a275a4d5390417ee48fabb2321a23fb59c208d32c1424259515924e903872b762afebcaaf5574afd713e4eade6c346aeb8e71719c051436
7
+ data.tar.gz: 71c007554240c40a7e7f9bee81d66d637b8643f1ccf18a5900c24087545d3c430830d8a30d9c4463244b13419d4edb349aee585885b6aecf03dc8d8b37d701a7
@@ -0,0 +1,32 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ main:
11
+ name: >-
12
+ ${{ matrix.ruby }}
13
+ runs-on: ubuntu-latest
14
+ strategy:
15
+ fail-fast: false
16
+ matrix:
17
+ ruby: [ 2.6, 2.7, 3.0, head ]
18
+
19
+ steps:
20
+ - name: checkout
21
+ uses: actions/checkout@v2
22
+ - name: set up Ruby
23
+ uses: ruby/setup-ruby@v1
24
+ with:
25
+ ruby-version: ${{ matrix.ruby }}
26
+
27
+ - name: install dependencies
28
+ run: bundle install --jobs 3 --retry 3
29
+ - name: spec
30
+ run: bundle exec rake spec
31
+ - name: rubocop
32
+ run: bundle exec rake rubocop
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Infoboxer's change log
2
2
 
3
+ ## 0.4.0 (2021-05-30)
4
+
5
+ * A cluster of bugs found in #81 fixed:
6
+ * Empty comment (`<!---->`) now processed properly;
7
+ * Templates that are implicitly inside tables (put on a separate row) now always create
8
+ an implicit `<TableCell>`
9
+ * Heading after non-closed table closes the table implicitly instead of being inserted
10
+ into the last cell.
11
+ * Drop Ruby < 2.6, and support 3.0 instead.
12
+
13
+ PS: Yeah, year-and-almost-half is much better than 2 years between releases, I guess.. And let's call
14
+ it non-patch version then.
15
+
3
16
  ## 0.3.3 (2020-02-09)
4
17
 
5
18
  * Fixed table captions handling (thanks @robfors for reporting)
data/Gemfile.lock CHANGED
@@ -10,7 +10,7 @@ GIT
10
10
  PATH
11
11
  remote: .
12
12
  specs:
13
- infoboxer (0.3.3)
13
+ infoboxer (0.4.0)
14
14
  addressable
15
15
  htmlentities
16
16
  mediawiktory (= 0.1.3)
@@ -19,31 +19,44 @@ PATH
19
19
  GEM
20
20
  remote: https://rubygems.org/
21
21
  specs:
22
- addressable (2.5.1)
23
- public_suffix (~> 2.0, >= 2.0.2)
22
+ addressable (2.7.0)
23
+ public_suffix (>= 2.0.2, < 5.0)
24
24
  ansi (1.5.0)
25
- ast (2.4.0)
26
- backports (3.10.3)
27
- byebug (9.0.6)
28
- coveralls (0.8.21)
25
+ ast (2.4.2)
26
+ backports (3.21.0)
27
+ byebug (11.1.3)
28
+ coveralls (0.8.23)
29
29
  json (>= 1.8, < 3)
30
- simplecov (~> 0.14.1)
30
+ simplecov (~> 0.16.1)
31
31
  term-ansicolor (~> 1.3)
32
- thor (~> 0.19.4)
32
+ thor (>= 0.19.4, < 2.0)
33
33
  tins (~> 1.6)
34
- crack (0.4.3)
35
- safe_yaml (~> 1.0.0)
36
- diff-lcs (1.3)
37
- docile (1.1.5)
38
- faraday (0.15.4)
34
+ crack (0.4.5)
35
+ rexml
36
+ diff-lcs (1.4.4)
37
+ docile (1.4.0)
38
+ faraday (1.4.2)
39
+ faraday-em_http (~> 1.0)
40
+ faraday-em_synchrony (~> 1.0)
41
+ faraday-excon (~> 1.1)
42
+ faraday-net_http (~> 1.0)
43
+ faraday-net_http_persistent (~> 1.1)
39
44
  multipart-post (>= 1.2, < 3)
40
- faraday_middleware (0.13.0)
41
- faraday (>= 0.7.4, < 1.0)
42
- hashdiff (0.3.4)
43
- hashie (3.6.0)
45
+ ruby2_keywords (>= 0.0.4)
46
+ faraday-em_http (1.0.0)
47
+ faraday-em_synchrony (1.0.0)
48
+ faraday-excon (1.1.0)
49
+ faraday-net_http (1.0.1)
50
+ faraday-net_http_persistent (1.1.0)
51
+ faraday_middleware (1.0.0)
52
+ faraday (~> 1.0)
53
+ hashdiff (1.0.1)
54
+ hashie (4.1.0)
44
55
  htmlentities (4.3.4)
45
- json (2.1.0)
46
- json (2.1.0-java)
56
+ io-console (0.5.9)
57
+ irb (1.3.5)
58
+ reline (>= 0.1.5)
59
+ json (2.5.1)
47
60
  mediawiktory (0.1.3)
48
61
  addressable
49
62
  faraday
@@ -51,80 +64,89 @@ GEM
51
64
  hashie
52
65
  naught
53
66
  nokogiri
54
- mini_portile2 (2.4.0)
55
67
  multipart-post (2.1.1)
56
68
  naught (1.1.0)
57
- nokogiri (1.10.4)
58
- mini_portile2 (~> 2.4.0)
59
- parallel (1.19.1)
60
- parser (2.7.0.2)
61
- ast (~> 2.4.0)
62
- powerpack (0.1.2)
63
- public_suffix (2.0.5)
69
+ nokogiri (1.11.6-x86_64-linux)
70
+ racc (~> 1.4)
71
+ parallel (1.20.1)
72
+ parser (3.0.1.1)
73
+ ast (~> 2.4.1)
74
+ public_suffix (4.0.6)
75
+ racc (1.5.2)
64
76
  rainbow (3.0.0)
65
- rake (12.3.0)
66
- redcarpet (3.3.4)
67
- rouge (2.1.1)
68
- rspec (3.6.0)
69
- rspec-core (~> 3.6.0)
70
- rspec-expectations (~> 3.6.0)
71
- rspec-mocks (~> 3.6.0)
72
- rspec-core (3.6.0)
73
- rspec-support (~> 3.6.0)
74
- rspec-expectations (3.6.0)
77
+ rake (13.0.3)
78
+ redcarpet (3.5.1)
79
+ regexp_parser (2.1.1)
80
+ reline (0.2.5)
81
+ io-console (~> 0.5)
82
+ rexml (3.2.5)
83
+ rouge (3.26.0)
84
+ rspec (3.10.0)
85
+ rspec-core (~> 3.10.0)
86
+ rspec-expectations (~> 3.10.0)
87
+ rspec-mocks (~> 3.10.0)
88
+ rspec-core (3.10.1)
89
+ rspec-support (~> 3.10.0)
90
+ rspec-expectations (3.10.1)
75
91
  diff-lcs (>= 1.2.0, < 2.0)
76
- rspec-support (~> 3.6.0)
77
- rspec-its (1.2.0)
92
+ rspec-support (~> 3.10.0)
93
+ rspec-its (1.3.0)
78
94
  rspec-core (>= 3.0.0)
79
95
  rspec-expectations (>= 3.0.0)
80
- rspec-mocks (3.6.0)
96
+ rspec-mocks (3.10.2)
81
97
  diff-lcs (>= 1.2.0, < 2.0)
82
- rspec-support (~> 3.6.0)
83
- rspec-support (3.6.0)
84
- rubocop (0.52.1)
98
+ rspec-support (~> 3.10.0)
99
+ rspec-support (3.10.2)
100
+ rubocop (1.15.0)
85
101
  parallel (~> 1.10)
86
- parser (>= 2.4.0.2, < 3.0)
87
- powerpack (~> 0.1)
102
+ parser (>= 3.0.0.0)
88
103
  rainbow (>= 2.2.2, < 4.0)
104
+ regexp_parser (>= 1.8, < 3.0)
105
+ rexml
106
+ rubocop-ast (>= 1.5.0, < 2.0)
89
107
  ruby-progressbar (~> 1.7)
90
- unicode-display_width (~> 1.0, >= 1.0.1)
91
- rubocop-rspec (1.20.1)
92
- rubocop (>= 0.51.0)
93
- ruby-prof (0.16.2)
94
- ruby-progressbar (1.10.1)
95
- rubygems-tasks (0.2.4)
96
- safe_yaml (1.0.4)
108
+ unicode-display_width (>= 1.4.0, < 3.0)
109
+ rubocop-ast (1.7.0)
110
+ parser (>= 3.0.1.1)
111
+ rubocop-rspec (2.3.0)
112
+ rubocop (~> 1.0)
113
+ rubocop-ast (>= 1.1.0)
114
+ ruby-prof (1.4.3)
115
+ ruby-progressbar (1.11.0)
116
+ ruby2_keywords (0.0.4)
117
+ rubygems-tasks (0.2.5)
118
+ irb (~> 1.0)
97
119
  saharspec (0.0.4)
98
- simplecov (0.14.1)
99
- docile (~> 1.1.0)
120
+ simplecov (0.16.1)
121
+ docile (~> 1.1)
100
122
  json (>= 1.8, < 3)
101
123
  simplecov-html (~> 0.10.0)
102
- simplecov-html (0.10.1)
124
+ simplecov-html (0.10.2)
103
125
  slop (3.6.0)
104
- term-ansicolor (1.6.0)
126
+ sync (0.5.0)
127
+ term-ansicolor (1.7.1)
105
128
  tins (~> 1.0)
106
- terminal-table (1.8.0)
107
- unicode-display_width (~> 1.1, >= 1.1.1)
108
- thor (0.19.4)
109
- timecop (0.9.0)
110
- tins (1.14.0)
111
- tty-color (0.4.2)
112
- unicode-display_width (1.6.1)
113
- vcr (3.0.3)
114
- webmock (3.0.1)
129
+ terminal-table (3.0.1)
130
+ unicode-display_width (>= 1.1.1, < 3)
131
+ thor (1.1.0)
132
+ timecop (0.9.4)
133
+ tins (1.29.1)
134
+ sync
135
+ unicode-display_width (2.0.0)
136
+ vcr (6.0.0)
137
+ webmock (3.13.0)
115
138
  addressable (>= 2.3.6)
116
139
  crack (>= 0.3.2)
117
- hashdiff
118
- yard (0.9.12)
119
- yard-junk (0.0.7)
120
- backports
140
+ hashdiff (>= 0.4.0, < 2.0.0)
141
+ yard (0.9.26)
142
+ yard-junk (0.0.9)
143
+ backports (>= 3.18)
121
144
  rainbow
122
- tty-color
123
145
  yard
124
146
 
125
147
  PLATFORMS
126
- java
127
148
  ruby
149
+ x86_64-linux
128
150
 
129
151
  DEPENDENCIES
130
152
  byebug
@@ -135,8 +157,8 @@ DEPENDENCIES
135
157
  redcarpet
136
158
  rspec (~> 3)
137
159
  rspec-its (~> 1)
138
- rubocop (~> 0.52.1)
139
- rubocop-rspec (~> 1.20)
160
+ rubocop (~> 1.15.0)
161
+ rubocop-rspec (~> 2.3.0)
140
162
  ruby-prof
141
163
  rubygems-tasks
142
164
  saharspec (= 0.0.4)
@@ -147,4 +169,4 @@ DEPENDENCIES
147
169
  yard-junk (~> 0.0.7)
148
170
 
149
171
  BUNDLED WITH
150
- 1.17.2
172
+ 2.2.0
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Infoboxer
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/infoboxer.svg)](http://badge.fury.io/rb/infoboxer)
4
- [![Build Status](https://travis-ci.org/molybdenum-99/infoboxer.svg?branch=master)](https://travis-ci.org/molybdenum-99/infoboxer)
4
+ ![Build Status](https://github.com/molybdenum-99/infoboxer/workflows/CI/badge.svg?branch=master)
5
5
  [![Coverage Status](https://coveralls.io/repos/molybdenum-99/infoboxer/badge.svg?branch=master&service=github)](https://coveralls.io/github/molybdenum-99/infoboxer?branch=master)
6
6
  [![Code Climate](https://codeclimate.com/github/molybdenum-99/infoboxer/badges/gpa.svg)](https://codeclimate.com/github/molybdenum-99/infoboxer)
7
7
  [![Infoboxer Gitter](https://badges.gitter.im/molybdenum-99/infoboxer.svg)](https://gitter.im/molybdenum-99/infoboxer)
data/lib/infoboxer.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Main client module for entire infoboxer functionality. If you're lucky,
2
4
  # there's no other classes/modules you need to instantiate or call
3
5
  # directly. You just do:
@@ -45,7 +47,7 @@
45
47
  #
46
48
  module Infoboxer
47
49
  # @private
48
- WIKIA_API_URL = 'http://%s.wikia.com/api.php'.freeze
50
+ WIKIA_API_URL = 'http://%s.wikia.com/api.php'
49
51
 
50
52
  WIKIMEDIA_PROJECTS = {
51
53
  wikipedia: 'wikipedia.org',
@@ -69,10 +71,10 @@ module Infoboxer
69
71
 
70
72
  # Includeable version of {Infoboxer.wiki}
71
73
  def wiki(api_url, **options)
72
- wikis[api_url] ||= MediaWiki.new(api_url, options)
74
+ wikis[api_url] ||= MediaWiki.new(api_url, **options)
73
75
  end
74
76
 
75
- class << self
77
+ class << self # rubocop:disable Lint/EmptyClass -- that's for YARD!
76
78
  # @!method wiki(api_url, options = {})
77
79
  # Default method for creating MediaWiki API client.
78
80
  #
@@ -167,7 +169,7 @@ module Infoboxer
167
169
  define_method name do |lang = 'en', **options|
168
170
  lang, options = 'en', lang if lang.is_a?(Hash)
169
171
 
170
- wiki("https://#{lang}.#{domain}/w/api.php", options)
172
+ wiki("https://#{lang}.#{domain}/w/api.php", **options)
171
173
  end
172
174
  end
173
175
 
@@ -226,7 +228,7 @@ module Infoboxer
226
228
  # Includeable version of {Infoboxer.wikia}
227
229
  def wikia(*domains)
228
230
  options = domains.last.is_a?(Hash) ? domains.pop : {}
229
- wiki(WIKIA_API_URL % domains.reverse.join('.'), options)
231
+ wiki(WIKIA_API_URL % domains.reverse.join('.'), **options)
230
232
  end
231
233
 
232
234
  # Sets user agent string globally. Default user agent is
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # @private
2
4
  class Object
3
5
  # Unfortunately, not in backports gem still :(
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # rubocop:disable Layout/EmptyLinesAroundArguments
2
4
  module Infoboxer
3
5
  MediaWiki::Traits.for('en.wikipedia.org') do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'mediawiktory'
2
4
  require 'addressable/uri'
3
5
 
@@ -25,7 +27,7 @@ module Infoboxer
25
27
  # You can set yours as an option to {Infoboxer.wiki} and its shortcuts,
26
28
  # or to {#initialize}
27
29
  UA = "Infoboxer/#{Infoboxer::VERSION} "\
28
- '(https://github.com/molybdenum-99/infoboxer; zverok.offline@gmail.com)'.freeze
30
+ '(https://github.com/molybdenum-99/infoboxer; zverok.offline@gmail.com)'
29
31
 
30
32
  class << self
31
33
  # User agent getter/setter.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Infoboxer
2
4
  class MediaWiki
3
5
  # A descendant of {Tree::Document Document}, representing page,
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Infoboxer
2
4
  class MediaWiki
3
5
  # DSL for defining "traits" for some site.
@@ -57,7 +59,7 @@ module Infoboxer
57
59
  # [English Wikipedia traits](https://github.com/molybdenum-99/infoboxer/blob/master/lib/infoboxer/definitions/en.wikipedia.org.rb)
58
60
  # for example implementation.
59
61
  def for(domain, &block)
60
- Traits.domains[domain].tap { |c| c && c.instance_eval(&block) } ||
62
+ Traits.domains[domain]&.instance_eval(&block) ||
61
63
  Class.new(self, &block).domain(domain)
62
64
  end
63
65
 
@@ -114,6 +116,7 @@ module Infoboxer
114
116
 
115
117
  def ns_aliases(base)
116
118
  return [base] if @site_info.empty?
119
+
117
120
  main = @site_info['namespaces'].values.detect { |n| n['canonical'] == base }
118
121
  [base, main['*']] +
119
122
  @site_info['namespacealiases']
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Infoboxer
2
4
  # Navigation is one of the things Infoboxer is proud about. It tries
3
5
  # to be logical, unobtrusive and compact.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'selector'
2
4
 
3
5
  module Infoboxer
@@ -157,11 +159,10 @@ module Infoboxer
157
159
  ]
158
160
  .map { |sym| [sym, :"_#{sym}"] }
159
161
  .each do |sym, underscored|
160
-
161
- define_method(sym) do |*args, &block|
162
- send(underscored, Selector.new(*args, &block))
162
+ define_method(sym) do |*args, &block|
163
+ send(underscored, Selector.new(*args, &block))
164
+ end
163
165
  end
164
- end
165
166
 
166
167
  # Checks if node has any parent matching selectors.
167
168
  def parent?(*selectors, &block)
@@ -217,7 +218,6 @@ module Infoboxer
217
218
  lookup_siblings
218
219
  lookup_next_siblings lookup_prev_siblings
219
220
  ].map { |sym| [sym, :"_#{sym}"] }.each do |sym, underscored|
220
-
221
221
  define_method(sym) do |*args, &block|
222
222
  send(underscored, Selector.new(*args, &block))
223
223
  end