konduto-ruby 2.0.0 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/konduto-ruby/associations/associations.rb +2 -4
- data/lib/konduto-ruby/attributes.rb +9 -1
- data/lib/konduto-ruby/konduto_base.rb +15 -1
- data/lib/konduto-ruby/konduto_delivery.rb +3 -0
- data/lib/konduto-ruby/{konduto_navigation_info.rb → konduto_navigation.rb} +1 -1
- data/lib/konduto-ruby/konduto_order.rb +3 -2
- data/lib/konduto-ruby/konduto_travel_leg.rb +1 -1
- data/lib/konduto-ruby/validations/class_methods.rb +11 -9
- data/lib/konduto-ruby/validations/validations.rb +1 -2
- data/lib/konduto-ruby.rb +3 -0
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ec1ca77129c269d4fde4b050cf435ea9ac0b0b32505c631677f49432bdf08f09
|
4
|
+
data.tar.gz: 1da2a417aa8806fbd456231f901a98a07f3080f4c1258aa74ff3434d9322570e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3db33a75125fa3849aebf4b7c8f10f3f76a19f323f983f8c1cf2de3f7e6fe9dd1975286c8a9b7cead9a034cfdb82698266cc0eb9b3a4faac219de203239ccea
|
7
|
+
data.tar.gz: c8ad6cebe2be3175652ddba10dca045da749825b3acb5caa0c081909febac638cb97e9814f17d107e60e5b71be82b9778a3a23158ce7f23b51067e3f87bd9f70
|
@@ -5,7 +5,7 @@ module Konduto
|
|
5
5
|
name = options[:alias] || model
|
6
6
|
|
7
7
|
self.send(:define_method, name) do
|
8
|
-
instance_variable_get("@#{name}")
|
8
|
+
instance_variable_get("@#{name}") if instance_variable_defined?("@#{name}")
|
9
9
|
end
|
10
10
|
|
11
11
|
self.send(:define_method, "#{name}=".to_sym) do |value|
|
@@ -25,9 +25,7 @@ module Konduto
|
|
25
25
|
name = options[:alias] || model
|
26
26
|
|
27
27
|
self.send(:define_method, name) do
|
28
|
-
|
29
|
-
|
30
|
-
instance_variable_get("@#{name}")
|
28
|
+
instance_variable_get("@#{name}") if instance_variable_defined?("@#{name}")
|
31
29
|
end
|
32
30
|
|
33
31
|
self.send(:define_method, "#{name}=".to_sym) do |arr|
|
@@ -6,6 +6,8 @@ module Konduto
|
|
6
6
|
klass = attribute.values[0].to_s.gsub(/_/, ' ').split.map(&:capitalize).join('')
|
7
7
|
type = Object::const_get(klass)
|
8
8
|
name = attribute.keys[0]
|
9
|
+
|
10
|
+
define_strftime_pattern(self, name, attribute[:strftime_pattern]) if attribute.has_key?(:strftime_pattern)
|
9
11
|
else
|
10
12
|
name = attribute
|
11
13
|
end
|
@@ -22,11 +24,17 @@ module Konduto
|
|
22
24
|
end
|
23
25
|
|
24
26
|
self.send(:define_method, name) do
|
25
|
-
instance_variable_get("@#{name.to_s.gsub(/[?|!]$/, '')}")
|
27
|
+
instance_variable_get("@#{name.to_s.gsub(/[?|!]$/, '')}") if instance_variable_defined?("@#{name.to_s.gsub(/[?|!]$/, '')}")
|
26
28
|
end
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
30
32
|
alias :attribute :attributes
|
33
|
+
|
34
|
+
def define_strftime_pattern(klass, name, value)
|
35
|
+
klass.send(:define_method, "#{name.to_s.gsub(/[?|!]$/, '')}_strftime_pattern") do
|
36
|
+
value
|
37
|
+
end
|
38
|
+
end
|
31
39
|
end
|
32
40
|
end
|
@@ -28,11 +28,17 @@ class KondutoBase
|
|
28
28
|
instance_variables.map do |name|
|
29
29
|
value = instance_variable_get(name)
|
30
30
|
|
31
|
+
strftime_pattern = defined_strftime_pattern(name) if defined_strftime_pattern?(name)
|
32
|
+
|
31
33
|
if value.respond_to? :each
|
32
34
|
value = value.map {|v| v.to_hash }
|
33
35
|
elsif !value.instance_variables.empty?
|
34
36
|
value = value.to_hash
|
35
|
-
elsif value.is_a?(
|
37
|
+
elsif value.is_a?(DateTime)
|
38
|
+
value = value.strftime(strftime_pattern || '%Y-%m-%dT%H:%MZ')
|
39
|
+
elsif value.is_a?(Date)
|
40
|
+
value = value.strftime(strftime_pattern || '%Y-%m-%d')
|
41
|
+
elsif value.is_a?(Symbol)
|
36
42
|
value = value.to_s
|
37
43
|
end
|
38
44
|
|
@@ -53,4 +59,12 @@ class KondutoBase
|
|
53
59
|
|
54
60
|
true
|
55
61
|
end
|
62
|
+
|
63
|
+
def defined_strftime_pattern?(attr)
|
64
|
+
respond_to? "#{attr.to_s.gsub(/^@/, '')}_strftime_pattern"
|
65
|
+
end
|
66
|
+
|
67
|
+
def defined_strftime_pattern(attr)
|
68
|
+
send("#{attr.to_s.gsub(/^@/, '')}_strftime_pattern")
|
69
|
+
end
|
56
70
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class
|
1
|
+
class KondutoNavigation < KondutoBase
|
2
2
|
attributes :session_time, :referrer, :time_site_1d, :new_accounts_1d, :password_resets_1d, :sales_declined_1d,\
|
3
3
|
:sessions_1d, :time_since_last_sale, :time_site_7d, :time_per_page_7d, :new_accounts_7d, \
|
4
4
|
:password_resets_7d, :checkout_count_7d, :sales_declined_7d, :sessions_7d
|
@@ -10,12 +10,13 @@ class KondutoOrder < KondutoBase
|
|
10
10
|
has_one :device
|
11
11
|
has_one :geolocation
|
12
12
|
has_one :navigation
|
13
|
+
has_one :delivery
|
13
14
|
|
14
15
|
attributes :id, :visitor, :timestamp, :total_amount, :tax_amount, :currency, :installments,
|
15
16
|
:ip, :score, :analyze, :messages_exchanged, :shipping_amount
|
16
17
|
|
17
|
-
attribute first_message: :date_time
|
18
|
-
attribute purchased_at: :date_time
|
18
|
+
attribute first_message: :date_time, strftime_pattern: '%Y-%m-%dT%H:%M:%SZ'
|
19
|
+
attribute purchased_at: :date_time, strftime_pattern: '%Y-%m-%dT%H:%M:%SZ'
|
19
20
|
attribute status: :symbol
|
20
21
|
attribute recommendation: :symbol
|
21
22
|
|
@@ -1,14 +1,16 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
module Konduto
|
2
|
+
module ClassMethods
|
3
|
+
def validates_presence_of(*attributes)
|
4
|
+
self.send(:define_method, :required_attr) do
|
5
|
+
attributes
|
6
|
+
end
|
5
7
|
end
|
6
|
-
end
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
def validates(*attributes, &block)
|
10
|
+
if block_given?
|
11
|
+
self.send(:define_method, :custom_validations) do
|
12
|
+
{ Proc.new(&block) => attributes }
|
13
|
+
end
|
12
14
|
end
|
13
15
|
end
|
14
16
|
end
|
@@ -4,7 +4,7 @@ module Konduto
|
|
4
4
|
module Validations
|
5
5
|
def self.included(base)
|
6
6
|
base.class_eval do
|
7
|
-
extend ClassMethods
|
7
|
+
extend Konduto::ClassMethods
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
@@ -12,7 +12,6 @@ module Konduto
|
|
12
12
|
if respond_to? :required_attr
|
13
13
|
required_attr.each do |attr|
|
14
14
|
return false if send(attr).nil?
|
15
|
-
return false if send(attr).is_a?(Array) && send(attr).empty?
|
16
15
|
end
|
17
16
|
end
|
18
17
|
|
data/lib/konduto-ruby.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: konduto-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriel Custodio
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-02-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: factory_girl
|
@@ -40,12 +40,13 @@ files:
|
|
40
40
|
- lib/konduto-ruby/konduto_base.rb
|
41
41
|
- lib/konduto-ruby/konduto_bus_leg.rb
|
42
42
|
- lib/konduto-ruby/konduto_customer.rb
|
43
|
+
- lib/konduto-ruby/konduto_delivery.rb
|
43
44
|
- lib/konduto-ruby/konduto_device.rb
|
44
45
|
- lib/konduto-ruby/konduto_flight_leg.rb
|
45
46
|
- lib/konduto-ruby/konduto_geolocation.rb
|
46
47
|
- lib/konduto-ruby/konduto_item.rb
|
47
48
|
- lib/konduto-ruby/konduto_loyalty.rb
|
48
|
-
- lib/konduto-ruby/
|
49
|
+
- lib/konduto-ruby/konduto_navigation.rb
|
49
50
|
- lib/konduto-ruby/konduto_order.rb
|
50
51
|
- lib/konduto-ruby/konduto_order_status.rb
|
51
52
|
- lib/konduto-ruby/konduto_passenger.rb
|
@@ -76,10 +77,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
77
|
- !ruby/object:Gem::Version
|
77
78
|
version: '0'
|
78
79
|
requirements: []
|
79
|
-
|
80
|
-
rubygems_version: 2.5.1
|
80
|
+
rubygems_version: 3.0.8
|
81
81
|
signing_key:
|
82
82
|
specification_version: 4
|
83
|
-
summary:
|
84
|
-
use interface
|
83
|
+
summary: ''
|
85
84
|
test_files: []
|