notion_ruby_mapping 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/.rubocop.yml +37 -0
  4. data/CHANGELOG.md +5 -0
  5. data/CODE_OF_CONDUCT.md +84 -0
  6. data/Gemfile +6 -0
  7. data/Guardfile +72 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +408 -0
  10. data/Rakefile +12 -0
  11. data/bin/console +15 -0
  12. data/bin/setup +8 -0
  13. data/lib/notion_ruby_mapping/base.rb +49 -0
  14. data/lib/notion_ruby_mapping/block.rb +10 -0
  15. data/lib/notion_ruby_mapping/checkbox_property.rb +9 -0
  16. data/lib/notion_ruby_mapping/created_by_property.rb +7 -0
  17. data/lib/notion_ruby_mapping/created_time_property.rb +7 -0
  18. data/lib/notion_ruby_mapping/database.rb +15 -0
  19. data/lib/notion_ruby_mapping/date_base_property.rb +73 -0
  20. data/lib/notion_ruby_mapping/date_property.rb +7 -0
  21. data/lib/notion_ruby_mapping/email_property.rb +7 -0
  22. data/lib/notion_ruby_mapping/files_property.rb +9 -0
  23. data/lib/notion_ruby_mapping/formula_property.rb +11 -0
  24. data/lib/notion_ruby_mapping/last_edited_by_property.rb +7 -0
  25. data/lib/notion_ruby_mapping/last_edited_time_property.rb +7 -0
  26. data/lib/notion_ruby_mapping/list.rb +16 -0
  27. data/lib/notion_ruby_mapping/multi_property.rb +9 -0
  28. data/lib/notion_ruby_mapping/multi_select_property.rb +8 -0
  29. data/lib/notion_ruby_mapping/notion_cache.rb +100 -0
  30. data/lib/notion_ruby_mapping/number_property.rb +11 -0
  31. data/lib/notion_ruby_mapping/page.rb +16 -0
  32. data/lib/notion_ruby_mapping/people_property.rb +7 -0
  33. data/lib/notion_ruby_mapping/phone_number_property.rb +7 -0
  34. data/lib/notion_ruby_mapping/property.rb +88 -0
  35. data/lib/notion_ruby_mapping/query.rb +50 -0
  36. data/lib/notion_ruby_mapping/relation_property.rb +8 -0
  37. data/lib/notion_ruby_mapping/rich_text_property.rb +7 -0
  38. data/lib/notion_ruby_mapping/select_property.rb +10 -0
  39. data/lib/notion_ruby_mapping/text_property.rb +11 -0
  40. data/lib/notion_ruby_mapping/title_property.rb +7 -0
  41. data/lib/notion_ruby_mapping/url_property.rb +7 -0
  42. data/lib/notion_ruby_mapping/version.rb +5 -0
  43. data/lib/notion_ruby_mapping.rb +9 -0
  44. data/notion_ruby_mapping.gemspec +47 -0
  45. data/sig/notion_ruby_mapping.rbs +4 -0
  46. metadata +171 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0262f773e54fec1b483554fb0d616706725ad422c10ce0830deeaf610ada1915
4
+ data.tar.gz: 554e4b2e4750f2b574fbfc73b77d23825a57ae92bc715fe1e977fcf56882efb8
5
+ SHA512:
6
+ metadata.gz: 504081f42de292dd7b462ed4565cfbc5c39ed6197c76d743081ffd847f5917328f5dbf63b50c1d7524f9fedc9457a12518a90422803996760256a4ac7f0aa549
7
+ data.tar.gz: cd069974312f74381d12605632e9782705c859e6f698fe76641f8917fbe259a758cdfac748dbde23888e8b6cdb0a472b32c68ccce9678598c6768f47a48b5a61
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,37 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
14
+
15
+ Layout/SpaceInsideHashLiteralBraces:
16
+ EnforcedStyle: no_space
17
+
18
+ Style/TrailingCommaInArguments:
19
+ EnforcedStyleForMultiline: comma
20
+
21
+ Style/TrailingCommaInArrayLiteral:
22
+ EnforcedStyleForMultiline: comma
23
+
24
+ Style/TrailingCommaInHashLiteral:
25
+ EnforcedStyleForMultiline: comma
26
+
27
+ Metrics/BlockLength:
28
+ Exclude:
29
+ - "Rakefile"
30
+ - "spec/**/*.rb"
31
+ - "Gemfile"
32
+ - "Guardfile"
33
+ - "*.gemspec"
34
+
35
+ Metrics/ModuleLength:
36
+ Exclude:
37
+ - "spec/**/*.rb"
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-02-07
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at hkob@metro-cit.ac.jp. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in notion_ruby_mapping.gemspec
6
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ # A sample Guardfile
4
+ # More info at https://github.com/guard/guard#readme
5
+
6
+ ## Uncomment and set this to only include directories you want to watch
7
+ # directories %w(app lib config test spec features) \
8
+ # .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
9
+
10
+ ## Note: if you are using the `directories` clause above and you are not
11
+ ## watching the project directory ('.'), then you will want to move
12
+ ## the Guardfile to a watched dir and symlink it back, e.g.
13
+ #
14
+ # $ mkdir config
15
+ # $ mv Guardfile config/
16
+ # $ ln -s config/Guardfile .
17
+ #
18
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
19
+
20
+ # NOTE: The cmd option is now required due to the increasing number of ways
21
+ # rspec may be run, below are examples of the most common uses.
22
+ # * bundler: 'bundle exec rspec'
23
+ # * bundler binstubs: 'bin/rspec'
24
+ # * spring: 'bin/rspec' (This will use spring if running and you have
25
+ # installed the spring binstubs per the docs)
26
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
27
+ # * 'just' rspec: 'rspec'
28
+
29
+ guard :rspec, cmd: "bundle exec rspec" do
30
+ require "guard/rspec/dsl"
31
+ dsl = Guard::RSpec::Dsl.new(self)
32
+
33
+ # Feel free to open issues for suggestions and improvements
34
+
35
+ # RSpec files
36
+ rspec = dsl.rspec
37
+ watch(rspec.spec_helper) { rspec.spec_dir }
38
+ watch(rspec.spec_support) { rspec.spec_dir }
39
+ watch(rspec.spec_files)
40
+
41
+ # Ruby files
42
+ ruby = dsl.ruby
43
+ dsl.watch_spec_files_for(ruby.lib_files)
44
+
45
+ # Rails files
46
+ rails = dsl.rails(view_extensions: %w[erb haml slim])
47
+ dsl.watch_spec_files_for(rails.app_files)
48
+ dsl.watch_spec_files_for(rails.views)
49
+
50
+ watch(rails.controllers) do |m|
51
+ [
52
+ rspec.spec.call("routing/#{m[1]}_routing"),
53
+ rspec.spec.call("controllers/#{m[1]}_controller"),
54
+ rspec.spec.call("acceptance/#{m[1]}"),
55
+ ]
56
+ end
57
+
58
+ # Rails config changes
59
+ watch(rails.spec_helper) { rspec.spec_dir }
60
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
61
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
62
+
63
+ # Capybara features specs
64
+ watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
65
+ watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
66
+
67
+ # Turnip features and steps
68
+ watch(%r{^spec/acceptance/(.+)\.feature$})
69
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
70
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
71
+ end
72
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Hiroyuki KOBAYASHI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,408 @@
1
+ # NotionRubyMapping
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/notion_ruby_mapping`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'notion_ruby_mapping'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install notion_ruby_mapping
22
+
23
+ ## Usage
24
+
25
+ ### Create a New Integration
26
+
27
+ Please check [Notion documentation](https://developers.notion.com/docs#getting-started).
28
+
29
+ ### Create client
30
+
31
+ ```Ruby
32
+ NotionCache.instance.create_client ENV["NOTION_API_TOKEN"]
33
+ ```
34
+ Please create a client (notion-ruby-client) before you use the following class.
35
+
36
+ ### Classes
37
+
38
+ #### Database class
39
+
40
+ - Retrieve a database
41
+ ```Ruby
42
+ db = Database.find("c37a2c66-e3aa-4a0d-a447-73de3b80c253")
43
+ ```
44
+ - Query a database
45
+
46
+ Gets a List object of Page objects contained in the database.
47
+ You can obtain filtered and ordered pages using Query object.
48
+ ```Ruby
49
+ Database.query("c37a2c66-e3aa-4a0d-a447-73de3b80c253") # retrieves all pages
50
+ Database.query("c37a2c66-e3aa-4a0d-a447-73de3b80c253", query) # retrieves using query
51
+ ```
52
+
53
+ #### Query class
54
+
55
+ Query object can be generated from the following Property objects.
56
+ For example, in order to obtain the pages whose title starts with "A" and ordered by ascending,
57
+ the following code can be used.
58
+ ```Ruby
59
+ tp = TitleProperty.new "Title"
60
+ query = tp.filter_starts_with("A").ascending(tp)
61
+ pages = Database.query database_id, query
62
+ ```
63
+
64
+ The following methods for the Property objects generate a query object.
65
+ - TitleProperty, RichTextProperty, UrlProperty, EmailProperty, PhoneNumberProperty
66
+ - filter_equals(value)
67
+ - filter_does_not_equal(value)
68
+ - filter_contains(value)
69
+ - filter_does_not_contain(value)
70
+ - filter_starts_with(value)
71
+ - filter_ends_with(value)
72
+ - filter_is_empty
73
+ - filter_is_not_empty
74
+ - NumberProperty
75
+ - filter_equals(value)
76
+ - filter_does_not_equal(value)
77
+ - filter_greater_than(value)
78
+ - filter_less_than(value)
79
+ - filter_greater_than_or_equal_to(value)
80
+ - filter_less_than_or_equal_to(value)
81
+ - filter_is_empty
82
+ - filter_is_not_empty
83
+ - CheckboxProperty
84
+ - filter_equals(value)
85
+ - filter_does_not_equal(value)
86
+ - SelectProperty
87
+ - filter_equals(value)
88
+ - filter_does_not_equal(value)
89
+ - filter_is_empty
90
+ - filter_is_not_empty
91
+ - MultiSelectProperty, PeopleProperty, CreatedByProperty, LastEditedByProperty
92
+ - filter_contains(value)
93
+ - filter_does_not_contain(value)
94
+ - filter_is_empty
95
+ - filter_is_not_empty
96
+ - DateProperty, CreatedTimeProperty, LastEditedTimeProperty
97
+ - filter_equals(value(Date / Time / DateTime / String))
98
+ - filter_does_not_equal(value(Date / Time / DateTime / String))
99
+ - filter_before(value(Date / Time / DateTime / String))
100
+ - filter_after(value(Date / Time / DateTime / String))
101
+ - filter_on_or_before(value(Date / Time / DateTime / String))
102
+ - filter_on_or_after(value(Date / Time / DateTime / String))
103
+ - filter_past_week
104
+ - filter_past_month
105
+ - filter_past_year
106
+ - filter_next_week
107
+ - filter_next_month
108
+ - filter_next_year
109
+ - FilesProperty
110
+ - filter_is_empty
111
+ - filter_is_not_empty
112
+ - FormulaProperty
113
+ - filter_equals(value(Date / Time / DateTime / String))
114
+ - filter_does_not_equal(value(Date / Time / DateTime / String))
115
+ - filter_before(value(Date / Time / DateTime / String))
116
+ - filter_after(value(Date / Time / DateTime / String))
117
+ - filter_on_or_before(value(Date / Time / DateTime / String))
118
+ - filter_on_or_after(value(Date / Time / DateTime / String))
119
+ - filter_past_week
120
+ - filter_past_month
121
+ - filter_past_year
122
+ - filter_next_week
123
+ - filter_next_month
124
+ - filter_next_year
125
+ - filter_contains(value)
126
+ - filter_does_not_contain(value)
127
+ - filter_starts_with(value)
128
+ - filter_ends_with(value)
129
+ - filter_greater_than(value)
130
+ - filter_less_than(value)
131
+ - filter_greater_than_or_equal_to(value)
132
+ - filter_less_than_or_equal_to(value)
133
+ - filter_is_empty
134
+ - filter_is_not_empty
135
+
136
+ Complex filters can be generated `and` / `or` methods.
137
+ ```Ruby
138
+ # Prepare sample properties
139
+ tp = TitleProperty.new "tp"
140
+ np = NumberProperty.new "np"
141
+ cp = CheckboxProperty.new "cp"
142
+ letp = LastEditedTimeProperty.new "letp"
143
+ ```
144
+
145
+ - (A and B) filter
146
+ ```Ruby
147
+ query1 = tp.filter_starts_with("start")
148
+ .and(np.filter_greater_than(100))
149
+
150
+ # Result of query1.filter
151
+ {
152
+ and: [
153
+ {
154
+ property: "tp",
155
+ title: {starts_with: "start"},
156
+ },
157
+ {
158
+ property: "np",
159
+ number: {greater_than: 100},
160
+ },
161
+ ],
162
+ }
163
+ ```
164
+
165
+ - (A and B and C) filter
166
+ ```Ruby
167
+ query2 = tp.filter_starts_with("start")
168
+ .and(np.filter_greater_than(100))
169
+ .and(cp.filter_equals(true))
170
+
171
+ # Result of query2.filter
172
+ {
173
+ and: [
174
+ {
175
+ property: "tp",
176
+ title: {starts_with: "start"},
177
+ },
178
+ {
179
+ property: "np",
180
+ number: {greater_than: 100},
181
+ },
182
+ {
183
+ property: "cp",
184
+ checkbox: {equals: true},
185
+ },
186
+ ],
187
+ }
188
+ ```
189
+
190
+ - (A or B) filter
191
+ ```Ruby
192
+ query3 = tp.filter_starts_with("start")
193
+ .or(np.filter_greater_than(100))
194
+
195
+ # Result of query3.filter
196
+ {
197
+ or: [
198
+ {
199
+ property: "tp",
200
+ title: {starts_with: "start"},
201
+ },
202
+ {
203
+ property: "np",
204
+ number: {greater_than: 100},
205
+ },
206
+ ],
207
+ }
208
+ ```
209
+
210
+ - (A or B or C) filter
211
+ ```Ruby
212
+ query4 = tp.filter_starts_with("start")
213
+ .or(np.filter_greater_than(100))
214
+ .or(cp.filter_equals(true))
215
+
216
+ # Result of query4.filter
217
+ {
218
+ or: [
219
+ {
220
+ property: "tp",
221
+ title: {starts_with: "start"},
222
+ },
223
+ {
224
+ property: "np",
225
+ number: {greater_than: 100},
226
+ },
227
+ {
228
+ property: "cp",
229
+ checkbox: {equals: true},
230
+ },
231
+ ],
232
+ }
233
+ ```
234
+
235
+ - ((A and B) or C) filter
236
+ ```Ruby
237
+ query5 = tp.filter_starts_with("start")
238
+ .and(np.filter_greater_than(100))
239
+ .or(cp.filter_equals(true))
240
+
241
+ # Result of query5.filter
242
+ {
243
+ or: [
244
+ {
245
+ and: [
246
+ {
247
+ property: "tp",
248
+ title: {starts_with: "start"},
249
+ },
250
+ {
251
+ property: "np",
252
+ number: {greater_than: 100},
253
+ },
254
+ ],
255
+ },
256
+ {
257
+ property: "cp",
258
+ checkbox: {equals: true},
259
+ },
260
+ ],
261
+ }
262
+ ```
263
+
264
+ - ((A or B) and C) filter
265
+ ```Ruby
266
+ query6 = tp.filter_starts_with("start")
267
+ .or(np.filter_greater_than(100))
268
+ .and(cp.filter_equals(true))
269
+
270
+ # Result of query6.filter
271
+ {
272
+ and: [
273
+ {
274
+ or: [
275
+ {
276
+ property: "tp",
277
+ title: {starts_with: "start"},
278
+ },
279
+ {
280
+ property: "np",
281
+ number: {greater_than: 100},
282
+ },
283
+ ],
284
+ },
285
+ {
286
+ property: "cp",
287
+ checkbox: {equals: true},
288
+ },
289
+ ],
290
+ }
291
+ ```
292
+
293
+ - ((A and B) or (C and D)) filter
294
+ ```Ruby
295
+ query7 = np.filter_greater_than(100).and(np.filter_less_than(200))
296
+ .or(np.filter_greater_than(300).and(np.filter_less_than(400)))
297
+
298
+ # Result of query7.filter
299
+ {
300
+ or: [
301
+ {
302
+ and: [
303
+ {
304
+ property: "np",
305
+ number: {greater_than: 100},
306
+ },
307
+ {
308
+ property: "np",
309
+ number: {less_than: 200},
310
+ },
311
+ ],
312
+ },
313
+ {
314
+ and: [
315
+ {
316
+ property: "np",
317
+ number: {greater_than: 300},
318
+ },
319
+ {
320
+ property: "np",
321
+ number: {less_than: 400},
322
+ },
323
+ ],
324
+ },
325
+ ],
326
+ }
327
+ ```
328
+
329
+ - sort criteria
330
+ ```Ruby
331
+ query8 = Query.new.ascending tp
332
+ query9 = Query.new.ascending letp
333
+ query10 = Query.new.descending tp
334
+ query11 = Query.new.descending letp
335
+ query12 = Query.new.ascending(tp).descending letp
336
+
337
+ # Result of query8.sort
338
+ [{property: "tp", direction: "ascending"}]
339
+
340
+ # Result of query9.sort
341
+ [{timestamp: "letp", direction: "ascending"}]
342
+
343
+ # Result of query10.sort
344
+ [{property: "tp", direction: "descending"}]
345
+
346
+ # Result of query11.sort
347
+ [{timestamp: "letp", direction: "descending"}]
348
+
349
+ # Result of query12.sort
350
+ [
351
+ {property: "tp", direction: "ascending"},
352
+ {timestamp: "letp", direction: "descending"},
353
+ ]
354
+ ```
355
+
356
+ #### Page class
357
+
358
+ - Retrieve a page
359
+ ```Ruby
360
+ page = Page.find("c01166c6-13ae-45cb-b968-18b4ef2f5a77")
361
+ ```
362
+
363
+ - Retrieve block children (List object)
364
+ ```Ruby
365
+ children = page.children
366
+ ```
367
+
368
+ - Set icon
369
+
370
+ ```Ruby
371
+ page.set_icon emoji: "💿"
372
+ page.set_icon url: "https://cdn.profile-image.st-hatena.com/users/hkob/profile.png"
373
+ ```
374
+
375
+ #### List class
376
+
377
+ - access for each components
378
+ ```Ruby
379
+ list.each do |obj| # obj's class is Page or Block
380
+ # do something
381
+ end
382
+ ```
383
+
384
+ ### Block class
385
+
386
+ Not implemented
387
+
388
+ ## Development
389
+
390
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
391
+
392
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
393
+
394
+ ## Contributing
395
+
396
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/notion_ruby_mapping. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/notion_ruby_mapping/blob/main/CODE_OF_CONDUCT.md).
397
+
398
+ ## License
399
+
400
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
401
+
402
+ ## Code of Conduct
403
+
404
+ Everyone interacting in the NotionRubyMapping project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/notion_ruby_mapping/blob/main/CODE_OF_CONDUCT.md).
405
+
406
+ ## Acknowledgements
407
+
408
+ The code depends on [notion-ruby-client](https://github.com/orbit-love/notion-ruby-client).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "notion_ruby_mapping"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here