notion_ruby_mapping 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/lib/notion_ruby_mapping/version.rb +1 -1
- data/tools/createErDiagram.rb +19 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b295b0ba6b110a2f9e2f559e251490005a446abd71d2b7cc67903f9b0e2e504a
|
4
|
+
data.tar.gz: 8b6d1ed3f4c53973c8391981cef7044628ba22894dd42f8b23364f9a995326d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d3e718b49fceea38ee34be30161496d9023158631b24a633408af4b9eb5f5507ae85484c74a4f0094a7e1d8aaa47c851cc2d47af128e45814d98a5c1f5a21f4
|
7
|
+
data.tar.gz: 95b5374a44768b1454d550abcad6343c06d24333d787045d5317ba91ef0a1f0a1ddb273879ca28e928e2808180b7acbd144a4e8f19c52cb7208d565083d19906
|
data/README.md
CHANGED
@@ -83,6 +83,11 @@ NotionCache.instance.create_client ENV["NOTION_API_TOKEN"] # from environment
|
|
83
83
|
1. [Set icon to all icon unsettled pages](examples/set_icon_to_all_icon_unsettled_pages.md)
|
84
84
|
1. [Renumbering pages](examples/renumbering_pages.md)
|
85
85
|
1. [Change title](examples/change_title.md)
|
86
|
+
1. [Create erDiagram from Notion database](tools/createErDiagram.rb)
|
87
|
+
```shell
|
88
|
+
Usage:
|
89
|
+
ruby tools/createErDiagram.rb database_id code_block_id
|
90
|
+
```
|
86
91
|
|
87
92
|
### 2.5 API reference
|
88
93
|
|
@@ -90,6 +95,9 @@ NotionCache.instance.create_client ENV["NOTION_API_TOKEN"] # from environment
|
|
90
95
|
|
91
96
|
## 3. ChangeLog
|
92
97
|
|
98
|
+
- 2022/8/9 [v0.6.3] update createErDiagram.rb (Fixed a bug with non-ASCII database titles)
|
99
|
+
- 2022/8/7 [v0.6.2] add comment_object support
|
100
|
+
- 2022/7/28 [v0.6.1] added createErDiagram.rb
|
93
101
|
- 2022/7/22 [v0.6.0] updates for Notion-Version 2022-06-28 (lazy retrieve property values, retrieve page/database/block parent, single_property/dual_property for RelationProperty)
|
94
102
|
- 2022/6/24 [v0.5.5] add file_names= to FileProperty
|
95
103
|
- 2022/6/23 [v0.5.4] add update 'is_inline' and 'description' for database object
|
data/tools/createErDiagram.rb
CHANGED
@@ -3,15 +3,23 @@
|
|
3
3
|
require "notion_ruby_mapping"
|
4
4
|
include NotionRubyMapping
|
5
5
|
|
6
|
-
def append_database(text, db)
|
7
|
-
|
6
|
+
def append_database(text, db, db_titles)
|
7
|
+
base_title = db_title db
|
8
|
+
normalize_db_title(db, db_titles) if db_titles[db].nil?
|
9
|
+
text << "#{db_titles[db]} {"
|
10
|
+
text << %( Database title "#{base_title}") unless base_title == db_titles[db]
|
8
11
|
db.properties.reject { |p| p.is_a? RelationProperty }.each_with_index do |p, i|
|
9
12
|
class_name = p.class.name.split("::").last.sub /Property/, ""
|
10
|
-
text << %
|
13
|
+
text << %( #{class_name} p#{i} "#{p.name}")
|
11
14
|
end
|
12
15
|
text << "}\n"
|
13
16
|
end
|
14
17
|
|
18
|
+
def normalize_db_title(db, db_titles)
|
19
|
+
base_title = db_title db
|
20
|
+
db_titles[db] = base_title.gsub(/[\w\d\-_]+/, "").empty? ? base_title : "d#{db_titles.count}"
|
21
|
+
end
|
22
|
+
|
15
23
|
def db_title(db)
|
16
24
|
db.database_title.full_text.gsub " ", "_"
|
17
25
|
end
|
@@ -25,22 +33,25 @@ NotionCache.instance.create_client ENV["NOTION_API_KEY"]
|
|
25
33
|
block = Block.find code_block_id
|
26
34
|
unless block.is_a? CodeBlock
|
27
35
|
print "#{code_block_id} is not CodeBlock's id"
|
36
|
+
exit
|
28
37
|
end
|
29
38
|
dbs = [Database.find(database_id)]
|
30
39
|
text = %w[erDiagram]
|
31
40
|
|
32
41
|
finished = {}
|
42
|
+
db_titles = {}
|
33
43
|
until dbs.empty?
|
34
44
|
db = dbs.shift
|
35
45
|
finished[db] = true
|
36
|
-
append_database(text, db)
|
37
|
-
db.properties.select { |
|
38
|
-
new_db = Database.find
|
39
|
-
|
46
|
+
append_database(text, db, db_titles)
|
47
|
+
db.properties.select { |pp| pp.is_a? RelationProperty }.each_with_index do |pp, i|
|
48
|
+
new_db = Database.find pp.relation_database_id
|
49
|
+
normalize_db_title(new_db, db_titles) if db_titles[new_db].nil?
|
50
|
+
text << "#{db_titles[db]} |o--o{ #{db_titles[new_db]} : r#{i}"
|
40
51
|
dbs << new_db unless finished[new_db]
|
41
52
|
end
|
42
53
|
text << ""
|
43
54
|
end
|
44
55
|
block.rich_text_array.rich_text_objects = text.join("\n ")
|
45
56
|
block.language = "mermaid"
|
46
|
-
block.save
|
57
|
+
block.save
|
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.6.
|
4
|
+
version: 0.6.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-08-
|
11
|
+
date: 2022-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|