date_defaulter 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/date_defaulter.rb +50 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5efa6b20a9814ec626bd39194a0240b43080012a4da4e4a0cd858a6cd25ea267
|
4
|
+
data.tar.gz: 551163c04906c93eb71249ad207ce26365e99e0b94d1302beafc29581b934a2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 636f3bcee83dd99c87f2004b64a17e8a3a376b10c9fb81e5452d6a7258ca323d38d531fe4e8aa89fe7bb319c96c13aee81ed1da496fa5494e2a6b10822d4a1df
|
7
|
+
data.tar.gz: 5750ced241f5ab9d020dae39d58a0f81e3898993b25f18453af7758e4a6011d08ac81ae15031ea6c1c88c138ed02a064e2b6b082ba05b1105f10374381cd7946
|
data/lib/date_defaulter.rb
CHANGED
@@ -1,7 +1,56 @@
|
|
1
1
|
require 'date'
|
2
2
|
|
3
|
+
module DateDefaulter
|
4
|
+
@@config = {}
|
5
|
+
|
6
|
+
class Configuration
|
7
|
+
@@instance = Configuration.new
|
8
|
+
|
9
|
+
attr_accessor :format
|
10
|
+
|
11
|
+
private_class_method :new
|
12
|
+
|
13
|
+
def self.instance
|
14
|
+
@@instance
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
module_function
|
19
|
+
|
20
|
+
def configuration
|
21
|
+
Configuration.instance.tap do |configuration|
|
22
|
+
yield configuration if block_given?
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def format
|
27
|
+
configuration.format
|
28
|
+
end
|
29
|
+
|
30
|
+
def format=(format)
|
31
|
+
configuration.format = format
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
3
35
|
class Date
|
36
|
+
alias_method :date_defaulter_strftime, :strftime
|
37
|
+
alias_method :date_defaulter_to_s, :to_s
|
38
|
+
|
4
39
|
def to_s
|
5
|
-
|
40
|
+
if DateDefaulter.format.nil?
|
41
|
+
date_defaulter_to_s
|
42
|
+
else
|
43
|
+
strftime(DateDefaulter.format)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def strftime(*args)
|
48
|
+
return date_defaulter_strftime(*args) if args.any?
|
49
|
+
|
50
|
+
if DateDefaulter.format.nil?
|
51
|
+
date_defaulter_strftime
|
52
|
+
else
|
53
|
+
date_defaulter_strftime(DateDefaulter.format)
|
54
|
+
end
|
6
55
|
end
|
7
56
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: date_defaulter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shkumbin Delija
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-02-
|
11
|
+
date: 2023-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -17,9 +17,10 @@ extensions: []
|
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
19
|
- lib/date_defaulter.rb
|
20
|
-
homepage:
|
20
|
+
homepage: https://github.com/ShkumbinDelija/date_defaulter
|
21
21
|
licenses: []
|
22
|
-
metadata:
|
22
|
+
metadata:
|
23
|
+
source_code_uri: https://github.com/ShkumbinDelija/date_defaulter
|
23
24
|
post_install_message:
|
24
25
|
rdoc_options: []
|
25
26
|
require_paths:
|