apisync-rails 0.1.1 → 0.1.2
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 +4 -4
- data/README.md +9 -10
- data/lib/apisync/rails/model.rb +10 -8
- data/lib/apisync/rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e93409d7922bcdb80e2730e7c0b5cb0c3d4d742
|
4
|
+
data.tar.gz: 64742854d0a8c36263f5318bb73e71433f6bee83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f409dc9cb80cab5cbab1b3ca1ad6c79eccfe964c28cf81fc43a6823139b4646b35e19a79ff0fbce66232fc3a1673850673cbff093c7f4c02a27208902fef338b
|
7
|
+
data.tar.gz: d00e9310116b51fdddfd559ec2b98328506243f3581c55948418a38a91749862223f5df5ce52b77429208973c3990137bc4c95cc8bd8bb3d5272370cd1b60a11
|
data/README.md
CHANGED
@@ -46,12 +46,12 @@ class Product < ActiveRecord::Base
|
|
46
46
|
# remove it to always sync all items
|
47
47
|
sync_if :should_sync?
|
48
48
|
|
49
|
-
#
|
49
|
+
# Required attributes
|
50
50
|
attribute :ad_template_type, from: :category
|
51
51
|
attribute :available, from: :active?
|
52
52
|
attribute :content_language, value: "pt-br"
|
53
53
|
|
54
|
-
#
|
54
|
+
# Recommended attributes
|
55
55
|
attribute :brand, from: :manufacturer
|
56
56
|
attribute :condition, from: :normalize_condition
|
57
57
|
attribute :description
|
@@ -63,8 +63,8 @@ class Product < ActiveRecord::Base
|
|
63
63
|
attribute :title
|
64
64
|
attribute :year
|
65
65
|
|
66
|
-
#
|
67
|
-
custom_attribute :city,
|
66
|
+
# Custom attributes
|
67
|
+
custom_attribute :city, identifier: 'city-name', label: 'City name'
|
68
68
|
end
|
69
69
|
|
70
70
|
private
|
@@ -76,10 +76,10 @@ class Product < ActiveRecord::Base
|
|
76
76
|
# required format (see reference docs)
|
77
77
|
def images
|
78
78
|
[{
|
79
|
-
|
79
|
+
url: "https://page.com/image1.jpg",
|
80
80
|
order: 1
|
81
81
|
}, {
|
82
|
-
|
82
|
+
url: "https://page.com/image2.jpg",
|
83
83
|
order: 2
|
84
84
|
}]
|
85
85
|
end
|
@@ -92,10 +92,9 @@ class Product < ActiveRecord::Base
|
|
92
92
|
}
|
93
93
|
end
|
94
94
|
|
95
|
-
#
|
96
|
-
|
97
|
-
|
98
|
-
"Delivery city"
|
95
|
+
# Custom attribute
|
96
|
+
def city
|
97
|
+
self.address.city
|
99
98
|
end
|
100
99
|
end
|
101
100
|
```
|
data/lib/apisync/rails/model.rb
CHANGED
@@ -31,13 +31,14 @@ class Apisync
|
|
31
31
|
@attributes[attr_name] = { attr_name: attr_name, from: from, value: value }
|
32
32
|
end
|
33
33
|
|
34
|
-
def custom_attribute(attr_name, from: nil, value: nil,
|
34
|
+
def custom_attribute(attr_name, from: nil, value: nil, identifier: nil, label:)
|
35
35
|
@attributes[:custom_attributes] ||= []
|
36
36
|
@attributes[:custom_attributes] << {
|
37
37
|
attr_name: attr_name,
|
38
38
|
from: from,
|
39
39
|
value: value,
|
40
|
-
|
40
|
+
identifier: identifier,
|
41
|
+
label: label
|
41
42
|
}
|
42
43
|
end
|
43
44
|
|
@@ -91,14 +92,15 @@ class Apisync
|
|
91
92
|
if attr == :custom_attributes
|
92
93
|
custom_attrs = []
|
93
94
|
properties.each do |custom_attr|
|
94
|
-
from
|
95
|
-
value
|
96
|
-
attr_name
|
97
|
-
|
95
|
+
from = custom_attr[:from]
|
96
|
+
value = custom_attr[:value]
|
97
|
+
attr_name = custom_attr[:attr_name]
|
98
|
+
label = custom_attr[:label]
|
99
|
+
identifier = custom_attr[:identifier]
|
98
100
|
|
99
101
|
custom_attrs << {
|
100
|
-
|
101
|
-
identifier: attr_name.to_s,
|
102
|
+
label: label || localized_name(name),
|
103
|
+
identifier: identifier || attr_name.to_s,
|
102
104
|
value: attr_value(attr_name, from: from, value: value)
|
103
105
|
}
|
104
106
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apisync-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexandre de Oliveira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|