notion_rails 0.2.0 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 95a025ff228890fafa2fd982d108512fa0980fbae091232c6fbfac6ae85667b8
4
- data.tar.gz: 8bc99ae3b897b5116ed5e4fe91847a8160db7436490f76360d637c10128df487
3
+ metadata.gz: 3eca01ee926a98e214454e4329988d1e383fafbd21a9b77fc3bbcbcb907e66c5
4
+ data.tar.gz: c900f19f3f6c0e8eac48b1890347a8b7305b688a7e77e754c3a7e5a603e45117
5
5
  SHA512:
6
- metadata.gz: bdd4412954a606cccf29b805a4db0c9f4ffcec32b9d1baf64feb7a7724fe48a2a72974e1e5650254bc86d0b5eb467961492c5e49284d1d3f9f7a62f31d072b0a
7
- data.tar.gz: 426dee990473e7a39722e81e32f282cd3f3909156884e2a9dd46f64fff0ef4893a235ab8eff6921621603c445a6117932116961d370c423cb393fc88a145c171
6
+ metadata.gz: 93b528ac174dbf02dc3ff4ae6ac8a56aaa2ab4b58e38657ff4832bd47700c4e59ca3da0b98a0c33dd1e01f05c674d018d50b77489831bef9c4c9882df334f665
7
+ data.tar.gz: 0d7f23fe9ebaecaed6bb83381d899332459123a3ae07f10ffc6cd2c4dab98b00dde236a330617ce8f23203e54bf81822faa48a2bc7d1c5ced987ac456923238a
@@ -52,7 +52,7 @@ module NotionRails
52
52
 
53
53
  def get_article(id)
54
54
  base_page = NotionRails::BasePage.new(__get_page(id))
55
- base_blocks = NotionRails.config.cache_store.fetch(id) { get_blocks(id) }
55
+ base_blocks = get_blocks(id)
56
56
  NotionRails::Page.new(base_page, base_blocks)
57
57
  end
58
58
 
@@ -61,6 +61,7 @@ module NotionRails
61
61
  parent_list_block_index = nil
62
62
  results = []
63
63
  blocks['results'].each_with_index do |block, index|
64
+ block = refresh_block(block['id']) if refresh_image?(block)
64
65
  base_block = NotionRails::BaseBlock.new(block)
65
66
  base_block.children = get_blocks(base_block.id) if base_block.has_children
66
67
  # Notion returns same list items as different blocks so we have to do some processing to have them be related
@@ -86,6 +87,14 @@ module NotionRails
86
87
  results
87
88
  end
88
89
 
90
+ def refresh_image?(data)
91
+ return false unless data['type'] == 'image'
92
+ return false unless data.dig('image', 'type') == 'file'
93
+
94
+ expiry_time = data.dig('image', 'file', 'expiry_time')
95
+ expiry_time.to_datetime.past?
96
+ end
97
+
89
98
  private
90
99
 
91
100
  def __get_articles(tag: nil, slug: nil, page_size: 10)
@@ -106,7 +115,15 @@ module NotionRails
106
115
  end
107
116
 
108
117
  def __get_blocks(id)
109
- @client.block_children(block_id: id)
118
+ NotionRails.config.cache_store.fetch(id) { @client.block_children(block_id: id) }
119
+ end
120
+
121
+ def __get_block(id)
122
+ @client.block(block_id: id)
123
+ end
124
+
125
+ def refresh_block(id)
126
+ __get_block(id)
110
127
  end
111
128
  end
112
129
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NotionRails
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.2'
5
5
  end
data/lib/notion_rails.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'active_support/all'
3
4
  require 'notion_rails/renderers'
4
5
  require 'notion_rails/base_block'
5
6
  require 'notion_rails/base_page'
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notion_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guillermo Aguirre
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-18 00:00:00.000000000 Z
11
+ date: 2024-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 7.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 7.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 7.0.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 7.0.0
41
41
  - !ruby/object:Gem::Dependency