rubysky 0.4.0 → 0.5.0

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: e6be362a96034c153bc6cd9e9d5737a9ef5eeef478f475a67ebf602f38f5dae8
4
- data.tar.gz: 1ef05e55261c62a371bf01bc35407597a4bd60588d372319b899779afcda702e
3
+ metadata.gz: f87f2e74de1715a21180af819d5fcca14528c11a281111f661c02046683aa161
4
+ data.tar.gz: 6bc798abba202fb175489092538862157d6e0238675e6086fb79578ddfeed5ac
5
5
  SHA512:
6
- metadata.gz: 62fe028987c92fc49e4db38b47a570ff999ca000ac0510b554c8e510faf59315929481dca4045209c7754cf0c6d98f6687e748e475907314d9dc16f2d974e261
7
- data.tar.gz: c6c34eda9ba22628a5124a7051146cafe3a88cee6c926326c0ed171c030035808a9a32b25d99b26c3afd6f53d3f424b9dc66f1d4309505f9b281091cd7002b5f
6
+ metadata.gz: 4490dfc932d909faf3ebb882518a19d9b922102850562e44ab04649cec114c8fbbe22edf84b10e0b7b422da00893b9733c9c63e5838bec3d6d08fa041895b978
7
+ data.tar.gz: 883934d47f33e22ce7a4020b9770c1c46bc72fd8c46eafae920b47b00e31ff37dfbf599c16cd37ab910098b84b56ed2a64001c82e3179398fc8f830916b5ddb8
@@ -4,6 +4,6 @@ version: '7.0'
4
4
  source:
5
5
  type: git
6
6
  name: ruby/gem_rbs_collection
7
- revision: 0a6ea105a0afc7eaee4494585a7775f47eea6145
7
+ revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
8
8
  remote: https://github.com/ruby/gem_rbs_collection.git
9
9
  repo_dir: gems
@@ -138,3 +138,242 @@ end
138
138
  class String
139
139
  def downcase_first: () -> String
140
140
  end
141
+
142
+ # active_support/core_ext/array/conversions.rb
143
+ class Array[unchecked out Elem]
144
+ # Extends <tt>Array#to_s</tt> to convert a collection of elements into a
145
+ # comma separated id list if <tt>:db</tt> argument is given as the format.
146
+ #
147
+ # This method is aliased to <tt>to_formatted_s</tt>.
148
+ #
149
+ # Blog.all.to_fs(:db) # => "1,2,3"
150
+ # Blog.none.to_fs(:db) # => "null"
151
+ # [1,2].to_fs # => "[1, 2]"
152
+ def to_fs: (?Symbol format) -> String
153
+ end
154
+
155
+ # active_support/core_ext/numeric/conversions.rb
156
+ class Numeric
157
+ # \Numeric With Format
158
+ #
159
+ # Provides options for converting numbers into formatted strings.
160
+ # Options are provided for phone numbers, currency, percentage,
161
+ # precision, positional notation, file size, and pretty printing.
162
+ #
163
+ # This method is aliased to <tt>to_formatted_s</tt>.
164
+ #
165
+ # ==== Options
166
+ #
167
+ # For details on which formats use which options, see ActiveSupport::NumberHelper
168
+ #
169
+ # ==== Examples
170
+ #
171
+ # Phone Numbers:
172
+ # 5551234.to_fs(:phone) # => "555-1234"
173
+ # 1235551234.to_fs(:phone) # => "123-555-1234"
174
+ # 1235551234.to_fs(:phone, area_code: true) # => "(123) 555-1234"
175
+ # 1235551234.to_fs(:phone, delimiter: ' ') # => "123 555 1234"
176
+ # 1235551234.to_fs(:phone, area_code: true, extension: 555) # => "(123) 555-1234 x 555"
177
+ # 1235551234.to_fs(:phone, country_code: 1) # => "+1-123-555-1234"
178
+ # 1235551234.to_fs(:phone, country_code: 1, extension: 1343, delimiter: '.')
179
+ # # => "+1.123.555.1234 x 1343"
180
+ #
181
+ # Currency:
182
+ # 1234567890.50.to_fs(:currency) # => "$1,234,567,890.50"
183
+ # 1234567890.506.to_fs(:currency) # => "$1,234,567,890.51"
184
+ # 1234567890.506.to_fs(:currency, precision: 3) # => "$1,234,567,890.506"
185
+ # 1234567890.506.to_fs(:currency, round_mode: :down) # => "$1,234,567,890.50"
186
+ # 1234567890.506.to_fs(:currency, locale: :fr) # => "1 234 567 890,51 €"
187
+ # -1234567890.50.to_fs(:currency, negative_format: '(%u%n)')
188
+ # # => "($1,234,567,890.50)"
189
+ # 1234567890.50.to_fs(:currency, unit: '&pound;', separator: ',', delimiter: '')
190
+ # # => "&pound;1234567890,50"
191
+ # 1234567890.50.to_fs(:currency, unit: '&pound;', separator: ',', delimiter: '', format: '%n %u')
192
+ # # => "1234567890,50 &pound;"
193
+ #
194
+ # Percentage:
195
+ # 100.to_fs(:percentage) # => "100.000%"
196
+ # 100.to_fs(:percentage, precision: 0) # => "100%"
197
+ # 1000.to_fs(:percentage, delimiter: '.', separator: ',') # => "1.000,000%"
198
+ # 302.24398923423.to_fs(:percentage, precision: 5) # => "302.24399%"
199
+ # 302.24398923423.to_fs(:percentage, round_mode: :down) # => "302.243%"
200
+ # 1000.to_fs(:percentage, locale: :fr) # => "1 000,000%"
201
+ # 100.to_fs(:percentage, format: '%n %') # => "100.000 %"
202
+ #
203
+ # Delimited:
204
+ # 12345678.to_fs(:delimited) # => "12,345,678"
205
+ # 12345678.05.to_fs(:delimited) # => "12,345,678.05"
206
+ # 12345678.to_fs(:delimited, delimiter: '.') # => "12.345.678"
207
+ # 12345678.to_fs(:delimited, delimiter: ',') # => "12,345,678"
208
+ # 12345678.05.to_fs(:delimited, separator: ' ') # => "12,345,678 05"
209
+ # 12345678.05.to_fs(:delimited, locale: :fr) # => "12 345 678,05"
210
+ # 98765432.98.to_fs(:delimited, delimiter: ' ', separator: ',')
211
+ # # => "98 765 432,98"
212
+ #
213
+ # Rounded:
214
+ # 111.2345.to_fs(:rounded) # => "111.235"
215
+ # 111.2345.to_fs(:rounded, precision: 2) # => "111.23"
216
+ # 111.2345.to_fs(:rounded, precision: 2, round_mode: :up) # => "111.24"
217
+ # 13.to_fs(:rounded, precision: 5) # => "13.00000"
218
+ # 389.32314.to_fs(:rounded, precision: 0) # => "389"
219
+ # 111.2345.to_fs(:rounded, significant: true) # => "111"
220
+ # 111.2345.to_fs(:rounded, precision: 1, significant: true) # => "100"
221
+ # 13.to_fs(:rounded, precision: 5, significant: true) # => "13.000"
222
+ # 111.234.to_fs(:rounded, locale: :fr) # => "111,234"
223
+ # 13.to_fs(:rounded, precision: 5, significant: true, strip_insignificant_zeros: true)
224
+ # # => "13"
225
+ # 389.32314.to_fs(:rounded, precision: 4, significant: true) # => "389.3"
226
+ # 1111.2345.to_fs(:rounded, precision: 2, separator: ',', delimiter: '.')
227
+ # # => "1.111,23"
228
+ #
229
+ # Human-friendly size in Bytes:
230
+ # 123.to_fs(:human_size) # => "123 Bytes"
231
+ # 1234.to_fs(:human_size) # => "1.21 KB"
232
+ # 12345.to_fs(:human_size) # => "12.1 KB"
233
+ # 1234567.to_fs(:human_size) # => "1.18 MB"
234
+ # 1234567890.to_fs(:human_size) # => "1.15 GB"
235
+ # 1234567890123.to_fs(:human_size) # => "1.12 TB"
236
+ # 1234567890123456.to_fs(:human_size) # => "1.1 PB"
237
+ # 1234567890123456789.to_fs(:human_size) # => "1.07 EB"
238
+ # 1234567.to_fs(:human_size, precision: 2) # => "1.2 MB"
239
+ # 1234567.to_fs(:human_size, precision: 2, round_mode: :up) # => "1.3 MB"
240
+ # 483989.to_fs(:human_size, precision: 2) # => "470 KB"
241
+ # 1234567.to_fs(:human_size, precision: 2, separator: ',') # => "1,2 MB"
242
+ # 1234567890123.to_fs(:human_size, precision: 5) # => "1.1228 TB"
243
+ # 524288000.to_fs(:human_size, precision: 5) # => "500 MB"
244
+ #
245
+ # Human-friendly format:
246
+ # 123.to_fs(:human) # => "123"
247
+ # 1234.to_fs(:human) # => "1.23 Thousand"
248
+ # 12345.to_fs(:human) # => "12.3 Thousand"
249
+ # 1234567.to_fs(:human) # => "1.23 Million"
250
+ # 1234567890.to_fs(:human) # => "1.23 Billion"
251
+ # 1234567890123.to_fs(:human) # => "1.23 Trillion"
252
+ # 1234567890123456.to_fs(:human) # => "1.23 Quadrillion"
253
+ # 1234567890123456789.to_fs(:human) # => "1230 Quadrillion"
254
+ # 489939.to_fs(:human, precision: 2) # => "490 Thousand"
255
+ # 489939.to_fs(:human, precision: 2, round_mode: :down) # => "480 Thousand"
256
+ # 489939.to_fs(:human, precision: 4) # => "489.9 Thousand"
257
+ # 1234567.to_fs(:human, precision: 4,
258
+ # significant: false) # => "1.2346 Million"
259
+ # 1234567.to_fs(:human, precision: 1,
260
+ # separator: ',',
261
+ # significant: false) # => "1,2 Million"
262
+ def to_fs: (?Symbol format, **untyped) -> String
263
+ end
264
+
265
+ # active_support/core_ext/range/conversions.rb
266
+ class Range[out Elem]
267
+ # Convert range to a formatted string. See RANGE_FORMATS for predefined formats.
268
+ #
269
+ # This method is aliased to <tt>to_formatted_s</tt>.
270
+ #
271
+ # range = (1..100) # => 1..100
272
+ #
273
+ # range.to_s # => "1..100"
274
+ # range.to_fs(:db) # => "BETWEEN '1' AND '100'"
275
+ #
276
+ # range = (1..) # => 1..
277
+ # range.to_fs(:db) # => ">= '1'"
278
+ #
279
+ # range = (..100) # => ..100
280
+ # range.to_fs(:db) # => "<= '100'"
281
+ #
282
+ # == Adding your own range formats to to_fs
283
+ # You can add your own formats to the Range::RANGE_FORMATS hash.
284
+ # Use the format name as the hash key and a Proc instance.
285
+ #
286
+ # # config/initializers/range_formats.rb
287
+ # Range::RANGE_FORMATS[:short] = ->(start, stop) { "Between #{start.to_fs(:db)} and #{stop.to_fs(:db)}" }
288
+ def to_fs: (?Symbol format) -> String
289
+ end
290
+
291
+ # active_support/core_ext/date/conversions.rb
292
+ class Date
293
+ # Convert to a formatted string. See DATE_FORMATS for predefined formats.
294
+ #
295
+ # This method is aliased to <tt>to_formatted_s</tt>.
296
+ #
297
+ # date = Date.new(2007, 11, 10) # => Sat, 10 Nov 2007
298
+ #
299
+ # date.to_fs(:db) # => "2007-11-10"
300
+ # date.to_formatted_s(:db) # => "2007-11-10"
301
+ #
302
+ # date.to_fs(:short) # => "10 Nov"
303
+ # date.to_fs(:number) # => "20071110"
304
+ # date.to_fs(:long) # => "November 10, 2007"
305
+ # date.to_fs(:long_ordinal) # => "November 10th, 2007"
306
+ # date.to_fs(:rfc822) # => "10 Nov 2007"
307
+ # date.to_fs(:iso8601) # => "2007-11-10"
308
+ #
309
+ # == Adding your own date formats to to_fs
310
+ # You can add your own formats to the Date::DATE_FORMATS hash.
311
+ # Use the format name as the hash key and either a strftime string
312
+ # or Proc instance that takes a date argument as the value.
313
+ #
314
+ # # config/initializers/date_formats.rb
315
+ # Date::DATE_FORMATS[:month_and_year] = '%B %Y'
316
+ # Date::DATE_FORMATS[:short_ordinal] = ->(date) { date.strftime("%B #{date.day.ordinalize}") }
317
+ def to_fs: (?Symbol format) -> String
318
+ end
319
+
320
+ # active_support/core_ext/time/conversions.rb
321
+ class Time
322
+ # Converts to a formatted string. See DATE_FORMATS for built-in formats.
323
+ #
324
+ # This method is aliased to <tt>to_formatted_s</tt>.
325
+ #
326
+ # time = Time.now # => 2007-01-18 06:10:17 -06:00
327
+ #
328
+ # time.to_fs(:time) # => "06:10"
329
+ # time.to_formatted_s(:time) # => "06:10"
330
+ #
331
+ # time.to_fs(:db) # => "2007-01-18 06:10:17"
332
+ # time.to_fs(:number) # => "20070118061017"
333
+ # time.to_fs(:short) # => "18 Jan 06:10"
334
+ # time.to_fs(:long) # => "January 18, 2007 06:10"
335
+ # time.to_fs(:long_ordinal) # => "January 18th, 2007 06:10"
336
+ # time.to_fs(:rfc822) # => "Thu, 18 Jan 2007 06:10:17 -0600"
337
+ # time.to_fs(:rfc2822) # => "Thu, 18 Jan 2007 06:10:17 -0600"
338
+ # time.to_fs(:iso8601) # => "2007-01-18T06:10:17-06:00"
339
+ #
340
+ # == Adding your own time formats to +to_fs+
341
+ # You can add your own formats to the Time::DATE_FORMATS hash.
342
+ # Use the format name as the hash key and either a strftime string
343
+ # or Proc instance that takes a time argument as the value.
344
+ #
345
+ # # config/initializers/time_formats.rb
346
+ # Time::DATE_FORMATS[:month_and_year] = '%B %Y'
347
+ # Time::DATE_FORMATS[:short_ordinal] = ->(time) { time.strftime("%B #{time.day.ordinalize}") }
348
+ def to_fs: (?Symbol format) -> String
349
+ end
350
+
351
+ # active_support/core_ext/date_time/conversions.rb
352
+ class DateTime
353
+ # Convert to a formatted string. See Time::DATE_FORMATS for predefined formats.
354
+ #
355
+ # This method is aliased to <tt>to_formatted_s</tt>.
356
+ #
357
+ # === Examples
358
+ # datetime = DateTime.civil(2007, 12, 4, 0, 0, 0, 0) # => Tue, 04 Dec 2007 00:00:00 +0000
359
+ #
360
+ # datetime.to_fs(:db) # => "2007-12-04 00:00:00"
361
+ # datetime.to_formatted_s(:db) # => "2007-12-04 00:00:00"
362
+ # datetime.to_fs(:number) # => "20071204000000"
363
+ # datetime.to_fs(:short) # => "04 Dec 00:00"
364
+ # datetime.to_fs(:long) # => "December 04, 2007 00:00"
365
+ # datetime.to_fs(:long_ordinal) # => "December 4th, 2007 00:00"
366
+ # datetime.to_fs(:rfc822) # => "Tue, 04 Dec 2007 00:00:00 +0000"
367
+ # datetime.to_fs(:iso8601) # => "2007-12-04T00:00:00+00:00"
368
+ #
369
+ # == Adding your own datetime formats to to_fs
370
+ # DateTime formats are shared with Time. You can add your own to the
371
+ # Time::DATE_FORMATS hash. Use the format name as the hash key and
372
+ # either a strftime string or Proc instance that takes a time or
373
+ # datetime argument as the value.
374
+ #
375
+ # # config/initializers/time_formats.rb
376
+ # Time::DATE_FORMATS[:month_and_year] = '%B %Y'
377
+ # Time::DATE_FORMATS[:short_ordinal] = lambda { |time| time.strftime("%B #{time.day.ordinalize}") }
378
+ def to_fs: (?Symbol format) -> String
379
+ end
@@ -1984,83 +1984,6 @@ class Array[unchecked out Elem]
1984
1984
  def to_formatted_s: (?::Symbol format) -> untyped
1985
1985
 
1986
1986
  alias to_default_s to_s
1987
-
1988
- # Returns a string that represents the array in XML by invoking +to_xml+
1989
- # on each element. Active Record collections delegate their representation
1990
- # in XML to this method.
1991
- #
1992
- # All elements are expected to respond to +to_xml+, if any of them does
1993
- # not then an exception is raised.
1994
- #
1995
- # The root node reflects the class name of the first element in plural
1996
- # if all elements belong to the same type and that's not Hash:
1997
- #
1998
- # customer.projects.to_xml
1999
- #
2000
- # <?xml version="1.0" encoding="UTF-8"?>
2001
- # <projects type="array">
2002
- # <project>
2003
- # <amount type="decimal">20000.0</amount>
2004
- # <customer-id type="integer">1567</customer-id>
2005
- # <deal-date type="date">2008-04-09</deal-date>
2006
- # ...
2007
- # </project>
2008
- # <project>
2009
- # <amount type="decimal">57230.0</amount>
2010
- # <customer-id type="integer">1567</customer-id>
2011
- # <deal-date type="date">2008-04-15</deal-date>
2012
- # ...
2013
- # </project>
2014
- # </projects>
2015
- #
2016
- # Otherwise the root element is "objects":
2017
- #
2018
- # [{ foo: 1, bar: 2}, { baz: 3}].to_xml
2019
- #
2020
- # <?xml version="1.0" encoding="UTF-8"?>
2021
- # <objects type="array">
2022
- # <object>
2023
- # <bar type="integer">2</bar>
2024
- # <foo type="integer">1</foo>
2025
- # </object>
2026
- # <object>
2027
- # <baz type="integer">3</baz>
2028
- # </object>
2029
- # </objects>
2030
- #
2031
- # If the collection is empty the root element is "nil-classes" by default:
2032
- #
2033
- # [].to_xml
2034
- #
2035
- # <?xml version="1.0" encoding="UTF-8"?>
2036
- # <nil-classes type="array"/>
2037
- #
2038
- # To ensure a meaningful root element use the <tt>:root</tt> option:
2039
- #
2040
- # customer_with_no_projects.projects.to_xml(root: 'projects')
2041
- #
2042
- # <?xml version="1.0" encoding="UTF-8"?>
2043
- # <projects type="array"/>
2044
- #
2045
- # By default name of the node for the children of root is <tt>root.singularize</tt>.
2046
- # You can change it with the <tt>:children</tt> option.
2047
- #
2048
- # The +options+ hash is passed downwards:
2049
- #
2050
- # Message.all.to_xml(skip_types: true)
2051
- #
2052
- # <?xml version="1.0" encoding="UTF-8"?>
2053
- # <messages>
2054
- # <message>
2055
- # <created-at>2008-03-07T09:58:18+01:00</created-at>
2056
- # <id>1</id>
2057
- # <name>1</name>
2058
- # <updated-at>2008-03-07T09:58:18+01:00</updated-at>
2059
- # <user-id>1</user-id>
2060
- # </message>
2061
- # </messages>
2062
- #
2063
- def to_xml: (?::Hash[untyped, untyped] options) { (untyped) -> untyped } -> untyped
2064
1987
  end
2065
1988
 
2066
1989
  class Array[unchecked out Elem]
@@ -3016,70 +2939,6 @@ class File
3016
2939
  end
3017
2940
 
3018
2941
  class Hash[unchecked out K, unchecked out V]
3019
- # Returns a string containing an XML representation of its receiver:
3020
- #
3021
- # { foo: 1, bar: 2 }.to_xml
3022
- # # =>
3023
- # # <?xml version="1.0" encoding="UTF-8"?>
3024
- # # <hash>
3025
- # # <foo type="integer">1</foo>
3026
- # # <bar type="integer">2</bar>
3027
- # # </hash>
3028
- #
3029
- # To do so, the method loops over the pairs and builds nodes that depend on
3030
- # the _values_. Given a pair +key+, +value+:
3031
- #
3032
- # * If +value+ is a hash there's a recursive call with +key+ as <tt>:root</tt>.
3033
- #
3034
- # * If +value+ is an array there's a recursive call with +key+ as <tt>:root</tt>,
3035
- # and +key+ singularized as <tt>:children</tt>.
3036
- #
3037
- # * If +value+ is a callable object it must expect one or two arguments. Depending
3038
- # on the arity, the callable is invoked with the +options+ hash as first argument
3039
- # with +key+ as <tt>:root</tt>, and +key+ singularized as second argument. The
3040
- # callable can add nodes by using <tt>options[:builder]</tt>.
3041
- #
3042
- # {foo: lambda { |options, key| options[:builder].b(key) }}.to_xml
3043
- # # => "<b>foo</b>"
3044
- #
3045
- # * If +value+ responds to +to_xml+ the method is invoked with +key+ as <tt>:root</tt>.
3046
- #
3047
- # class Foo
3048
- # def to_xml(options)
3049
- # options[:builder].bar 'fooing!'
3050
- # end
3051
- # end
3052
- #
3053
- # { foo: Foo.new }.to_xml(skip_instruct: true)
3054
- # # =>
3055
- # # <hash>
3056
- # # <bar>fooing!</bar>
3057
- # # </hash>
3058
- #
3059
- # * Otherwise, a node with +key+ as tag is created with a string representation of
3060
- # +value+ as text node. If +value+ is +nil+ an attribute "nil" set to "true" is added.
3061
- # Unless the option <tt>:skip_types</tt> exists and is true, an attribute "type" is
3062
- # added as well according to the following mapping:
3063
- #
3064
- # XML_TYPE_NAMES = {
3065
- # "Symbol" => "symbol",
3066
- # "Integer" => "integer",
3067
- # "BigDecimal" => "decimal",
3068
- # "Float" => "float",
3069
- # "TrueClass" => "boolean",
3070
- # "FalseClass" => "boolean",
3071
- # "Date" => "date",
3072
- # "DateTime" => "dateTime",
3073
- # "Time" => "dateTime"
3074
- # }
3075
- #
3076
- # By default the root node is "hash", but that's configurable via the <tt>:root</tt> option.
3077
- #
3078
- # The default XML builder is a fresh instance of <tt>Builder::XmlMarkup</tt>. You can
3079
- # configure your own builder with the <tt>:builder</tt> option. The method also accepts
3080
- # options like <tt>:dasherize</tt> and friends, they are forwarded to the builder.
3081
- def to_xml: (?::Hash[untyped, untyped] options) { (untyped) -> untyped } -> untyped
3082
-
3083
2942
  # Returns a Hash containing a collection of pairs when the key is the node name and the value is
3084
2943
  # its content
3085
2944
  #
@@ -394,6 +394,83 @@ end
394
394
  class Array[unchecked out Elem]
395
395
  # Manual definition to make block optional
396
396
  def in_groups: (untyped number, ?untyped? fill_with) ?{ (untyped) -> untyped } -> untyped
397
+
398
+ # Returns a string that represents the array in XML by invoking +to_xml+
399
+ # on each element. Active Record collections delegate their representation
400
+ # in XML to this method.
401
+ #
402
+ # All elements are expected to respond to +to_xml+, if any of them does
403
+ # not then an exception is raised.
404
+ #
405
+ # The root node reflects the class name of the first element in plural
406
+ # if all elements belong to the same type and that's not Hash:
407
+ #
408
+ # customer.projects.to_xml
409
+ #
410
+ # <?xml version="1.0" encoding="UTF-8"?>
411
+ # <projects type="array">
412
+ # <project>
413
+ # <amount type="decimal">20000.0</amount>
414
+ # <customer-id type="integer">1567</customer-id>
415
+ # <deal-date type="date">2008-04-09</deal-date>
416
+ # ...
417
+ # </project>
418
+ # <project>
419
+ # <amount type="decimal">57230.0</amount>
420
+ # <customer-id type="integer">1567</customer-id>
421
+ # <deal-date type="date">2008-04-15</deal-date>
422
+ # ...
423
+ # </project>
424
+ # </projects>
425
+ #
426
+ # Otherwise the root element is "objects":
427
+ #
428
+ # [{ foo: 1, bar: 2}, { baz: 3}].to_xml
429
+ #
430
+ # <?xml version="1.0" encoding="UTF-8"?>
431
+ # <objects type="array">
432
+ # <object>
433
+ # <bar type="integer">2</bar>
434
+ # <foo type="integer">1</foo>
435
+ # </object>
436
+ # <object>
437
+ # <baz type="integer">3</baz>
438
+ # </object>
439
+ # </objects>
440
+ #
441
+ # If the collection is empty the root element is "nil-classes" by default:
442
+ #
443
+ # [].to_xml
444
+ #
445
+ # <?xml version="1.0" encoding="UTF-8"?>
446
+ # <nil-classes type="array"/>
447
+ #
448
+ # To ensure a meaningful root element use the <tt>:root</tt> option:
449
+ #
450
+ # customer_with_no_projects.projects.to_xml(root: 'projects')
451
+ #
452
+ # <?xml version="1.0" encoding="UTF-8"?>
453
+ # <projects type="array"/>
454
+ #
455
+ # By default name of the node for the children of root is <tt>root.singularize</tt>.
456
+ # You can change it with the <tt>:children</tt> option.
457
+ #
458
+ # The +options+ hash is passed downwards:
459
+ #
460
+ # Message.all.to_xml(skip_types: true)
461
+ #
462
+ # <?xml version="1.0" encoding="UTF-8"?>
463
+ # <messages>
464
+ # <message>
465
+ # <created-at>2008-03-07T09:58:18+01:00</created-at>
466
+ # <id>1</id>
467
+ # <name>1</name>
468
+ # <updated-at>2008-03-07T09:58:18+01:00</updated-at>
469
+ # <user-id>1</user-id>
470
+ # </message>
471
+ # </messages>
472
+ #
473
+ def to_xml: (?::Hash[untyped, untyped] options) ?{ (untyped) -> untyped } -> untyped
397
474
  end
398
475
 
399
476
  # active_support/core_ext/object/blank.rb
@@ -427,6 +504,70 @@ end
427
504
 
428
505
  class Hash[unchecked out K, unchecked out V]
429
506
  alias blank? empty?
507
+
508
+ # Returns a string containing an XML representation of its receiver:
509
+ #
510
+ # { foo: 1, bar: 2 }.to_xml
511
+ # # =>
512
+ # # <?xml version="1.0" encoding="UTF-8"?>
513
+ # # <hash>
514
+ # # <foo type="integer">1</foo>
515
+ # # <bar type="integer">2</bar>
516
+ # # </hash>
517
+ #
518
+ # To do so, the method loops over the pairs and builds nodes that depend on
519
+ # the _values_. Given a pair +key+, +value+:
520
+ #
521
+ # * If +value+ is a hash there's a recursive call with +key+ as <tt>:root</tt>.
522
+ #
523
+ # * If +value+ is an array there's a recursive call with +key+ as <tt>:root</tt>,
524
+ # and +key+ singularized as <tt>:children</tt>.
525
+ #
526
+ # * If +value+ is a callable object it must expect one or two arguments. Depending
527
+ # on the arity, the callable is invoked with the +options+ hash as first argument
528
+ # with +key+ as <tt>:root</tt>, and +key+ singularized as second argument. The
529
+ # callable can add nodes by using <tt>options[:builder]</tt>.
530
+ #
531
+ # {foo: lambda { |options, key| options[:builder].b(key) }}.to_xml
532
+ # # => "<b>foo</b>"
533
+ #
534
+ # * If +value+ responds to +to_xml+ the method is invoked with +key+ as <tt>:root</tt>.
535
+ #
536
+ # class Foo
537
+ # def to_xml(options)
538
+ # options[:builder].bar 'fooing!'
539
+ # end
540
+ # end
541
+ #
542
+ # { foo: Foo.new }.to_xml(skip_instruct: true)
543
+ # # =>
544
+ # # <hash>
545
+ # # <bar>fooing!</bar>
546
+ # # </hash>
547
+ #
548
+ # * Otherwise, a node with +key+ as tag is created with a string representation of
549
+ # +value+ as text node. If +value+ is +nil+ an attribute "nil" set to "true" is added.
550
+ # Unless the option <tt>:skip_types</tt> exists and is true, an attribute "type" is
551
+ # added as well according to the following mapping:
552
+ #
553
+ # XML_TYPE_NAMES = {
554
+ # "Symbol" => "symbol",
555
+ # "Integer" => "integer",
556
+ # "BigDecimal" => "decimal",
557
+ # "Float" => "float",
558
+ # "TrueClass" => "boolean",
559
+ # "FalseClass" => "boolean",
560
+ # "Date" => "date",
561
+ # "DateTime" => "dateTime",
562
+ # "Time" => "dateTime"
563
+ # }
564
+ #
565
+ # By default the root node is "hash", but that's configurable via the <tt>:root</tt> option.
566
+ #
567
+ # The default XML builder is a fresh instance of <tt>Builder::XmlMarkup</tt>. You can
568
+ # configure your own builder with the <tt>:builder</tt> option. The method also accepts
569
+ # options like <tt>:dasherize</tt> and friends, they are forwarded to the builder.
570
+ def to_xml: (?::Hash[untyped, untyped] options) ?{ (untyped) -> untyped } -> untyped
430
571
  end
431
572
 
432
573
  class String
@@ -4,6 +4,6 @@ version: '2.4'
4
4
  source:
5
5
  type: git
6
6
  name: ruby/gem_rbs_collection
7
- revision: 0a6ea105a0afc7eaee4494585a7775f47eea6145
7
+ revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
8
8
  remote: https://github.com/ruby/gem_rbs_collection.git
9
9
  repo_dir: gems
@@ -4,6 +4,6 @@ version: '1.1'
4
4
  source:
5
5
  type: git
6
6
  name: ruby/gem_rbs_collection
7
- revision: 0a6ea105a0afc7eaee4494585a7775f47eea6145
7
+ revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
8
8
  remote: https://github.com/ruby/gem_rbs_collection.git
9
9
  repo_dir: gems
@@ -4,6 +4,6 @@ version: '2.4'
4
4
  source:
5
5
  type: git
6
6
  name: ruby/gem_rbs_collection
7
- revision: 0a6ea105a0afc7eaee4494585a7775f47eea6145
7
+ revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
8
8
  remote: https://github.com/ruby/gem_rbs_collection.git
9
9
  repo_dir: gems
@@ -1,2 +1,2 @@
1
- rdependencies:
1
+ dependencies:
2
2
  - name: timeout
@@ -4,6 +4,6 @@ version: '1.5'
4
4
  source:
5
5
  type: git
6
6
  name: ruby/gem_rbs_collection
7
- revision: 0a6ea105a0afc7eaee4494585a7775f47eea6145
7
+ revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
8
8
  remote: https://github.com/ruby/gem_rbs_collection.git
9
9
  repo_dir: gems
@@ -4,6 +4,6 @@ version: '1.10'
4
4
  source:
5
5
  type: git
6
6
  name: ruby/gem_rbs_collection
7
- revision: 0a6ea105a0afc7eaee4494585a7775f47eea6145
7
+ revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
8
8
  remote: https://github.com/ruby/gem_rbs_collection.git
9
9
  repo_dir: gems
@@ -4,6 +4,6 @@ version: '3.9'
4
4
  source:
5
5
  type: git
6
6
  name: ruby/gem_rbs_collection
7
- revision: 0a6ea105a0afc7eaee4494585a7775f47eea6145
7
+ revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
8
8
  remote: https://github.com/ruby/gem_rbs_collection.git
9
9
  repo_dir: gems
@@ -4,6 +4,6 @@ version: '1.20'
4
4
  source:
5
5
  type: git
6
6
  name: ruby/gem_rbs_collection
7
- revision: 0a6ea105a0afc7eaee4494585a7775f47eea6145
7
+ revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
8
8
  remote: https://github.com/ruby/gem_rbs_collection.git
9
9
  repo_dir: gems
@@ -4,6 +4,6 @@ version: '3.2'
4
4
  source:
5
5
  type: git
6
6
  name: ruby/gem_rbs_collection
7
- revision: 0a6ea105a0afc7eaee4494585a7775f47eea6145
7
+ revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
8
8
  remote: https://github.com/ruby/gem_rbs_collection.git
9
9
  repo_dir: gems
@@ -4,6 +4,6 @@ version: '3.0'
4
4
  source:
5
5
  type: git
6
6
  name: ruby/gem_rbs_collection
7
- revision: 0a6ea105a0afc7eaee4494585a7775f47eea6145
7
+ revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
8
8
  remote: https://github.com/ruby/gem_rbs_collection.git
9
9
  repo_dir: gems
@@ -4,6 +4,6 @@ version: '13.0'
4
4
  source:
5
5
  type: git
6
6
  name: ruby/gem_rbs_collection
7
- revision: 0a6ea105a0afc7eaee4494585a7775f47eea6145
7
+ revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
8
8
  remote: https://github.com/ruby/gem_rbs_collection.git
9
9
  repo_dir: gems
@@ -4,6 +4,6 @@ version: '2.8'
4
4
  source:
5
5
  type: git
6
6
  name: ruby/gem_rbs_collection
7
- revision: 0a6ea105a0afc7eaee4494585a7775f47eea6145
7
+ revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
8
8
  remote: https://github.com/ruby/gem_rbs_collection.git
9
9
  repo_dir: gems
@@ -4,6 +4,6 @@ version: '1.57'
4
4
  source:
5
5
  type: git
6
6
  name: ruby/gem_rbs_collection
7
- revision: 0a6ea105a0afc7eaee4494585a7775f47eea6145
7
+ revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
8
8
  remote: https://github.com/ruby/gem_rbs_collection.git
9
9
  repo_dir: gems
@@ -4,6 +4,6 @@ version: '1.30'
4
4
  source:
5
5
  type: git
6
6
  name: ruby/gem_rbs_collection
7
- revision: 0a6ea105a0afc7eaee4494585a7775f47eea6145
7
+ revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
8
8
  remote: https://github.com/ruby/gem_rbs_collection.git
9
9
  repo_dir: gems
@@ -4,6 +4,6 @@ version: '2.0'
4
4
  source:
5
5
  type: git
6
6
  name: ruby/gem_rbs_collection
7
- revision: 0a6ea105a0afc7eaee4494585a7775f47eea6145
7
+ revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
8
8
  remote: https://github.com/ruby/gem_rbs_collection.git
9
9
  repo_dir: gems
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "net/http"
4
+
3
5
  module RubySky
4
6
  module Raw # :nodoc:
5
7
  class Client # :nodoc:
@@ -74,6 +76,9 @@ module RubySky
74
76
  createdAt: created_at
75
77
  } # : Hash[Symbol, untyped]
76
78
 
79
+ facets = parse_facets(text:)
80
+
81
+ record[:facets] = facets unless facets.empty?
77
82
  record[:embed] = embed if embed
78
83
 
79
84
  res = send_post(pds: @pds, path: CREATE_RECORD_PATH,
@@ -127,6 +132,36 @@ module RubySky
127
132
  json = JSON.parse(res.body)
128
133
  @session = Session.from_hash(json)
129
134
  end
135
+
136
+ def parse_facets(text:)
137
+ facets = [] # : Array[facet]
138
+ # parse_mentions もここでする必要が本当はあるよ。
139
+ facets += parse_uris(text:)
140
+ facets
141
+ end
142
+
143
+ def link_facet(start:, end:, uri:)
144
+ {
145
+ index: {
146
+ byteStart: start,
147
+ byteEnd: binding.local_variable_get(:end) # endは予約語
148
+ },
149
+ features: [
150
+ {
151
+ "$type": "app.bsky.richtext.facet#link",
152
+ uri:
153
+ }
154
+ ]
155
+ }
156
+ end
157
+
158
+ def parse_uris(text:)
159
+ reg = URI::DEFAULT_PARSER.make_regexp(%w[http https])
160
+ text.gsub(reg).map do
161
+ m = Regexp.last_match
162
+ link_facet(start: m.begin(0), end: m.end(0), uri: m.to_s)
163
+ end
164
+ end
130
165
  end
131
166
  end
132
167
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubySky
4
- VERSION = "0.4.0"
4
+ VERSION = "0.5.0"
5
5
  end
@@ -6,7 +6,7 @@ gems:
6
6
  source:
7
7
  type: git
8
8
  name: ruby/gem_rbs_collection
9
- revision: 0a6ea105a0afc7eaee4494585a7775f47eea6145
9
+ revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
10
10
  remote: https://github.com/ruby/gem_rbs_collection.git
11
11
  repo_dir: gems
12
12
  - name: ast
@@ -14,7 +14,7 @@ gems:
14
14
  source:
15
15
  type: git
16
16
  name: ruby/gem_rbs_collection
17
- revision: 0a6ea105a0afc7eaee4494585a7775f47eea6145
17
+ revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
18
18
  remote: https://github.com/ruby/gem_rbs_collection.git
19
19
  repo_dir: gems
20
20
  - name: base64
@@ -34,7 +34,7 @@ gems:
34
34
  source:
35
35
  type: git
36
36
  name: ruby/gem_rbs_collection
37
- revision: 0a6ea105a0afc7eaee4494585a7775f47eea6145
37
+ revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
38
38
  remote: https://github.com/ruby/gem_rbs_collection.git
39
39
  repo_dir: gems
40
40
  - name: connection_pool
@@ -42,7 +42,7 @@ gems:
42
42
  source:
43
43
  type: git
44
44
  name: ruby/gem_rbs_collection
45
- revision: 0a6ea105a0afc7eaee4494585a7775f47eea6145
45
+ revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
46
46
  remote: https://github.com/ruby/gem_rbs_collection.git
47
47
  repo_dir: gems
48
48
  - name: csv
@@ -58,17 +58,17 @@ gems:
58
58
  source:
59
59
  type: git
60
60
  name: ruby/gem_rbs_collection
61
- revision: 0a6ea105a0afc7eaee4494585a7775f47eea6145
61
+ revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
62
62
  remote: https://github.com/ruby/gem_rbs_collection.git
63
63
  repo_dir: gems
64
- - name: erb
64
+ - name: digest
65
65
  version: '0'
66
66
  source:
67
67
  type: stdlib
68
- - name: ffi
69
- version: 1.17.0
68
+ - name: erb
69
+ version: '0'
70
70
  source:
71
- type: rubygems
71
+ type: stdlib
72
72
  - name: fileutils
73
73
  version: '0'
74
74
  source:
@@ -82,7 +82,7 @@ gems:
82
82
  source:
83
83
  type: git
84
84
  name: ruby/gem_rbs_collection
85
- revision: 0a6ea105a0afc7eaee4494585a7775f47eea6145
85
+ revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
86
86
  remote: https://github.com/ruby/gem_rbs_collection.git
87
87
  repo_dir: gems
88
88
  - name: json
@@ -94,7 +94,7 @@ gems:
94
94
  source:
95
95
  type: git
96
96
  name: ruby/gem_rbs_collection
97
- revision: 0a6ea105a0afc7eaee4494585a7775f47eea6145
97
+ revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
98
98
  remote: https://github.com/ruby/gem_rbs_collection.git
99
99
  repo_dir: gems
100
100
  - name: logger
@@ -110,9 +110,9 @@ gems:
110
110
  source:
111
111
  type: stdlib
112
112
  - name: mutex_m
113
- version: '0'
113
+ version: 0.3.0
114
114
  source:
115
- type: stdlib
115
+ type: rubygems
116
116
  - name: openssl
117
117
  version: '0'
118
118
  source:
@@ -126,7 +126,7 @@ gems:
126
126
  source:
127
127
  type: git
128
128
  name: ruby/gem_rbs_collection
129
- revision: 0a6ea105a0afc7eaee4494585a7775f47eea6145
129
+ revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
130
130
  remote: https://github.com/ruby/gem_rbs_collection.git
131
131
  repo_dir: gems
132
132
  - name: parser
@@ -134,7 +134,7 @@ gems:
134
134
  source:
135
135
  type: git
136
136
  name: ruby/gem_rbs_collection
137
- revision: 0a6ea105a0afc7eaee4494585a7775f47eea6145
137
+ revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
138
138
  remote: https://github.com/ruby/gem_rbs_collection.git
139
139
  repo_dir: gems
140
140
  - name: pathname
@@ -146,7 +146,7 @@ gems:
146
146
  source:
147
147
  type: git
148
148
  name: ruby/gem_rbs_collection
149
- revision: 0a6ea105a0afc7eaee4494585a7775f47eea6145
149
+ revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
150
150
  remote: https://github.com/ruby/gem_rbs_collection.git
151
151
  repo_dir: gems
152
152
  - name: rake
@@ -154,11 +154,11 @@ gems:
154
154
  source:
155
155
  type: git
156
156
  name: ruby/gem_rbs_collection
157
- revision: 0a6ea105a0afc7eaee4494585a7775f47eea6145
157
+ revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
158
158
  remote: https://github.com/ruby/gem_rbs_collection.git
159
159
  repo_dir: gems
160
160
  - name: rbs
161
- version: 3.6.1
161
+ version: 3.8.0
162
162
  source:
163
163
  type: rubygems
164
164
  - name: rdoc
@@ -170,7 +170,7 @@ gems:
170
170
  source:
171
171
  type: git
172
172
  name: ruby/gem_rbs_collection
173
- revision: 0a6ea105a0afc7eaee4494585a7775f47eea6145
173
+ revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
174
174
  remote: https://github.com/ruby/gem_rbs_collection.git
175
175
  repo_dir: gems
176
176
  - name: rubocop
@@ -178,7 +178,7 @@ gems:
178
178
  source:
179
179
  type: git
180
180
  name: ruby/gem_rbs_collection
181
- revision: 0a6ea105a0afc7eaee4494585a7775f47eea6145
181
+ revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
182
182
  remote: https://github.com/ruby/gem_rbs_collection.git
183
183
  repo_dir: gems
184
184
  - name: rubocop-ast
@@ -186,7 +186,7 @@ gems:
186
186
  source:
187
187
  type: git
188
188
  name: ruby/gem_rbs_collection
189
- revision: 0a6ea105a0afc7eaee4494585a7775f47eea6145
189
+ revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
190
190
  remote: https://github.com/ruby/gem_rbs_collection.git
191
191
  repo_dir: gems
192
192
  - name: securerandom
@@ -201,6 +201,10 @@ gems:
201
201
  version: '0'
202
202
  source:
203
203
  type: stdlib
204
+ - name: stringio
205
+ version: '0'
206
+ source:
207
+ type: stdlib
204
208
  - name: strscan
205
209
  version: '0'
206
210
  source:
@@ -222,7 +226,7 @@ gems:
222
226
  source:
223
227
  type: git
224
228
  name: ruby/gem_rbs_collection
225
- revision: 0a6ea105a0afc7eaee4494585a7775f47eea6145
229
+ revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
226
230
  remote: https://github.com/ruby/gem_rbs_collection.git
227
231
  repo_dir: gems
228
232
  - name: uri
data/sig/rubysky.rbs CHANGED
@@ -8,7 +8,7 @@ module RubySky
8
8
  def self.from_app_jwt: (identifier: String, password: String, ?pds: String) -> Client
9
9
 
10
10
  def initialize: (client: Raw::Client) -> void
11
- def post: (text: String, images: Array[{data: IO, mime_type: String, ?alt: String}]) -> Post
11
+ def post: (text: String, ?images: Array[{data: IO, mime_type: String, ?alt: String}]) -> Post
12
12
  def refresh_jwt: () -> String
13
13
  def user_did: () -> Hash[String, untyped]
14
14
  def user_info: () -> Hash[String, untyped]
@@ -41,6 +41,7 @@ module RubySky
41
41
  POST_COLLECTION: String
42
42
 
43
43
  type embed = Raw::ImageEmbed
44
+ type facet = { index: { byteStart: Integer, byteEnd: Integer }, features: Array[Hash[Symbol, untyped]] }
44
45
 
45
46
  def self.from_refresh_jwt: (refresh_jwt: String, pds: String) -> Client
46
47
  def self.create_session: (pds: String, identifier: String, password: String) -> Client
@@ -55,6 +56,11 @@ module RubySky
55
56
 
56
57
  def valid_access_jwt?: () -> bool
57
58
 
59
+ def parse_facets: (text: String) -> Array[facet]
60
+ def parse_uris: (text: String) -> Array[facet]
61
+
62
+ def link_facet: (start: Integer, end: Integer, uri: String) -> facet
63
+
58
64
  attr_reader pds: String
59
65
  attr_reader session: Raw::Session
60
66
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubysky
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kugayama Nana
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-12-19 00:00:00.000000000 Z
10
+ date: 2024-12-26 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: jwt
@@ -107,7 +106,6 @@ metadata:
107
106
  source_code_uri: https://github.com/nota/rubysky
108
107
  changelog_uri: https://github.com/nota/simple_tweet/blob/main/CHANGELOG.md
109
108
  rubygems_mfa_required: 'true'
110
- post_install_message:
111
109
  rdoc_options: []
112
110
  require_paths:
113
111
  - lib
@@ -122,8 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
120
  - !ruby/object:Gem::Version
123
121
  version: '0'
124
122
  requirements: []
125
- rubygems_version: 3.5.22
126
- signing_key:
123
+ rubygems_version: 3.6.2
127
124
  specification_version: 4
128
125
  summary: BlueSky API Client
129
126
  test_files: []