notion_ruby_mapping 0.4.1 → 0.5.0
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/README.md +16 -14
- data/examples/change_title.md +1 -1
- data/examples/renumbering_pages.md +3 -3
- data/examples/set_icon_to_all_icon_unsettled_pages.md +4 -4
- data/lib/notion_ruby_mapping/blocks/base.rb +11 -13
- data/lib/notion_ruby_mapping/blocks/block.rb +67 -487
- data/lib/notion_ruby_mapping/blocks/bookmark_block.rb +11 -0
- data/lib/notion_ruby_mapping/blocks/breadcrumb_block.rb +19 -0
- data/lib/notion_ruby_mapping/blocks/bulleted_list_item_block.rb +11 -0
- data/lib/notion_ruby_mapping/blocks/callout_block.rb +82 -0
- data/lib/notion_ruby_mapping/blocks/child_base_block.rb +21 -0
- data/lib/notion_ruby_mapping/blocks/child_database_block.rb +11 -0
- data/lib/notion_ruby_mapping/blocks/child_page_block.rb +11 -0
- data/lib/notion_ruby_mapping/blocks/code_block.rb +50 -0
- data/lib/notion_ruby_mapping/blocks/column_block.rb +29 -0
- data/lib/notion_ruby_mapping/blocks/column_list_block.rb +33 -0
- data/lib/notion_ruby_mapping/blocks/database.rb +7 -1
- data/lib/notion_ruby_mapping/blocks/divider_block.rb +19 -0
- data/lib/notion_ruby_mapping/blocks/embed_block.rb +11 -0
- data/lib/notion_ruby_mapping/blocks/equation_block.rb +43 -0
- data/lib/notion_ruby_mapping/blocks/file_base_block.rb +50 -0
- data/lib/notion_ruby_mapping/blocks/file_block.rb +11 -0
- data/lib/notion_ruby_mapping/blocks/heading1_block.rb +18 -0
- data/lib/notion_ruby_mapping/blocks/heading2_block.rb +18 -0
- data/lib/notion_ruby_mapping/blocks/heading3_block.rb +18 -0
- data/lib/notion_ruby_mapping/blocks/image_block.rb +11 -0
- data/lib/notion_ruby_mapping/blocks/link_preview_block.rb +16 -0
- data/lib/notion_ruby_mapping/blocks/link_to_page_block.rb +40 -0
- data/lib/notion_ruby_mapping/blocks/list.rb +2 -3
- data/lib/notion_ruby_mapping/blocks/numbered_list_item_block.rb +11 -0
- data/lib/notion_ruby_mapping/blocks/page.rb +6 -0
- data/lib/notion_ruby_mapping/blocks/paragraph_block.rb +11 -0
- data/lib/notion_ruby_mapping/blocks/pdf_block.rb +11 -0
- data/lib/notion_ruby_mapping/blocks/quote_block.rb +11 -0
- data/lib/notion_ruby_mapping/blocks/synced_block.rb +44 -0
- data/lib/notion_ruby_mapping/blocks/table_block.rb +50 -0
- data/lib/notion_ruby_mapping/blocks/table_of_contents_block.rb +34 -0
- data/lib/notion_ruby_mapping/blocks/table_row_block.rb +34 -0
- data/lib/notion_ruby_mapping/blocks/template_block.rb +34 -0
- data/lib/notion_ruby_mapping/blocks/text_sub_block_color_base_block.rb +45 -0
- data/lib/notion_ruby_mapping/blocks/to_do_block.rb +42 -0
- data/lib/notion_ruby_mapping/blocks/toggle_block.rb +11 -0
- data/lib/notion_ruby_mapping/blocks/toggle_heading1_block.rb +11 -0
- data/lib/notion_ruby_mapping/blocks/toggle_heading2_block.rb +11 -0
- data/lib/notion_ruby_mapping/blocks/toggle_heading3_block.rb +11 -0
- data/lib/notion_ruby_mapping/blocks/url_base_block.rb +34 -0
- data/lib/notion_ruby_mapping/blocks/url_caption_base_block.rb +46 -0
- data/lib/notion_ruby_mapping/blocks/video_block.rb +11 -0
- data/lib/notion_ruby_mapping/controllers/notion_cache.rb +26 -20
- data/lib/notion_ruby_mapping/controllers/payload.rb +32 -18
- data/lib/notion_ruby_mapping/controllers/query.rb +1 -1
- data/lib/notion_ruby_mapping/controllers/rich_text_array.rb +13 -2
- data/lib/notion_ruby_mapping/objects/rich_text_object.rb +2 -5
- data/lib/notion_ruby_mapping/properties/created_by_property.rb +1 -0
- data/lib/notion_ruby_mapping/properties/date_base_property.rb +24 -11
- data/lib/notion_ruby_mapping/properties/email_property.rb +1 -2
- data/lib/notion_ruby_mapping/properties/files_property.rb +1 -1
- data/lib/notion_ruby_mapping/properties/formula_property.rb +1 -1
- data/lib/notion_ruby_mapping/properties/multi_select_property.rb +2 -0
- data/lib/notion_ruby_mapping/properties/phone_number_property.rb +0 -1
- data/lib/notion_ruby_mapping/properties/select_property.rb +2 -1
- data/lib/notion_ruby_mapping/properties/url_property.rb +0 -2
- data/lib/notion_ruby_mapping/version.rb +1 -1
- data/lib/notion_ruby_mapping.rb +8 -1
- metadata +41 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfd02c2aeeed43efa6a45f35bcaf1173b0113e870e1432b8e39cbac8fdc2d6a4
|
4
|
+
data.tar.gz: 73768acce904d567936bde1e524d47a25649b4f74e4f275a7de8a74b3753bf8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12c8db1f986e739ddea1d57440cdb4e422729c7aed54a1b94b3e65f71124de20cfb7be6bd276c7b143f82c8d2b627a98dfcaf6da087426cfada9c6e21c216f83
|
7
|
+
data.tar.gz: 964763d2dc6449f51c2fb0d1edae7072aec875b8936c94d4826dcffb5334db0ee1094e7a01bbecd0035586844cce5532d4e8d291c50df321a535022218b0fc7d
|
data/README.md
CHANGED
@@ -8,6 +8,7 @@ Development note is here. → [Idea note of "notion_ruby_mapping"](https://www.n
|
|
8
8
|
|
9
9
|
- [notion_ruby_mapping](#notion_ruby_mapping)
|
10
10
|
- [Table of Contents](#table-of-contents)
|
11
|
+
- [0. Changes in v0.5.0](#0-changes-in-v050)
|
11
12
|
- [1. Installation](#1-installation)
|
12
13
|
- [2. How to use](#2-how-to-use)
|
13
14
|
- [2.1 Create a New Integration](#21-create-a-new-integration)
|
@@ -19,7 +20,11 @@ Development note is here. → [Idea note of "notion_ruby_mapping"](https://www.n
|
|
19
20
|
- [4. Contributing](#4-contributing)
|
20
21
|
- [5. License](#5-license)
|
21
22
|
- [6. Code of Conduct](#6-code-of-conduct)
|
22
|
-
|
23
|
+
|
24
|
+
## 0. Changes in v0.5.0
|
25
|
+
|
26
|
+
NotionRubyMapping v.0.5.0 now supports block updates.
|
27
|
+
For efficiency, subclasses are provided under Block class. As a result, they are no longer compatible with the scripts used in v0.4.0.
|
23
28
|
|
24
29
|
## 1. Installation
|
25
30
|
|
@@ -60,6 +65,7 @@ NotionCache.instance.create_client ENV["NOTION_API_TOKEN"] # from environment
|
|
60
65
|
|
61
66
|
1. [Database and page access sample](https://www.notion.so/hkob/Database-and-page-access-sample-d30033e707194faf995741167eb2b6f8)
|
62
67
|
1. [Append block children sample](https://www.notion.so/hkob/Append-block-children-sample-3867910a437340be931cf7f2c06443c6)
|
68
|
+
1. [Update block sample](https://www.notion.so/hkob/update-block-sample-5568c1c36fe84f12b83edfe2dda83028)
|
63
69
|
|
64
70
|
### 2.4. Another example code (Use case)
|
65
71
|
|
@@ -73,17 +79,17 @@ NotionCache.instance.create_client ENV["NOTION_API_TOKEN"] # from environment
|
|
73
79
|
|
74
80
|
## 3. ChangeLog
|
75
81
|
|
76
|
-
- added
|
77
|
-
- added
|
78
|
-
- 2022/4/29 Change directory structure, TEST_IDs are moved from env.yml to TestConnection's constants
|
82
|
+
- 2022/6/4 [v0.5.0] added subclasses of the block class and update_block API support
|
83
|
+
- 2022/5/19 [v0.4.1] added delete_block
|
84
|
+
- 2022/4/29 [v0.4.0] Change directory structure, TEST_IDs are moved from env.yml to TestConnection's constants, added retrieve_block spec, added append_block_children
|
79
85
|
- 2022/4/27 added Base#children
|
80
|
-
- 2022/3/27 create_child_page can receive a block for initialization.
|
81
|
-
- 2022/3/27 properties of a created child page are automatically assigned using the parent database.
|
82
|
-
- 2022/3/25 added create_child_database, update_database, add_property, rename_property and remove_property
|
83
|
-
- 2022/3/17 added template_mention objects, tools/an command
|
84
|
-
- 2022/3/16 added database.create_child_page and base.save instead of base.update/create
|
86
|
+
- 2022/3/27 [v0.3.3] create_child_page can receive a block for initialization.
|
87
|
+
- 2022/3/27 [v0.3.2] properties of a created child page are automatically assigned using the parent database.
|
88
|
+
- 2022/3/25 [v0.3.0] added create_child_database, update_database, add_property, rename_property and remove_property
|
89
|
+
- 2022/3/17 [v0.2.3] added template_mention objects, tools/an command
|
90
|
+
- 2022/3/16 [v0.2.2] added database.create_child_page and base.save instead of base.update/create
|
85
91
|
- 2022/3/15 Fixed not to reload from API when all contents are loaded
|
86
|
-
- 2022/3/14 Exclude notion-ruby-client, update Property values, update for Notion-Version 2022-02-22
|
92
|
+
- 2022/3/14 [v0.2.0] Exclude notion-ruby-client, update Property values, update for Notion-Version 2022-02-22
|
87
93
|
- 2022/2/25 add_property_for_update -> assign_property, update README.md
|
88
94
|
- 2022/2/20 add support for MultiSelectProperty
|
89
95
|
- 2022/2/19 add support for SelectProperty
|
@@ -105,7 +111,3 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
105
111
|
## 6. Code of Conduct
|
106
112
|
|
107
113
|
Everyone interacting in the NotionRubyMapping project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/notion_ruby_mapping/blob/main/CODE_OF_CONDUCT.md).
|
108
|
-
|
109
|
-
## 7. Acknowledgements
|
110
|
-
|
111
|
-
The code depends on [notion-ruby-client](https://github.com/orbit-love/notion-ruby-client).
|
data/examples/change_title.md
CHANGED
@@ -12,9 +12,9 @@ db.query_database(tp.filter_is_not_empty.ascending(tp)).each.with_index(1) do |p
|
|
12
12
|
end
|
13
13
|
```
|
14
14
|
|
15
|
-
| After execution
|
16
|
-
|
15
|
+
| After execution |
|
16
|
+
|--------------------------------------------------|
|
17
17
|
|  |
|
18
18
|
|
19
19
|
---
|
20
|
-
[Return to README.md](../README.md
|
20
|
+
[Return to README.md](../README.md)
|
@@ -22,9 +22,9 @@ db.query_database.each do |page|
|
|
22
22
|
end
|
23
23
|
```
|
24
24
|
|
25
|
-
|Before execution|After execution|
|
26
|
-
|
27
|
-
|
25
|
+
| Before execution | After execution |
|
26
|
+
|-------------------------------------------------|-------------------------------------------------|
|
27
|
+
|  |  |
|
28
28
|
|
29
29
|
---
|
30
|
-
[Return to README.md](../README.md
|
30
|
+
[Return to README.md](../README.md)
|
@@ -10,7 +10,9 @@ module NotionRubyMapping
|
|
10
10
|
def initialize(json: nil, id: nil, assign: [], parent: nil)
|
11
11
|
@nc = NotionCache.instance
|
12
12
|
@json = json
|
13
|
-
@id = @nc.hex_id(id || json && @json["id"])
|
13
|
+
@id = @nc.hex_id(id || @json && @json["id"])
|
14
|
+
@archived = @json && @json["archived"]
|
15
|
+
@has_children = @json && @json["has_children"]
|
14
16
|
@new_record = true unless parent.nil?
|
15
17
|
raise StandardError, "Unknown id" if !is_a?(List) && !is_a?(Block) && @id.nil? && parent.nil?
|
16
18
|
|
@@ -36,7 +38,7 @@ module NotionRubyMapping
|
|
36
38
|
when "list"
|
37
39
|
List.new json: json
|
38
40
|
when "block"
|
39
|
-
Block.
|
41
|
+
Block.decode_block json
|
40
42
|
else
|
41
43
|
raise StandardError, json.inspect
|
42
44
|
end
|
@@ -58,7 +60,7 @@ module NotionRubyMapping
|
|
58
60
|
|
59
61
|
# @param [String] key
|
60
62
|
# @return [NotionRubyMapping::PropertyCache, Hash] obtained Page value or PropertyCache
|
61
|
-
def
|
63
|
+
def get(key)
|
62
64
|
unless @json
|
63
65
|
raise StandardError, "Unknown id" if @id.nil?
|
64
66
|
|
@@ -111,7 +113,7 @@ module NotionRubyMapping
|
|
111
113
|
raise StandardError, "Internal file block can not append." if bt == "file"
|
112
114
|
|
113
115
|
raise StandardError, "Column block can only append column_list block" unless bt == "column" &&
|
114
|
-
block? && type == "
|
116
|
+
block? && type == "column_list"
|
115
117
|
end
|
116
118
|
|
117
119
|
# @param [NotionRubyMapping::Property] klass
|
@@ -148,13 +150,6 @@ module NotionRubyMapping
|
|
148
150
|
end
|
149
151
|
end
|
150
152
|
|
151
|
-
# @return [NotionRubyMapping::Block]
|
152
|
-
def create_child_breadcrumb
|
153
|
-
raise StandardError unless page? || (block? && can_have_children)
|
154
|
-
|
155
|
-
Block.new(parent: self).breadcrumb
|
156
|
-
end
|
157
|
-
|
158
153
|
# @return [NotionRubyMapping::CreatedTimeProperty]
|
159
154
|
def created_time
|
160
155
|
@created_time ||= CreatedTimeProperty.new("__timestamp__", json: self["created_time"])
|
@@ -243,7 +238,7 @@ module NotionRubyMapping
|
|
243
238
|
@new_record ? create(dry_run: true) : update(dry_run: true)
|
244
239
|
else
|
245
240
|
@new_record ? create : update
|
246
|
-
@property_cache.clear_will_update
|
241
|
+
@property_cache.clear_will_update unless block?
|
247
242
|
@payload.clear
|
248
243
|
self
|
249
244
|
end
|
@@ -267,7 +262,10 @@ module NotionRubyMapping
|
|
267
262
|
# @param [Hash] json
|
268
263
|
# @return [NotionRubyMapping::Base]
|
269
264
|
def update_json(json)
|
270
|
-
|
265
|
+
unless json["object"] != "error" && (@json.nil? || @json["type"] == json["type"])
|
266
|
+
raise StandardError,
|
267
|
+
json.inspect
|
268
|
+
end
|
271
269
|
|
272
270
|
@json = json
|
273
271
|
@id = @nc.hex_id(@json["id"])
|