sequent 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2fce46d6a1e3cf678095978eef7e50640510f4d
|
4
|
+
data.tar.gz: 1da9ad9573f554a2fde4ccb45847a2c6102316fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 238fb123246feaaf104bd9e8cfee06241378c6d274a4c90cb88e761c3b6728277e5faef94f555c88cf5ef3c7b7abe8d86034d651a36d91d37eaa65bfaba65e3b
|
7
|
+
data.tar.gz: 5e3ac92286b6178c2147c301c3edc7db5a499f60e734886b2d9e39764a5a79cc7778205b5519a670e039a2fb9c2abbbe0ab739954c0e00c4786c11b5bdd91c3a
|
@@ -30,7 +30,13 @@ module Sequent
|
|
30
30
|
if type.respond_to? :from_params
|
31
31
|
value = type.from_params(value)
|
32
32
|
elsif type.is_a? Sequent::Core::Helpers::ArrayWithType
|
33
|
-
value = value.map
|
33
|
+
value = value.map do |v|
|
34
|
+
if type.item_type.respond_to?(:from_params)
|
35
|
+
type.item_type.from_params(v)
|
36
|
+
else
|
37
|
+
v
|
38
|
+
end
|
39
|
+
end
|
34
40
|
end
|
35
41
|
instance_variable_set(:"@#{attribute}", value)
|
36
42
|
end
|
@@ -45,36 +51,54 @@ module Sequent
|
|
45
51
|
self.class.types.each do |field|
|
46
52
|
value = self.instance_variable_get("@#{field[0]}")
|
47
53
|
next if field[0] == "errors"
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
elsif value.is_a? Date
|
55
|
-
value = value.strftime("%d-%m-%Y") # TODO Remove to TypeConverter
|
56
|
-
end
|
57
|
-
hash[field[0]] = value
|
54
|
+
hash[field[0]] = if value.kind_of?(Array)
|
55
|
+
next if value.blank?
|
56
|
+
value.map{|v|value_to_string(v)}
|
57
|
+
else
|
58
|
+
value_to_string(value)
|
59
|
+
end
|
58
60
|
end
|
59
61
|
hash
|
60
62
|
end
|
61
63
|
|
62
64
|
private
|
63
|
-
|
64
|
-
|
65
|
+
|
66
|
+
def value_to_string(val)
|
67
|
+
if val.is_a?(Sequent::Core::ValueObject)
|
68
|
+
val.as_params
|
69
|
+
elsif val.is_a? DateTime
|
70
|
+
val.iso8601
|
71
|
+
elsif val.is_a? Date
|
72
|
+
val.strftime("%d-%m-%Y")
|
73
|
+
else
|
74
|
+
val
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def make_params(root, hash, memo = {})
|
65
79
|
hash.each do |k, v|
|
66
80
|
key = "#{root}[#{k}]"
|
67
81
|
if v.is_a? Hash
|
68
|
-
make_params(key, v
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
82
|
+
make_params(key, v, memo)
|
83
|
+
elsif v.is_a?(Array) && v.first.is_a?(Hash)
|
84
|
+
key = "#{key}[]"
|
85
|
+
v.each { |value| make_params(key, value, memo) }
|
86
|
+
elsif v.is_a?(Array)
|
87
|
+
memo["#{key}[]"] = v
|
73
88
|
else
|
74
|
-
|
89
|
+
string_value = v.nil? ? "" : v.to_s
|
90
|
+
if memo.has_key?(key)
|
91
|
+
if memo[:key].is_a? Array
|
92
|
+
memo[key] << string_value
|
93
|
+
else
|
94
|
+
memo[key] = [memo[key], string_value]
|
95
|
+
end
|
96
|
+
else
|
97
|
+
memo[key] = string_value
|
98
|
+
end
|
75
99
|
end
|
76
100
|
end
|
77
|
-
|
101
|
+
memo
|
78
102
|
end
|
79
103
|
end
|
80
104
|
end
|
@@ -75,6 +75,7 @@ module Sequent
|
|
75
75
|
|
76
76
|
def create_record(record_class, values)
|
77
77
|
column_names = record_class.column_names
|
78
|
+
values = record_class.column_defaults.merge(values)
|
78
79
|
values.merge!(updated_at: values[:created_at]) if column_names.include?("updated_at")
|
79
80
|
struct_class_name = "#{record_class.to_s}Struct"
|
80
81
|
if self.class.struct_cache.has_key?(struct_class_name)
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Sequent
|
2
|
+
module Test
|
3
|
+
module DateTimePatches
|
4
|
+
module Normalize
|
5
|
+
def normalize
|
6
|
+
in_time_zone("UTC")
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
module Compare
|
11
|
+
alias_method :'___<=>', :<=>
|
12
|
+
|
13
|
+
# omit nsec in datetime comparisons
|
14
|
+
def <=>(other)
|
15
|
+
if other && other.is_a?(DateTimePatches::Normalize)
|
16
|
+
result = normalize.iso8601 <=> other.normalize.iso8601
|
17
|
+
return result unless result == 0
|
18
|
+
# use usec here, which *truncates* the nsec (ie. like Postgres)
|
19
|
+
return normalize.usec <=> other.normalize.usec
|
20
|
+
end
|
21
|
+
public_send(:'___<=>', other)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class Time
|
29
|
+
prepend Sequent::Test::DateTimePatches::Normalize
|
30
|
+
prepend Sequent::Test::DateTimePatches::Compare
|
31
|
+
end
|
32
|
+
|
33
|
+
class DateTime
|
34
|
+
prepend Sequent::Test::DateTimePatches::Normalize
|
35
|
+
prepend Sequent::Test::DateTimePatches::Compare
|
36
|
+
end
|
37
|
+
|
38
|
+
class ActiveSupport::TimeWithZone
|
39
|
+
prepend Sequent::Test::DateTimePatches::Normalize
|
40
|
+
end
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lars Vonk
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-09-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -213,6 +213,7 @@ files:
|
|
213
213
|
- lib/sequent/test/command_handler_helpers.rb
|
214
214
|
- lib/sequent/test/event_handler_helpers.rb
|
215
215
|
- lib/sequent/test/event_stream_helpers.rb
|
216
|
+
- lib/sequent/test/time_comparison.rb
|
216
217
|
- lib/version.rb
|
217
218
|
homepage: https://github.com/zilverline/sequent
|
218
219
|
licenses:
|