chilexpress_rails 0.0.4 → 0.1.1

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/chilexpress_rails.rb +5 -6
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bb782641b68d2116d559b6778b464278cb29dfd4
4
- data.tar.gz: 8dcd8aebd0370b019a59371ea6f0d43bcf85a4a8
3
+ metadata.gz: d7b97f99ed148abd9cf6b8dba52c279a78569e01
4
+ data.tar.gz: b53c218582a94c30ca05301bb06dad35feba1b5e
5
5
  SHA512:
6
- metadata.gz: 4ec8e8aa824bba6e0ffd8731a251942ba4e4cf3dd2d61ac9ab36640f28da0cecab2d2c19f71675001f5aecdab8bce304d50970c9e4c1bc5ab2bfe0b1f930c205
7
- data.tar.gz: 7bf94eb41acee3871ef605f3572bc152cfc81cf6a907041e8ccee3a14cc3201cdd1d3e29a0f46c24cbd16dc17e4b0ddae96697b1d2fed36bcb1a07b4857a0ddb
6
+ metadata.gz: 3ea661da19b527c0395316a19dcd060cc93d169c335d83b0e399a2b0e13c977d0154bc6169db4341c1426cbfdeaeb80b75ded69cd3950ad6f08ffec01f2f5c45
7
+ data.tar.gz: 298d5c737162a77bb30f0a5fe8e5fa64752465e97f6c81aa38b5132d57e98456069e81416203a035b52149816b0f56a6f8708cc6186c7b26d7242a00ee378dcf
@@ -7,16 +7,15 @@ module ChilexpressRails
7
7
  def self.search_order(tracking_number)
8
8
  url = "http://www.chilexpress.cl/Views/ChilexpressCL/Resultado-busqueda.aspx?DATA=#{tracking_number}"
9
9
  doc = Nokogiri::HTML(open(url))
10
- return 'No se obtuvo respuesta' if doc.css('.section-title')[0].text.include?('No hemos encontrado')
10
+ return "The order doesn't exist" if doc.css('.section-title')[0].text.include?('No hemos encontrado')
11
11
  attributes = shipping_info(doc).merge!(receiver_info(doc))
12
12
  Order.new(attributes)
13
13
  end
14
14
 
15
15
  def self.shipping_info(html_doc)
16
- puts html_doc.at_css('title').text
17
16
  widget_content = html_doc.css('.wigdet-content')
18
17
  li = widget_content[0].css('li')
19
- return 'El sitio web parece haber modificado su estructura' unless li
18
+ return "Website's structure has change" unless li
20
19
  {
21
20
  track_number: li[1].text.to_s.split(':')[1].strip.gsub(/\A\p{Space}*/, ''),
22
21
  product: li[2].text.to_s.split(':')[1].strip.gsub(/\A\p{Space}*/, ''),
@@ -24,13 +23,13 @@ module ChilexpressRails
24
23
  status: li[4].text.to_s.split(':')[1].strip.gsub(/\A\p{Space}*/, '')
25
24
  }
26
25
  rescue
27
- 'El sitio web parece haber modificado su estructura'
26
+ "Website's structure has change"
28
27
  end
29
28
 
30
29
  def self.receiver_info(html_doc)
31
30
  widget_content = html_doc.css('.wigdet-content')
32
31
  li = widget_content[1].css('li')
33
- return 'El sitio web parece haber modificado su estructura' unless li
32
+ return "Website's structure has change" unless li
34
33
  date = li[2].text.to_s.split(':')[1].strip.gsub(/\A\p{Space}*/, '')
35
34
  hour = " #{li[3].text.to_s.split(':')[1].strip.gsub(/\A\p{Space}*/, '')}:#{li[3].text.to_s.split(':')[2].strip.gsub(/\A\p{Space}*/, '')}"
36
35
  {
@@ -39,6 +38,6 @@ module ChilexpressRails
39
38
  receiver_name: li[4].text.to_s.split(':')[1].split(' ').first(2).join(' ').gsub(/\A\p{Space}*/, '')
40
39
  }
41
40
  rescue
42
- 'El sitio web parece haber modificado su estructura'
41
+ "Website's structure has change"
43
42
  end
44
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chilexpress_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zetahawke