notion_ruby_mapping 0.3.3 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +44 -1237
- data/env.yml.sample +0 -13
- 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/{base.rb → blocks/base.rb} +163 -92
- data/lib/notion_ruby_mapping/blocks/block.rb +145 -0
- 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/{database.rb → blocks/database.rb} +41 -8
- 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/{list.rb → blocks/list.rb} +37 -6
- data/lib/notion_ruby_mapping/blocks/numbered_list_item_block.rb +11 -0
- data/lib/notion_ruby_mapping/blocks/page.rb +77 -0
- data/lib/notion_ruby_mapping/blocks/paragraph_block.rb +11 -0
- data/lib/notion_ruby_mapping/{block.rb → blocks/pdf_block.rb} +4 -3
- 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/{notion_cache.rb → controllers/notion_cache.rb} +144 -102
- data/lib/notion_ruby_mapping/{payload.rb → controllers/payload.rb} +32 -18
- data/lib/notion_ruby_mapping/{property_cache.rb → controllers/property_cache.rb} +21 -20
- data/lib/notion_ruby_mapping/{query.rb → controllers/query.rb} +27 -19
- data/lib/notion_ruby_mapping/{rich_text_array.rb → controllers/rich_text_array.rb} +39 -17
- data/lib/notion_ruby_mapping/objects/emoji_object.rb +40 -0
- data/lib/notion_ruby_mapping/objects/equation_object.rb +43 -0
- data/lib/notion_ruby_mapping/objects/file_object.rb +60 -0
- data/lib/notion_ruby_mapping/{mention_object.rb → objects/mention_object.rb} +11 -0
- data/lib/notion_ruby_mapping/{rich_text_object.rb → objects/rich_text_object.rb} +12 -4
- data/lib/notion_ruby_mapping/{text_object.rb → objects/text_object.rb} +0 -1
- data/lib/notion_ruby_mapping/{user_object.rb → objects/user_object.rb} +9 -4
- data/lib/notion_ruby_mapping/{checkbox_property.rb → properties/checkbox_property.rb} +3 -0
- data/lib/notion_ruby_mapping/{created_by_property.rb → properties/created_by_property.rb} +1 -0
- data/lib/notion_ruby_mapping/{created_time_property.rb → properties/created_time_property.rb} +1 -0
- data/lib/notion_ruby_mapping/properties/date_base_property.rb +135 -0
- data/lib/notion_ruby_mapping/{date_property.rb → properties/date_property.rb} +13 -0
- data/lib/notion_ruby_mapping/{email_property.rb → properties/email_property.rb} +2 -2
- data/lib/notion_ruby_mapping/{files_property.rb → properties/files_property.rb} +26 -13
- data/lib/notion_ruby_mapping/{formula_property.rb → properties/formula_property.rb} +5 -1
- data/lib/notion_ruby_mapping/{last_edited_by_property.rb → properties/last_edited_by_property.rb} +1 -0
- data/lib/notion_ruby_mapping/{last_edited_time_property.rb → properties/last_edited_time_property.rb} +1 -0
- data/lib/notion_ruby_mapping/{multi_property.rb → properties/multi_property.rb} +0 -0
- data/lib/notion_ruby_mapping/{multi_select_property.rb → properties/multi_select_property.rb} +4 -3
- data/lib/notion_ruby_mapping/{number_property.rb → properties/number_property.rb} +4 -0
- data/lib/notion_ruby_mapping/{people_property.rb → properties/people_property.rb} +8 -3
- data/lib/notion_ruby_mapping/{phone_number_property.rb → properties/phone_number_property.rb} +4 -1
- data/lib/notion_ruby_mapping/{property.rb → properties/property.rb} +33 -0
- data/lib/notion_ruby_mapping/{relation_property.rb → properties/relation_property.rb} +30 -10
- data/lib/notion_ruby_mapping/{rich_text_property.rb → properties/rich_text_property.rb} +0 -0
- data/lib/notion_ruby_mapping/{rollup_property.rb → properties/rollup_property.rb} +7 -0
- data/lib/notion_ruby_mapping/{select_property.rb → properties/select_property.rb} +8 -2
- data/lib/notion_ruby_mapping/{text_property.rb → properties/text_property.rb} +0 -0
- data/lib/notion_ruby_mapping/{title_property.rb → properties/title_property.rb} +0 -0
- data/lib/notion_ruby_mapping/{url_property.rb → properties/url_property.rb} +4 -1
- data/lib/notion_ruby_mapping/version.rb +1 -1
- data/lib/notion_ruby_mapping.rb +21 -7
- metadata +82 -40
- data/lib/notion_ruby_mapping/date_base_property.rb +0 -75
- data/lib/notion_ruby_mapping/page.rb +0 -50
@@ -10,22 +10,27 @@ module NotionRubyMapping
|
|
10
10
|
## Common methods
|
11
11
|
|
12
12
|
# @return [Array, Hash]
|
13
|
+
# @see https://www.notion.so/hkob/PeopleProperty-144355d25f0e4feba9ae39fe28ca6ae7#7e3e56c2080d4834902cfa0223e807e5
|
13
14
|
def people
|
14
15
|
@json
|
15
16
|
end
|
16
17
|
|
17
18
|
## Page property only methods
|
18
19
|
|
19
|
-
# @param [String, NotionRubyMapping::UserObject]
|
20
|
+
# @param [String, NotionRubyMapping::UserObject] user_id_or_uo
|
20
21
|
# @return [Array<UserObject>]
|
21
|
-
|
22
|
+
# @see https://www.notion.so/hkob/PeopleProperty-144355d25f0e4feba9ae39fe28ca6ae7#26344b145a254cc58dd845780e0a26ea
|
23
|
+
def add_person(user_id_or_uo)
|
24
|
+
assert_page_property __method__
|
22
25
|
@will_update = true
|
23
|
-
@json << UserObject.user_object(
|
26
|
+
@json << UserObject.user_object(user_id_or_uo)
|
24
27
|
end
|
25
28
|
|
26
29
|
# @param [Hash] people
|
27
30
|
# @return [Array, nil] replaced array
|
31
|
+
# @see https://www.notion.so/hkob/PeopleProperty-144355d25f0e4feba9ae39fe28ca6ae7#815acfef9a664e3e8915fb31b8fefc42
|
28
32
|
def people=(people)
|
33
|
+
assert_page_property __method__
|
29
34
|
@will_update = true
|
30
35
|
@json = people ? Array(people).map { |uo| UserObject.user_object(uo) } : []
|
31
36
|
end
|
data/lib/notion_ruby_mapping/{phone_number_property.rb → properties/phone_number_property.rb}
RENAMED
@@ -14,13 +14,17 @@ module NotionRubyMapping
|
|
14
14
|
## Common methods
|
15
15
|
|
16
16
|
# @return [String, Hash, nil] phone number (Page), {} (Database)
|
17
|
+
# @see https://www.notion.so/hkob/PhoneNumberProperty-5df14aaa938c4888aecd53ab6752d2e6#40bceda04fe04c64b932d6a1ed180eaa
|
17
18
|
def phone_number
|
18
19
|
@json
|
19
20
|
end
|
20
21
|
|
21
22
|
## Page property only methods
|
22
23
|
|
24
|
+
# @param [String] phone_number
|
25
|
+
# @see https://www.notion.so/hkob/PhoneNumberProperty-5df14aaa938c4888aecd53ab6752d2e6#dc7e00e0558d40f79ca5cade1fccef29
|
23
26
|
def phone_number=(phone_number)
|
27
|
+
assert_page_property __method__
|
24
28
|
@will_update = true
|
25
29
|
@json = phone_number
|
26
30
|
end
|
@@ -30,7 +34,6 @@ module NotionRubyMapping
|
|
30
34
|
## Common methods
|
31
35
|
|
32
36
|
# @param [String] name Property name
|
33
|
-
# @param [String] phone_number phone_number value (optional)
|
34
37
|
def initialize(name, will_update: false, base_type: :page, json: nil)
|
35
38
|
super name, will_update: will_update, base_type: base_type
|
36
39
|
@json = database? ? {} : json
|
@@ -91,6 +91,8 @@ module NotionRubyMapping
|
|
91
91
|
def make_filter_query(key, value, rollup = nil, rollup_type = nil)
|
92
92
|
if rollup
|
93
93
|
Query.new filter: {"property" => @name, rollup => {rollup_type => {key => value}}}
|
94
|
+
elsif rollup_type
|
95
|
+
Query.new filter: {"property" => @name, rollup_type => {key => value}}
|
94
96
|
elsif @name == "__timestamp__"
|
95
97
|
Query.new filter: {"timestamp" => type, type => {key => value}}
|
96
98
|
else
|
@@ -169,13 +171,19 @@ module NotionRubyMapping
|
|
169
171
|
### Public announced methods
|
170
172
|
|
171
173
|
# @param [String, Number] value Query value
|
174
|
+
# @param [String] rollup Rollup name
|
175
|
+
# @param [String] rollup_type Rollup type
|
172
176
|
# @return [NotionRubyMapping::Query] generated Query object
|
177
|
+
# @see https://www.notion.so/hkob/CheckboxProperty-ac1edbdb8e264af5ad1432b522b429fd#5f07c4ebc4744986bfc99a43827349fc
|
173
178
|
def filter_equals(value, rollup = nil, rollup_type = nil)
|
174
179
|
make_filter_query "equals", value, rollup, rollup_type
|
175
180
|
end
|
176
181
|
|
177
182
|
# @param [String, Number] value Query value
|
183
|
+
# @param [String] rollup Rollup name
|
184
|
+
# @param [String] rollup_type Rollup type
|
178
185
|
# @return [NotionRubyMapping::Query] generated Query object
|
186
|
+
# @see https://www.notion.so/hkob/CheckboxProperty-ac1edbdb8e264af5ad1432b522b429fd#a44a1875c3ef49f2b4f817291953a1d4
|
179
187
|
def filter_does_not_equal(value, rollup = nil, rollup_type = nil)
|
180
188
|
make_filter_query "does_not_equal", value, rollup, rollup_type
|
181
189
|
end
|
@@ -186,13 +194,19 @@ module NotionRubyMapping
|
|
186
194
|
### Public announced methods
|
187
195
|
|
188
196
|
# @param [String] value Query value
|
197
|
+
# @param [String] rollup Rollup name
|
198
|
+
# @param [String] rollup_type Rollup type
|
189
199
|
# @return [NotionRubyMapping::Query] generated Query object
|
200
|
+
# @see https://www.notion.so/hkob/CreatedByProperty-945fa6be1c014da2b7e55a2b76e37b57#271a2ebaa1ec48acae732ca98920feab
|
190
201
|
def filter_contains(value, rollup = nil, rollup_type = nil)
|
191
202
|
make_filter_query "contains", value, rollup, rollup_type
|
192
203
|
end
|
193
204
|
|
194
205
|
# @param [String] value Query value
|
206
|
+
# @param [String] rollup Rollup name
|
207
|
+
# @param [String] rollup_type Rollup type
|
195
208
|
# @return [NotionRubyMapping::Query] generated Query object
|
209
|
+
# @see https://www.notion.so/hkob/CreatedByProperty-945fa6be1c014da2b7e55a2b76e37b57#b0328e3b146f48a4ad4c9c2ee5363486
|
196
210
|
def filter_does_not_contain(value, rollup = nil, rollup_type = nil)
|
197
211
|
make_filter_query "does_not_contain", value, rollup, rollup_type
|
198
212
|
end
|
@@ -203,12 +217,17 @@ module NotionRubyMapping
|
|
203
217
|
### Public announced methods
|
204
218
|
|
205
219
|
# @param [String] value Query value
|
220
|
+
# @param [String] rollup Rollup name
|
221
|
+
# @param [String] rollup_type Rollup type
|
206
222
|
# @return [NotionRubyMapping::Query] generated Query object
|
223
|
+
# @see https://www.notion.so/hkob/EmailProperty-39aeb5df56ea4cc1b9380574e4fdeec0#d3e098b2f38c4c8c9d3e815516cfd953
|
207
224
|
def filter_starts_with(value, rollup = nil, rollup_type = nil)
|
208
225
|
make_filter_query "starts_with", value, rollup, rollup_type
|
209
226
|
end
|
210
227
|
|
211
228
|
# @param [String] value Query value
|
229
|
+
# @param [String] rollup Rollup name
|
230
|
+
# @param [String] rollup_type Rollup type
|
212
231
|
# @return [NotionRubyMapping::Query] generated Query object
|
213
232
|
def filter_ends_with(value, rollup = nil, rollup_type = nil)
|
214
233
|
make_filter_query "ends_with", value, rollup, rollup_type
|
@@ -219,12 +238,18 @@ module NotionRubyMapping
|
|
219
238
|
module IsEmptyIsNotEmpty
|
220
239
|
### Public announced methods
|
221
240
|
|
241
|
+
# @param [String] rollup Rollup name
|
242
|
+
# @param [String] rollup_type Rollup type
|
222
243
|
# @return [NotionRubyMapping::Query] generated Query object
|
244
|
+
# @see https://www.notion.so/hkob/CreatedByProperty-945fa6be1c014da2b7e55a2b76e37b57#38749dfae0854c68b4c55095d3efbff1
|
223
245
|
def filter_is_empty(rollup = nil, rollup_type = nil)
|
224
246
|
make_filter_query "is_empty", true, rollup, rollup_type
|
225
247
|
end
|
226
248
|
|
249
|
+
# @param [String] rollup Rollup name
|
250
|
+
# @param [String] rollup_type Rollup type
|
227
251
|
# @return [NotionRubyMapping::Query] generated Query object
|
252
|
+
# @see https://www.notion.so/hkob/CreatedByProperty-945fa6be1c014da2b7e55a2b76e37b57#515659ea52b54fb48c81b813f3b705f6
|
228
253
|
def filter_is_not_empty(rollup = nil, rollup_type = nil)
|
229
254
|
make_filter_query "is_not_empty", true, rollup, rollup_type
|
230
255
|
end
|
@@ -235,24 +260,32 @@ module NotionRubyMapping
|
|
235
260
|
### Public announced methods
|
236
261
|
|
237
262
|
# @param [Number] value Query value
|
263
|
+
# @param [String] rollup Rollup name
|
264
|
+
# @param [String] rollup_type Rollup type
|
238
265
|
# @return [NotionRubyMapping::Query] generated Query object
|
239
266
|
def filter_greater_than(value, rollup = nil, rollup_type = nil)
|
240
267
|
make_filter_query "greater_than", value, rollup, rollup_type
|
241
268
|
end
|
242
269
|
|
243
270
|
# @param [Number] value Query value
|
271
|
+
# @param [String] rollup Rollup name
|
272
|
+
# @param [String] rollup_type Rollup type
|
244
273
|
# @return [NotionRubyMapping::Query] generated Query object
|
245
274
|
def filter_less_than(value, rollup = nil, rollup_type = nil)
|
246
275
|
make_filter_query "less_than", value, rollup, rollup_type
|
247
276
|
end
|
248
277
|
|
249
278
|
# @param [Number] value Query value
|
279
|
+
# @param [String] rollup Rollup name
|
280
|
+
# @param [String] rollup_type Rollup type
|
250
281
|
# @return [NotionRubyMapping::Query] generated Query object
|
251
282
|
def filter_greater_than_or_equal_to(value, rollup = nil, rollup_type = nil)
|
252
283
|
make_filter_query "greater_than_or_equal_to", value, rollup, rollup_type
|
253
284
|
end
|
254
285
|
|
255
286
|
# @param [Number] value Query value
|
287
|
+
# @param [String] rollup Rollup name
|
288
|
+
# @param [String] rollup_type Rollup type
|
256
289
|
# @return [NotionRubyMapping::Query] generated Query object
|
257
290
|
def filter_less_than_or_equal_to(value, rollup = nil, rollup_type = nil)
|
258
291
|
make_filter_query "less_than_or_equal_to", value, rollup, rollup_type
|
@@ -10,13 +10,42 @@ module NotionRubyMapping
|
|
10
10
|
## Common methods
|
11
11
|
|
12
12
|
# @return [Hash, Array]
|
13
|
+
# @see https://www.notion.so/hkob/RelationProperty-f608ab41a1f0476b98456620346fba03#6c14207b2d1340d2bbc08d17eee2cb22
|
13
14
|
def relation
|
14
15
|
@json
|
15
16
|
end
|
16
17
|
|
18
|
+
## Page property only methods
|
19
|
+
|
20
|
+
# @param [String, Hash] page_id_or_json
|
21
|
+
# @see https://www.notion.so/hkob/RelationProperty-f608ab41a1f0476b98456620346fba03#52572d8745ef4b66bc34ba202c84b87c
|
22
|
+
def add_relation(page_id_or_json)
|
23
|
+
assert_page_property __method__
|
24
|
+
@will_update = true
|
25
|
+
@json << if page_id_or_json.is_a? String
|
26
|
+
{"id" => page_id_or_json}
|
27
|
+
else
|
28
|
+
page_id_or_json
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# @param [String, Array<String>, Hash, Array<Hash>] page_ids_or_jsons
|
33
|
+
# @return [Array] settled relation Array
|
34
|
+
# @see https://www.notion.so/hkob/RelationProperty-f608ab41a1f0476b98456620346fba03#1025f772ecd64e678912a5036a95eda6
|
35
|
+
def relation=(page_ids_or_jsons)
|
36
|
+
assert_page_property __method__
|
37
|
+
@will_update = true
|
38
|
+
page_ids_or_jsons = [page_ids_or_jsons] unless page_ids_or_jsons.is_a? Array
|
39
|
+
|
40
|
+
@json = page_ids_or_jsons.map do |page_id_or_json|
|
41
|
+
page_id_or_json.is_a?(String) ? {"id" => page_id_or_json} : page_id_or_json
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
17
45
|
## Database property only methods
|
18
46
|
|
19
47
|
# @return [String] relation database_id
|
48
|
+
# @see https://www.notion.so/hkob/RelationProperty-f608ab41a1f0476b98456620346fba03#eb40f1a2ad5c4e368d343870a7e529f9
|
20
49
|
def relation_database_id
|
21
50
|
assert_database_property __method__
|
22
51
|
@json["database_id"]
|
@@ -24,6 +53,7 @@ module NotionRubyMapping
|
|
24
53
|
|
25
54
|
# @param [String] database_id
|
26
55
|
# @param [String] synced_property_name
|
56
|
+
# @see https://www.notion.so/hkob/RelationProperty-f608ab41a1f0476b98456620346fba03#7f5029fb7f6e4c009f22888b233e6f64
|
27
57
|
def replace_relation_database(database_id: nil, synced_property_name: nil)
|
28
58
|
assert_database_property __method__
|
29
59
|
@will_update = true
|
@@ -65,16 +95,6 @@ module NotionRubyMapping
|
|
65
95
|
ans
|
66
96
|
end
|
67
97
|
|
68
|
-
## Page property only methods
|
69
|
-
|
70
|
-
# @param [String, Array<String>] relation a id or Array of id
|
71
|
-
# @return [Array] settled relation Array
|
72
|
-
def relation=(page_ids)
|
73
|
-
assert_page_property __method__
|
74
|
-
@will_update = true
|
75
|
-
@json = Array(page_ids).map { |r| {"id" => r} }
|
76
|
-
end
|
77
|
-
|
78
98
|
# @return [Hash] created json
|
79
99
|
def property_values_json
|
80
100
|
assert_page_property __method__
|
File without changes
|
@@ -13,6 +13,7 @@ module NotionRubyMapping
|
|
13
13
|
## Common methods
|
14
14
|
|
15
15
|
# @return [Hash]
|
16
|
+
# @see https://www.notion.so/hkob/RollupProperty-eb10fbac3a93436289e74e5c651e9134#4b5749f350e542e5a018030bde411fb9
|
16
17
|
def rollup
|
17
18
|
@json
|
18
19
|
end
|
@@ -20,12 +21,14 @@ module NotionRubyMapping
|
|
20
21
|
## Database property only methods
|
21
22
|
|
22
23
|
# @return [String] new or settled function
|
24
|
+
# @see https://www.notion.so/hkob/RollupProperty-eb10fbac3a93436289e74e5c651e9134#94021d4e6c0b44519443c1e1cc6b3aba
|
23
25
|
def function
|
24
26
|
assert_database_property __method__
|
25
27
|
@json["function"]
|
26
28
|
end
|
27
29
|
|
28
30
|
# @param [String] func
|
31
|
+
# @see https://www.notion.so/hkob/RollupProperty-eb10fbac3a93436289e74e5c651e9134#647c74803cac49a9b79199828157e17a
|
29
32
|
def function=(func)
|
30
33
|
assert_database_property __method__
|
31
34
|
@will_update = true
|
@@ -33,12 +36,14 @@ module NotionRubyMapping
|
|
33
36
|
end
|
34
37
|
|
35
38
|
# @return [String] new or settled relation_property_name
|
39
|
+
# @see https://www.notion.so/hkob/RollupProperty-eb10fbac3a93436289e74e5c651e9134#684fc4739c4f4d6a9b93687f72cd8dad
|
36
40
|
def relation_property_name
|
37
41
|
assert_database_property __method__
|
38
42
|
@json["relation_property_name"]
|
39
43
|
end
|
40
44
|
|
41
45
|
# @param [String] rpn
|
46
|
+
# @see https://www.notion.so/hkob/RollupProperty-eb10fbac3a93436289e74e5c651e9134#a61c2100758841c381edd820aa88ac65
|
42
47
|
def relation_property_name=(rpn)
|
43
48
|
assert_database_property __method__
|
44
49
|
@will_update = true
|
@@ -46,12 +51,14 @@ module NotionRubyMapping
|
|
46
51
|
end
|
47
52
|
|
48
53
|
# @return [String] new or settled rollup_property_name
|
54
|
+
# @see https://www.notion.so/hkob/RollupProperty-eb10fbac3a93436289e74e5c651e9134#8ce9ee31a2e2473ab7ba21781e4b440d
|
49
55
|
def rollup_property_name
|
50
56
|
assert_database_property __method__
|
51
57
|
@json["rollup_property_name"]
|
52
58
|
end
|
53
59
|
|
54
60
|
# @param [String] rpn
|
61
|
+
# @see https://www.notion.so/hkob/RollupProperty-eb10fbac3a93436289e74e5c651e9134#66503f4472f2456aa9b383f03b1fe0a6
|
55
62
|
def rollup_property_name=(rpn)
|
56
63
|
assert_database_property __method__
|
57
64
|
@will_update = true
|
@@ -12,6 +12,7 @@ module NotionRubyMapping
|
|
12
12
|
## Common methods
|
13
13
|
|
14
14
|
# @return [Hash]
|
15
|
+
# @see https://www.notion.so/hkob/SelectProperty-6d6a0defa70d4b26af0fdbdcfbf99f28#7ad3734ac42c43068f1e04633bab400b
|
15
16
|
def select
|
16
17
|
@json
|
17
18
|
end
|
@@ -19,6 +20,7 @@ module NotionRubyMapping
|
|
19
20
|
## Page property only methods
|
20
21
|
|
21
22
|
# @return [String]
|
23
|
+
# @see https://www.notion.so/hkob/SelectProperty-6d6a0defa70d4b26af0fdbdcfbf99f28#27a05e52715a4acd9156b5f146653e51
|
22
24
|
def select_name
|
23
25
|
assert_page_property __method__
|
24
26
|
@json["name"]
|
@@ -29,7 +31,8 @@ module NotionRubyMapping
|
|
29
31
|
# @param [String] name
|
30
32
|
# @param [String] color
|
31
33
|
# @return [Array] added array
|
32
|
-
|
34
|
+
# @see https://www.notion.so/hkob/SelectProperty-6d6a0defa70d4b26af0fdbdcfbf99f28#3e1c7dbda7fb455f94ee93d9653b7880
|
35
|
+
def add_select_option(name:, color:)
|
33
36
|
edit_select_options << {"name" => name, "color" => color}
|
34
37
|
end
|
35
38
|
|
@@ -41,12 +44,14 @@ module NotionRubyMapping
|
|
41
44
|
end
|
42
45
|
|
43
46
|
# @return [Array]
|
47
|
+
# @see https://www.notion.so/hkob/SelectProperty-6d6a0defa70d4b26af0fdbdcfbf99f28#790a297f2c1b4ba5a4d86074d4c70a89
|
44
48
|
def select_options
|
45
49
|
assert_database_property __method__
|
46
50
|
@json["options"] || []
|
47
51
|
end
|
48
52
|
|
49
53
|
# @return [String]
|
54
|
+
# @see https://www.notion.so/hkob/SelectProperty-6d6a0defa70d4b26af0fdbdcfbf99f28#72da1632793c4a5296f3bc89de2df413
|
50
55
|
def select_names
|
51
56
|
assert_database_property __method__
|
52
57
|
@json["options"].map { |s| s["name"] }
|
@@ -55,8 +60,9 @@ module NotionRubyMapping
|
|
55
60
|
## Page property only methods
|
56
61
|
|
57
62
|
# @param [String] select
|
58
|
-
# @
|
63
|
+
# @see https://www.notion.so/hkob/SelectProperty-6d6a0defa70d4b26af0fdbdcfbf99f28#3bd195bf5c0a498ebf850409f7deb67a
|
59
64
|
def select=(select)
|
65
|
+
assert_page_property __method__
|
60
66
|
@will_update = true
|
61
67
|
@json = {"name" => select}
|
62
68
|
end
|
File without changes
|
File without changes
|
@@ -14,13 +14,17 @@ module NotionRubyMapping
|
|
14
14
|
## Common methods
|
15
15
|
|
16
16
|
# @return [String, Hash, nil] url (Page), {} (Database)
|
17
|
+
# @see https://www.notion.so/hkob/UrlProperty-8a0094fdf6494151983cb4694f6626cc#8342eef7df3c43eaad10c48d4757b4ae
|
17
18
|
def url
|
18
19
|
@json
|
19
20
|
end
|
20
21
|
|
21
22
|
## Page property only methods
|
22
23
|
|
24
|
+
# @param [String] url
|
25
|
+
# @see https://www.notion.so/hkob/UrlProperty-8a0094fdf6494151983cb4694f6626cc#cfa5463a121b4002b250b38d7d0a0d34
|
23
26
|
def url=(url)
|
27
|
+
assert_page_property __method__
|
24
28
|
@will_update = true
|
25
29
|
@json = url
|
26
30
|
end
|
@@ -30,7 +34,6 @@ module NotionRubyMapping
|
|
30
34
|
## Common methods
|
31
35
|
|
32
36
|
# @param [String] name Property name
|
33
|
-
# @param [String] url url value (optional)
|
34
37
|
def initialize(name, will_update: false, base_type: :page, json: nil)
|
35
38
|
super name, will_update: will_update, base_type: base_type
|
36
39
|
@json = json || (database? ? {} : nil)
|
data/lib/notion_ruby_mapping.rb
CHANGED
@@ -2,11 +2,25 @@
|
|
2
2
|
|
3
3
|
require "yaml"
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
require_relative "notion_ruby_mapping/version"
|
6
|
+
{
|
7
|
+
blocks: %w[base block database list page url_caption_base_block bookmark_block breadcrumb_block
|
8
|
+
text_sub_block_color_base_block bulleted_list_item_block callout_block child_base_block
|
9
|
+
child_database_block child_page_block code_block column_list_block column_block divider_block
|
10
|
+
embed_block equation_block file_base_block file_block heading1_block heading2_block heading3_block
|
11
|
+
image_block toggle_heading1_block toggle_heading2_block toggle_heading3_block url_base_block
|
12
|
+
link_preview_block link_to_page_block numbered_list_item_block paragraph_block pdf_block quote_block
|
13
|
+
synced_block table_block table_row_block table_of_contents_block template_block to_do_block
|
14
|
+
toggle_block video_block],
|
15
|
+
controllers: %w[notion_cache payload property_cache query rich_text_array],
|
16
|
+
objects: %w[rich_text_object emoji_object equation_object file_object mention_object text_object user_object],
|
17
|
+
properties: %w[property checkbox_property multi_property created_by_property date_base_property created_time_property
|
18
|
+
date_property email_property files_property formula_property last_edited_by_property
|
19
|
+
last_edited_time_property multi_select_property number_property people_property phone_number_property
|
20
|
+
relation_property text_property rich_text_property rollup_property select_property title_property
|
21
|
+
url_property],
|
22
|
+
}.each do |key, values|
|
23
|
+
values.each do |klass|
|
24
|
+
require_relative "notion_ruby_mapping/#{key}/#{klass}"
|
25
|
+
end
|
12
26
|
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.
|
4
|
+
version: 0.5.0
|
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-
|
11
|
+
date: 2022-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -148,43 +148,85 @@ files:
|
|
148
148
|
- images/pre_set_icon.png
|
149
149
|
- images/serial_number.png
|
150
150
|
- lib/notion_ruby_mapping.rb
|
151
|
-
- lib/notion_ruby_mapping/base.rb
|
152
|
-
- lib/notion_ruby_mapping/block.rb
|
153
|
-
- lib/notion_ruby_mapping/
|
154
|
-
- lib/notion_ruby_mapping/
|
155
|
-
- lib/notion_ruby_mapping/
|
156
|
-
- lib/notion_ruby_mapping/
|
157
|
-
- lib/notion_ruby_mapping/
|
158
|
-
- lib/notion_ruby_mapping/
|
159
|
-
- lib/notion_ruby_mapping/
|
160
|
-
- lib/notion_ruby_mapping/
|
161
|
-
- lib/notion_ruby_mapping/
|
162
|
-
- lib/notion_ruby_mapping/
|
163
|
-
- lib/notion_ruby_mapping/
|
164
|
-
- lib/notion_ruby_mapping/
|
165
|
-
- lib/notion_ruby_mapping/
|
166
|
-
- lib/notion_ruby_mapping/
|
167
|
-
- lib/notion_ruby_mapping/
|
168
|
-
- lib/notion_ruby_mapping/
|
169
|
-
- lib/notion_ruby_mapping/
|
170
|
-
- lib/notion_ruby_mapping/
|
171
|
-
- lib/notion_ruby_mapping/
|
172
|
-
- lib/notion_ruby_mapping/
|
173
|
-
- lib/notion_ruby_mapping/
|
174
|
-
- lib/notion_ruby_mapping/
|
175
|
-
- lib/notion_ruby_mapping/
|
176
|
-
- lib/notion_ruby_mapping/
|
177
|
-
- lib/notion_ruby_mapping/
|
178
|
-
- lib/notion_ruby_mapping/
|
179
|
-
- lib/notion_ruby_mapping/
|
180
|
-
- lib/notion_ruby_mapping/
|
181
|
-
- lib/notion_ruby_mapping/
|
182
|
-
- lib/notion_ruby_mapping/
|
183
|
-
- lib/notion_ruby_mapping/
|
184
|
-
- lib/notion_ruby_mapping/
|
185
|
-
- lib/notion_ruby_mapping/
|
186
|
-
- lib/notion_ruby_mapping/
|
187
|
-
- lib/notion_ruby_mapping/
|
151
|
+
- lib/notion_ruby_mapping/blocks/base.rb
|
152
|
+
- lib/notion_ruby_mapping/blocks/block.rb
|
153
|
+
- lib/notion_ruby_mapping/blocks/bookmark_block.rb
|
154
|
+
- lib/notion_ruby_mapping/blocks/breadcrumb_block.rb
|
155
|
+
- lib/notion_ruby_mapping/blocks/bulleted_list_item_block.rb
|
156
|
+
- lib/notion_ruby_mapping/blocks/callout_block.rb
|
157
|
+
- lib/notion_ruby_mapping/blocks/child_base_block.rb
|
158
|
+
- lib/notion_ruby_mapping/blocks/child_database_block.rb
|
159
|
+
- lib/notion_ruby_mapping/blocks/child_page_block.rb
|
160
|
+
- lib/notion_ruby_mapping/blocks/code_block.rb
|
161
|
+
- lib/notion_ruby_mapping/blocks/column_block.rb
|
162
|
+
- lib/notion_ruby_mapping/blocks/column_list_block.rb
|
163
|
+
- lib/notion_ruby_mapping/blocks/database.rb
|
164
|
+
- lib/notion_ruby_mapping/blocks/divider_block.rb
|
165
|
+
- lib/notion_ruby_mapping/blocks/embed_block.rb
|
166
|
+
- lib/notion_ruby_mapping/blocks/equation_block.rb
|
167
|
+
- lib/notion_ruby_mapping/blocks/file_base_block.rb
|
168
|
+
- lib/notion_ruby_mapping/blocks/file_block.rb
|
169
|
+
- lib/notion_ruby_mapping/blocks/heading1_block.rb
|
170
|
+
- lib/notion_ruby_mapping/blocks/heading2_block.rb
|
171
|
+
- lib/notion_ruby_mapping/blocks/heading3_block.rb
|
172
|
+
- lib/notion_ruby_mapping/blocks/image_block.rb
|
173
|
+
- lib/notion_ruby_mapping/blocks/link_preview_block.rb
|
174
|
+
- lib/notion_ruby_mapping/blocks/link_to_page_block.rb
|
175
|
+
- lib/notion_ruby_mapping/blocks/list.rb
|
176
|
+
- lib/notion_ruby_mapping/blocks/numbered_list_item_block.rb
|
177
|
+
- lib/notion_ruby_mapping/blocks/page.rb
|
178
|
+
- lib/notion_ruby_mapping/blocks/paragraph_block.rb
|
179
|
+
- lib/notion_ruby_mapping/blocks/pdf_block.rb
|
180
|
+
- lib/notion_ruby_mapping/blocks/quote_block.rb
|
181
|
+
- lib/notion_ruby_mapping/blocks/synced_block.rb
|
182
|
+
- lib/notion_ruby_mapping/blocks/table_block.rb
|
183
|
+
- lib/notion_ruby_mapping/blocks/table_of_contents_block.rb
|
184
|
+
- lib/notion_ruby_mapping/blocks/table_row_block.rb
|
185
|
+
- lib/notion_ruby_mapping/blocks/template_block.rb
|
186
|
+
- lib/notion_ruby_mapping/blocks/text_sub_block_color_base_block.rb
|
187
|
+
- lib/notion_ruby_mapping/blocks/to_do_block.rb
|
188
|
+
- lib/notion_ruby_mapping/blocks/toggle_block.rb
|
189
|
+
- lib/notion_ruby_mapping/blocks/toggle_heading1_block.rb
|
190
|
+
- lib/notion_ruby_mapping/blocks/toggle_heading2_block.rb
|
191
|
+
- lib/notion_ruby_mapping/blocks/toggle_heading3_block.rb
|
192
|
+
- lib/notion_ruby_mapping/blocks/url_base_block.rb
|
193
|
+
- lib/notion_ruby_mapping/blocks/url_caption_base_block.rb
|
194
|
+
- lib/notion_ruby_mapping/blocks/video_block.rb
|
195
|
+
- lib/notion_ruby_mapping/controllers/notion_cache.rb
|
196
|
+
- lib/notion_ruby_mapping/controllers/payload.rb
|
197
|
+
- lib/notion_ruby_mapping/controllers/property_cache.rb
|
198
|
+
- lib/notion_ruby_mapping/controllers/query.rb
|
199
|
+
- lib/notion_ruby_mapping/controllers/rich_text_array.rb
|
200
|
+
- lib/notion_ruby_mapping/objects/emoji_object.rb
|
201
|
+
- lib/notion_ruby_mapping/objects/equation_object.rb
|
202
|
+
- lib/notion_ruby_mapping/objects/file_object.rb
|
203
|
+
- lib/notion_ruby_mapping/objects/mention_object.rb
|
204
|
+
- lib/notion_ruby_mapping/objects/rich_text_object.rb
|
205
|
+
- lib/notion_ruby_mapping/objects/text_object.rb
|
206
|
+
- lib/notion_ruby_mapping/objects/user_object.rb
|
207
|
+
- lib/notion_ruby_mapping/properties/checkbox_property.rb
|
208
|
+
- lib/notion_ruby_mapping/properties/created_by_property.rb
|
209
|
+
- lib/notion_ruby_mapping/properties/created_time_property.rb
|
210
|
+
- lib/notion_ruby_mapping/properties/date_base_property.rb
|
211
|
+
- lib/notion_ruby_mapping/properties/date_property.rb
|
212
|
+
- lib/notion_ruby_mapping/properties/email_property.rb
|
213
|
+
- lib/notion_ruby_mapping/properties/files_property.rb
|
214
|
+
- lib/notion_ruby_mapping/properties/formula_property.rb
|
215
|
+
- lib/notion_ruby_mapping/properties/last_edited_by_property.rb
|
216
|
+
- lib/notion_ruby_mapping/properties/last_edited_time_property.rb
|
217
|
+
- lib/notion_ruby_mapping/properties/multi_property.rb
|
218
|
+
- lib/notion_ruby_mapping/properties/multi_select_property.rb
|
219
|
+
- lib/notion_ruby_mapping/properties/number_property.rb
|
220
|
+
- lib/notion_ruby_mapping/properties/people_property.rb
|
221
|
+
- lib/notion_ruby_mapping/properties/phone_number_property.rb
|
222
|
+
- lib/notion_ruby_mapping/properties/property.rb
|
223
|
+
- lib/notion_ruby_mapping/properties/relation_property.rb
|
224
|
+
- lib/notion_ruby_mapping/properties/rich_text_property.rb
|
225
|
+
- lib/notion_ruby_mapping/properties/rollup_property.rb
|
226
|
+
- lib/notion_ruby_mapping/properties/select_property.rb
|
227
|
+
- lib/notion_ruby_mapping/properties/text_property.rb
|
228
|
+
- lib/notion_ruby_mapping/properties/title_property.rb
|
229
|
+
- lib/notion_ruby_mapping/properties/url_property.rb
|
188
230
|
- lib/notion_ruby_mapping/version.rb
|
189
231
|
- notion_ruby_mapping.gemspec
|
190
232
|
- sig/notion_ruby_mapping.rbs
|
@@ -208,7 +250,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
208
250
|
- !ruby/object:Gem::Version
|
209
251
|
version: '0'
|
210
252
|
requirements: []
|
211
|
-
rubygems_version: 3.3.
|
253
|
+
rubygems_version: 3.3.7
|
212
254
|
signing_key:
|
213
255
|
specification_version: 4
|
214
256
|
summary: Notion Ruby mapping tool
|
@@ -1,75 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "date"
|
4
|
-
|
5
|
-
module NotionRubyMapping
|
6
|
-
# Date base property (date, created_time, last_edited_time, formula)
|
7
|
-
class DateBaseProperty < Property
|
8
|
-
include IsEmptyIsNotEmpty
|
9
|
-
|
10
|
-
def filter_equals(date, rollup = nil, rollup_type = nil)
|
11
|
-
make_filter_query "equals", value_str(date), rollup, rollup_type
|
12
|
-
end
|
13
|
-
|
14
|
-
def filter_does_not_equal(date, rollup = nil, rollup_type = nil)
|
15
|
-
make_filter_query "does_not_equal", value_str(date), rollup, rollup_type
|
16
|
-
end
|
17
|
-
|
18
|
-
def filter_before(date, rollup = nil, rollup_type = nil)
|
19
|
-
make_filter_query "before", value_str(date), rollup, rollup_type
|
20
|
-
end
|
21
|
-
|
22
|
-
def filter_after(date, rollup = nil, rollup_type = nil)
|
23
|
-
make_filter_query "after", value_str(date), rollup, rollup_type
|
24
|
-
end
|
25
|
-
|
26
|
-
def filter_on_or_before(date, rollup = nil, rollup_type = nil)
|
27
|
-
make_filter_query "on_or_before", value_str(date), rollup, rollup_type
|
28
|
-
end
|
29
|
-
|
30
|
-
def filter_on_or_after(date, rollup = nil, rollup_type = nil)
|
31
|
-
make_filter_query "on_or_after", value_str(date), rollup, rollup_type
|
32
|
-
end
|
33
|
-
|
34
|
-
def filter_past_week(rollup = nil, rollup_type = nil)
|
35
|
-
make_filter_query "past_week", {}, rollup, rollup_type
|
36
|
-
end
|
37
|
-
|
38
|
-
def filter_past_month(rollup = nil, rollup_type = nil)
|
39
|
-
make_filter_query "past_month", {}, rollup, rollup_type
|
40
|
-
end
|
41
|
-
|
42
|
-
def filter_past_year(rollup = nil, rollup_type = nil)
|
43
|
-
make_filter_query "past_year", {}, rollup, rollup_type
|
44
|
-
end
|
45
|
-
|
46
|
-
def filter_next_week(rollup = nil, rollup_type = nil)
|
47
|
-
make_filter_query "next_week", {}, rollup, rollup_type
|
48
|
-
end
|
49
|
-
|
50
|
-
def filter_next_month(rollup = nil, rollup_type = nil)
|
51
|
-
make_filter_query "next_month", {}, rollup, rollup_type
|
52
|
-
end
|
53
|
-
|
54
|
-
def filter_next_year(rollup = nil, rollup_type = nil)
|
55
|
-
make_filter_query "next_year", {}, rollup, rollup_type
|
56
|
-
end
|
57
|
-
|
58
|
-
protected
|
59
|
-
|
60
|
-
# @param [Date, Time, DateTime, String, nil] obj
|
61
|
-
# @return [String] iso8601 format string
|
62
|
-
def value_str(obj)
|
63
|
-
case obj
|
64
|
-
when Date
|
65
|
-
obj.iso8601
|
66
|
-
when Time
|
67
|
-
obj.strftime("%Y-%m-%dT%H:%M:%S%:z")
|
68
|
-
when DateTime
|
69
|
-
obj.iso8601
|
70
|
-
else
|
71
|
-
obj
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|