mediawiki-page-replaceable_content 0.1.3 → 0.1.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
- SHA1:
3
- metadata.gz: 6de805495e9a8a705620c1d3c3688401fe5e39b9
4
- data.tar.gz: 0e2997536489f3ff9ea1bdb29de6137037cb08ef
2
+ SHA256:
3
+ metadata.gz: 10861a2810d963915537a61ede8026780438fbd2729abe68fd18ee4134e07baf
4
+ data.tar.gz: 64164f38a99995da1ca6e1da027035e1fd1ea5c10883be03f39e1d1b45fc8a20
5
5
  SHA512:
6
- metadata.gz: c9332c50ef58a03c2076cf6c3f466ebf5621c22292148c9eb62251ba382bbd35d1b97bd43121508aef33e4010520321f3dc2db7839d8570a4aa7926d8d74b211
7
- data.tar.gz: a4f7c2896b6811bd0ba59ca136164348b38abbfee68310f3ff6e1e072c022861c925eb01bce56e33f7cd7149969e1216b97bca41e619a3a651322dd61644434d
6
+ metadata.gz: 5293756998fc8d69a882ab38f5e8c7b4a880fa239dbc99b37c8d79f4e3586f6d71684b1599359c902a4d2f76f37a9d487b2f8bc4066795f54b6b7c26d97e45b9
7
+ data.tar.gz: 74d2e0d8e5398c6fec99950d6b0ec9408f95080e6a63f79229ba4f508f17ce1f60feff86bbcd299521cd6a7dc8bc43976d2c0a6f0888e91cbaf91345393515a0
@@ -18,9 +18,7 @@ module MediaWiki
18
18
  def wrapped_client
19
19
  @wrapped_client ||= MediawikiApi::Client.new("https://#{site}/w/api.php").tap do |c|
20
20
  result = c.log_in(username, password)
21
- unless result['result'] == 'Success'
22
- raise "MediawikiApi::Client#log_in failed: #{result}"
23
- end
21
+ raise "MediawikiApi::Client#log_in failed: #{result}" if result['result'] != 'Success'
24
22
  end
25
23
  end
26
24
  end
@@ -5,6 +5,8 @@ module MediaWiki
5
5
  class ReplaceableContent
6
6
  NAMED_TEMPLATE_PARAM_RE = /(.*?)=(.*)/m
7
7
 
8
+ TemplateNotFoundError = Class.new(StandardError)
9
+
8
10
  def initialize(client:, title:, template:)
9
11
  @client = client
10
12
  @title = title
@@ -81,7 +83,7 @@ module MediaWiki
81
83
  def page_parts
82
84
  return @page_parts if @page_parts
83
85
  m = template_re.match(wikitext)
84
- raise "The template '#{template}' was not found in '#{title}'" unless m
86
+ raise TemplateNotFoundError, "The template '#{template}' was not found in '#{title}'" unless m
85
87
  parts = matchdata_to_h(m)
86
88
  @page_parts = parts.merge(split_after(parts[:after]))
87
89
  end
@@ -108,8 +110,8 @@ module MediaWiki
108
110
  end
109
111
  end
110
112
 
111
- def matchdata_to_h(md)
112
- md.names.map(&:to_sym).zip(md.captures).to_h
113
+ def matchdata_to_h(matchdata)
114
+ matchdata.names.map(&:to_sym).zip(matchdata.captures).to_h
113
115
  end
114
116
  end
115
117
  end
@@ -1,11 +1,9 @@
1
- # coding: utf-8
2
-
3
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
4
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
3
 
6
4
  Gem::Specification.new do |spec|
7
5
  spec.name = 'mediawiki-page-replaceable_content'
8
- spec.version = '0.1.3'
6
+ spec.version = '0.1.4'
9
7
  spec.authors = ['EveryPolitician']
10
8
  spec.email = ['team@everypolitician.org']
11
9
  spec.licenses = ['MIT']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mediawiki-page-replaceable_content
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - EveryPolitician
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-03 00:00:00.000000000 Z
11
+ date: 2018-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mediawiki_api
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
137
  version: '0'
138
138
  requirements: []
139
139
  rubyforge_project:
140
- rubygems_version: 2.5.1
140
+ rubygems_version: 2.7.6
141
141
  signing_key:
142
142
  specification_version: 4
143
143
  summary: Rewrite content after a template tag based on the template parameters