popular_deals 0.2.3 → 0.2.4

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: 8606c89f39a2dde9a6562a8b395da843d684d24a
4
- data.tar.gz: 27b736c61ad8b8b491c9623cd54d333fa69a3800
3
+ metadata.gz: d9b1e55dce42d84c2c166bf3936582e8e376b823
4
+ data.tar.gz: fd4f2ac9788661e3d0f29e3e87b42d5bb4f718cc
5
5
  SHA512:
6
- metadata.gz: 17a62dfb741a2872b7d8fcf3736336a41a38fe050280baea9b8154b0fd43ff287b6fac54cfe7cbcc22a4937fef2e7e04305f0a369ca80fb9ff7a1369e3fe0bec
7
- data.tar.gz: 2ef14362f7aaac16903f86a5d338c3a56a7f83c92974560d808f09c5aff4d47a3fa67a31ff1401e670a893d80c22bf2ca24c1367f1130f27b3ce5f600faf35d7
6
+ metadata.gz: 114017a976bd61d22cca180c6e8669f2f7aa65d4de1e38ed53420f1dbf2ff46a77773f69ee485d1cc46ffa3fe63e08d96cbb4e7db207eb44e37d1b5a0686e5a0
7
+ data.tar.gz: 6039c383d85eff38dc615f094de86f5f27236b4f167b71a98307dc79cb3333db2716a4a5a427ea9fe88267aa7986ca62bba5fbde2263d33cc4f594a71c3f6bff
@@ -1,7 +1,7 @@
1
1
  require 'open-uri'
2
2
  require 'nokogiri'
3
3
  require 'colorize'
4
- #gem 'popular_deals', '0.2.0', :require => 'popular_deals'
4
+
5
5
 
6
6
 
7
7
 
@@ -2,6 +2,7 @@
2
2
  class PopularDeals::CLI
3
3
 
4
4
  attr_accessor :product_url
5
+ #BROWSER=(/usr/local/bin/firefox-bin -new-tab '%s':/usr/local/bin/google-chrome-stable)
5
6
 
6
7
  def call
7
8
  list_deals
@@ -33,6 +34,7 @@ class PopularDeals::CLI
33
34
  puts "-----------------------------------------------------------------------------------------------------------"
34
35
  puts "Please see below details of deal no. #{input}".yellow.underline
35
36
  disply_deal(input, product_url)
37
+ #open_deal_in_browser
36
38
  elsif input == "list"
37
39
  list_deals
38
40
  elsif input == "exit"
@@ -44,6 +46,13 @@ class PopularDeals::CLI
44
46
  end
45
47
  end
46
48
 
49
+ # def open_deal_in_browser
50
+ # uri = "http://www.ruby-lang.org"
51
+ # Launchy.open( uri ) do |exception|
52
+ # puts "Attempted to open #{uri} and failed because #{exception}"
53
+ # end
54
+ # end
55
+
47
56
  def disply_deal(input, product_url)
48
57
  @deal = PopularDeals::NewDeals.deal_page(input, product_url)
49
58
  keys = @deal.keys
@@ -1,7 +1,7 @@
1
1
  class PopularDeals::NewDeals
2
2
 
3
3
 
4
- attr_accessor :title, :url, :deal_rating, :price, :posted, :name, :discription, :purchase
4
+ attr_accessor :title, :url, :deal_rating, :price, :posted, :name, :discription, :purchase, :purchase_link
5
5
 
6
6
  def self.new_deals
7
7
  self.scrap_deals
@@ -50,8 +50,14 @@ class PopularDeals::NewDeals
50
50
  data = doc.text.strip
51
51
  deal[:name] = doc.css("h1").text.strip
52
52
  deal[:discription] = doc.css(".textDescription").text.strip
53
- deal[:purchase] = doc.css("div.detailLeftColumn a.success").attribute("href").value
54
- deal
53
+ @purchase_link = nil
54
+ @purchase_link= doc.at_css("div.detailLeftColumn a.success").attr("href")
55
+ if @purchase_link.nil?
56
+ deal[:purchase] = @product_url
57
+ else
58
+ deal[:purchase] = @purchase_link
59
+ end
60
+ deal
55
61
  end
56
62
 
57
63
  end
@@ -1,3 +1,3 @@
1
1
  module PopularDeals
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
@@ -27,4 +27,5 @@ spec.add_development_dependency "bundler", "~> 1.14"
27
27
  spec.add_dependency "nokogiri"
28
28
  spec.add_dependency "colorize", '~> 0'
29
29
 
30
+
30
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: popular_deals
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - "'Hima Chitalia'"
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-04 00:00:00.000000000 Z
11
+ date: 2017-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler