infoboxer 0.2.3 → 0.2.4

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
  SHA1:
3
- metadata.gz: fcf940ddedd92a04eb2e555bc16c5ef765a3e8d3
4
- data.tar.gz: c8e8c4976ea2e8e023c79c26bd221ff5f22b5a32
3
+ metadata.gz: b9b19c697cee8b3687f6be2750819cbd38c91508
4
+ data.tar.gz: 7db684f6b8b1bd1c0fff88c8a41240844fe0bda3
5
5
  SHA512:
6
- metadata.gz: d2e54fe4fe9d1a7714f6aa5b0d47b2957a0b0a00b1d65ca9ea4f925efa2dafb364d354235f3c19990f812293ee6bfe6e86602b019fb71eff4b6a67b96d6bf82a
7
- data.tar.gz: d3ea47fcedb10473abc5083b750b4c3804532f8f6d0278a51a2d270913a899f3897c35fee9099a5aa08bf1dea8dfaa7292fc5b06cc350671cbde24625936d956
6
+ metadata.gz: 0fb2a48e19eb445575f4bc3a622cee4b8a1e7567211d6e936cb5ddd150f0a12930a58e32ec16a658154b799dc4585d6bb3b7700decdf3bdda4d600f9455fc969
7
+ data.tar.gz: d5583aefd5734b8ae694e4d33d0b0a522349ae3a3df17d8b5ff1d7513576de3e073cd7c8b5a28026cd0ef3521375161df65cfc89dad43caff8190fd3ee48163d
@@ -1,5 +1,11 @@
1
1
  # Infoboxer's change log
2
2
 
3
+ ## 0.2.4 (2016-04-16)
4
+
5
+ * `MediaWiki#get_h` works correctly with several synonymous pages now;
6
+ * `get` and `get_h` work better when some of required titles are downcase;
7
+ * Travis compatibility check restored.
8
+
3
9
  ## 0.2.3 (2016-03-02)
4
10
 
5
11
  New and enchanced features:
@@ -31,7 +31,7 @@ if wiki_url
31
31
 
32
32
  DEFAULT_WIKI = Infoboxer.wiki(wiki_url)
33
33
  puts "Default Wiki selected: #{wiki_url}.\nNow you can use `get('Pagename')`, `category('Categoryname')` and so on.\n\n"
34
- [:raw, :get, :category, :search, :prefixsearch].each do |m|
34
+ [:raw, :get, :get_h, :category, :search, :prefixsearch].each do |m|
35
35
  define_method(m){|*arg|
36
36
  DEFAULT_WIKI.send(m, *arg)
37
37
  }
@@ -60,6 +60,8 @@ module Infoboxer
60
60
  #
61
61
  # @return [Array<Hash>]
62
62
  def raw(*titles)
63
+ return [] if titles.empty? # could emerge on "automatically" created page lists, should work
64
+
63
65
  titles.each_slice(50).map{|part|
64
66
  @client.query.
65
67
  titles(*part).
@@ -67,7 +69,10 @@ module Infoboxer
67
69
  redirects(true). # FIXME: should be done transparently by MediaWiktory?
68
70
  perform.pages
69
71
  }.inject(:concat). # somehow flatten(1) fails!
70
- sort_by{|page| titles.index(page.queried_title) || 1_000}
72
+ sort_by{|page|
73
+ res_title = page.alt_titles.detect{|t| titles.map(&:downcase).include?(t.downcase)} # FIXME?..
74
+ titles.index(res_title) || 1_000
75
+ }
71
76
  end
72
77
 
73
78
  # Receive list of parsed MediaWiki pages for list of titles provided.
@@ -123,7 +128,7 @@ module Infoboxer
123
128
  def get_h(*titles)
124
129
  pages = [*get(*titles)]
125
130
  titles.map{|t|
126
- [t, pages.detect{|p| p.source.queried_title == t}]
131
+ [t, pages.detect{|p| p.source.alt_titles.map(&:downcase).include?(t.downcase)}]
127
132
  }.to_h
128
133
  end
129
134
 
@@ -3,10 +3,8 @@ require 'mediawiktory'
3
3
  # FIXME: looks like pretty "core" functionality and should moved to mediawiktory itself
4
4
 
5
5
  class MediaWiktory::Page
6
- attr_writer :queried_title
7
-
8
- def queried_title
9
- @queried_title || title
6
+ def alt_titles
7
+ @alt_titles ||= [title]
10
8
  end
11
9
  end
12
10
 
@@ -18,7 +16,7 @@ class MediaWiktory::Query::Response
18
16
  if raw.query.redirects
19
17
  raw.query.redirects.each do |redirect|
20
18
  pg = @pages.detect{|p| p.title == redirect.to} or next
21
- pg.queried_title = redirect.from
19
+ pg.alt_titles << redirect.from
22
20
  end
23
21
  end
24
22
  end
@@ -2,6 +2,6 @@
2
2
  module Infoboxer
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- PATCH = 3
5
+ PATCH = 4
6
6
  VERSION = [MAJOR, MINOR, PATCH].join('.')
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infoboxer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Shepelev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-02 00:00:00.000000000 Z
11
+ date: 2016-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities