wikidatum 0.3.0 → 0.3.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/lib/wikidatum/client.rb +23 -6
- data/lib/wikidatum/data_type/wikibase_item.rb +1 -3
- data/lib/wikidatum/version.rb +1 -1
- data/lib/wikidatum.rb +9 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2ee435a3831b816e6e64465040a5197de654450551812b835b28329be9c287d
|
4
|
+
data.tar.gz: d23fb1902df5465b123fc0bcea0c7594fb64a6e918604a9f1bb1f4e4eadf6eff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccd8210a5120fbbfb35ed03899938bf4ca4e5302bc93e3e53652180b86b221a3ec23afe57db78777ffcda5971150f7c0ed6af89cde7b294fe21d716491653c49
|
7
|
+
data.tar.gz: cb4e092b80c6ab871c1dd7f5bd46f700029eab7438c7a4063a2aee42b389c0e86ec0e387fc15fa996037d2478f494ac46572879078930c41c18ae6b7e4073e00
|
data/CHANGELOG.md
CHANGED
@@ -4,11 +4,23 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
6
6
|
|
7
|
+
## Unreleased
|
8
|
+
|
9
|
+
## 0.3.1 - 2022-12-28
|
10
|
+
### Added
|
11
|
+
|
12
|
+
- Add an error message when attempting to make a bot edit without authentication, as this will always trigger a 403 error from the REST API.
|
13
|
+
|
14
|
+
### Fixed
|
15
|
+
|
16
|
+
- Fix the creation of WikibaseItem statements, the format used in the previous release was incorrect.
|
17
|
+
|
7
18
|
## 0.3.0 - 2022-12-27
|
8
19
|
### Added
|
9
20
|
|
10
21
|
- Add `allow_ip_edits` argument on `Wikidatum::Client.new`. This protects users from making IP address-exposing edits if they haven't explicitly opted-in to doing that. The argument defaults to false.
|
11
22
|
- Add code to raise errors when various types of invalid input are passed to `Wikidatum::Client#add_statement`.
|
23
|
+
- Start testing the gem on Ruby 3.2.
|
12
24
|
|
13
25
|
### Fixed
|
14
26
|
|
data/lib/wikidatum/client.rb
CHANGED
@@ -245,7 +245,15 @@ module Wikidatum
|
|
245
245
|
}
|
246
246
|
end
|
247
247
|
|
248
|
-
body = {
|
248
|
+
body = {
|
249
|
+
statement: statement_hash.merge(
|
250
|
+
{
|
251
|
+
qualifiers: qualifiers,
|
252
|
+
references: references,
|
253
|
+
rank: rank.to_s
|
254
|
+
}
|
255
|
+
)
|
256
|
+
}
|
249
257
|
|
250
258
|
response = post_request("/entities/items/#{id}/statements", body, tags: tags, comment: comment)
|
251
259
|
|
@@ -292,6 +300,13 @@ module Wikidatum
|
|
292
300
|
@allow_ip_edits
|
293
301
|
end
|
294
302
|
|
303
|
+
# Is the current instance of Client editing as a bot?
|
304
|
+
#
|
305
|
+
# @return [Boolean]
|
306
|
+
def bot?
|
307
|
+
@bot
|
308
|
+
end
|
309
|
+
|
295
310
|
private
|
296
311
|
|
297
312
|
# For now this just returns the `@wikibase_url`, but in the future the API
|
@@ -426,13 +441,15 @@ module Wikidatum
|
|
426
441
|
# Check if authentication has been provided, and then check if IP edits
|
427
442
|
# are allowed. If neither condition returns true, raise an error.
|
428
443
|
#
|
444
|
+
# Also check if the user is performing IP edits as a bot, which will
|
445
|
+
# always return a 403 error from the REST API, and return a specific
|
446
|
+
# error message if so.
|
447
|
+
#
|
429
448
|
# @return [void]
|
430
|
-
# @raise [DisallowedIpEditError]
|
449
|
+
# @raise [DisallowedIpEditError, DisallowedBotEditError]
|
431
450
|
def ensure_edit_permitted!
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
raise DisallowedIpEditError
|
451
|
+
raise DisallowedIpEditError if !authenticated? && !allow_ip_edits?
|
452
|
+
raise DisallowedBotEditError if !authenticated? && bot?
|
436
453
|
end
|
437
454
|
end
|
438
455
|
end
|
data/lib/wikidatum/version.rb
CHANGED
data/lib/wikidatum.rb
CHANGED
@@ -24,6 +24,15 @@ module Wikidatum
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
# If the Wikidatum::Client is set to mark their edits as belonging to a bot,
|
28
|
+
# they must be authenticated as a bot user. We will disallow these edits
|
29
|
+
# as long as they're not authenticated as a specific user.
|
30
|
+
class DisallowedBotEditError < Error
|
31
|
+
def message
|
32
|
+
'No authentication provided, but attempted to edit as a bot. You cannot make edits as a bot unless you have authenticated as a user with the Bot flag.'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
27
36
|
# rubocop:disable Naming/ConstantName
|
28
37
|
|
29
38
|
# These language codes are not enforced, you can pass whatever language code
|