notion_ruby_mapping 0.1.2 → 0.2.0

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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/Guardfile +1 -1
  3. data/README.md +550 -197
  4. data/env.yml.sample +7 -0
  5. data/lib/notion_ruby_mapping/base.rb +45 -25
  6. data/lib/notion_ruby_mapping/checkbox_property.rb +26 -0
  7. data/lib/notion_ruby_mapping/created_by_property.rb +21 -0
  8. data/lib/notion_ruby_mapping/created_time_property.rb +20 -0
  9. data/lib/notion_ruby_mapping/database.rb +8 -8
  10. data/lib/notion_ruby_mapping/date_base_property.rb +40 -38
  11. data/lib/notion_ruby_mapping/date_property.rb +61 -0
  12. data/lib/notion_ruby_mapping/email_property.rb +30 -1
  13. data/lib/notion_ruby_mapping/files_property.rb +40 -0
  14. data/lib/notion_ruby_mapping/formula_property.rb +18 -0
  15. data/lib/notion_ruby_mapping/last_edited_by_property.rb +21 -0
  16. data/lib/notion_ruby_mapping/last_edited_time_property.rb +20 -0
  17. data/lib/notion_ruby_mapping/list.rb +33 -2
  18. data/lib/notion_ruby_mapping/mention_object.rb +49 -0
  19. data/lib/notion_ruby_mapping/multi_select_property.rb +25 -6
  20. data/lib/notion_ruby_mapping/notion_cache.rb +126 -53
  21. data/lib/notion_ruby_mapping/number_property.rb +13 -8
  22. data/lib/notion_ruby_mapping/page.rb +5 -2
  23. data/lib/notion_ruby_mapping/payload.rb +10 -2
  24. data/lib/notion_ruby_mapping/people_property.rb +38 -0
  25. data/lib/notion_ruby_mapping/phone_number_property.rb +30 -1
  26. data/lib/notion_ruby_mapping/property.rb +79 -41
  27. data/lib/notion_ruby_mapping/property_cache.rb +31 -12
  28. data/lib/notion_ruby_mapping/query.rb +5 -2
  29. data/lib/notion_ruby_mapping/relation_property.rb +37 -0
  30. data/lib/notion_ruby_mapping/rich_text_object.rb +74 -0
  31. data/lib/notion_ruby_mapping/rich_text_property.rb +18 -0
  32. data/lib/notion_ruby_mapping/rollup_property.rb +29 -0
  33. data/lib/notion_ruby_mapping/select_property.rb +12 -6
  34. data/lib/notion_ruby_mapping/text_object.rb +89 -0
  35. data/lib/notion_ruby_mapping/text_property.rb +61 -0
  36. data/lib/notion_ruby_mapping/title_property.rb +18 -0
  37. data/lib/notion_ruby_mapping/url_property.rb +30 -1
  38. data/lib/notion_ruby_mapping/user_object.rb +38 -0
  39. data/lib/notion_ruby_mapping/version.rb +2 -1
  40. data/lib/notion_ruby_mapping.rb +3 -3
  41. data/notion_ruby_mapping.gemspec +3 -1
  42. metadata +40 -7
@@ -1,7 +1,36 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NotionRubyMapping
4
- class UrlProperty < TextProperty
4
+ # UrlProperty
5
+ class UrlProperty < Property
6
+ include EqualsDoesNotEqual
7
+ include ContainsDoesNotContain
8
+ include StartsWithEndsWith
9
+ include IsEmptyIsNotEmpty
5
10
  TYPE = "url"
11
+
12
+ # @param [String] name Property name
13
+ # @param [String] url url value (optional)
14
+ def initialize(name, will_update: false, url: nil)
15
+ super name, will_update: will_update
16
+ @url = url
17
+ end
18
+ attr_reader :url
19
+
20
+ # @param [Hash] json
21
+ def update_from_json(json)
22
+ @will_update = false
23
+ @url = json["url"]
24
+ end
25
+
26
+ # @return [Hash]
27
+ def property_values_json
28
+ {@name => {"url" => @url, "type" => "url"}}
29
+ end
30
+
31
+ def url=(url)
32
+ @will_update = true
33
+ @url = url
34
+ end
6
35
  end
7
36
  end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NotionRubyMapping
4
+ # TextObject
5
+ class UserObject
6
+ # @param [String] user_id
7
+ # @return [TextObject]
8
+ def initialize(user_id: nil, json: {})
9
+ @user_id = user_id || json && json["id"]
10
+ @json = json
11
+ @will_update = false
12
+ end
13
+ attr_reader :will_update, :user_id
14
+
15
+ # @param [UserObject, String] uo
16
+ # @return [UserObject] self or created UserObject
17
+ def self.user_object(uo)
18
+ if uo.is_a? UserObject
19
+ uo
20
+ else
21
+ UserObject.new user_id: uo
22
+ end
23
+ end
24
+
25
+ # @return [String]
26
+ def name
27
+ @json["name"]
28
+ end
29
+
30
+ # @return [Hash]
31
+ def property_values_json
32
+ {
33
+ "object" => "user",
34
+ "id" => @user_id,
35
+ }
36
+ end
37
+ end
38
+ end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NotionRubyMapping
4
- VERSION = "0.1.2"
4
+ VERSION = "0.2.0"
5
+ NOTION_VERSION = "2022-02-22"
5
6
  end
@@ -3,9 +3,9 @@
3
3
  require "yaml"
4
4
 
5
5
  %w[version notion_cache base page database list block property text_property title_property rich_text_property
6
- url_property email_property phone_number_property number_property checkbox_property select_property
7
- multi_property multi_select_property date_base_property date_property created_time_property last_edited_time_property
6
+ url_property email_property phone_number_property number_property checkbox_property select_property multi_property
7
+ multi_select_property date_base_property date_property created_time_property last_edited_time_property
8
8
  people_property created_by_property last_edited_by_property files_property relation_property formula_property
9
- query payload property_cache.rb].each do |k|
9
+ rollup_property query payload property_cache rich_text_object text_object mention_object user_object].each do |k|
10
10
  require_relative "notion_ruby_mapping/#{k}"
11
11
  end
@@ -34,13 +34,15 @@ Gem::Specification.new do |spec|
34
34
  # Uncomment to register a new dependency of your gem
35
35
  # spec.add_dependency "example-gem", "~> 1.0"
36
36
 
37
- spec.add_dependency "notion-ruby-client", "0.1.0.pre.beta1"
37
+ spec.add_dependency "faraday"
38
+ spec.add_dependency "faraday_middleware"
38
39
 
39
40
  spec.add_development_dependency "guard"
40
41
  spec.add_development_dependency "guard-rspec"
41
42
  spec.add_development_dependency "rake"
42
43
  spec.add_development_dependency "rspec"
43
44
  spec.add_development_dependency "rubocop"
45
+ spec.add_development_dependency "webmock"
44
46
 
45
47
  # For more information and examples about making a new gem, check out our
46
48
  # guide at: https://bundler.io/guides/creating_gem.html
metadata CHANGED
@@ -1,29 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notion_ruby_mapping
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
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-02-20 00:00:00.000000000 Z
11
+ date: 2022-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: notion-ruby-client
14
+ name: faraday
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '='
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
18
25
  - !ruby/object:Gem::Version
19
- version: 0.1.0.pre.beta1
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday_middleware
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
20
34
  type: :runtime
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
- - - '='
38
+ - - ">="
25
39
  - !ruby/object:Gem::Version
26
- version: 0.1.0.pre.beta1
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: guard
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +108,20 @@ dependencies:
94
108
  - - ">="
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: webmock
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
97
125
  description: Mapping tool from Notion Database/Page/Block to Ruby Objects.
98
126
  email:
99
127
  - hkob@metro-cit.ac.jp
@@ -131,6 +159,7 @@ files:
131
159
  - lib/notion_ruby_mapping/last_edited_by_property.rb
132
160
  - lib/notion_ruby_mapping/last_edited_time_property.rb
133
161
  - lib/notion_ruby_mapping/list.rb
162
+ - lib/notion_ruby_mapping/mention_object.rb
134
163
  - lib/notion_ruby_mapping/multi_property.rb
135
164
  - lib/notion_ruby_mapping/multi_select_property.rb
136
165
  - lib/notion_ruby_mapping/notion_cache.rb
@@ -143,11 +172,15 @@ files:
143
172
  - lib/notion_ruby_mapping/property_cache.rb
144
173
  - lib/notion_ruby_mapping/query.rb
145
174
  - lib/notion_ruby_mapping/relation_property.rb
175
+ - lib/notion_ruby_mapping/rich_text_object.rb
146
176
  - lib/notion_ruby_mapping/rich_text_property.rb
177
+ - lib/notion_ruby_mapping/rollup_property.rb
147
178
  - lib/notion_ruby_mapping/select_property.rb
179
+ - lib/notion_ruby_mapping/text_object.rb
148
180
  - lib/notion_ruby_mapping/text_property.rb
149
181
  - lib/notion_ruby_mapping/title_property.rb
150
182
  - lib/notion_ruby_mapping/url_property.rb
183
+ - lib/notion_ruby_mapping/user_object.rb
151
184
  - lib/notion_ruby_mapping/version.rb
152
185
  - notion_ruby_mapping.gemspec
153
186
  - sig/notion_ruby_mapping.rbs