lite-ruby 1.0.14 → 1.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/Gemfile.lock +1 -1
- data/lib/lite/ruby/array.rb +221 -219
- data/lib/lite/ruby/boolean.rb +18 -16
- data/lib/lite/ruby/date.rb +18 -16
- data/lib/lite/ruby/enumerable.rb +169 -167
- data/lib/lite/ruby/hash.rb +309 -307
- data/lib/lite/ruby/helpers/date_helper.rb +97 -95
- data/lib/lite/ruby/helpers/time_helper.rb +79 -77
- data/lib/lite/ruby/integer.rb +57 -55
- data/lib/lite/ruby/kernel.rb +21 -19
- data/lib/lite/ruby/numeric.rb +189 -187
- data/lib/lite/ruby/object.rb +138 -136
- data/lib/lite/ruby/open_struct.rb +30 -28
- data/lib/lite/ruby/range.rb +23 -21
- data/lib/lite/ruby/string.rb +495 -493
- data/lib/lite/ruby/struct.rb +15 -13
- data/lib/lite/ruby/time.rb +27 -25
- data/lib/lite/ruby/version.rb +1 -1
- metadata +1 -1
data/lib/lite/ruby/struct.rb
CHANGED
@@ -1,21 +1,23 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
|
3
|
-
|
3
|
+
if Lite::Ruby.configuration.monkey_patches.include?('struct')
|
4
|
+
class Struct
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
6
|
+
def [](key)
|
7
|
+
send(key)
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
def []=(key, val)
|
11
|
+
send("#{key}=", val)
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
def attributes
|
15
|
+
each_pair.with_object({}) { |(key, val), hash| hash[key] = val }
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
def replace(args)
|
19
|
+
args.each_pair { |key, val| send("#{key}=", val) }
|
20
|
+
end
|
20
21
|
|
22
|
+
end
|
21
23
|
end
|
data/lib/lite/ruby/time.rb
CHANGED
@@ -1,40 +1,42 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
if Lite::Ruby.configuration.monkey_patches.include?('time')
|
4
|
+
class Time
|
4
5
|
|
5
|
-
|
6
|
-
|
6
|
+
include Lite::Ruby::DateHelper
|
7
|
+
include Lite::Ruby::TimeHelper
|
7
8
|
|
8
|
-
|
9
|
+
class << self
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
def elapse(verbose: false)
|
12
|
+
started_at = now.to_f
|
13
|
+
yield
|
14
|
+
ended_at = now.to_f
|
15
|
+
runtime = ended_at - started_at
|
16
|
+
return runtime unless verbose
|
17
|
+
|
18
|
+
{ started_at: started_at, ended_at: ended_at, runtime: runtime }
|
19
|
+
end
|
16
20
|
|
17
|
-
{ started_at: started_at, ended_at: ended_at, runtime: runtime }
|
18
21
|
end
|
19
22
|
|
20
|
-
|
23
|
+
private
|
21
24
|
|
22
|
-
|
25
|
+
def default_format
|
26
|
+
'year-month-day hour:minute'
|
27
|
+
end
|
23
28
|
|
24
|
-
|
25
|
-
|
26
|
-
|
29
|
+
def default_stamp
|
30
|
+
:datetime_iso
|
31
|
+
end
|
27
32
|
|
28
|
-
|
29
|
-
|
30
|
-
|
33
|
+
def format_for(key)
|
34
|
+
TIME_UNITS[key] || DATE_UNITS[key]
|
35
|
+
end
|
31
36
|
|
32
|
-
|
33
|
-
|
34
|
-
|
37
|
+
def stamp_for(key)
|
38
|
+
TIME_STAMPS[key] || DATE_STAMPS[key]
|
39
|
+
end
|
35
40
|
|
36
|
-
def stamp_for(key)
|
37
|
-
TIME_STAMPS[key] || DATE_STAMPS[key]
|
38
41
|
end
|
39
|
-
|
40
42
|
end
|
data/lib/lite/ruby/version.rb
CHANGED