notion_ruby_mapping 0.8.1 → 0.8.3
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 +1 -0
- data/lib/notion_ruby_mapping/blocks/base.rb +4 -2
- data/lib/notion_ruby_mapping/blocks/block.rb +7 -0
- data/lib/notion_ruby_mapping/blocks/page.rb +11 -0
- data/lib/notion_ruby_mapping/properties/button_property.rb +33 -0
- data/lib/notion_ruby_mapping/properties/property.rb +1 -0
- data/lib/notion_ruby_mapping/version.rb +1 -1
- data/lib/notion_ruby_mapping.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88063ea97ad5859285370907bf40121b34718e0acae70f88b564fb35f646b416
|
4
|
+
data.tar.gz: 163da74c41fe90ac6209ffe80262ebcac6f8e54f0ebcba14739d3e6fd1feb6dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e49c0bf7bcff56d1657cc2668d407fcd3e79724526c46ab58f0845fbf5d18322eec830801eec5e6f06c3a6b9c489f7f2f9bff237331b9cbbc94698ef9af93a6
|
7
|
+
data.tar.gz: 4b1e62e1a61ac2cd7274a2cd8abb4aaa1f331fe8cd3e624031ba428ce8d619926dbae6806d20d30648301212ad44d21b7d0d737a055238575d873ece9d2cd6aa
|
data/README.md
CHANGED
@@ -127,6 +127,7 @@ NotionRubyMapping.configuration { |c| c.notion_token = ENV["NOTION_API_TOKEN"] }
|
|
127
127
|
|
128
128
|
## 3. ChangeLog
|
129
129
|
|
130
|
+
- 2023/7/13 [v0.8.2] add 'after' option to append_block_chidren, 'append_after' method to block, and 'public_url' method to page
|
130
131
|
- 2023/7/10 [v0.8.1] Automatically change type to external when file object is updated
|
131
132
|
- 2023/6/4 [v0.8.0] add unique_id properties, filter_properties
|
132
133
|
- 2023/4/14 [v0.7.7] add token= method for Notion API book typo
|
@@ -94,7 +94,7 @@ module NotionRubyMapping
|
|
94
94
|
json: @nc.retrieve_comments_request(@id, query),
|
95
95
|
query: query).each do |comment|
|
96
96
|
dt_id = comment.discussion_id
|
97
|
-
dt = ans[dt_id] ||= DiscussionThread.new
|
97
|
+
dt = ans[dt_id] ||= DiscussionThread.new(dt_id)
|
98
98
|
dt.comments << comment
|
99
99
|
end
|
100
100
|
ans
|
@@ -118,11 +118,12 @@ module NotionRubyMapping
|
|
118
118
|
end
|
119
119
|
|
120
120
|
# @param [Array<Block>] blocks
|
121
|
+
# @param [String, nil] after block id of previous block
|
121
122
|
# @param [Boolean] dry_run true if dry_run
|
122
123
|
# @return [NotionRubyMapping::Block, String]
|
123
124
|
# @see https://www.notion.so/hkob/Page-d359650e3ca94424af8359a24147b9a0#44bbf83d852c419485c5efe9fe1558fb
|
124
125
|
# @see https://www.notion.so/hkob/Block-689ad4cbff50404d8a1baf67b6d6d78d#2c47f7fedae543cf8566389ba1677132
|
125
|
-
def append_block_children(*blocks, dry_run: false)
|
126
|
+
def append_block_children(*blocks, after: nil, dry_run: false)
|
126
127
|
raise StandardError, "This block can have no children." unless page? || (block? && can_have_children)
|
127
128
|
|
128
129
|
only_one = blocks.length == 1
|
@@ -132,6 +133,7 @@ module NotionRubyMapping
|
|
132
133
|
block.block_json
|
133
134
|
end,
|
134
135
|
}
|
136
|
+
json["after"] = after if after
|
135
137
|
if dry_run
|
136
138
|
path = @nc.append_block_children_page_path(id)
|
137
139
|
self.class.dry_run_script :patch, path, json
|
@@ -76,6 +76,13 @@ module NotionRubyMapping
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
+
# @param [Boolean] dry_run true if dry_run
|
80
|
+
# @return [NotionRubyMapping::Block, String]
|
81
|
+
# @param [Array<Block>] blocks
|
82
|
+
def append_after(*blocks, dry_run: false)
|
83
|
+
parent.append_block_children *blocks, after: id, dry_run: dry_run
|
84
|
+
end
|
85
|
+
|
79
86
|
# @param [Boolean] not_update false when update
|
80
87
|
# @return [Hash{String (frozen)->Hash}]
|
81
88
|
def block_json(not_update: true)
|
@@ -59,6 +59,11 @@ module NotionRubyMapping
|
|
59
59
|
db.save dry_run: dry_run
|
60
60
|
end
|
61
61
|
|
62
|
+
# @return [String] 公開URL
|
63
|
+
def public_url
|
64
|
+
@json["public_url"]
|
65
|
+
end
|
66
|
+
|
62
67
|
# @return [String] title
|
63
68
|
# @see https://www.notion.so/hkob/Page-d359650e3ca94424af8359a24147b9a0#2ff7209055f346fbbda454cdbb40b1c8
|
64
69
|
def title
|
@@ -66,6 +71,11 @@ module NotionRubyMapping
|
|
66
71
|
tp.map(&:full_text).join ""
|
67
72
|
end
|
68
73
|
|
74
|
+
# @return [String] URL
|
75
|
+
def url
|
76
|
+
@json["url"]
|
77
|
+
end
|
78
|
+
|
69
79
|
protected
|
70
80
|
|
71
81
|
# @param [Boolean] dry_run true if dry_run
|
@@ -93,5 +103,6 @@ module NotionRubyMapping
|
|
93
103
|
update_json @nc.update_page_request(@id, property_values_json)
|
94
104
|
end
|
95
105
|
end
|
106
|
+
|
96
107
|
end
|
97
108
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module NotionRubyMapping
|
4
|
+
# Button property
|
5
|
+
class ButtonProperty < Property
|
6
|
+
TYPE = "button"
|
7
|
+
|
8
|
+
### Public announced methods
|
9
|
+
|
10
|
+
## Common methods
|
11
|
+
|
12
|
+
# @return [Boolean, Hash, nil]
|
13
|
+
def button
|
14
|
+
@json
|
15
|
+
end
|
16
|
+
|
17
|
+
# @param [String] name Property name
|
18
|
+
# @param [Boolean, Hash] json
|
19
|
+
def initialize(name, will_update: false, base_type: :page, property_id: nil, property_cache: nil, json: nil)
|
20
|
+
super name, will_update: will_update, base_type: base_type, property_id: property_id,
|
21
|
+
property_cache: property_cache
|
22
|
+
@json = json
|
23
|
+
end
|
24
|
+
|
25
|
+
## Page property only methods
|
26
|
+
|
27
|
+
# @return [Hash]
|
28
|
+
def property_values_json
|
29
|
+
assert_page_property __method__
|
30
|
+
{@name => {"button" => @json, "type" => "button"}}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/notion_ruby_mapping.rb
CHANGED
@@ -20,7 +20,7 @@ require_relative "notion_ruby_mapping/version"
|
|
20
20
|
date_property email_property files_property formula_property last_edited_by_property
|
21
21
|
last_edited_time_property multi_select_property number_property people_property phone_number_property
|
22
22
|
relation_property text_property rich_text_property rollup_property select_property status_property
|
23
|
-
title_property unique_id_property url_property],
|
23
|
+
title_property unique_id_property url_property button_property],
|
24
24
|
}.each do |key, values|
|
25
25
|
values.each do |klass|
|
26
26
|
require_relative "notion_ruby_mapping/#{key}/#{klass}"
|
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.8.
|
4
|
+
version: 0.8.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:
|
11
|
+
date: 2024-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -231,6 +231,7 @@ files:
|
|
231
231
|
- lib/notion_ruby_mapping/objects/rich_text_object.rb
|
232
232
|
- lib/notion_ruby_mapping/objects/text_object.rb
|
233
233
|
- lib/notion_ruby_mapping/objects/user_object.rb
|
234
|
+
- lib/notion_ruby_mapping/properties/button_property.rb
|
234
235
|
- lib/notion_ruby_mapping/properties/checkbox_property.rb
|
235
236
|
- lib/notion_ruby_mapping/properties/created_by_property.rb
|
236
237
|
- lib/notion_ruby_mapping/properties/created_time_property.rb
|
@@ -279,7 +280,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
279
280
|
- !ruby/object:Gem::Version
|
280
281
|
version: '0'
|
281
282
|
requirements: []
|
282
|
-
rubygems_version: 3.
|
283
|
+
rubygems_version: 3.5.3
|
283
284
|
signing_key:
|
284
285
|
specification_version: 4
|
285
286
|
summary: Notion Ruby mapping tool
|