notion_ruby_mapping 0.3.2 → 0.3.3

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
2
  SHA256:
3
- metadata.gz: 5456cec1bec59a457b4ec8341226f9d01afb2bba707d525c8c23745eb1c5ce96
4
- data.tar.gz: 569eab15b3b42b871aa0873d66c07a869631d0d7d68be5c733726b571c92ca02
3
+ metadata.gz: e1d0dd6fcc42d250f8da729a07d788c2f2dd49739cc8810edde17c4eea913f06
4
+ data.tar.gz: d9c7822db6b4d40505626d95e7e947c8436ca9d2ff0d61409cf15dba30adb97d
5
5
  SHA512:
6
- metadata.gz: 57f9809f36aadb3f0b6af35f36cbe0b1b2e6c830b7b35273c30956e75b084e9bd51aeb2a819139f71a6f4adfd7c48a2edc021b56e3614924949c2c16f0b9bb98
7
- data.tar.gz: b7869c6db0ad601d01c90cbecd32b7c54a9c85a4fda139a1b3b92bc8a2d7cec320d5efa58cd6f539ec06331f244be584d240821a8fc9e577f2e9bc904482924e
6
+ metadata.gz: b568105ff9e1acb644432233c3d2e8de8c7b3151d27f014a331437b90459d3afde4e25f4fd2a0e429149f781fe01cb77664fd12ac00e5990ab64780a031faf1d
7
+ data.tar.gz: 1f5871c01afe0aae9d15a978b3dfc85ed641b5017210247dc9e80b451afb857e15f0404aaefe3983a27596759a1e7bc4997c21d3c970742d342e6948f035bfd6
data/README.md CHANGED
@@ -526,11 +526,15 @@ print db.query_database query, dry_run: true
526
526
 
527
527
  #### 4.2.3 Create child page
528
528
 
529
- `create_child_page` creates a child page object of the database. After setting some properties, please call `page.save` to send page information to Notion. Properties of the created child page are automatically assigned using the parent database.
529
+ `create_child_page` creates a child page object of the database. After setting some properties, please call `page.save` to send page information to Notion. Properties of the created child page are automatically assigned using the parent database. if a block is provided, the method will yield the new Page object and the properties (PropertyCache object) to that block for initialization.
530
530
 
531
531
  ```Ruby
532
- page = db.create_child_page
533
- page.properties["Name"] << "New Page"
532
+ page = db.create_child_page do |p, pp|
533
+ # p is the new Page object
534
+ # pp is the properties of the new Page object (PropertyCache Object)
535
+ p.set_icon emoji: "🎉"
536
+ pp["Name"] << "New Page"
537
+ end
534
538
  page.save
535
539
  ```
536
540
 
@@ -1268,6 +1272,7 @@ textMentionObjects = RichTextArray.new "title", [TextObject.new("A TextObject"),
1268
1272
 
1269
1273
  ## 6. ChangeLog
1270
1274
 
1275
+ - 2022/3/27 create_child_page can receive a block for initialization.
1271
1276
  - 2022/3/27 properties of a created child page are automatically assigned using the parent database.
1272
1277
  - 2022/3/25 added create_child_database, update_database, add_property, rename_property and remove_property
1273
1278
  - 2022/3/17 added template_mention objects, tools/an command
@@ -19,7 +19,10 @@ module NotionRubyMapping
19
19
  @property_cache = nil
20
20
  @created_time = nil
21
21
  @last_edited_time = nil
22
+ return if assign.empty?
23
+
22
24
  assign.each_slice(2) { |(klass, key)| assign_property(klass, key) }
25
+ @json ||= {}
23
26
  end
24
27
  attr_reader :json, :id
25
28
 
@@ -173,7 +176,7 @@ module NotionRubyMapping
173
176
  # @param [Hash] json
174
177
  # @return [NotionRubyMapping::Base]
175
178
  def update_json(json)
176
- raise StandardError, json.inspect unless json["object"] != "error" && @json.nil? || @json["type"] == json["type"]
179
+ raise StandardError, json.inspect unless json["object"] != "error" && (@json.nil? || @json["type"] == json["type"])
177
180
 
178
181
  @json = json
179
182
  @id = @nc.hex_id(@json["id"])
@@ -30,8 +30,12 @@ module NotionRubyMapping
30
30
  # @param [Array<Property, Class, String>] assign
31
31
  # @return [NotionRubyMapping::Base]
32
32
  def create_child_page(*assign)
33
- assign = properties.map { |p| [p.class, p.name ] }.flatten if assign.empty?
34
- Page.new assign: assign, parent: {"database_id" => @id}
33
+ assign = properties.map { |p| [p.class, p.name] }.flatten if assign.empty?
34
+ page = Page.new assign: assign, parent: {"database_id" => @id}
35
+ pp = page.properties
36
+ pp.clear_will_update
37
+ yield page, pp if block_given?
38
+ page
35
39
  end
36
40
 
37
41
  # @return [NotionRubyMapping::RichTextArray]
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NotionRubyMapping
4
- VERSION = "0.3.2"
4
+ VERSION = "0.3.3"
5
5
  NOTION_VERSION = "2022-02-22"
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notion_ruby_mapping
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroyuki KOBAYASHI
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-26 00:00:00.000000000 Z
11
+ date: 2022-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday