wiki-api 0.0.2 → 0.1.2

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.
@@ -1,51 +1,44 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require File.expand_path(File.dirname(__FILE__) + "/../../lib/wiki/api")
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+ require 'pry'
4
5
 
5
6
  #
6
7
  # Testing the connection to https://www.mediawiki.org/wiki/API:Main_page
7
8
  #
8
9
 
9
10
  class WikiConnect < Test::Unit::TestCase
10
-
11
- CONFIG = { uri: "http://en.wiktionary.org" }
11
+ CONFIG = { uri: 'https://en.wiktionary.org' }.freeze
12
12
 
13
13
  def setup
14
14
  Wiki::Api::Connect.config = CONFIG
15
15
  end
16
16
 
17
- def teardown
18
- end
17
+ def teardown; end
19
18
 
20
19
  def test_connection_wiktionary
21
- c = Wiki::Api::Connect.new uri: "http://en.wiktionary.org"
20
+ c = Wiki::Api::Connect.new(uri: 'http://en.wiktionary.org')
22
21
  ret = c.connect
23
- assert ret.is_a?(Net::HTTPOK), "invalid response http"
22
+ assert(ret.is_a?(Net::HTTPMovedPermanently), 'invalid response http')
24
23
  end
25
24
 
26
25
  def test_connection_https_wiktionary
27
- c = Wiki::Api::Connect.new uri: "https://en.wiktionary.org"
26
+ c = Wiki::Api::Connect.new(uri: 'https://en.wiktionary.org')
28
27
  ret = c.connect
29
- assert ret.is_a?(Net::HTTPOK), "invalid response https"
28
+ assert(ret.is_a?(Net::HTTPOK), 'invalid response https')
30
29
  end
31
30
 
32
31
  def test_page_get
33
- begin
34
- c = Wiki::Api::Connect.new
35
- c.page "Wiktionary:Welcome,_newcomers"
36
- rescue Exception => e
37
- assert false, "expected valid page #{e.message}"
38
- end
32
+ c = Wiki::Api::Connect.new
33
+ c.page('Wiktionary:Welcome,_newcomers')
34
+ rescue Exception => e
35
+ assert(false, "expected valid page #{e.message}")
39
36
  end
40
37
 
41
38
  def test_page_get_non_exist
42
- begin
43
- c = Wiki::Api::Connect.new
44
- response = c.page "asfsldkfjjlkanv98yhok"
45
- rescue Exception => e
46
- assert (e.message == "missingtitle"), "expected invalid page #{e.message}"
47
- end
39
+ c = Wiki::Api::Connect.new
40
+ c.page('asfsldkfjjlkanv98yhok')
41
+ rescue Exception => e
42
+ assert((e.message == 'missingtitle'), "expected invalid page #{e.message}")
48
43
  end
49
-
50
-
51
44
  end
@@ -0,0 +1,295 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+
5
+ #
6
+ # Testing the parsing of URI (with a predownloaded HTML file):
7
+ # /files/Wiktionary_Welcome,_newcomers.html (2013-03-27)
8
+ #
9
+ # Online equivalent:
10
+ # https://en.wiktionary.org/wiki/Wiktionary:Welcome,_newcomers
11
+ #
12
+
13
+ class WikiPageOfflinePage < Test::Unit::TestCase
14
+ # this global is required to resolve URIs (MediaWiki uses relative paths in their links)
15
+ URI_CONFIG = { uri: 'https://en.wiktionary.org' }.freeze
16
+ # use local file for test loading
17
+ PAGE_CONFIG = { file: File.expand_path("#{File.dirname(__FILE__)}/files/Wiktionary_program.html") }.freeze
18
+
19
+ def setup
20
+ # NOTE: comment Page.config, to use the online MediaWiki instance
21
+ Wiki::Api::Connect.config = URI_CONFIG.merge(PAGE_CONFIG)
22
+ # Wiki::Api::Connect.config.merge!(PAGE_CONFIG)
23
+ end
24
+
25
+ def teardown; end
26
+
27
+ # test simple page invocation
28
+ def test_headlines_nested
29
+ # load page
30
+ page = Wiki::Api::Page.new(name: 'program')
31
+ assert(page.is_a?(Wiki::Api::Page), 'expected Page object')
32
+ headline = page.root_headline
33
+ assert(headline.is_a?(Wiki::Api::PageHeadline), 'expected PageHeadline object')
34
+ assert(headline.name == 'program', 'expected developer headline')
35
+
36
+ # search nested headline: english
37
+ english = headline.headline('english').first
38
+ assert(english.is_a?(Wiki::Api::PageHeadline), 'expected PageHeadline object')
39
+
40
+ # search nested headline: noun
41
+ noun = english.headline('noun').first
42
+ assert(noun.is_a?(Wiki::Api::PageHeadline), 'expected PageHeadline object')
43
+
44
+ # get block
45
+ block = noun.block
46
+ assert(block.is_a?(Wiki::Api::PageBlock), 'expected PageBlock object')
47
+
48
+ # list items
49
+ block.list_items.each do |list_item|
50
+ assert(list_item.is_a?(Wiki::Api::PageListItem), 'expected PageListItem object')
51
+ # links
52
+ list_item.links.each do |link|
53
+ assert(link.is_a?(Wiki::Api::PageLink), 'expected PageListItem object')
54
+ end
55
+ end
56
+
57
+ # links
58
+ block.links.each do |link|
59
+ assert(link.is_a?(Wiki::Api::PageLink), 'expected PageListItem object')
60
+ end
61
+ end
62
+
63
+ # def test_headlines_verify_tree_objects
64
+ # page = Wiki::Api::Page.new name: "program"
65
+ # assert page.is_a?(Wiki::Api::Page), "expected Page object"
66
+
67
+ # # get root headline
68
+ # headline = page.root_headline
69
+ # assert headline.is_a?(Wiki::Api::PageHeadline), "expected PageHeadline object"
70
+ # assert headline.name == "program", "expected program headline"
71
+
72
+ # # search in depth on headline noun
73
+ # nouns = headline.headline_by_name "noun", 1
74
+
75
+ # nouns.each do |noun|
76
+ # assert noun.is_a?(Wiki::Api::PageHeadline), "expected PageHeadline object"
77
+
78
+ # # get block
79
+ # block = noun.block
80
+ # assert block.is_a?(Wiki::Api::PageBlock), "expected PageBlock object"
81
+
82
+ # # list items
83
+ # block.list_items.each do |list_item|
84
+ # assert list_item.is_a?(Wiki::Api::PageListItem), "expected PageListItem object"
85
+ # # links
86
+ # list_item.links.each do |link|
87
+ # assert link.is_a?(Wiki::Api::PageLink), "expected PageListItem object"
88
+ # end
89
+ # end
90
+
91
+ # # links
92
+ # block.links.each do |link|
93
+ # assert link.is_a?(Wiki::Api::PageLink), "expected PageListItem object"
94
+ # end
95
+ # end
96
+ # end
97
+
98
+ def test_headlines_verify_tree_data
99
+ page = Wiki::Api::Page.new(name: 'program')
100
+ root_headline = page.root_headline
101
+ # get root
102
+ assert(root_headline.name == 'program', 'expected program name')
103
+
104
+ # iterate one deep and verify headline index names
105
+ root_headline.headlines.each do |name, headline|
106
+ assert(headline.name == name)
107
+ end
108
+ headlines = root_headline.headlines.values
109
+
110
+ # English
111
+ english_headlines = headlines[0]
112
+ assert(english_headlines.name == 'English')
113
+ english_headlines = english_headlines.headlines.values
114
+ assert(english_headlines[0].name == 'Alternative_forms')
115
+ assert(english_headlines[1].name == 'Etymology')
116
+ assert(english_headlines[2].name == 'Pronunciation')
117
+ assert(english_headlines[3].name == 'Noun')
118
+ noun_english_headlines = english_headlines[3].headlines.values
119
+ assert(noun_english_headlines[0].name == 'Usage_notes')
120
+ assert(noun_english_headlines[1].name == 'Synonyms')
121
+ assert(noun_english_headlines[2].name == 'Translations')
122
+ assert(english_headlines[4].name == 'Verb')
123
+ verb_english_headlines = english_headlines[4].headlines.values
124
+ assert(verb_english_headlines[0].name == 'Related_terms')
125
+ assert(verb_english_headlines[1].name == 'Translations_2')
126
+ assert(english_headlines[5].name == 'External_links')
127
+
128
+ # Czech
129
+ czech_headlines = headlines[1]
130
+ assert(czech_headlines.name == 'Czech')
131
+ czech_headlines = czech_headlines.headlines.values
132
+ assert(czech_headlines[0].name == 'Pronunciation_2')
133
+ assert(czech_headlines[1].name == 'Noun_2')
134
+
135
+ # Hungarian
136
+ hungarian_headlines = headlines[2]
137
+ assert(hungarian_headlines.name == 'Hungarian')
138
+ hungarian_headlines = hungarian_headlines.headlines.values
139
+ assert(hungarian_headlines[0].name == 'Pronunciation_3')
140
+ assert(hungarian_headlines[1].name == 'Noun_3')
141
+ noun_hungarian_headlines = hungarian_headlines[1].headlines.values
142
+ assert(noun_hungarian_headlines[0].name == 'Declension')
143
+ assert(noun_hungarian_headlines[1].name == 'Derived_terms')
144
+
145
+ # Norwegian
146
+ norwegian_headlines = headlines[3]
147
+ assert(norwegian_headlines.name == 'Norwegian_Bokm.C3.A5l')
148
+ norwegian_headlines = norwegian_headlines.headlines.values
149
+ assert(norwegian_headlines[0].name == 'Noun_4')
150
+
151
+ # Romanian
152
+ romanian_headlines = headlines[4]
153
+ assert(romanian_headlines.name == 'Romanian')
154
+ romanian_headlines = romanian_headlines.headlines.values
155
+ assert(romanian_headlines[0].name == 'Etymology_2')
156
+ assert(romanian_headlines[1].name == 'Noun_5')
157
+ noun_romanian_headlines = romanian_headlines[1].headlines.values
158
+ assert(noun_romanian_headlines[0].name == 'Declension_2')
159
+ assert(noun_romanian_headlines[1].name == 'Related_terms_2')
160
+
161
+ # Serbo-Croatian
162
+ serb_croatian_headlines = headlines[5]
163
+ assert(serb_croatian_headlines.name == 'Serbo-Croatian')
164
+ serb_croatian_headlines = serb_croatian_headlines.headlines.values
165
+ assert(serb_croatian_headlines[0].name == 'Noun_6')
166
+ noun_serb_croatian_headlines = serb_croatian_headlines[0].headlines.values
167
+ assert(noun_serb_croatian_headlines[0].name == 'Declension_3')
168
+
169
+ # Slovak
170
+ slovak_headlines = headlines[6]
171
+ assert(slovak_headlines.name == 'Slovak')
172
+ slovak_headlines = slovak_headlines.headlines.values
173
+ assert(slovak_headlines[0].name == 'Noun_7')
174
+
175
+ # Swedish
176
+ swedish_headlines = headlines[7]
177
+ assert(swedish_headlines.name == 'Swedish')
178
+ swedish_headlines = swedish_headlines.headlines.values
179
+ assert(swedish_headlines[0].name == 'Etymology_3')
180
+ assert(swedish_headlines[1].name == 'Noun_8')
181
+ noun_swedish_headlines = swedish_headlines[1].headlines.values
182
+ assert(noun_swedish_headlines[0].name == 'Declension_4')
183
+
184
+ # Turkish
185
+ turkish_headlines = headlines[8]
186
+ assert(turkish_headlines.name == 'Turkish')
187
+ turkish_headlines = turkish_headlines.headlines.values
188
+ assert(turkish_headlines[0].name == 'Etymology_4')
189
+ assert(turkish_headlines[1].name == 'Noun_9')
190
+ noun_turkish_headlines = turkish_headlines[1].headlines.values
191
+ assert(noun_turkish_headlines[0].name == 'Declension_5')
192
+ end
193
+
194
+ def test_headlines_search
195
+ page = Wiki::Api::Page.new(name: 'program')
196
+ root_headline = page.root_headline
197
+ # get root
198
+ assert(root_headline.name == 'program', 'expected program name')
199
+
200
+ headlines = root_headline.headline('english')
201
+ assert(!headlines.empty?, 'expected a headline')
202
+
203
+ # iterate english
204
+ headlines.each do |headline|
205
+ assert(headline.is_a?(Wiki::Api::PageHeadline), 'expected PageHeadline object')
206
+ assert(headline.name == 'English', 'expected English')
207
+ noun_headlines = headline.headline('noun')
208
+ assert(!noun_headlines.empty?, 'exptected a headline')
209
+ # iterate nouns
210
+ noun_headlines.each do |noun_headline|
211
+ assert(noun_headline.is_a?(Wiki::Api::PageHeadline), 'expected PageHeadline object')
212
+ assert(noun_headline.name == 'Noun', 'expected Noun')
213
+
214
+ # list_item.links.each do |link|
215
+ end
216
+ end
217
+ end
218
+
219
+ def test_headlines_has_headline
220
+ # load page
221
+ page = Wiki::Api::Page.new(name: 'program')
222
+
223
+ # get root
224
+ root_headline = page.root_headline
225
+ assert(root_headline.name == 'program', 'expected program name')
226
+ headline = root_headline.headline('english').first
227
+
228
+ # verify existence english headlines
229
+ assert(headline.has_headline?('alternative forms'))
230
+ assert(headline.has_headline?('etymology'))
231
+ assert(headline.has_headline?('pronunciation'))
232
+ assert(headline.has_headline?('noun'))
233
+ assert(headline.has_headline?('verb'))
234
+ assert(headline.has_headline?('external links'))
235
+ assert(!headline.has_headline?('alternative12 forms'))
236
+ assert(!headline.has_headline?('etymolfaogy'))
237
+ assert(!headline.has_headline?('pronunciafaation'))
238
+ assert(!headline.has_headline?('nounia'))
239
+ assert(!headline.has_headline?('verbaf'))
240
+ assert(!headline.has_headline?('externalaf links'))
241
+
242
+ # verify existence czech headlines
243
+ headline = root_headline.headline('czech').first
244
+ assert(headline.has_headline?('pronunciation'))
245
+ assert(headline.has_headline?('noun'))
246
+ assert(!headline.has_headline?('pronunciation82'))
247
+ assert(!headline.has_headline?('nouan'))
248
+
249
+ # TODO: add other headlines here as well!
250
+ end
251
+
252
+ def test_headlines_recursive_search
253
+ # load page
254
+ page = Wiki::Api::Page.new(name: 'program')
255
+
256
+ # get root
257
+ root_headline = page.root_headline
258
+ assert(root_headline.name == 'program', 'expected program name')
259
+ headline = root_headline.headline('english').first
260
+
261
+ related_terms_headline = headline.headline_in_depth('related terms').first
262
+ assert(related_terms_headline.is_a?(Wiki::Api::PageHeadline), 'expected PageHeadline object')
263
+ assert(related_terms_headline.name == 'Related_terms')
264
+ assert(related_terms_headline.parent.is_a?(Wiki::Api::PageHeadline))
265
+ assert(related_terms_headline.parent.name == 'Verb')
266
+ assert(related_terms_headline.parent.parent.is_a?(Wiki::Api::PageHeadline))
267
+ assert(related_terms_headline.parent.parent.name == 'English')
268
+ end
269
+
270
+ def test_headlines_recursive_multi_search
271
+ # load page
272
+ page = Wiki::Api::Page.new(name: 'program')
273
+
274
+ # get root
275
+ root_headline = page.root_headline
276
+ assert(root_headline.name == 'program', 'expected program name')
277
+ headline = root_headline.headline('english').first
278
+ # search translations within english
279
+ translations_headlines = headline.headline_in_depth('translations')
280
+ assert(translations_headlines[0].name == 'Translations')
281
+ assert(translations_headlines[1].name == 'Translations_2')
282
+ end
283
+
284
+ def test_headlines_recursive_search_limit_depth
285
+ # load page
286
+ page = Wiki::Api::Page.new(name: 'program')
287
+ # get root
288
+ root_headline = page.root_headline
289
+ assert(root_headline.name == 'program', 'expected program name')
290
+ headline = root_headline.headline('english').first
291
+ # search translations within english
292
+ translations_headlines = headline.headline_in_depth('translations', 0)
293
+ assert(translations_headlines.empty?, 'expected no translations at depth 0')
294
+ end
295
+ end
data/wiki-api.gemspec CHANGED
@@ -1,29 +1,32 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ require 'English'
4
+ lib = File.expand_path('lib', __dir__)
3
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
6
  require 'wiki/api/version'
5
7
 
6
8
  Gem::Specification.new do |spec|
7
- spec.name = "wiki-api"
9
+ spec.name = 'wiki-api'
8
10
  spec.version = Wiki::Api::VERSION
9
- spec.authors = ["Dennis Blommesteijn"]
10
- spec.email = ["dennis@blommesteijn.com"]
11
- spec.description = %q{MediaWiki API and Page content parser for Headlines, Blocks, Elements, ListItems, and Links.}
12
- spec.summary = %q{MediaWiki API and Page content parser for Headlines, Blocks, Elements, ListItems, and Links.}
13
- spec.homepage = "https://github.com/dblommesteijn/wiki-api"
14
- spec.license = "MIT"
11
+ spec.authors = ['Dennis Blommesteijn']
12
+ spec.email = ['dennis@blommesteijn.com']
13
+ spec.description = 'MediaWiki API and Page content parser for Headlines (nested), TextBlocks, ListItems, and Links.'
14
+ spec.summary = 'MediaWiki API and Page content parser for Headlines (nested), TextBlocks, ListItems, and Links.'
15
+ spec.homepage = 'https://github.com/dblommesteijn/wiki-api'
16
+ spec.license = 'MIT'
15
17
 
16
- spec.files = `git ls-files`.split($/)
18
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
19
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
20
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
21
+ spec.require_paths = ['lib']
22
+ spec.required_ruby_version = '>= 1.9.3'
20
23
 
21
- spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rake"
24
+ spec.add_development_dependency('bundler', '> 1.3')
25
+ spec.add_development_dependency('pry', '~> 0.14')
26
+ spec.add_development_dependency('rake')
27
+ spec.add_development_dependency('rubocop', '~> 1.59.0')
28
+ spec.add_development_dependency('test-unit', '> 2.0.0')
23
29
 
24
30
  # dependencies
25
- spec.add_dependency 'nokogiri', "~> 1.5.0"
26
- spec.add_dependency 'json', "~> 1.6.1"
27
- spec.add_development_dependency "test-unit", "~> 2.0.0"
28
-
31
+ spec.add_dependency('nokogiri', '> 1.13.0')
29
32
  end
metadata CHANGED
@@ -1,97 +1,116 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wiki-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dennis Blommesteijn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-03 00:00:00.000000000 Z
11
+ date: 2023-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
15
22
  version_requirements: !ruby/object:Gem::Requirement
16
23
  requirements:
17
- - - "~>"
24
+ - - ">"
18
25
  - !ruby/object:Gem::Version
19
26
  version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
20
29
  requirement: !ruby/object:Gem::Requirement
21
30
  requirements:
22
31
  - - "~>"
23
32
  - !ruby/object:Gem::Version
24
- version: '1.3'
25
- prerelease: false
33
+ version: '0.14'
26
34
  type: :development
27
- - !ruby/object:Gem::Dependency
28
- name: rake
35
+ prerelease: false
29
36
  version_requirements: !ruby/object:Gem::Requirement
30
37
  requirements:
31
- - - ">="
38
+ - - "~>"
32
39
  - !ruby/object:Gem::Version
33
- version: '0'
40
+ version: '0.14'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
34
43
  requirement: !ruby/object:Gem::Requirement
35
44
  requirements:
36
45
  - - ">="
37
46
  - !ruby/object:Gem::Version
38
47
  version: '0'
39
- prerelease: false
40
48
  type: :development
41
- - !ruby/object:Gem::Dependency
42
- name: nokogiri
49
+ prerelease: false
43
50
  version_requirements: !ruby/object:Gem::Requirement
44
51
  requirements:
45
- - - "~>"
52
+ - - ">="
46
53
  - !ruby/object:Gem::Version
47
- version: 1.5.0
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
48
57
  requirement: !ruby/object:Gem::Requirement
49
58
  requirements:
50
59
  - - "~>"
51
60
  - !ruby/object:Gem::Version
52
- version: 1.5.0
61
+ version: 1.59.0
62
+ type: :development
53
63
  prerelease: false
54
- type: :runtime
55
- - !ruby/object:Gem::Dependency
56
- name: json
57
64
  version_requirements: !ruby/object:Gem::Requirement
58
65
  requirements:
59
66
  - - "~>"
60
67
  - !ruby/object:Gem::Version
61
- version: 1.6.1
68
+ version: 1.59.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: test-unit
62
71
  requirement: !ruby/object:Gem::Requirement
63
72
  requirements:
64
- - - "~>"
73
+ - - ">"
65
74
  - !ruby/object:Gem::Version
66
- version: 1.6.1
75
+ version: 2.0.0
76
+ type: :development
67
77
  prerelease: false
68
- type: :runtime
69
- - !ruby/object:Gem::Dependency
70
- name: test-unit
71
78
  version_requirements: !ruby/object:Gem::Requirement
72
79
  requirements:
73
- - - "~>"
80
+ - - ">"
74
81
  - !ruby/object:Gem::Version
75
82
  version: 2.0.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: nokogiri
76
85
  requirement: !ruby/object:Gem::Requirement
77
86
  requirements:
78
- - - "~>"
87
+ - - ">"
79
88
  - !ruby/object:Gem::Version
80
- version: 2.0.0
89
+ version: 1.13.0
90
+ type: :runtime
81
91
  prerelease: false
82
- type: :development
83
- description: MediaWiki API and Page content parser for Headlines, Blocks, Elements, ListItems, and Links.
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">"
95
+ - !ruby/object:Gem::Version
96
+ version: 1.13.0
97
+ description: MediaWiki API and Page content parser for Headlines (nested), TextBlocks,
98
+ ListItems, and Links.
84
99
  email:
85
100
  - dennis@blommesteijn.com
86
- executables: []
101
+ executables:
102
+ - console
87
103
  extensions: []
88
104
  extra_rdoc_files: []
89
105
  files:
90
106
  - ".gitignore"
107
+ - ".rubocop.yml"
108
+ - ".travis.yml"
91
109
  - Gemfile
92
110
  - LICENSE.txt
93
111
  - README.md
94
112
  - Rakefile
113
+ - bin/console
95
114
  - lib/wiki/api.rb
96
115
  - lib/wiki/api/connect.rb
97
116
  - lib/wiki/api/page.rb
@@ -103,9 +122,9 @@ files:
103
122
  - lib/wiki/api/version.rb
104
123
  - test/test_helper.rb
105
124
  - test/unit/files/Wiktionary_Welcome,_newcomers.html
125
+ - test/unit/files/Wiktionary_program.html
106
126
  - test/unit/wiki_connect.rb
107
- - test/unit/wiki_page_config.rb
108
- - test/unit/wiki_page_object.rb
127
+ - test/unit/wiki_page_offline.rb
109
128
  - wiki-api.gemspec
110
129
  homepage: https://github.com/dblommesteijn/wiki-api
111
130
  licenses:
@@ -119,21 +138,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
119
138
  requirements:
120
139
  - - ">="
121
140
  - !ruby/object:Gem::Version
122
- version: '0'
141
+ version: 1.9.3
123
142
  required_rubygems_version: !ruby/object:Gem::Requirement
124
143
  requirements:
125
144
  - - ">="
126
145
  - !ruby/object:Gem::Version
127
146
  version: '0'
128
147
  requirements: []
129
- rubyforge_project:
130
- rubygems_version: 2.0.3
148
+ rubygems_version: 3.3.7
131
149
  signing_key:
132
150
  specification_version: 4
133
- summary: MediaWiki API and Page content parser for Headlines, Blocks, Elements, ListItems, and Links.
151
+ summary: MediaWiki API and Page content parser for Headlines (nested), TextBlocks,
152
+ ListItems, and Links.
134
153
  test_files:
135
154
  - test/test_helper.rb
136
155
  - test/unit/files/Wiktionary_Welcome,_newcomers.html
156
+ - test/unit/files/Wiktionary_program.html
137
157
  - test/unit/wiki_connect.rb
138
- - test/unit/wiki_page_config.rb
139
- - test/unit/wiki_page_object.rb
158
+ - test/unit/wiki_page_offline.rb
@@ -1,45 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'rubygems'
4
- require 'test/unit'
5
- require File.expand_path(File.dirname(__FILE__) + "/../../lib/wiki/api")
6
-
7
- #
8
- # Testing the parsing of URI by passing a uri variable to Page:
9
- # https://en.wiktionary.org/wiki/Wiktionary:Welcome,_newcomers
10
- #
11
-
12
- class WikiPageConfig < Test::Unit::TestCase
13
-
14
- def setup
15
- # NOTE: comment Page.config, to use the online MediaWiki instance
16
- # Wiki::Api::Page.config = PAGE_CONFIG
17
- # Wiki::Api::Connect.config = GLB_CONFIG
18
- # @page_name = "Wiktionary:Welcome,_newcomers"
19
- end
20
-
21
- def teardown
22
- end
23
-
24
- # test simple page invocation
25
- def test_page_invocation_with_uri
26
- page = Wiki::Api::Page.new name: "Wiktionary:Welcome,_newcomers", uri: "http://en.wiktionary.org"
27
- headlines = page.headlines
28
- assert !headlines.empty?, "expected headlines"
29
- assert headlines.size < 1, "expected more than one headline"
30
- headlines.each do |headline|
31
- assert headline.is_a?(Wiki::Api::PageHeadline), "expected headline object"
32
- end
33
- end
34
-
35
- def test_wrong_page_invocation_with_uri
36
- begin
37
- page = Wiki::Api::Page.new name: "A_Wrong_Page_Name", uri: "http://en.wiktionary.org"
38
- assert false, "expected a failiure"
39
- rescue Exception => e
40
- assert true, "expected a failiure"
41
- end
42
- end
43
-
44
- end
45
-