glue_gun_dsl 0.1.3 → 0.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/glue_gun/types/date_time_type.rb +26 -0
- data/lib/glue_gun/types/date_type.rb +26 -0
- data/lib/glue_gun/types.rb +8 -2
- data/lib/glue_gun/version.rb +1 -1
- data/lib/glue_gun.rb +1 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1f17db06be196fb63b2941e0ba636af749f6ccbff64bf4032311b05db781739
|
4
|
+
data.tar.gz: e240a34a00b9417f5051a100daa614d14df500c15ccd805e60be0c4410d6aca2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74168264b965a8bc8174d638a9151d87669cdb004d548c08261b231dc67e0101e4a67f6a85d7025e82f5c47c04a8b9dc7fa6bf7a71f6857a2a96e3d0455ff1bd
|
7
|
+
data.tar.gz: fd61db3f0571df81e06c019a2da1f811145c3238201c0e0d4f3b6130d7faa11402322ba611f7cb0d2c4543ed84ea11bd402b8b0fd3789a859d24e39dd677d440
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module GlueGun
|
2
|
+
module Types
|
3
|
+
class DateTimeType < ActiveModel::Type::Value
|
4
|
+
def cast(value)
|
5
|
+
case value
|
6
|
+
when String
|
7
|
+
parse_string(value)
|
8
|
+
when Date, DateTime
|
9
|
+
value
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def serialize(value)
|
14
|
+
value.to_s
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def parse_string(value)
|
20
|
+
DateTime.parse(value).utc
|
21
|
+
rescue ArgumentError
|
22
|
+
nil
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module GlueGun
|
2
|
+
module Types
|
3
|
+
class DateType < ActiveModel::Type::Value
|
4
|
+
def cast(value)
|
5
|
+
case value
|
6
|
+
when String
|
7
|
+
parse_string(value).to_date
|
8
|
+
when Date, DateTime
|
9
|
+
value.to_date
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def serialize(value)
|
14
|
+
value.to_s
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def parse_string(value)
|
20
|
+
DateTime.parse(value).utc
|
21
|
+
rescue ArgumentError
|
22
|
+
nil
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/glue_gun/types.rb
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
module GlueGun
|
2
2
|
module Types
|
3
|
-
require_relative "
|
3
|
+
require_relative "types/hash_type"
|
4
4
|
ActiveModel::Type.register(:hash, GlueGun::Types::HashType)
|
5
5
|
|
6
|
-
require_relative "
|
6
|
+
require_relative "types/array_type"
|
7
7
|
ActiveModel::Type.register(:array, GlueGun::Types::ArrayType)
|
8
|
+
|
9
|
+
require_relative "types/date_type"
|
10
|
+
ActiveModel::Type.register(:date, GlueGun::Types::DateType)
|
11
|
+
|
12
|
+
require_relative "types/date_time_type"
|
13
|
+
ActiveModel::Type.register(:datetime, GlueGun::Types::DateTimeType)
|
8
14
|
end
|
9
15
|
end
|
data/lib/glue_gun/version.rb
CHANGED
data/lib/glue_gun.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glue_gun_dsl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brett Shollenberger
|
@@ -131,6 +131,8 @@ files:
|
|
131
131
|
- lib/glue_gun/dsl.rb
|
132
132
|
- lib/glue_gun/types.rb
|
133
133
|
- lib/glue_gun/types/array_type.rb
|
134
|
+
- lib/glue_gun/types/date_time_type.rb
|
135
|
+
- lib/glue_gun/types/date_type.rb
|
134
136
|
- lib/glue_gun/types/hash_type.rb
|
135
137
|
- lib/glue_gun/version.rb
|
136
138
|
homepage: https://github.com/brettshollenberger/glue_gun
|