notion_ruby_mapping 0.8.9 → 2.0.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/.rubocop.yml +12 -1
- data/lib/notion_ruby_mapping/blocks/base.rb +28 -14
- data/lib/notion_ruby_mapping/blocks/block.rb +42 -41
- data/lib/notion_ruby_mapping/blocks/callout_block.rb +1 -1
- data/lib/notion_ruby_mapping/blocks/child_database_block.rb +1 -1
- data/lib/notion_ruby_mapping/blocks/child_page_block.rb +1 -1
- data/lib/notion_ruby_mapping/blocks/code_block.rb +1 -1
- data/lib/notion_ruby_mapping/blocks/column_block.rb +1 -1
- data/lib/notion_ruby_mapping/blocks/database.rb +1 -1
- data/lib/notion_ruby_mapping/blocks/embed_block.rb +1 -1
- data/lib/notion_ruby_mapping/blocks/equation_block.rb +1 -1
- data/lib/notion_ruby_mapping/blocks/file_base_block.rb +13 -1
- data/lib/notion_ruby_mapping/blocks/file_block.rb +1 -1
- data/lib/notion_ruby_mapping/blocks/heading1_block.rb +2 -2
- data/lib/notion_ruby_mapping/blocks/heading3_block.rb +1 -1
- data/lib/notion_ruby_mapping/blocks/image_block.rb +1 -1
- data/lib/notion_ruby_mapping/blocks/link_preview_block.rb +1 -1
- data/lib/notion_ruby_mapping/blocks/link_to_page_block.rb +1 -1
- data/lib/notion_ruby_mapping/blocks/list.rb +12 -11
- data/lib/notion_ruby_mapping/blocks/numbered_list_item_block.rb +1 -1
- data/lib/notion_ruby_mapping/blocks/page.rb +1 -2
- data/lib/notion_ruby_mapping/blocks/paragraph_block.rb +1 -1
- data/lib/notion_ruby_mapping/blocks/pdf_block.rb +1 -1
- data/lib/notion_ruby_mapping/blocks/toggle_block.rb +1 -1
- data/lib/notion_ruby_mapping/blocks/toggle_heading3_block.rb +1 -1
- data/lib/notion_ruby_mapping/blocks/video_block.rb +1 -1
- data/lib/notion_ruby_mapping/controllers/discussion_thread.rb +1 -1
- data/lib/notion_ruby_mapping/controllers/mermaid.rb +2 -5
- data/lib/notion_ruby_mapping/controllers/mermaid_database.rb +3 -6
- data/lib/notion_ruby_mapping/controllers/notion_cache.rb +73 -9
- data/lib/notion_ruby_mapping/controllers/payload.rb +20 -2
- data/lib/notion_ruby_mapping/controllers/property_cache.rb +1 -1
- data/lib/notion_ruby_mapping/controllers/query.rb +4 -4
- data/lib/notion_ruby_mapping/controllers/search.rb +4 -5
- data/lib/notion_ruby_mapping/objects/file_object.rb +38 -15
- data/lib/notion_ruby_mapping/objects/file_upload_object.rb +78 -0
- data/lib/notion_ruby_mapping/properties/button_property.rb +3 -3
- data/lib/notion_ruby_mapping/properties/checkbox_property.rb +2 -2
- data/lib/notion_ruby_mapping/properties/created_by_property.rb +2 -2
- data/lib/notion_ruby_mapping/properties/created_time_property.rb +2 -2
- data/lib/notion_ruby_mapping/properties/date_base_property.rb +4 -2
- data/lib/notion_ruby_mapping/properties/date_property.rb +4 -4
- data/lib/notion_ruby_mapping/properties/email_property.rb +2 -2
- data/lib/notion_ruby_mapping/properties/files_property.rb +9 -4
- data/lib/notion_ruby_mapping/properties/formula_property.rb +2 -2
- data/lib/notion_ruby_mapping/properties/last_edited_by_property.rb +2 -1
- data/lib/notion_ruby_mapping/properties/last_edited_time_property.rb +2 -2
- data/lib/notion_ruby_mapping/properties/multi_select_property.rb +3 -3
- data/lib/notion_ruby_mapping/properties/number_property.rb +3 -3
- data/lib/notion_ruby_mapping/properties/people_property.rb +3 -3
- data/lib/notion_ruby_mapping/properties/phone_number_property.rb +3 -3
- data/lib/notion_ruby_mapping/properties/property.rb +39 -37
- data/lib/notion_ruby_mapping/properties/relation_property.rb +2 -2
- data/lib/notion_ruby_mapping/properties/rollup_property.rb +2 -2
- data/lib/notion_ruby_mapping/properties/select_property.rb +2 -2
- data/lib/notion_ruby_mapping/properties/status_property.rb +2 -2
- data/lib/notion_ruby_mapping/properties/text_property.rb +2 -2
- data/lib/notion_ruby_mapping/properties/title_property.rb +1 -1
- data/lib/notion_ruby_mapping/properties/unique_id_property.rb +1 -1
- data/lib/notion_ruby_mapping/properties/url_property.rb +2 -2
- data/lib/notion_ruby_mapping/properties/verification_property.rb +3 -3
- data/lib/notion_ruby_mapping/version.rb +1 -1
- data/lib/notion_ruby_mapping.rb +1 -1
- data/notion_ruby_mapping.gemspec +3 -2
- metadata +20 -6
- data/sig/notion_ruby_mapping.rbs +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac7180c69212c47d60456deee3790f5cdd2b7f2074f7c5e244ccf2aae102b371
|
4
|
+
data.tar.gz: d7c88e0ab4d4afdb30cf1d95d285ea2f4a533353886bd0d33c9a3eea5e19ea35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e5aec4c569a646464f20f57a96c6cb714425faacd96d3be8f1413f67531d4c887e2fc5f21f5bfabe95a2614fdc31abed5e638337b64269ad460b99c089ffd78
|
7
|
+
data.tar.gz: 54639e4104e52699c1b26b92e07b934f6902a74210ef7652f79ce2db420e611e91bc61bcd6dffef48aeda2360a0fda2c165d5b967638ca9816aed2e96f80f066
|
data/.rubocop.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require: rubocop-rspec
|
2
2
|
|
3
3
|
AllCops:
|
4
|
-
TargetRubyVersion:
|
4
|
+
TargetRubyVersion: 3.0
|
5
5
|
|
6
6
|
Style/StringLiterals:
|
7
7
|
Enabled: true
|
@@ -26,6 +26,17 @@ Style/TrailingCommaInArrayLiteral:
|
|
26
26
|
Style/TrailingCommaInHashLiteral:
|
27
27
|
EnforcedStyleForMultiline: comma
|
28
28
|
|
29
|
+
Naming/VariableNumber:
|
30
|
+
EnforcedStyle: snake_case
|
31
|
+
|
32
|
+
RSpec/NestedGroups:
|
33
|
+
Enabled: true
|
34
|
+
MaxNesting: 5
|
35
|
+
|
36
|
+
RSpec/MultipleMemoizedHelpers:
|
37
|
+
Enabled: true
|
38
|
+
Max: 8
|
39
|
+
|
29
40
|
Metrics/BlockLength:
|
30
41
|
Exclude:
|
31
42
|
- "Rakefile"
|
@@ -90,7 +90,7 @@ module NotionRubyMapping
|
|
90
90
|
self.class.dry_run_script :get, @nc.retrieve_comments_path(@id)
|
91
91
|
else
|
92
92
|
ans = {}
|
93
|
-
List.new(type:
|
93
|
+
List.new(type: "comment_parent", value: self,
|
94
94
|
json: @nc.retrieve_comments_request(@id, query),
|
95
95
|
query: query).each do |comment|
|
96
96
|
dt_id = comment.discussion_id
|
@@ -128,7 +128,7 @@ module NotionRubyMapping
|
|
128
128
|
|
129
129
|
only_one = blocks.length == 1
|
130
130
|
json = {
|
131
|
-
|
131
|
+
children: Array(blocks).map do |block|
|
132
132
|
assert_parent_children_pair block
|
133
133
|
block.block_json
|
134
134
|
end,
|
@@ -155,10 +155,10 @@ module NotionRubyMapping
|
|
155
155
|
return if block.can_append
|
156
156
|
|
157
157
|
bt = block.type
|
158
|
-
raise StandardError, "Internal file block can not append." if bt ==
|
158
|
+
raise StandardError, "Internal file block can not append." if bt == :file
|
159
159
|
|
160
|
-
raise StandardError, "Column block can only append column_list block" unless bt ==
|
161
|
-
block? && type ==
|
160
|
+
raise StandardError, "Column block can only append column_list block" unless bt == :column &&
|
161
|
+
block? && type == :column_list
|
162
162
|
end
|
163
163
|
|
164
164
|
# @param [NotionRubyMapping::Property] klass
|
@@ -166,12 +166,12 @@ module NotionRubyMapping
|
|
166
166
|
# @return [NotionRubyMapping::Property] generated property
|
167
167
|
def assign_property(klass, title)
|
168
168
|
@property_cache ||= PropertyCache.new({},
|
169
|
-
base_type: database? ?
|
169
|
+
base_type: database? ? "database" : "page",
|
170
170
|
page_id: page? ? @id : nil)
|
171
171
|
property = if database?
|
172
|
-
klass.new(title, will_update: new_record?, base_type:
|
172
|
+
klass.new(title, will_update: new_record?, base_type: "database")
|
173
173
|
else
|
174
|
-
klass.new(title, will_update: true, base_type:
|
174
|
+
klass.new(title, will_update: true, base_type: "page", property_cache: @property_cache)
|
175
175
|
end
|
176
176
|
@property_cache.add_property property
|
177
177
|
property
|
@@ -193,10 +193,15 @@ module NotionRubyMapping
|
|
193
193
|
@children
|
194
194
|
else
|
195
195
|
response = @nc.block_children_request @id, query.query_string
|
196
|
-
@children = List.new json: response, type:
|
196
|
+
@children = List.new json: response, type: "parent", value: self, query: query
|
197
197
|
end
|
198
198
|
end
|
199
199
|
|
200
|
+
# @return [Hash, nil] obtained Hash
|
201
|
+
def cover
|
202
|
+
self["cover"]
|
203
|
+
end
|
204
|
+
|
200
205
|
# @return [NotionRubyMapping::CreatedTimeProperty]
|
201
206
|
def created_time
|
202
207
|
@created_time ||= CreatedTimeProperty.new("__timestamp__", json: self["created_time"])
|
@@ -275,7 +280,7 @@ module NotionRubyMapping
|
|
275
280
|
reload
|
276
281
|
end
|
277
282
|
@property_cache = PropertyCache.new json_properties,
|
278
|
-
base_type: database? ?
|
283
|
+
base_type: database? ? "database" : "page",
|
279
284
|
page_id: page? ? @id : nil
|
280
285
|
end
|
281
286
|
@property_cache
|
@@ -323,13 +328,22 @@ module NotionRubyMapping
|
|
323
328
|
end
|
324
329
|
end
|
325
330
|
|
326
|
-
# @param [String]
|
327
|
-
# @param [String]
|
331
|
+
# @param [String, nil] url
|
332
|
+
# @param [String, nil] file_upload_object
|
333
|
+
# @return [NotionRubyMapping::Base]
|
334
|
+
def set_cover(url: nil, file_upload_object: nil)
|
335
|
+
@payload.set_cover(url: url, file_upload_object: file_upload_object) if page? || database?
|
336
|
+
self
|
337
|
+
end
|
338
|
+
|
339
|
+
# @param [String, nil] emoji
|
340
|
+
# @param [String, nil] url
|
341
|
+
# @param [FileUploadObject, nil] file_upload_object
|
328
342
|
# @return [NotionRubyMapping::Base]
|
329
343
|
# @see https://www.notion.so/hkob/Page-d359650e3ca94424af8359a24147b9a0#62eea67af7824496820c6bb903503540
|
330
344
|
# @see https://www.notion.so/hkob/Page-d359650e3ca94424af8359a24147b9a0#e13d526bd709451e9b06fd32e8d07fcd
|
331
|
-
def set_icon(emoji: nil, url: nil)
|
332
|
-
@payload.set_icon(emoji: emoji, url: url) if page? || database?
|
345
|
+
def set_icon(emoji: nil, url: nil, file_upload_object: nil)
|
346
|
+
@payload.set_icon(emoji: emoji, url: url, file_upload_object: file_upload_object) if page? || database?
|
333
347
|
self
|
334
348
|
end
|
335
349
|
|
@@ -17,45 +17,45 @@ module NotionRubyMapping
|
|
17
17
|
def self.type2class(type, has_children = false)
|
18
18
|
@type2class ||= {
|
19
19
|
false => {
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
20
|
+
bookmark: BookmarkBlock,
|
21
|
+
breadcrumb: BreadcrumbBlock,
|
22
|
+
bulleted_list_item: BulletedListItemBlock,
|
23
|
+
callout: CalloutBlock,
|
24
|
+
child_database: ChildDatabaseBlock,
|
25
|
+
child_page: ChildPageBlock,
|
26
|
+
code: CodeBlock,
|
27
|
+
column: ColumnBlock,
|
28
|
+
column_list: ColumnListBlock,
|
29
|
+
divider: DividerBlock,
|
30
|
+
embed: EmbedBlock,
|
31
|
+
equation: EquationBlock,
|
32
|
+
file: FileBlock,
|
33
|
+
heading_1: Heading1Block,
|
34
|
+
heading_2: Heading2Block,
|
35
|
+
heading_3: Heading3Block,
|
36
|
+
image: ImageBlock,
|
37
|
+
link_preview: LinkPreviewBlock,
|
38
|
+
link_to_page: LinkToPageBlock,
|
39
|
+
numbered_list_item: NumberedListItemBlock,
|
40
|
+
paragraph: ParagraphBlock,
|
41
|
+
pdf: PdfBlock,
|
42
|
+
quote: QuoteBlock,
|
43
|
+
synced_block: SyncedBlock,
|
44
|
+
table: TableBlock,
|
45
|
+
table_row: TableRowBlock,
|
46
|
+
table_of_contents: TableOfContentsBlock,
|
47
|
+
template: TemplateBlock,
|
48
|
+
to_do: ToDoBlock,
|
49
|
+
toggle: ToggleBlock,
|
50
|
+
video: VideoBlock,
|
51
51
|
},
|
52
52
|
true => {
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
}
|
53
|
+
heading_1: ToggleHeading1Block,
|
54
|
+
heading_2: ToggleHeading2Block,
|
55
|
+
heading_3: ToggleHeading3Block,
|
56
|
+
},
|
57
57
|
}
|
58
|
-
@klass = @type2class[has_children][type] || @type2class[false][type] || Block
|
58
|
+
@klass = @type2class[has_children][type.to_sym] || @type2class[false][type.to_sym] || Block
|
59
59
|
end
|
60
60
|
|
61
61
|
def self.decode_block(json)
|
@@ -65,7 +65,7 @@ module NotionRubyMapping
|
|
65
65
|
# @see https://www.notion.so/hkob/Block-689ad4cbff50404d8a1baf67b6d6d78d#298916c7c379424682f39ff09ee38544
|
66
66
|
# @param [String] id
|
67
67
|
# @param [Boolean] dry_run true if dry_run
|
68
|
-
# @return [NotionRubyMapping::Block]
|
68
|
+
# @return [String, NotionRubyMapping::Block]
|
69
69
|
def self.find(id, dry_run: false)
|
70
70
|
nc = NotionCache.instance
|
71
71
|
block_id = Base.block_id id
|
@@ -80,7 +80,7 @@ module NotionRubyMapping
|
|
80
80
|
# @return [NotionRubyMapping::Block, String]
|
81
81
|
# @param [Array<Block>] blocks
|
82
82
|
def append_after(*blocks, dry_run: false)
|
83
|
-
parent.append_block_children
|
83
|
+
parent.append_block_children(*blocks, after: id, dry_run: dry_run)
|
84
84
|
end
|
85
85
|
|
86
86
|
# @param [Boolean] not_update false when update
|
@@ -99,7 +99,7 @@ module NotionRubyMapping
|
|
99
99
|
|
100
100
|
# @return [NotionRubyMapping::RichTextArray]
|
101
101
|
def decode_block_caption
|
102
|
-
@caption = RichTextArray.new "caption", json: @json[type]["caption"]
|
102
|
+
@caption = RichTextArray.new "caption", json: @json[type]["caption"] if @json[type]["caption"]
|
103
103
|
end
|
104
104
|
|
105
105
|
# @return [String]
|
@@ -128,7 +128,8 @@ module NotionRubyMapping
|
|
128
128
|
if dry_run
|
129
129
|
dry_run_script :patch, @nc.block_path(@id), :update_block_json
|
130
130
|
else
|
131
|
-
|
131
|
+
@json = @nc.update_block_request(@id, update_block_json)
|
132
|
+
update_file_object_from_json(@json) if is_a? FileBaseBlock
|
132
133
|
end
|
133
134
|
end
|
134
135
|
|
@@ -144,7 +145,7 @@ module NotionRubyMapping
|
|
144
145
|
@can_have_children = true
|
145
146
|
end
|
146
147
|
|
147
|
-
# @param [String] type
|
148
|
+
# @param [String, Symbol] type
|
148
149
|
# @param [String] color
|
149
150
|
def rich_text_array_and_color(type, text_info, color = "default")
|
150
151
|
@rich_text_array = RichTextArray.rich_text_array type, text_info
|
@@ -107,7 +107,7 @@ module NotionRubyMapping
|
|
107
107
|
Base.dry_run_script :post, @nc.query_database_path(@id), query.query_json
|
108
108
|
else
|
109
109
|
response = @nc.database_query_request @id, query
|
110
|
-
List.new json: response, type:
|
110
|
+
List.new json: response, type: "database", value: self, query: query
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
@@ -21,7 +21,7 @@ module NotionRubyMapping
|
|
21
21
|
|
22
22
|
# @see https://www.notion.so/hkob/FileBlock-08f2aa6948364d00b92beacaac9a619c#158487a7e1644fae8778dcff59869356
|
23
23
|
# @see https://www.notion.so/hkob/ImageBlock-806b3d2a9a2c4bf5a5aca6e3fbc8a7e2#19a4aa3e06514bbe84be9d3b8a45a20f
|
24
|
-
attr_reader :caption
|
24
|
+
attr_reader :caption, :file_object
|
25
25
|
|
26
26
|
# @param [Boolean] not_update false when update
|
27
27
|
# @return [Hash{String (frozen)->Hash}]
|
@@ -46,5 +46,17 @@ module NotionRubyMapping
|
|
46
46
|
@file_object.url = url
|
47
47
|
@payload.add_update_block_key "external"
|
48
48
|
end
|
49
|
+
|
50
|
+
# @param [FileUploadObject] fuo
|
51
|
+
def file_upload_object=(fuo)
|
52
|
+
@file_object.file_upload_object = fuo
|
53
|
+
@payload.add_update_block_key "file_upload"
|
54
|
+
end
|
55
|
+
|
56
|
+
def update_file_object_from_json(json)
|
57
|
+
@file_object = FileObject.new json: json[type]
|
58
|
+
decode_block_caption
|
59
|
+
@can_append = @file_object.external?
|
60
|
+
end
|
49
61
|
end
|
50
62
|
end
|
@@ -10,13 +10,13 @@ module NotionRubyMapping
|
|
10
10
|
@can_have_children = false
|
11
11
|
end
|
12
12
|
|
13
|
-
# @return [String
|
13
|
+
# @return [String]
|
14
14
|
def type
|
15
15
|
"heading_1"
|
16
16
|
end
|
17
17
|
|
18
18
|
# @param [Boolean] not_update false when update
|
19
|
-
# @return [Hash{
|
19
|
+
# @return [Hash{Symbol->Hash}]
|
20
20
|
def block_json(not_update: true)
|
21
21
|
ans = super
|
22
22
|
ans[type]["is_toggleable"] = false
|
@@ -11,17 +11,17 @@ module NotionRubyMapping
|
|
11
11
|
@load_all_contents = !@has_more
|
12
12
|
|
13
13
|
case type
|
14
|
-
when
|
14
|
+
when "comment_parent"
|
15
15
|
@comment_parent = value
|
16
|
-
when
|
16
|
+
when "database"
|
17
17
|
@database = value
|
18
|
-
when
|
18
|
+
when "parent"
|
19
19
|
@parent = value
|
20
|
-
when
|
20
|
+
when "property"
|
21
21
|
@property = value
|
22
|
-
when
|
23
|
-
@user_object =
|
24
|
-
when
|
22
|
+
when "user_object"
|
23
|
+
@user_object = value
|
24
|
+
when "search"
|
25
25
|
@search = value
|
26
26
|
end
|
27
27
|
@query = query
|
@@ -34,6 +34,7 @@ module NotionRubyMapping
|
|
34
34
|
# @see https://www.notion.so/hkob/List-9a0b32335e0d48849a785ce5e162c760#12e1c261a0944a4095776b7515bef4a1
|
35
35
|
def each(&block)
|
36
36
|
return enum_for(:each) if block.nil?
|
37
|
+
|
37
38
|
if @parent
|
38
39
|
each_sub base: @page,
|
39
40
|
query: -> { @parent.children @query },
|
@@ -46,12 +47,12 @@ module NotionRubyMapping
|
|
46
47
|
&block
|
47
48
|
elsif @property
|
48
49
|
each_sub base: @property,
|
49
|
-
query:
|
50
|
+
query: lambda {
|
50
51
|
@nc.page_property_request @property.property_cache.page_id,
|
51
52
|
@property.property_id,
|
52
53
|
@query.query_json
|
53
|
-
|
54
|
-
create_object:
|
54
|
+
},
|
55
|
+
create_object: lambda { |json|
|
55
56
|
case json["type"]
|
56
57
|
when "people"
|
57
58
|
UserObject.new json: json["people"]
|
@@ -64,7 +65,7 @@ module NotionRubyMapping
|
|
64
65
|
else
|
65
66
|
json
|
66
67
|
end
|
67
|
-
|
68
|
+
},
|
68
69
|
&block
|
69
70
|
elsif @comment_parent
|
70
71
|
each_sub base: @comment_parent,
|
@@ -67,7 +67,7 @@ module NotionRubyMapping
|
|
67
67
|
# @return [String] title
|
68
68
|
# @see https://www.notion.so/hkob/Page-d359650e3ca94424af8359a24147b9a0#2ff7209055f346fbbda454cdbb40b1c8
|
69
69
|
def title
|
70
|
-
tp = properties.select { |p| p.is_a?(TitleProperty) || (p.is_a?(Property) && p.property_id ==
|
70
|
+
tp = properties.select { |p| p.is_a?(TitleProperty) || (p.is_a?(Property) && p.property_id == :title) }
|
71
71
|
tp.map(&:full_text).join ""
|
72
72
|
end
|
73
73
|
|
@@ -103,6 +103,5 @@ module NotionRubyMapping
|
|
103
103
|
update_json @nc.update_page_request(@id, property_values_json)
|
104
104
|
end
|
105
105
|
end
|
106
|
-
|
107
106
|
end
|
108
107
|
end
|
@@ -16,7 +16,7 @@ module NotionRubyMapping
|
|
16
16
|
def append_comment(text_objects, dry_run: false)
|
17
17
|
rto = RichTextArray.new "rich_text", text_objects: text_objects, will_update: true
|
18
18
|
nc = NotionCache.instance
|
19
|
-
json = rto.property_schema_json.merge({
|
19
|
+
json = rto.property_schema_json.merge({discussion_id: @discussion_id})
|
20
20
|
if dry_run
|
21
21
|
Base.dry_run_script :post, nc.comments_path, json
|
22
22
|
else
|
@@ -16,11 +16,10 @@ module NotionRubyMapping
|
|
16
16
|
until @lines.empty?
|
17
17
|
case @lines.shift
|
18
18
|
when / *(\w+) *[|}][|o]--[o|][|{] *(\w+) *: *"(.*)" */
|
19
|
-
db_or_create(Regexp.last_match(1)).append_relation_queue db_or_create(Regexp.last_match(2)),
|
19
|
+
db_or_create(Regexp.last_match(1)).append_relation_queue db_or_create(Regexp.last_match(2)),
|
20
|
+
Regexp.last_match(3)
|
20
21
|
when / *(\w+) *{ */
|
21
22
|
append_db_with_attributes Regexp.last_match(1)
|
22
|
-
else
|
23
|
-
nil
|
24
23
|
end
|
25
24
|
end
|
26
25
|
end
|
@@ -41,8 +40,6 @@ module NotionRubyMapping
|
|
41
40
|
db.add_property Regexp.last_match(1), Regexp.last_match(2)
|
42
41
|
when /^ *([^ ]+) +([^ ]+) *$/
|
43
42
|
db.add_property Regexp.last_match(1), Regexp.last_match(2)
|
44
|
-
else
|
45
|
-
nil
|
46
43
|
end
|
47
44
|
end
|
48
45
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
module NotionRubyMapping
|
2
2
|
class MermaidDatabase
|
3
|
-
|
4
3
|
def initialize(key)
|
5
4
|
@key = key
|
6
5
|
@name = key
|
@@ -157,14 +156,12 @@ module NotionRubyMapping
|
|
157
156
|
end
|
158
157
|
end
|
159
158
|
@working << name
|
160
|
-
else
|
161
|
-
nil
|
162
159
|
end
|
163
160
|
end
|
164
|
-
while (array = @relation_queue.shift)
|
161
|
+
while (array = @relation_queue.shift)
|
165
162
|
value, relation_db = array
|
166
163
|
db_id = relation_db.real_db.id
|
167
|
-
forward, reverse = value.split
|
164
|
+
forward, reverse = value.split("|").map(&:to_s)
|
168
165
|
property = ps.values_at(forward).first
|
169
166
|
if property
|
170
167
|
if reverse
|
@@ -243,4 +240,4 @@ module NotionRubyMapping
|
|
243
240
|
@reverse_name_queue = {}
|
244
241
|
end
|
245
242
|
end
|
246
|
-
end
|
243
|
+
end
|