notion_ruby_mapping 0.5.2 → 0.5.5

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: 6958b79feeac5556e9eec4fcfac214099d81319f85249db07ad7e7d5ef326359
4
- data.tar.gz: 8fb970d28b42a5c0354ad6caf3aee0165362c76b1c3b0786548eafd654019255
3
+ metadata.gz: e79de731e05cc8d52d2a4bf1cff43aa9af37fd0351632a163d250d5b1a021ccc
4
+ data.tar.gz: 603eed686b6c9aee581c921fd43416a1c835f8f7ebac38b40b6f69483e61368b
5
5
  SHA512:
6
- metadata.gz: 755b7031ff208823d9434bbe5850845f2b4bfe0b8bf4585418fe8ef42b5095df080d7461ff0788c3ddb0a500a9c4017fa5e287d63721c6a34e9c7baea4a55884
7
- data.tar.gz: 4227d5ac411aa5dc48f46a6d9bab1f4b097f17ba6fb9a1f9eb47b4b34167a5dc36a2e44d8f5df359a1f0ab1afeb256423ec7fe37603685df010f3891c4feaf2d
6
+ metadata.gz: f45b546354600850901dafded3f1dc2bded150466b4b4cc4d40a80e1d75ea50be5822ba6e494bf060a97961697fd3996de4a20fe537a519e84eb116f0d47292d
7
+ data.tar.gz: 0a30d84fad6ddfb80efee6fe222cf9ad33b85457017dd0fb8b68792ab40dd613d7d7f75a77d874f1153e442a08ae704a76c7210b5c1e884f96ffcab3283c1bc8
@@ -65,6 +65,26 @@ module NotionRubyMapping
65
65
  @database_title ||= RichTextArray.new "title", json: (self["title"]), will_update: new_record?
66
66
  end
67
67
 
68
+ # @return [NotionRubyMapping::RichTextArray]
69
+ def description
70
+ RichTextArray.new "description", json: self["description"]
71
+ end
72
+
73
+ # @param [RichTextArray, String, Array<String>, RichTextObject, Array<RichTextObject>] text_info
74
+ def description=(text_info)
75
+ @payload.description = text_info
76
+ end
77
+
78
+ # @return [Boolean]
79
+ def is_inline
80
+ self["is_inline"]
81
+ end
82
+
83
+ # @param [Boolean] flag
84
+ def is_inline=(flag)
85
+ @payload.is_inline = flag
86
+ end
87
+
68
88
  # @return [Hash] created json for property schemas (for create database)
69
89
  def property_schema_json
70
90
  @payload.property_schema_json @property_cache, database_title
@@ -18,6 +18,16 @@ module NotionRubyMapping
18
18
  @json = {}
19
19
  end
20
20
 
21
+ def description=(text_objects)
22
+ rta = RichTextArray.rich_text_array "description", text_objects
23
+ @json.merge!(rta.update_property_schema_json true)
24
+ end
25
+
26
+ # @param [Boolean] flag
27
+ def is_inline=(flag)
28
+ @json["is_inline"] = flag
29
+ end
30
+
21
31
  # @param [Hash] json
22
32
  def merge_property(json)
23
33
  @json["properties"] ||= {}
@@ -72,6 +72,7 @@ module NotionRubyMapping
72
72
  map(&:text).join ""
73
73
  end
74
74
 
75
+ # @param [RichTextArray, String, Array<String>, RichTextObject, Array<RichTextObject>] text_info
75
76
  def rich_text_objects=(text_info)
76
77
  @will_update = true
77
78
  @rich_text_objects = if text_info.is_a? RichTextArray
@@ -9,10 +9,18 @@ module NotionRubyMapping
9
9
 
10
10
  # @param [Date, Time, DateTime, String, nil] obj
11
11
  # @return [String, nil] iso8601 format string
12
- def self.value_str(obj)
12
+ def self.value_str(obj, start_time: false, end_time: false)
13
13
  case obj
14
14
  when Date
15
- obj.iso8601
15
+ tz = Time.now.strftime "%:z"
16
+ ds = obj.iso8601
17
+ if start_time
18
+ "#{ds}T00:00:00#{tz}"
19
+ elsif end_time
20
+ "#{ds}T23:59:59#{tz}"
21
+ else
22
+ ds
23
+ end
16
24
  when Time
17
25
  obj.strftime("%Y-%m-%dT%H:%M:%S%:z")
18
26
  when DateTime
@@ -76,7 +84,7 @@ module NotionRubyMapping
76
84
  # @return [NotionRubyMapping::Query] generated Query object
77
85
  # @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#841815bfaf684964bebf3fa6712ae26c
78
86
  def filter_before(date, rollup = nil, rollup_type = nil)
79
- make_filter_query "before", value_str(date), rollup, rollup_type
87
+ make_filter_query "before", value_str(date, start_time: true), rollup, rollup_type
80
88
  end
81
89
 
82
90
  # @param [String] rollup Rollup name
@@ -84,7 +92,7 @@ module NotionRubyMapping
84
92
  # @return [NotionRubyMapping::Query] generated Query object
85
93
  # @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#c0ea140866ea46f9a746b24773dc821c
86
94
  def filter_after(date, rollup = nil, rollup_type = nil)
87
- make_filter_query "after", value_str(date), rollup, rollup_type
95
+ make_filter_query "after", value_str(date, end_time: true), rollup, rollup_type
88
96
  end
89
97
 
90
98
  # @param [String] rollup Rollup name
@@ -92,7 +100,7 @@ module NotionRubyMapping
92
100
  # @return [NotionRubyMapping::Query] generated Query object
93
101
  # @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#6a20ade0ee964aad81aae4c08ea29d6b
94
102
  def filter_on_or_before(date, rollup = nil, rollup_type = nil)
95
- make_filter_query "on_or_before", value_str(date), rollup, rollup_type
103
+ make_filter_query "on_or_before", value_str(date, end_time: true), rollup, rollup_type
96
104
  end
97
105
 
98
106
  # @param [String] rollup Rollup name
@@ -100,7 +108,7 @@ module NotionRubyMapping
100
108
  # @return [NotionRubyMapping::Query] generated Query object
101
109
  # @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#1469e3fb3068426a8ea8492d191d1563
102
110
  def filter_on_or_after(date, rollup = nil, rollup_type = nil)
103
- make_filter_query "on_or_after", value_str(date), rollup, rollup_type
111
+ make_filter_query "on_or_after", value_str(date, start_time: true), rollup, rollup_type
104
112
  end
105
113
 
106
114
  # @param [String] rollup Rollup name
@@ -151,12 +159,10 @@ module NotionRubyMapping
151
159
  make_filter_query "next_year", {}, rollup, rollup_type
152
160
  end
153
161
 
154
- protected
155
-
156
162
  # @param [Date, Time, DateTime, String, nil] obj
157
163
  # @return [String, nil] iso8601 format string
158
- def value_str(obj)
159
- self.class.value_str(obj)
164
+ def value_str(obj, start_time: false, end_time: false)
165
+ self.class.value_str(obj, start_time: start_time, end_time: end_time)
160
166
  end
161
167
  end
162
168
  end
@@ -19,6 +19,14 @@ module NotionRubyMapping
19
19
  @file_names = Array(files)
20
20
  end
21
21
 
22
+ def file_names=(file_names = [])
23
+ array_file_names = Array(file_names)
24
+ raise StandardError, "files and file_names must be the same sizes." unless @files.length == array_file_names.length
25
+
26
+ @will_update = true
27
+ @file_names = array_file_names
28
+ end
29
+
22
30
  ### Not public announced methods
23
31
 
24
32
  ## Common methods
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NotionRubyMapping
4
- VERSION = "0.5.2"
4
+ VERSION = "0.5.5"
5
5
  NOTION_VERSION = "2022-02-22"
6
6
  end
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.5.2
4
+ version: 0.5.5
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-06-08 00:00:00.000000000 Z
11
+ date: 2022-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday