mercadolibre_rails 0.3 → 0.5
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/MIT-LICENSE +0 -0
- data/README.md +0 -0
- data/Rakefile +0 -0
- data/app/assets/config/mercadolibre_rails_manifest.js +0 -0
- data/app/assets/javascripts/mercadolibre_rails/application.js +0 -0
- data/app/assets/stylesheets/mercadolibre_rails/application.css +0 -0
- data/app/controllers/mercadolibre_rails/application_controller.rb +0 -0
- data/app/helpers/mercadolibre_rails/application_helper.rb +0 -0
- data/app/jobs/mercadolibre_rails/application_job.rb +0 -0
- data/app/mailers/mercadolibre_rails/application_mailer.rb +0 -0
- data/app/models/mercadolibre_rails/application_record.rb +0 -0
- data/app/models/mercadolibre_rails/picture.rb +8 -0
- data/app/models/mercadolibre_rails/product.rb +8 -1
- data/app/models/mercadolibre_rails/seller.rb +9 -0
- data/app/models/mercadolibre_rails/site.rb +0 -0
- data/app/models/mercadolibre_rails/version.rb +0 -0
- data/app/models/paper_trail/version.rb +0 -0
- data/app/views/layouts/mercadolibre_rails/application.html.erb +0 -0
- data/config/routes.rb +0 -0
- data/db/migrate/20181003152541_create_mercadolibre_rails_sites.rb +0 -0
- data/db/migrate/20181004142438_create_mercadolibre_rails_products.rb +0 -0
- data/db/migrate/20181004143133_create_mercadolibre_rails_sellers.rb +0 -0
- data/db/migrate/20181004143244_add_site_to_products.rb +0 -0
- data/db/migrate/20181004150308_add_seller_to_mercadolibre_rails_products.rb +0 -0
- data/db/migrate/20181010142220_create_mercadolibre_rails_versions.rb +0 -0
- data/db/migrate/20181010142221_add_object_changes_to_mercadolibre_rails_versions.rb +0 -0
- data/db/migrate/20181012133312_create_mercadolibre_rails_pictures.rb +10 -0
- data/lib/mercadolibre_rails/engine.rb +0 -0
- data/lib/mercadolibre_rails/version.rb +1 -1
- data/lib/mercadolibre_rails.rb +0 -0
- data/lib/tasks/mercadolibre_rails_tasks.rake +0 -0
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4534f513781489dd5f68379a0e10e95370918f8376b2820de504329d16655f5
|
4
|
+
data.tar.gz: 5f0209ae2ed18ccd17b24c74e9681cef0e3d7705301d2bc5d7fa8c4b64008f8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ff935a2e2005a6f7b5d885fe79a60398b98a450eda2c30c5121d2883b62c87d19bd62b09b0fe3627aa088df82e3a164ab37470cca51a6489e3ec2e1fc643832
|
7
|
+
data.tar.gz: c312ccc37ca12ad892dbd1ee9bdb70a40debbab1910f36a916e039981377e175248abc23ca175b77fc0e0de29cceae6584e62f75413648e4e40af2d299a8904b
|
data/MIT-LICENSE
CHANGED
File without changes
|
data/README.md
CHANGED
File without changes
|
data/Rakefile
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -14,6 +14,7 @@ module MercadolibreRails
|
|
14
14
|
|
15
15
|
delegate :code, to: :site, prefix: true
|
16
16
|
after_create_commit :update_metadata
|
17
|
+
has_many :pictures, dependent: :destroy, class_name: 'MercadolibreRails::Picture'
|
17
18
|
|
18
19
|
def self.create_from(url:)
|
19
20
|
ml_id = MercadolibreApi::Products::Queries::GetID.run!(product_url: url)
|
@@ -25,14 +26,20 @@ module MercadolibreRails
|
|
25
26
|
mercadolibre_site.products.find_or_create_by!(mercadolibre_id: ml_id)
|
26
27
|
end
|
27
28
|
|
29
|
+
# rubocop:disable Metrics/AbcSize
|
28
30
|
def update_metadata
|
29
31
|
ml_product = MercadolibreApi::Products::Queries::Find.run!(product_id: mercadolibre_id)
|
30
|
-
ml_seller = Seller.find_or_create_by!(mercadolibre_id: ml_product[:seller_id])
|
32
|
+
ml_seller = MercadolibreRails::Seller.find_or_create_by!(mercadolibre_id: ml_product[:seller_id])
|
31
33
|
|
32
34
|
update!(seller: ml_seller, title: ml_product[:title], price: ml_product[:price],
|
33
35
|
currency_code: ml_product[:currency_id], sold_quantity: ml_product[:sold_quantity],
|
34
36
|
description: ml_product[:description], status: ml_product[:status],
|
35
37
|
latitude: ml_product.dig(:geolocation, :latitude), longitude: ml_product.dig(:geolocation, :longitude))
|
38
|
+
|
39
|
+
ml_product[:pictures].each do |picture|
|
40
|
+
MercadolibreRails::Picture.find_or_create_by!(url: picture[:url], product_id: id)
|
41
|
+
end
|
36
42
|
end
|
43
|
+
# rubocop:enable Metrics/AbcSize
|
37
44
|
end
|
38
45
|
end
|
@@ -1,5 +1,14 @@
|
|
1
|
+
require 'mercadolibre_api'
|
2
|
+
|
1
3
|
module MercadolibreRails
|
2
4
|
class Seller < ApplicationRecord
|
3
5
|
has_many :products, dependent: :destroy
|
6
|
+
|
7
|
+
def self.create_from(product_url:)
|
8
|
+
ml_product_id = MercadolibreApi::Products::Queries::GetID.run!(product_url: product_url)
|
9
|
+
ml_seller_id = MercadolibreApi::Sellers::Queries::GetID.run!(product_id: ml_product_id)
|
10
|
+
|
11
|
+
find_or_create_by!(mercadolibre_id: ml_seller_id)
|
12
|
+
end
|
4
13
|
end
|
5
14
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/config/routes.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class CreateMercadolibreRailsPictures < ActiveRecord::Migration[5.2]
|
2
|
+
def change
|
3
|
+
create_table :mercadolibre_rails_pictures do |t|
|
4
|
+
t.string :url, null: false, index: { unique: true }
|
5
|
+
t.references :product, index: true, foreign_key: { to_table: :mercadolibre_rails_products }
|
6
|
+
|
7
|
+
t.timestamps
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
File without changes
|
data/lib/mercadolibre_rails.rb
CHANGED
File without changes
|
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mercadolibre_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.5'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pablo Gonzaga
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mercadolibre_api
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.9'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
26
|
+
version: '0.9'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: paper_trail
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -168,6 +168,7 @@ files:
|
|
168
168
|
- app/jobs/mercadolibre_rails/application_job.rb
|
169
169
|
- app/mailers/mercadolibre_rails/application_mailer.rb
|
170
170
|
- app/models/mercadolibre_rails/application_record.rb
|
171
|
+
- app/models/mercadolibre_rails/picture.rb
|
171
172
|
- app/models/mercadolibre_rails/product.rb
|
172
173
|
- app/models/mercadolibre_rails/seller.rb
|
173
174
|
- app/models/mercadolibre_rails/site.rb
|
@@ -182,6 +183,7 @@ files:
|
|
182
183
|
- db/migrate/20181004150308_add_seller_to_mercadolibre_rails_products.rb
|
183
184
|
- db/migrate/20181010142220_create_mercadolibre_rails_versions.rb
|
184
185
|
- db/migrate/20181010142221_add_object_changes_to_mercadolibre_rails_versions.rb
|
186
|
+
- db/migrate/20181012133312_create_mercadolibre_rails_pictures.rb
|
185
187
|
- lib/mercadolibre_rails.rb
|
186
188
|
- lib/mercadolibre_rails/engine.rb
|
187
189
|
- lib/mercadolibre_rails/version.rb
|
@@ -206,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
206
208
|
version: '0'
|
207
209
|
requirements: []
|
208
210
|
rubyforge_project:
|
209
|
-
rubygems_version: 2.7.
|
211
|
+
rubygems_version: 2.7.6
|
210
212
|
signing_key:
|
211
213
|
specification_version: 4
|
212
214
|
summary: Library to integrate MercadolibreApi into a Rails Project.
|