wikidata_position_history 1.4.1 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +14 -0
- data/CHANGELOG.md +6 -0
- data/Rakefile +1 -1
- data/lib/sparql/mandates.rb +4 -0
- data/lib/wikidata_position_history.rb +14 -14
- data/lib/wikidata_position_history/checks.rb +1 -3
- data/lib/wikidata_position_history/report.rb +3 -4
- data/lib/wikidata_position_history/version.rb +1 -1
- data/wikidata_position_history.gemspec +4 -2
- metadata +34 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d53ac2920ebe5b13817ab9aa31d32150cc24d7896362097bcbc18d17f93bebd
|
4
|
+
data.tar.gz: d7b98d022698cc33738b6f11f8aa3d5c2b8408f79b57fd459179fbac2ec3df08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e2cbe1a3e7772a038d566a0ddacd27ededf3e2ffd36a9ebea7bf1fa98af411a8ded14ec994a300d5e2c8ef2f194c5f49a7a6b72f5838d87e350e12035390db9
|
7
|
+
data.tar.gz: 946c5ae13a66b4fde102cd6e6c18af9855b96da0840979211ba1b8c3f85b4dafd15dbb4b8978c220e1a3236937707df59c6faf3ab652bdaf4a8e1c891765eadc
|
data/.rubocop.yml
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-performance
|
3
|
+
- rubocop-rspec
|
4
|
+
|
1
5
|
AllCops:
|
2
6
|
Exclude:
|
3
7
|
- 'Vagrantfile'
|
@@ -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/CHANGELOG.md
CHANGED
data/Rakefile
CHANGED
data/lib/sparql/mandates.rb
CHANGED
@@ -63,10 +63,14 @@ module WikidataPositionHistory
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def start_date
|
66
|
+
return if start_date_raw.empty?
|
67
|
+
|
66
68
|
QueryService::WikidataDate.new(start_date_raw, start_date_precision)
|
67
69
|
end
|
68
70
|
|
69
71
|
def end_date
|
72
|
+
return if end_date_raw.empty?
|
73
|
+
|
70
74
|
QueryService::WikidataDate.new(end_date_raw, end_date_precision)
|
71
75
|
end
|
72
76
|
|
@@ -22,6 +22,19 @@ module WikidataPositionHistory
|
|
22
22
|
WIKI_USERNAME = ENV['WIKI_USERNAME']
|
23
23
|
WIKI_PASSWORD = ENV['WIKI_PASSWORD']
|
24
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
|
+
|
25
38
|
def initialize(mediawiki_site:, page_title:)
|
26
39
|
@mediawiki_site = mediawiki_site
|
27
40
|
@page_title = page_title.tr('_', ' ')
|
@@ -33,7 +46,7 @@ module WikidataPositionHistory
|
|
33
46
|
|
34
47
|
def new_content
|
35
48
|
return [NO_ID_ERROR, 'The id parameter was missing'] if position_id.empty?
|
36
|
-
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+$/]
|
37
50
|
|
38
51
|
[WikidataPositionHistory::Report.new(position_id).wikitext, "Successfully updated holders of #{position_id}"]
|
39
52
|
end
|
@@ -42,19 +55,6 @@ module WikidataPositionHistory
|
|
42
55
|
|
43
56
|
attr_reader :mediawiki_site, :page_title
|
44
57
|
|
45
|
-
NO_ID_ERROR = <<~EOERROR
|
46
|
-
'''#{WIKI_TEMPLATE_NAME} Error''': You must pass the <code>id</code>
|
47
|
-
parameter to the <code>#{WIKI_TEMPLATE_NAME}</code> template; e.g.
|
48
|
-
<nowiki>{{#{WIKI_TEMPLATE_NAME}|id=Q14211}}</nowiki>
|
49
|
-
EOERROR
|
50
|
-
|
51
|
-
MALFORMED_ID_ERROR = <<~EOERROR
|
52
|
-
'''#{WIKI_TEMPLATE_NAME} Error''': The <code>id</code> parameter was
|
53
|
-
malformed; it should be Q followed by a number of digits, e.g. as in:
|
54
|
-
|
55
|
-
<nowiki>{{#{WIKI_TEMPLATE_NAME}|id=Q14211}}</nowiki>
|
56
|
-
EOERROR
|
57
|
-
|
58
58
|
def position_id
|
59
59
|
return id_param unless id_param.empty?
|
60
60
|
|
@@ -124,9 +124,7 @@ module WikidataPositionHistory
|
|
124
124
|
def problem?
|
125
125
|
return false unless later
|
126
126
|
|
127
|
-
ends = current.end_date
|
128
|
-
return false if ends.empty?
|
129
|
-
|
127
|
+
ends = current.end_date or return false
|
130
128
|
ends > later.start_date
|
131
129
|
rescue ArgumentError
|
132
130
|
true
|
@@ -3,6 +3,8 @@
|
|
3
3
|
module WikidataPositionHistory
|
4
4
|
# Date for a single mandate row, to be passed to the report template
|
5
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
|
@@ -20,8 +22,7 @@ module WikidataPositionHistory
|
|
20
22
|
|
21
23
|
def dates
|
22
24
|
dates = [current.start_date, current.end_date]
|
23
|
-
|
24
|
-
return '' if dates.reject(&:empty?).empty?
|
25
|
+
return '' if dates.compact.empty?
|
25
26
|
|
26
27
|
dates.join(' – ')
|
27
28
|
end
|
@@ -36,8 +37,6 @@ module WikidataPositionHistory
|
|
36
37
|
|
37
38
|
private
|
38
39
|
|
39
|
-
CHECKS = [Check::MissingFields, Check::WrongPredecessor, Check::WrongSuccessor, Check::Overlap].freeze
|
40
|
-
|
41
40
|
attr_reader :later, :current, :earlier
|
42
41
|
end
|
43
42
|
|
@@ -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-replaceable-content', '0.2.
|
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.
|
4
|
+
version: 1.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Bowden
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-09-
|
12
|
+
date: 2020-09-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mediawiki-replaceable-content
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - '='
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 0.2.
|
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.2.
|
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
|