wikidata_position_history 1.3.3 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ruby.yml +33 -0
- data/.rubocop.yml +15 -1
- data/.travis.yml +1 -4
- data/CHANGELOG.md +39 -0
- data/Rakefile +1 -1
- data/bin/console +0 -0
- data/bin/setup +0 -0
- data/exe/update_wikidata_page +1 -1
- data/lib/sparql/bio_data.rb +56 -0
- data/lib/sparql/item_query.rb +6 -0
- data/lib/sparql/mandates.rb +11 -2
- data/lib/wikidata_position_history.rb +16 -14
- data/lib/wikidata_position_history/checks.rb +5 -5
- data/lib/wikidata_position_history/report.rb +49 -64
- data/lib/wikidata_position_history/template.rb +38 -0
- data/lib/wikidata_position_history/version.rb +1 -1
- data/wikidata_position_history.gemspec +7 -5
- metadata +42 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 35a434aeccb7428a5d7ebc4ff9b534e6477980d153e744760459c3125c4e90ae
|
4
|
+
data.tar.gz: bf8f4773d018ae8800104989e2052689ea19217a2a2cafbc09c8d4e4839ce7d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9900bcc56726b22bf6a2e590400298fdd50dec62c992c1613fd33d2250d4a909ceed1dfc409ec94d5c4ff992a4ffbfcd15893fd9522f3061e967ca2370b03fad
|
7
|
+
data.tar.gz: c1d5ad9bdf3378afbebb3b97ffdd0bebca18e88be03605e0ba5d6a379efee73e5293b6881ebe854873fe879b1409320d721f20162d15a654350ccea4587e506c
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ master ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ master ]
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
test:
|
18
|
+
|
19
|
+
runs-on: ubuntu-latest
|
20
|
+
|
21
|
+
steps:
|
22
|
+
- uses: actions/checkout@v2
|
23
|
+
- name: Set up Ruby
|
24
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
25
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
26
|
+
# uses: ruby/setup-ruby@v1
|
27
|
+
uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
|
28
|
+
with:
|
29
|
+
ruby-version: 2.5
|
30
|
+
- name: Install dependencies
|
31
|
+
run: bundle install
|
32
|
+
- name: Run tests
|
33
|
+
run: bundle exec rake
|
data/.rubocop.yml
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-performance
|
3
|
+
- rubocop-rspec
|
4
|
+
|
1
5
|
AllCops:
|
2
6
|
Exclude:
|
3
7
|
- 'Vagrantfile'
|
4
8
|
- 'vendor/**/*'
|
5
|
-
TargetRubyVersion: 2.
|
9
|
+
TargetRubyVersion: 2.5
|
6
10
|
NewCops: enable
|
7
11
|
|
8
12
|
Metrics/AbcSize:
|
@@ -29,6 +33,13 @@ Lint/AssignmentInCondition:
|
|
29
33
|
Naming/ClassAndModuleCamelCase:
|
30
34
|
Enabled: false
|
31
35
|
|
36
|
+
RSpec/DescribedClass:
|
37
|
+
Enabled: false
|
38
|
+
|
39
|
+
# TODO: remove this?
|
40
|
+
RSpec/MultipleExpectations:
|
41
|
+
Max: 2
|
42
|
+
|
32
43
|
Style/CollectionMethods:
|
33
44
|
Enabled: true
|
34
45
|
|
@@ -52,3 +63,6 @@ Style/TrailingCommaInHashLiteral:
|
|
52
63
|
|
53
64
|
Style/TrailingCommaInArrayLiteral:
|
54
65
|
EnforcedStyleForMultiline: no_comma
|
66
|
+
|
67
|
+
Layout/ClassStructure:
|
68
|
+
Enabled: true
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,44 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
# [1.4.3] 2020-09-05
|
4
|
+
|
5
|
+
## Fixes
|
6
|
+
|
7
|
+
* No longer blows up when a P39 has a start date, but no end date
|
8
|
+
|
9
|
+
# [1.4.2] 2020-09-05
|
10
|
+
|
11
|
+
## Fixes
|
12
|
+
|
13
|
+
* Bring back the warnings when start or end dates are missing.
|
14
|
+
|
15
|
+
# [1.4.1] 2020-09-04
|
16
|
+
|
17
|
+
## Fixes
|
18
|
+
|
19
|
+
* Work around template deployment issue.
|
20
|
+
|
21
|
+
# [1.4.0] 2020-09-04
|
22
|
+
|
23
|
+
## Enhancements
|
24
|
+
|
25
|
+
* Add an image column.
|
26
|
+
* Improve the warning for inconsistent successor/predecessor values.
|
27
|
+
|
28
|
+
# [1.3.4] - 2020-09-01
|
29
|
+
|
30
|
+
## Fixes
|
31
|
+
|
32
|
+
* Update to latest version of mediawiki-replaceable-content to include
|
33
|
+
upstream bug fix.
|
34
|
+
|
35
|
+
# [1.3.3] - 2020-08-29
|
36
|
+
|
37
|
+
## Enhancements
|
38
|
+
|
39
|
+
* Include link to Wikidata Query Service showing the SPARQL used to
|
40
|
+
generate the list.
|
41
|
+
|
3
42
|
# [1.3.2] - 2020-08-29
|
4
43
|
|
5
44
|
## Fixes
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
File without changes
|
data/bin/setup
CHANGED
File without changes
|
data/exe/update_wikidata_page
CHANGED
@@ -17,7 +17,7 @@ if ARGV.first.start_with?('http')
|
|
17
17
|
page_title: uri.path.gsub('/wiki/', ''), # with 2.5.1 we could use delete_prefix
|
18
18
|
}
|
19
19
|
else
|
20
|
-
options = URI.decode_www_form(ARGV.first).
|
20
|
+
options = URI.decode_www_form(ARGV.first).transform_keys(&:to_sym)
|
21
21
|
end
|
22
22
|
|
23
23
|
warn "Running with options: #{options.inspect}" if ENV.key?('DEBUG')
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WikidataPositionHistory
|
4
|
+
module SPARQL
|
5
|
+
# SPARQL for fetching biographical about all holders of a position
|
6
|
+
#
|
7
|
+
# This is distinct from the mandate query itself to avoid complex
|
8
|
+
# GROUP BY scenarios where people have multiple values for
|
9
|
+
# biographical properties.
|
10
|
+
class BioData < ItemQuery
|
11
|
+
def raw_sparql
|
12
|
+
<<~SPARQL
|
13
|
+
# holder-biodata
|
14
|
+
|
15
|
+
SELECT DISTINCT ?item ?image
|
16
|
+
WHERE {
|
17
|
+
?item wdt:P31 wd:Q5 ; p:P39/ps:P39 wd:%s .
|
18
|
+
OPTIONAL { ?item wdt:P18 ?image }
|
19
|
+
}
|
20
|
+
ORDER BY ?item
|
21
|
+
SPARQL
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Represents a single row returned from the Position query
|
27
|
+
class BioData
|
28
|
+
def initialize(row)
|
29
|
+
@row = row
|
30
|
+
end
|
31
|
+
|
32
|
+
def person
|
33
|
+
QueryService::WikidataItem.new(row.dig(:item, :value))
|
34
|
+
end
|
35
|
+
|
36
|
+
def image_title
|
37
|
+
return if image_url.to_s.empty?
|
38
|
+
|
39
|
+
image_url.split('/').last
|
40
|
+
end
|
41
|
+
|
42
|
+
def image_link(size = 75)
|
43
|
+
return '' unless image_title
|
44
|
+
|
45
|
+
"[[File:#{image_title}|#{size}px]]"
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
attr_reader :row
|
51
|
+
|
52
|
+
def image_url
|
53
|
+
row.dig(:image, :value)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/sparql/item_query.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'erb'
|
4
|
+
|
3
5
|
module WikidataPositionHistory
|
4
6
|
module SPARQL
|
5
7
|
# Turn raw SPARQL into result objects
|
@@ -12,6 +14,10 @@ module WikidataPositionHistory
|
|
12
14
|
json.map { |result| klass.new(result) }
|
13
15
|
end
|
14
16
|
|
17
|
+
def wdqs_url
|
18
|
+
"https://query.wikidata.org/##{ERB::Util.url_encode(sparql)}"
|
19
|
+
end
|
20
|
+
|
15
21
|
private
|
16
22
|
|
17
23
|
attr_reader :itemid
|
data/lib/sparql/mandates.rb
CHANGED
@@ -7,6 +7,7 @@ module WikidataPositionHistory
|
|
7
7
|
def raw_sparql
|
8
8
|
<<~SPARQL
|
9
9
|
# position-mandates
|
10
|
+
|
10
11
|
SELECT DISTINCT ?ordinal ?item ?start_date ?start_precision ?end_date ?end_precision ?prev ?next ?nature
|
11
12
|
WHERE {
|
12
13
|
?item wdt:P31 wd:Q5 ; p:P39 ?posn .
|
@@ -19,7 +20,6 @@ module WikidataPositionHistory
|
|
19
20
|
OPTIONAL { ?posn pq:P1366|pq:P156 ?next }
|
20
21
|
OPTIONAL { ?posn pq:P1545 ?ordinal }
|
21
22
|
OPTIONAL { ?posn pq:P5102 ?nature }
|
22
|
-
OPTIONAL { ?posn pq:P5102 ?nature }
|
23
23
|
}
|
24
24
|
ORDER BY DESC(?start_date)
|
25
25
|
SPARQL
|
@@ -37,8 +37,13 @@ module WikidataPositionHistory
|
|
37
37
|
row.dig(:ordinal, :value)
|
38
38
|
end
|
39
39
|
|
40
|
+
def officeholder
|
41
|
+
QueryService::WikidataItem.new(row.dig(:item, :value))
|
42
|
+
end
|
43
|
+
|
44
|
+
# TODO: rename or remove. 'item' is meaningless/ambiguous
|
40
45
|
def item
|
41
|
-
|
46
|
+
officeholder.qlink
|
42
47
|
end
|
43
48
|
|
44
49
|
def prev
|
@@ -58,10 +63,14 @@ module WikidataPositionHistory
|
|
58
63
|
end
|
59
64
|
|
60
65
|
def start_date
|
66
|
+
return if start_date_raw.empty?
|
67
|
+
|
61
68
|
QueryService::WikidataDate.new(start_date_raw, start_date_precision)
|
62
69
|
end
|
63
70
|
|
64
71
|
def end_date
|
72
|
+
return if end_date_raw.empty?
|
73
|
+
|
65
74
|
QueryService::WikidataDate.new(end_date_raw, end_date_precision)
|
66
75
|
end
|
67
76
|
|
@@ -3,8 +3,10 @@
|
|
3
3
|
require 'query_service'
|
4
4
|
require 'sparql/item_query'
|
5
5
|
require 'sparql/position_data'
|
6
|
+
require 'sparql/bio_data'
|
6
7
|
require 'sparql/mandates'
|
7
8
|
require 'wikidata_position_history/checks'
|
9
|
+
require 'wikidata_position_history/template'
|
8
10
|
require 'wikidata_position_history/report'
|
9
11
|
require 'wikidata_position_history/version'
|
10
12
|
|
@@ -20,6 +22,19 @@ module WikidataPositionHistory
|
|
20
22
|
WIKI_USERNAME = ENV['WIKI_USERNAME']
|
21
23
|
WIKI_PASSWORD = ENV['WIKI_PASSWORD']
|
22
24
|
|
25
|
+
NO_ID_ERROR = <<~WIKITEXT
|
26
|
+
'''#{WIKI_TEMPLATE_NAME} Error''': You must pass the <code>id</code>
|
27
|
+
parameter to the <code>#{WIKI_TEMPLATE_NAME}</code> template; e.g.
|
28
|
+
<nowiki>{{#{WIKI_TEMPLATE_NAME}|id=Q14211}}</nowiki>
|
29
|
+
WIKITEXT
|
30
|
+
|
31
|
+
MALFORMED_ID_ERROR = <<~WIKITEXT
|
32
|
+
'''#{WIKI_TEMPLATE_NAME} Error''': The <code>id</code> parameter was
|
33
|
+
malformed; it should be Q followed by a number of digits, e.g. as in:
|
34
|
+
|
35
|
+
<nowiki>{{#{WIKI_TEMPLATE_NAME}|id=Q14211}}</nowiki>
|
36
|
+
WIKITEXT
|
37
|
+
|
23
38
|
def initialize(mediawiki_site:, page_title:)
|
24
39
|
@mediawiki_site = mediawiki_site
|
25
40
|
@page_title = page_title.tr('_', ' ')
|
@@ -31,7 +46,7 @@ module WikidataPositionHistory
|
|
31
46
|
|
32
47
|
def new_content
|
33
48
|
return [NO_ID_ERROR, 'The id parameter was missing'] if position_id.empty?
|
34
|
-
return [MALFORMED_ID_ERROR, 'The id parameter was malformed'] unless position_id
|
49
|
+
return [MALFORMED_ID_ERROR, 'The id parameter was malformed'] unless position_id[/^Q\d+$/]
|
35
50
|
|
36
51
|
[WikidataPositionHistory::Report.new(position_id).wikitext, "Successfully updated holders of #{position_id}"]
|
37
52
|
end
|
@@ -40,19 +55,6 @@ module WikidataPositionHistory
|
|
40
55
|
|
41
56
|
attr_reader :mediawiki_site, :page_title
|
42
57
|
|
43
|
-
NO_ID_ERROR = <<~EOERROR
|
44
|
-
'''#{WIKI_TEMPLATE_NAME} Error''': You must pass the <code>id</code>
|
45
|
-
parameter to the <code>#{WIKI_TEMPLATE_NAME}</code> template; e.g.
|
46
|
-
<nowiki>{{#{WIKI_TEMPLATE_NAME}|id=Q14211}}</nowiki>
|
47
|
-
EOERROR
|
48
|
-
|
49
|
-
MALFORMED_ID_ERROR = <<~EOERROR
|
50
|
-
'''#{WIKI_TEMPLATE_NAME} Error''': The <code>id</code> parameter was
|
51
|
-
malformed; it should be Q followed by a number of digits, e.g. as in:
|
52
|
-
|
53
|
-
<nowiki>{{#{WIKI_TEMPLATE_NAME}|id=Q14211}}</nowiki>
|
54
|
-
EOERROR
|
55
|
-
|
56
58
|
def position_id
|
57
59
|
return id_param unless id_param.empty?
|
58
60
|
|
@@ -100,7 +100,7 @@ module WikidataPositionHistory
|
|
100
100
|
end
|
101
101
|
|
102
102
|
def possible_explanation
|
103
|
-
"#{current.item} has a {{P|1365}} of #{predecessor},
|
103
|
+
"#{current.item} has a {{P|1365}} of #{predecessor}, but follows #{earlier.item} here"
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
@@ -115,7 +115,7 @@ module WikidataPositionHistory
|
|
115
115
|
end
|
116
116
|
|
117
117
|
def possible_explanation
|
118
|
-
"#{current.item} has a {{P|1366}} of #{successor},
|
118
|
+
"#{current.item} has a {{P|1366}} of #{successor}, but is followed by #{later.item} here"
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
@@ -124,10 +124,10 @@ module WikidataPositionHistory
|
|
124
124
|
def problem?
|
125
125
|
return false unless later
|
126
126
|
|
127
|
-
|
128
|
-
return false
|
127
|
+
next_starts = later.start_date or return false
|
128
|
+
ends = current.end_date or return false
|
129
129
|
|
130
|
-
ends >
|
130
|
+
ends > next_starts
|
131
131
|
rescue ArgumentError
|
132
132
|
true
|
133
133
|
end
|
@@ -1,95 +1,62 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module WikidataPositionHistory
|
4
|
-
#
|
5
|
-
class
|
4
|
+
# Date for a single mandate row, to be passed to the report template
|
5
|
+
class MandateData
|
6
|
+
CHECKS = [Check::MissingFields, Check::WrongPredecessor, Check::WrongSuccessor, Check::Overlap].freeze
|
7
|
+
|
6
8
|
def initialize(later, current, earlier)
|
7
9
|
@later = later
|
8
10
|
@current = current
|
9
11
|
@earlier = earlier
|
10
12
|
end
|
11
13
|
|
12
|
-
def output
|
13
|
-
[row_start, ordinal_cell, member_cell, warnings_cell].join("\n")
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
CHECKS = [Check::MissingFields, Check::WrongPredecessor, Check::WrongSuccessor, Check::Overlap].freeze
|
19
|
-
|
20
|
-
WARNING_LAYOUT = [
|
21
|
-
'<span style="display: block">[[File:Pictogram voting comment.svg|15px|link=]] ',
|
22
|
-
'<span style="color: #d33; font-weight: bold; vertical-align: middle;">%s</span> ',
|
23
|
-
'<ref>%s</ref></span>'
|
24
|
-
].join
|
25
|
-
|
26
|
-
attr_reader :later, :current, :earlier
|
27
|
-
|
28
|
-
def row_start
|
29
|
-
'|-'
|
30
|
-
end
|
31
|
-
|
32
|
-
def ordinal_cell
|
33
|
-
%(| style="padding:0.5em 2em" | #{ordinal_string})
|
34
|
-
end
|
35
|
-
|
36
14
|
def ordinal_string
|
37
15
|
ordinal = current.ordinal or return ''
|
38
|
-
ordinal.
|
16
|
+
"#{ordinal}."
|
39
17
|
end
|
40
18
|
|
41
|
-
def
|
42
|
-
|
43
|
-
|
44
|
-
'font-size: 1.5em; display: block;'
|
19
|
+
def person
|
20
|
+
current.item
|
45
21
|
end
|
46
22
|
|
47
|
-
def
|
48
|
-
|
49
|
-
|
50
|
-
end
|
23
|
+
def dates
|
24
|
+
dates = [current.start_date, current.end_date]
|
25
|
+
return '' if dates.compact.empty?
|
51
26
|
|
52
|
-
|
53
|
-
format('| style="padding:0.5em 2em 0.5em 1em; border: none; background: #fff; text-align: left;" | %s',
|
54
|
-
combined_warnings)
|
27
|
+
dates.join(' – ')
|
55
28
|
end
|
56
29
|
|
57
|
-
def
|
58
|
-
|
59
|
-
check = check_class.new(later, current, earlier)
|
60
|
-
format(WARNING_LAYOUT, check.headline, check.explanation) if check.problem?
|
61
|
-
end.join
|
30
|
+
def acting?
|
31
|
+
current.acting?
|
62
32
|
end
|
63
33
|
|
64
|
-
def
|
65
|
-
current.
|
34
|
+
def warnings
|
35
|
+
CHECKS.map { |klass| klass.new(later, current, earlier) }.select(&:problem?)
|
66
36
|
end
|
67
37
|
|
68
|
-
|
69
|
-
dates = [current.start_date, current.end_date]
|
70
|
-
# compact doesn't work here, even if we add #nil? to WikidataDate
|
71
|
-
return '' if dates.reject(&:empty?).empty?
|
38
|
+
private
|
72
39
|
|
73
|
-
|
74
|
-
end
|
40
|
+
attr_reader :later, :current, :earlier
|
75
41
|
end
|
76
42
|
|
77
43
|
# The entire wikitext generated for this report
|
78
44
|
class Report
|
79
|
-
def initialize(
|
80
|
-
@
|
45
|
+
def initialize(position_id, template_class = ReportTemplate)
|
46
|
+
@position_id = position_id
|
47
|
+
@template_class = template_class
|
81
48
|
end
|
82
49
|
|
83
|
-
attr_reader :
|
50
|
+
attr_reader :position_id, :template_class
|
84
51
|
|
85
52
|
def wikitext
|
86
53
|
return no_items_output if mandates.empty?
|
87
54
|
|
88
|
-
|
55
|
+
output
|
89
56
|
end
|
90
57
|
|
91
58
|
def header
|
92
|
-
"== {{Q|#{
|
59
|
+
"== {{Q|#{position_id}}} officeholders #{position_dates} =="
|
93
60
|
end
|
94
61
|
|
95
62
|
def position_dates
|
@@ -108,32 +75,50 @@ module WikidataPositionHistory
|
|
108
75
|
def metadata
|
109
76
|
# TODO: we might get more than one response, if a position has
|
110
77
|
# multiple dates
|
111
|
-
@metadata ||= SPARQL::PositionData.new(
|
78
|
+
@metadata ||= SPARQL::PositionData.new(position_id).results_as(PositionData).first
|
79
|
+
end
|
80
|
+
|
81
|
+
def biodata
|
82
|
+
@biodata ||= SPARQL::BioData.new(position_id).results_as(BioData)
|
83
|
+
end
|
84
|
+
|
85
|
+
def biodata_for(officeholder)
|
86
|
+
biodata.select { |bio| bio.person.id == officeholder.id }
|
112
87
|
end
|
113
88
|
|
114
89
|
def padded_mandates
|
115
90
|
[nil, mandates, nil].flatten(1)
|
116
91
|
end
|
117
92
|
|
93
|
+
def sparql
|
94
|
+
@sparql ||= SPARQL::Mandates.new(position_id)
|
95
|
+
end
|
96
|
+
|
118
97
|
def mandates
|
119
|
-
@mandates ||=
|
98
|
+
@mandates ||= sparql.results_as(Mandate)
|
120
99
|
end
|
121
100
|
|
122
101
|
def no_items_output
|
123
|
-
"\n{{PositionHolderHistory/error_no_holders|id=#{
|
102
|
+
"\n{{PositionHolderHistory/error_no_holders|id=#{position_id}}}\n"
|
124
103
|
end
|
125
104
|
|
126
|
-
def
|
127
|
-
|
105
|
+
def output
|
106
|
+
template_class.new(template_params).output
|
128
107
|
end
|
129
108
|
|
130
|
-
def
|
131
|
-
|
109
|
+
def template_params
|
110
|
+
{
|
111
|
+
table_rows: table_rows,
|
112
|
+
sparql_url: sparql.wdqs_url,
|
113
|
+
}
|
132
114
|
end
|
133
115
|
|
134
116
|
def table_rows
|
135
117
|
padded_mandates.each_cons(3).map do |later, current, earlier|
|
136
|
-
|
118
|
+
{
|
119
|
+
mandate: MandateData.new(later, current, earlier),
|
120
|
+
bio: biodata_for(current.officeholder),
|
121
|
+
}
|
137
122
|
end
|
138
123
|
end
|
139
124
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WikidataPositionHistory
|
4
|
+
# Interface to the ERB Template for the output
|
5
|
+
class ReportTemplate
|
6
|
+
def initialize(data)
|
7
|
+
@data = data
|
8
|
+
end
|
9
|
+
|
10
|
+
def output
|
11
|
+
template.result_with_hash(data)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
attr_reader :data
|
17
|
+
|
18
|
+
def template
|
19
|
+
@template ||= ERB.new(template_text)
|
20
|
+
end
|
21
|
+
|
22
|
+
def template_text
|
23
|
+
<<~ERB
|
24
|
+
{| class="wikitable" style="text-align: center; border: none;"
|
25
|
+
<% table_rows.map(&:values).each do |mandate, bio| %>|-
|
26
|
+
| style="padding:0.5em 2em" | <%= mandate.ordinal_string %>
|
27
|
+
| style="padding:0.5em 2em" | <%= bio.map(&:image_link).first %>
|
28
|
+
| style="padding:0.5em 2em" | <span style="font-size: <%= mandate.acting? ? '1.25em; font-style: italic;' : '1.5em' %>; display: block;"><%= mandate.person %></span> <%= mandate.dates %>
|
29
|
+
| style="padding:0.5em 2em 0.5em 1em; border: none; background: #fff; text-align: left;" | <% mandate.warnings.each do |warning| %><span style="display: block">[[File:Pictogram voting comment.svg|15px|link=]] <span style="color: #d33; font-weight: bold; vertical-align: middle;"><%= warning.headline %></span> <ref><%= warning.explanation %></ref></span><% end %>
|
30
|
+
<% end %>|}
|
31
|
+
|
32
|
+
<div style="margin-bottom:5px; border-bottom:3px solid #2f74d0; font-size:8pt">
|
33
|
+
<div style="float:right">[<%= sparql_url %> WDQS]</div>
|
34
|
+
</div>
|
35
|
+
ERB
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -5,14 +5,14 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
require 'wikidata_position_history/version'
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
|
-
spec.required_ruby_version = '>= 2.
|
8
|
+
spec.required_ruby_version = '>= 2.5.0'
|
9
9
|
spec.name = 'wikidata_position_history'
|
10
10
|
spec.version = WikidataPositionHistory::VERSION
|
11
11
|
spec.authors = ['Tony Bowden', 'Mark Longair']
|
12
12
|
spec.email = ['tony@tmtm.com']
|
13
13
|
|
14
|
-
spec.summary = 'Generates a
|
15
|
-
spec.homepage = 'https://github.com/
|
14
|
+
spec.summary = 'Generates a table of historic holders of a Wikidata position'
|
15
|
+
spec.homepage = 'https://github.com/tmtmtmtm/wikidata-position-history/'
|
16
16
|
spec.license = 'MIT'
|
17
17
|
|
18
18
|
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
25
|
spec.require_paths = ['lib']
|
26
26
|
|
27
|
-
spec.add_runtime_dependency 'mediawiki-
|
27
|
+
spec.add_runtime_dependency 'mediawiki-replaceable-content', '0.2.2'
|
28
28
|
spec.add_runtime_dependency 'rest-client', '~> 2.0'
|
29
29
|
|
30
30
|
spec.add_development_dependency 'bundler', '~> 2.1'
|
@@ -33,6 +33,8 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_development_dependency 'rake', '~> 13.0'
|
34
34
|
spec.add_development_dependency 'reek', '~> 6.0'
|
35
35
|
spec.add_development_dependency 'rubocop', '~> 0.89'
|
36
|
+
spec.add_development_dependency 'rubocop-performance', '~> 1.8.0'
|
37
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 1.43.2'
|
36
38
|
spec.add_development_dependency 'warning', '~> 1.1'
|
37
|
-
spec.add_development_dependency 'webmock', '~> 3.
|
39
|
+
spec.add_development_dependency 'webmock', '~> 3.8.3'
|
38
40
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wikidata_position_history
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Bowden
|
@@ -9,22 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-09-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name: mediawiki-
|
15
|
+
name: mediawiki-replaceable-content
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
18
|
- - '='
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 0.
|
20
|
+
version: 0.2.2
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - '='
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 0.
|
27
|
+
version: 0.2.2
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rest-client
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,6 +123,34 @@ dependencies:
|
|
123
123
|
- - "~>"
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0.89'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: rubocop-performance
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - "~>"
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: 1.8.0
|
133
|
+
type: :development
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - "~>"
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: 1.8.0
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: rubocop-rspec
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - "~>"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: 1.43.2
|
147
|
+
type: :development
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - "~>"
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: 1.43.2
|
126
154
|
- !ruby/object:Gem::Dependency
|
127
155
|
name: warning
|
128
156
|
requirement: !ruby/object:Gem::Requirement
|
@@ -143,14 +171,14 @@ dependencies:
|
|
143
171
|
requirements:
|
144
172
|
- - "~>"
|
145
173
|
- !ruby/object:Gem::Version
|
146
|
-
version: 3.
|
174
|
+
version: 3.8.3
|
147
175
|
type: :development
|
148
176
|
prerelease: false
|
149
177
|
version_requirements: !ruby/object:Gem::Requirement
|
150
178
|
requirements:
|
151
179
|
- - "~>"
|
152
180
|
- !ruby/object:Gem::Version
|
153
|
-
version: 3.
|
181
|
+
version: 3.8.3
|
154
182
|
description:
|
155
183
|
email:
|
156
184
|
- tony@tmtm.com
|
@@ -160,6 +188,7 @@ executables:
|
|
160
188
|
extensions: []
|
161
189
|
extra_rdoc_files: []
|
162
190
|
files:
|
191
|
+
- ".github/workflows/ruby.yml"
|
163
192
|
- ".gitignore"
|
164
193
|
- ".reek.yml"
|
165
194
|
- ".rubocop.yml"
|
@@ -175,15 +204,17 @@ files:
|
|
175
204
|
- exe/position-history-for-item
|
176
205
|
- exe/update_wikidata_page
|
177
206
|
- lib/query_service.rb
|
207
|
+
- lib/sparql/bio_data.rb
|
178
208
|
- lib/sparql/item_query.rb
|
179
209
|
- lib/sparql/mandates.rb
|
180
210
|
- lib/sparql/position_data.rb
|
181
211
|
- lib/wikidata_position_history.rb
|
182
212
|
- lib/wikidata_position_history/checks.rb
|
183
213
|
- lib/wikidata_position_history/report.rb
|
214
|
+
- lib/wikidata_position_history/template.rb
|
184
215
|
- lib/wikidata_position_history/version.rb
|
185
216
|
- wikidata_position_history.gemspec
|
186
|
-
homepage: https://github.com/
|
217
|
+
homepage: https://github.com/tmtmtmtm/wikidata-position-history/
|
187
218
|
licenses:
|
188
219
|
- MIT
|
189
220
|
metadata:
|
@@ -196,7 +227,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
196
227
|
requirements:
|
197
228
|
- - ">="
|
198
229
|
- !ruby/object:Gem::Version
|
199
|
-
version: 2.
|
230
|
+
version: 2.5.0
|
200
231
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
201
232
|
requirements:
|
202
233
|
- - ">="
|
@@ -204,8 +235,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
204
235
|
version: '0'
|
205
236
|
requirements: []
|
206
237
|
rubyforge_project:
|
207
|
-
rubygems_version: 2.6.
|
238
|
+
rubygems_version: 2.7.6.2
|
208
239
|
signing_key:
|
209
240
|
specification_version: 4
|
210
|
-
summary: Generates a
|
241
|
+
summary: Generates a table of historic holders of a Wikidata position
|
211
242
|
test_files: []
|