pixar-ruby-extensions 1.11.1 → 1.13.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.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a63c902db12bba0b26953ee5e310ed409ac8790d4142f4a2e93112f52254ea83
|
|
4
|
+
data.tar.gz: 38197de21323ebcbecee7d390482a45f1bbe44caeaff4c21030cc2a1a0f61408
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2555c58e00f97631668d6f68adb52ac23ea109e199caf1e60fac1d0686af1c95aa0a1463a343ebd7e77fbb6b025e882ef0f8a4b73d7b269baa621a5e4e43ac3a
|
|
7
|
+
data.tar.gz: 06316dfb30b8b554233d6744192d24620d59aa59eed2044c59ab7ef03654726e243c20ddd61f43b3a39bb507e9840ad980c9a9109f0994bb83606ec61c5b7a67
|
|
@@ -180,6 +180,24 @@ module PixarRubyExtensions
|
|
|
180
180
|
"#{hsize} #{unit}"
|
|
181
181
|
end
|
|
182
182
|
|
|
183
|
+
# Taken from Rails...
|
|
184
|
+
#
|
|
185
|
+
# @return [String] The English ordinal version of the integer, e.g. 1 => '1st', 225 => '225th'
|
|
186
|
+
#############
|
|
187
|
+
def pix_ordinalize
|
|
188
|
+
# Handle 11th, 12th, 13th, etc.
|
|
189
|
+
if (11..13).include?(abs % 100)
|
|
190
|
+
"#{self}th"
|
|
191
|
+
else
|
|
192
|
+
case abs % 10
|
|
193
|
+
when 1 then "#{self}st"
|
|
194
|
+
when 2 then "#{self}nd"
|
|
195
|
+
when 3 then "#{self}rd"
|
|
196
|
+
else "#{self}th"
|
|
197
|
+
end
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
|
|
183
201
|
end # module
|
|
184
202
|
|
|
185
203
|
end # module
|
|
@@ -14,6 +14,9 @@ module PixarRubyExtensions
|
|
|
14
14
|
INTEGER_RE = /\A-?[0-9]+\Z/.freeze
|
|
15
15
|
FLOAT_RE = /\A-?[0-9]+\.[0-9]+\Z/.freeze
|
|
16
16
|
|
|
17
|
+
DELIM_PLACEHOLDER = '_DELIM_'
|
|
18
|
+
UUID_RE_STR = "\\A[a-f0-9]{8}#{DELIM_PLACEHOLDER}([a-f0-9]{4}#{DELIM_PLACEHOLDER}){3}[a-f0-9]{12}\\z"
|
|
19
|
+
|
|
17
20
|
# Does this string contain an integer?
|
|
18
21
|
# (i.e. it consists only of numeric digits,
|
|
19
22
|
# maybe with a dash in front)
|
|
@@ -21,10 +24,10 @@ module PixarRubyExtensions
|
|
|
21
24
|
# @return [Boolean]
|
|
22
25
|
#
|
|
23
26
|
def pix_integer?
|
|
24
|
-
|
|
27
|
+
INTEGER_RE.match? self
|
|
25
28
|
end
|
|
26
29
|
|
|
27
|
-
# Does this string contain a float?
|
|
30
|
+
# Does this string contain a simple float?
|
|
28
31
|
# (i.e. it consists only of numeric digits,
|
|
29
32
|
# maybe with a dash in front followed by one
|
|
30
33
|
# dot, followed by at least one more digit)
|
|
@@ -32,7 +35,7 @@ module PixarRubyExtensions
|
|
|
32
35
|
# @return [Boolean]
|
|
33
36
|
#
|
|
34
37
|
def pix_float?
|
|
35
|
-
|
|
38
|
+
FLOAT_RE.match? self
|
|
36
39
|
end
|
|
37
40
|
|
|
38
41
|
# is this some representation of a number?
|
|
@@ -45,6 +48,23 @@ module PixarRubyExtensions
|
|
|
45
48
|
false
|
|
46
49
|
end
|
|
47
50
|
|
|
51
|
+
# Is this string a UUID?
|
|
52
|
+
#
|
|
53
|
+
# Looks for the standard hyphenated form: 32 hexadecimal characters (0-9, a-f)
|
|
54
|
+
# and four hyphen delimiters in this pattern: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
|
55
|
+
#
|
|
56
|
+
# You can specify a different delimiter if needed.
|
|
57
|
+
#
|
|
58
|
+
# @param delimiter [String] the delimiter used in the UUID, default '-'
|
|
59
|
+
#
|
|
60
|
+
# @return [Boolean]
|
|
61
|
+
#
|
|
62
|
+
def pix_uuid?(delimiter = '-')
|
|
63
|
+
re_str = UUID_RE_STR.gsub DELIM_PLACEHOLDER, Regexp.escape(delimiter)
|
|
64
|
+
regex = Regexp.new re_str, 'i'
|
|
65
|
+
regex.match? self
|
|
66
|
+
end
|
|
67
|
+
|
|
48
68
|
end # module
|
|
49
69
|
|
|
50
70
|
end # module
|
|
@@ -39,8 +39,20 @@ module PixarRubyExtensions
|
|
|
39
39
|
strftime("%FT%T.#{pix_msec}%z")
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
# @param full_dayname [Boolean] The day name is the full version (strftime %A)
|
|
43
|
+
# instead of the default 3-letter short version (strftime %a)
|
|
44
|
+
# @return [String] The English ordinal weekday of the month:
|
|
45
|
+
# Time.now.ordinal_weekday => "2nd Wed"
|
|
46
|
+
#
|
|
47
|
+
def pix_ordinal_weekday(full_dayname: false)
|
|
48
|
+
require 'pixar_ruby_extensions/integer'
|
|
49
|
+
weeknum = (((day - 1) / 7) + 1)
|
|
50
|
+
dayname_format = full_dayname ? '%A' : '%a'
|
|
51
|
+
"#{weeknum.pix_ordinalize} #{strftime dayname_format}"
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end # Module Utils
|
|
43
55
|
|
|
44
|
-
end
|
|
56
|
+
end # Module
|
|
45
57
|
|
|
46
|
-
end
|
|
58
|
+
end # Module
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pixar-ruby-extensions
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.13.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chris Lasell
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-09-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: |
|
|
14
14
|
This gem contans extensions to the Ruby core and standard libraries which have been used in many
|