pricebr_apple 0.2.5 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 57d4c2356cb91937c40dec2be91e57b209665499
4
- data.tar.gz: d1f62501bce8a477858ebbff2f3f6aad6a4a3bf4
3
+ metadata.gz: 56c9ba3d1389c1b63de72080843c1cf0d959cc9c
4
+ data.tar.gz: 19f369f1959cc41fa453f72e3b5deb3f7abd16bb
5
5
  SHA512:
6
- metadata.gz: d75faaba3ec94c38af1fd8fd29b85b07aef001a7e8f183dc57a9b99c4797edea285e4f24831ed69ef9aba3e2c49636dc89e415acf043b62a0816ec3935f5ec42
7
- data.tar.gz: a7abe2a6177c0b946a931b246e6aabfec17411d7ede990ce0dd43ff61d5491b28df461d2056afd8fbd2a451e74adc1d1f21237a3f94e509e85b4dea7e5671bf3
6
+ metadata.gz: 1c71a9562d0906d0535b1029d315fbced4c9ab13b54b9c2dce61769a0f80de46dbd0d73d0cb3797a5ffe03794aa59569465a68d87795e32cc0c201a9ce1f3494
7
+ data.tar.gz: 639a81820dbd32b48d84740b993eda638879795f5a5bb4644fa793587e85027c6294f9af6800d821b99d78bf9485695d9864be6eebad783efcb1e6b6bc4e5aee
data/.gitignore CHANGED
File without changes
data/.rspec CHANGED
File without changes
data/.ruby-gemset CHANGED
File without changes
data/.ruby-version CHANGED
File without changes
data/.travis.yml CHANGED
File without changes
data/Gemfile CHANGED
File without changes
data/LICENSE.txt CHANGED
File without changes
data/README.md CHANGED
@@ -22,7 +22,13 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- TODO: Write usage instructions here
25
+ Brazil Price
26
+
27
+ $ price = PricebrApple::PriceBR.new
28
+
29
+ Products list with prices
30
+
31
+ $ list = price.update_price
26
32
 
27
33
  ## Development
28
34
 
data/Rakefile CHANGED
File without changes
data/lib/pricebr_apple.rb CHANGED
@@ -1,4 +1,4 @@
1
- require "pricebr_apple/version"
1
+ require 'pricebr_apple/version'
2
2
  require 'nokogiri'
3
3
  require 'open-uri'
4
4
  require 'pry'
@@ -7,17 +7,20 @@ module PricebrApple
7
7
  # EUA
8
8
  # MacBook Pro : http://www.apple.com/shop/buy-mac/macbook-pro
9
9
  PRICE_URL = {
10
- "iPhone 6S" => "http://www.apple.com/br/shop/buy-iphone/iphone6s",
11
- "iPhone 6" => "http://www.apple.com/br/shop/buy-iphone/iphone6",
12
- "iPhone 5S" => "http://www.apple.com/br/shop/buy-iphone/iphone5s",
13
- "MacBook Pro" => "http://www.apple.com/br/shop/buy-mac/macbook-pro",
14
- "MacBook Air" => "http://www.apple.com/br/shop/buy-mac/macbook-air",
15
- "MacBook" => "http://www.apple.com/br/shop/buy-mac/macbook",
16
- "iMac" => "http://www.apple.com/br/shop/buy-mac/imac",
17
- "Watch Sport" => "http://www.apple.com/br/shop/buy-watch/apple-watch-sport",
18
- "Watch" => "http://www.apple.com/br/shop/buy-watch/apple-watch",
19
- "Watch Edition" => "http://www.apple.com/br/shop/buy-watch/apple-watch-edition",
20
- "Apple TV" => "http://www.apple.com/br/shop/buy-tv/apple-tv"
10
+ "IPHONE 6S" => "http://www.apple.com/br/shop/buy-iphone/iphone6s",
11
+ "IPHONE SE" => "http://www.apple.com/br/shop/buy-iphone/iphone-se",
12
+ "IPHONE 5S" => "http://www.apple.com/br/shop/buy-iphone/iphone5s",
13
+ "MACBOOK PRO" => "http://www.apple.com/br/shop/buy-mac/macbook-pro",
14
+ "MACBOOK AIR" => "http://www.apple.com/br/shop/buy-mac/macbook-air",
15
+ "MACBOOK" => "http://www.apple.com/br/shop/buy-mac/macbook",
16
+ "IMAC" => "http://www.apple.com/br/shop/buy-mac/imac",
17
+ "APPLE TV" => "http://www.apple.com/br/shop/buy-tv/apple-tv",
18
+ "IPAD PRO" => "http://www.apple.com/br/shop/buy-ipad/ipad-pro",
19
+ "IPAD AIR 2" => "http://www.apple.com/br/shop/buy-ipad/ipad-air-2",
20
+ "IPAD MINI 4" => "http://www.apple.com/br/shop/buy-ipad/ipad-mini-4",
21
+ "IPAD MINI 2" => "http://www.apple.com/br/shop/buy-ipad/ipad-mini-2",
22
+ "WATCH SERIES 1" => "http://www.apple.com/br/shop/buy-watch/apple-watch-series-1",
23
+ "WATCH" => "http://www.apple.com/br/shop/buy-watch/apple-watch",
21
24
  }
22
25
 
23
26
  class PriceBR
@@ -35,11 +38,12 @@ module PricebrApple
35
38
  end
36
39
  end
37
40
 
38
- # params {url_page: 'http://', partNumber: 'model'}
41
+ # params {url_page: 'device page', partNumber: 'model'}
39
42
  def get_price(params)
40
43
  @model = params[:partNumber]
41
- unless params[:url_page].nil? || @model.nil?
42
- @page = Nokogiri::HTML(open(params[:url_page]))
44
+ url_page = params[:url_page]
45
+ if !url_page.nil? && !@model.nil?
46
+ @page = Nokogiri::HTML(open(url_page))
43
47
  list_price = @page.css('.current_price')
44
48
  unless list_price.nil?
45
49
  list_price.map{|item| @price = item.children[1].children[3].children[0].text.gsub(' ', '').gsub("\nR$",'').gsub("\n",'').gsub('.','').gsub(',','.').to_f if !item.nil? && item.children[1].children[1].values[1].to_s == @model}
@@ -1,3 +1,3 @@
1
1
  module PricebrApple
2
- VERSION = "0.2.5"
2
+ VERSION = "0.5"
3
3
  end
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pricebr_apple
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: '0.5'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo Alencar
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-02 00:00:00.000000000 Z
11
+ date: 2016-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler