motion-yaml 1.4.6 → 1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/YAMLKit/libYAMLKit_OSX.a +0 -0
- data/lib/YAMLKit/libYAMLKit_iOS.a +0 -0
- data/lib/project/scanner.rb +32 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3edda00f9eb55537a0f5cf71a03c7556372995ba
|
4
|
+
data.tar.gz: f58d2501ae71cd243148cccca72340621fb6bbf4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a51f7fd60f44e9b9de393fca9ce74456e1875002c3ab6a0efe039a7058e6e78e80bdcc3ab04023b6d9e2ae70218621db6b011bc62e4b3649bd6739c6a0bf13f3
|
7
|
+
data.tar.gz: f280cff468f089dd803c118ffe53903f3be82a43eb7882d859da744648d8ca7686b3918c0ae024ad2d87cc0e3cab45e56d7cbeb5d0761ccfe7521df06951eecf
|
Binary file
|
Binary file
|
data/lib/project/scanner.rb
CHANGED
@@ -22,7 +22,11 @@
|
|
22
22
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
23
23
|
# POSSIBILITY OF SUCH DAMAGE.
|
24
24
|
|
25
|
+
# Special thanks to https://github.com/tenderlove/psych
|
25
26
|
class YAMLKitScanner
|
27
|
+
# http://yaml.org/type/timestamp.html
|
28
|
+
TIME = /^-?\d{4}-\d{1,2}-\d{1,2}(?:[Tt]|\s+)\d{1,2}:\d\d:\d\d(?:\.\d*)?(?:\s*(?:Z|[-+]\d{1,2}:?(?:\d\d)?))?$/
|
29
|
+
|
26
30
|
# http://yaml.org/type/float.html
|
27
31
|
FLOAT = /^(?:[-+]?([0-9][0-9_,]*)?\.[0-9]*([eE][-+][0-9]+)?(?# base 10)
|
28
32
|
|[-+]?[0-9][0-9_,]*(:[0-5]?[0-9])+\.[0-9_]*(?# base 60)
|
@@ -57,6 +61,8 @@ class YAMLKitScanner
|
|
57
61
|
Integer(string.gsub(/_/, ''))
|
58
62
|
when FLOAT
|
59
63
|
Float(string.gsub(/_/, ''))
|
64
|
+
when TIME
|
65
|
+
self.parse_time(string)
|
60
66
|
when /^(yes|y|true|on)$/i
|
61
67
|
true
|
62
68
|
when /^(no|n|false|off)$/i
|
@@ -65,4 +71,30 @@ class YAMLKitScanner
|
|
65
71
|
nil
|
66
72
|
end
|
67
73
|
end
|
74
|
+
|
75
|
+
def self.parse_time string
|
76
|
+
date, time = *(string.split(/[ tT]/, 2))
|
77
|
+
(yy, m, dd) = date.match(/^(-?\d{4})-(\d{1,2})-(\d{1,2})/).captures.map { |x| x.to_i }
|
78
|
+
md = time.match(/(\d+:\d+:\d+)(?:\.(\d*))?\s*(Z|[-+]\d+(:\d\d)?)?/)
|
79
|
+
|
80
|
+
(hh, mm, ss) = md[1].split(':').map { |x| x.to_i }
|
81
|
+
us = (md[2] ? Rational("0.#{md[2]}") : 0) * 1000000
|
82
|
+
|
83
|
+
time = Time.utc(yy, m, dd, hh, mm, ss, us)
|
84
|
+
|
85
|
+
return time if 'Z' == md[3]
|
86
|
+
return Time.at(time.to_i, us) unless md[3]
|
87
|
+
|
88
|
+
tz = md[3].match(/^([+\-]?\d{1,2})\:?(\d{1,2})?$/)[1..-1].compact.map { |digit| Integer(digit, 10) }
|
89
|
+
offset = tz.first * 3600
|
90
|
+
|
91
|
+
if offset < 0
|
92
|
+
offset -= ((tz[1] || 0) * 60)
|
93
|
+
else
|
94
|
+
offset += ((tz[1] || 0) * 60)
|
95
|
+
end
|
96
|
+
|
97
|
+
Time.at((time - offset).to_i, us)
|
98
|
+
end
|
99
|
+
|
68
100
|
end
|