notion_ruby_mapping 0.6.0 → 0.6.1
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/lib/notion_ruby_mapping/version.rb +1 -1
- data/tools/createErDiagram.rb +46 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d2f6819154bd2ae6fb448cd36d06311d20e6ba29a0e2e4fda6584d49ca58732
|
4
|
+
data.tar.gz: 042e30bda77b5c21a3226a37579254e52eb19d537abaa94a5233238846ba6a76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69419656c3c728d5472aade37de759a2a9b58124cd6856df7ecfa9b0838f5755af84f80a9936434a82991a7418a9f33de6188c87b20afff32573565c64ea5099
|
7
|
+
data.tar.gz: '093e56922c2f2aef5b6efd45043472e165b8bc3d04cce3613b9d1f363d779adca495982c818091e067dc9413107afbd26371ba73676d4def61b8abc1e1ea83b8'
|
@@ -0,0 +1,46 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
require "notion_ruby_mapping"
|
4
|
+
include NotionRubyMapping
|
5
|
+
|
6
|
+
def append_database(text, db)
|
7
|
+
text << "#{db_title db} {"
|
8
|
+
db.properties.reject { |p| p.is_a? RelationProperty }.each_with_index do |p, i|
|
9
|
+
class_name = p.class.name.split("::").last.sub /Property/, ""
|
10
|
+
text << %Q[ #{class_name} p#{i} "#{p.name}"]
|
11
|
+
end
|
12
|
+
text << "}\n"
|
13
|
+
end
|
14
|
+
|
15
|
+
def db_title(db)
|
16
|
+
db.database_title.full_text.gsub " ", "_"
|
17
|
+
end
|
18
|
+
|
19
|
+
if ARGV.length < 2
|
20
|
+
print "Usage: createErDiagram.rb top_database_id code_block_id"
|
21
|
+
exit
|
22
|
+
end
|
23
|
+
database_id, code_block_id = ARGV
|
24
|
+
NotionCache.instance.create_client ENV["NOTION_API_KEY"]
|
25
|
+
block = Block.find code_block_id
|
26
|
+
unless block.is_a? CodeBlock
|
27
|
+
print "#{code_block_id} is not CodeBlock's id"
|
28
|
+
end
|
29
|
+
dbs = [Database.find(database_id)]
|
30
|
+
text = %w[erDiagram]
|
31
|
+
|
32
|
+
finished = {}
|
33
|
+
until dbs.empty?
|
34
|
+
db = dbs.shift
|
35
|
+
finished[db] = true
|
36
|
+
append_database(text, db)
|
37
|
+
db.properties.select { |p| p.is_a? RelationProperty }.each_with_index do |p, i|
|
38
|
+
new_db = Database.find p.relation_database_id
|
39
|
+
text << "#{db_title db} ||--o{ #{db_title new_db} : r#{i}"
|
40
|
+
dbs << new_db unless finished[new_db]
|
41
|
+
end
|
42
|
+
text << ""
|
43
|
+
end
|
44
|
+
block.rich_text_array.rich_text_objects = text.join("\n ")
|
45
|
+
block.language = "mermaid"
|
46
|
+
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.1
|
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-07-
|
11
|
+
date: 2022-07-28 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
|
- notion_ruby_mapping.gemspec
|
232
232
|
- sig/notion_ruby_mapping.rbs
|
233
233
|
- tools/an
|
234
|
+
- tools/createErDiagram.rb
|
234
235
|
homepage: https://github.com/hkob/notion_ruby_mapping.git
|
235
236
|
licenses:
|
236
237
|
- MIT
|