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.
@@ -1,21 +1,23 @@
1
1
  # frozen_string_literal: false
2
2
 
3
- class Struct
3
+ if Lite::Ruby.configuration.monkey_patches.include?('struct')
4
+ class Struct
4
5
 
5
- def [](key)
6
- send(key)
7
- end
6
+ def [](key)
7
+ send(key)
8
+ end
8
9
 
9
- def []=(key, val)
10
- send("#{key}=", val)
11
- end
10
+ def []=(key, val)
11
+ send("#{key}=", val)
12
+ end
12
13
 
13
- def attributes
14
- each_pair.with_object({}) { |(key, val), hash| hash[key] = val }
15
- end
14
+ def attributes
15
+ each_pair.with_object({}) { |(key, val), hash| hash[key] = val }
16
+ end
16
17
 
17
- def replace(args)
18
- args.each_pair { |key, val| send("#{key}=", val) }
19
- end
18
+ def replace(args)
19
+ args.each_pair { |key, val| send("#{key}=", val) }
20
+ end
20
21
 
22
+ end
21
23
  end
@@ -1,40 +1,42 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Time
3
+ if Lite::Ruby.configuration.monkey_patches.include?('time')
4
+ class Time
4
5
 
5
- include Lite::Ruby::DateHelper
6
- include Lite::Ruby::TimeHelper
6
+ include Lite::Ruby::DateHelper
7
+ include Lite::Ruby::TimeHelper
7
8
 
8
- class << self
9
+ class << self
9
10
 
10
- def elapse(verbose: false)
11
- started_at = now.to_f
12
- yield
13
- ended_at = now.to_f
14
- runtime = ended_at - started_at
15
- return runtime unless verbose
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
- end
23
+ private
21
24
 
22
- private
25
+ def default_format
26
+ 'year-month-day hour:minute'
27
+ end
23
28
 
24
- def default_format
25
- 'year-month-day hour:minute'
26
- end
29
+ def default_stamp
30
+ :datetime_iso
31
+ end
27
32
 
28
- def default_stamp
29
- :datetime_iso
30
- end
33
+ def format_for(key)
34
+ TIME_UNITS[key] || DATE_UNITS[key]
35
+ end
31
36
 
32
- def format_for(key)
33
- TIME_UNITS[key] || DATE_UNITS[key]
34
- end
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
@@ -3,7 +3,7 @@
3
3
  module Lite
4
4
  module Ruby
5
5
 
6
- VERSION ||= '1.0.14'
6
+ VERSION ||= '1.0.15'
7
7
 
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lite-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.14
4
+ version: 1.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez