notion_rb 0.1.1 → 0.1.2
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/Gemfile.lock +2 -2
- data/README.md +3 -1
- data/lib/notion_rb/block.rb +22 -6
- data/lib/notion_rb/version.rb +1 -1
- 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: 1ab0eb041c68351cf2c9a9749b78f01cfe13f7d1aae3b11aa452ba95f468c764
|
4
|
+
data.tar.gz: 37ff8830acab646cb9d970846ea6fa2c388d75bacbcdcb684938536ead57a43b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2738bba8027e7f7e6b741ae67a5771c67d8c27678e5b3e8460da8d6679128d03109f748fb7e2065b091de213f076ee0fdeb0312e6de2421e491172f457f5002
|
7
|
+
data.tar.gz: 36444104173a52ff3877d92288613bc0380f3fd5e281e87c436ab6a17bb97ee7fbd7d2d038a8cf60e94800d26e481f82d2ba5394a97e50de7e10b4377dbe15cc
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
notion_rb (0.1.
|
4
|
+
notion_rb (0.1.2)
|
5
5
|
mechanize
|
6
6
|
|
7
7
|
GEM
|
@@ -41,7 +41,7 @@ GEM
|
|
41
41
|
nokogiri (~> 1.6)
|
42
42
|
ntlm-http (~> 0.1, >= 0.1.1)
|
43
43
|
webrobots (>= 0.0.9, < 0.2)
|
44
|
-
mime-types (3.3)
|
44
|
+
mime-types (3.3.1)
|
45
45
|
mime-types-data (~> 3.2015)
|
46
46
|
mime-types-data (3.2019.1009)
|
47
47
|
mini_portile2 (2.4.0)
|
data/README.md
CHANGED
@@ -26,7 +26,9 @@ Or install it yourself as:
|
|
26
26
|
|
27
27
|
```ruby
|
28
28
|
# Obtain the `token_v2` value by inspecting your browser cookies on a logged-in session on Notion.so
|
29
|
-
|
29
|
+
NotionRb.configure do |config|
|
30
|
+
config[:token_v2] = '<some token>'
|
31
|
+
end
|
30
32
|
|
31
33
|
# Get the block
|
32
34
|
block = NotionRb::Block.new('https://www.notion.so/some_org/some-title-30d7f6e4c2284cbab860a6f40ed3372e')
|
data/lib/notion_rb/block.rb
CHANGED
@@ -34,8 +34,7 @@ module NotionRb
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def metadata
|
37
|
-
|
38
|
-
add_parent_metadata(metadata)
|
37
|
+
@block[:metadata].except(:properties)
|
39
38
|
end
|
40
39
|
|
41
40
|
def parent
|
@@ -83,15 +82,32 @@ module NotionRb
|
|
83
82
|
NotionRb::Api::Update.new(notion_id: @uuid, title: @block[:title], block_type: @block[:block_type]).success?
|
84
83
|
end
|
85
84
|
|
86
|
-
def
|
87
|
-
|
85
|
+
def method_missing(method, *args, &block)
|
86
|
+
if schema_methods.include?(method)
|
87
|
+
send_schema_method(method)
|
88
|
+
else
|
89
|
+
super
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def respond_to_missing?(method_name, *args)
|
94
|
+
schema_methods.include?(method_name) || super
|
95
|
+
end
|
88
96
|
|
97
|
+
def schema_methods
|
98
|
+
return [] unless parent.type == 'collection'
|
99
|
+
|
100
|
+
parent.metadata[:schema].values.map { |value| value['name'].tableize.to_sym }
|
101
|
+
end
|
102
|
+
|
103
|
+
def send_schema_method(method)
|
89
104
|
parent_schema = parent.metadata[:schema]
|
90
105
|
@block.dig(:metadata, :properties).each do |key, value|
|
91
106
|
schema = parent_schema[key]
|
92
|
-
|
107
|
+
next unless schema['name'].tableize.to_sym == method
|
108
|
+
|
109
|
+
return value[0][0]
|
93
110
|
end
|
94
|
-
metadata
|
95
111
|
end
|
96
112
|
end
|
97
113
|
end
|
data/lib/notion_rb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: notion_rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Gunther
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mechanize
|