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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78bb68e7872a77e0dc21f9904d0fd8306b4d4caa23329824d87257a91e503925
4
- data.tar.gz: 84765a7d5f3cee85b0c6ad68953f1d6e9718d068037247f8e8e7e1c4b651c51b
3
+ metadata.gz: d2ee435a3831b816e6e64465040a5197de654450551812b835b28329be9c287d
4
+ data.tar.gz: d23fb1902df5465b123fc0bcea0c7594fb64a6e918604a9f1bb1f4e4eadf6eff
5
5
  SHA512:
6
- metadata.gz: 24dd512b025f3e618b46ba9b5cc280c2ef500909b7f68c666f29914b5a64e1da63729ded4e321e37461f68f6fdc1f429ec87a71684b773eacb5f25f56ee5c212
7
- data.tar.gz: e43e1b92d171667ce5af5028c56b7d5c28971ef3c3aed93f55a919088e6a990796889eb32293563191d857cf547ca685b6d571bc629a199cbbb6ab332283a731
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
 
@@ -245,7 +245,15 @@ module Wikidatum
245
245
  }
246
246
  end
247
247
 
248
- body = { statement: statement_hash.merge({ qualifiers: qualifiers, references: references, rank: rank.to_s, type: 'statement' }) }
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
- return if authenticated?
433
- return if allow_ip_edits?
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
@@ -57,8 +57,6 @@ class Wikidatum::DataType::WikibaseItem
57
57
 
58
58
  # @!visibility private
59
59
  def marshal_dump
60
- {
61
- id: @id
62
- }
60
+ @id
63
61
  end
64
62
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Wikidatum
4
- VERSION = '0.3.0'
4
+ VERSION = '0.3.1'
5
5
  end
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wikidatum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Connor Shea