tipsanity_merchant_extractor 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,3 @@
1
- ## v0.0.6
1
+ ## v0.0.7
2
2
 
3
3
  * initial release with amazon api derivatives.
@@ -1,7 +1,7 @@
1
1
  module TipsanityMerchantExtractor
2
2
  class AttributeExtractor
3
3
  extend UrlFormatter
4
- [Amazon, LinkShare, Rakuten, BestBuy, Cj].each do |merchant|
4
+ [Amazon, LinkShare, Rakuten, BestBuy, Cj, TigerDirect].each do |merchant|
5
5
  extend merchant
6
6
  end
7
7
 
@@ -31,6 +31,8 @@ module TipsanityMerchantExtractor
31
31
  RegisteredMerchantList::REGISTERED_MERCHANT[:cjunction][:bestbuy]
32
32
  when is_merchant_linkshare_rakuten?(merchant_url)
33
33
  RegisteredMerchantList::REGISTERED_MERCHANT[:linkshare][0][:rakuten]
34
+ when is_merchant_linkshare_tiger_direct?(merchant_url)
35
+ RegisteredMerchantList::REGISTERED_MERCHANT[:linkshare][1][:tiger_direct]
34
36
  else
35
37
  "this merchant is not registered merchant with our system. Please recommend us to affliate with us."
36
38
  # URI(merchant_url).host
@@ -55,6 +57,9 @@ module TipsanityMerchantExtractor
55
57
  when RegisteredMerchantList::REGISTERED_MERCHANT[:linkshare][0][:rakuten]
56
58
  find_product_rakuten @merchant_url, @options[:linkshare][:token], RegisteredMerchantList::REGISTERED_MERCHANT[:linkshare][0][:mid]
57
59
 
60
+ when RegisteredMerchantList::REGISTERED_MERCHANT[:linkshare][1][:tiger_direct]
61
+ find_product_tiger_direct @merchant_url, @options[:linkshare][:token], RegisteredMerchantList::REGISTERED_MERCHANT[:linkshare][1][:mid]
62
+
58
63
  else
59
64
  @product_name = nil
60
65
  @description = nil
@@ -25,6 +25,10 @@ module TipsanityMerchantExtractor
25
25
  capitalized_product_name = product_name.gsub(/\d/,'').split('-').delete_if{|x| x==""}.collect{|x| x.capitalize}[0..6].join(" ")
26
26
  return capitalized_product_name
27
27
  end
28
+ end
29
+ def provide_buy_url(token, mid, merchant_url)
30
+ buy_url = "http://getdeeplink.linksynergy.com/createcustomlink.shtml?token=#{token}&mid=#{mid}&murl=#{merchant_url}"
31
+ Nokogiri::HTML(open(buy_url)).search("p").text
28
32
  end
29
33
  end
30
34
  end
@@ -1,7 +1,7 @@
1
1
  module TipsanityMerchantExtractor
2
- # include LinkShare
3
2
 
4
3
  module Rakuten
4
+ include LinkShare
5
5
  def self.extended(base)
6
6
  if base == AttributeExtractor
7
7
  base.send :include, Rakuten
@@ -27,11 +27,10 @@ module TipsanityMerchantExtractor
27
27
  scraped_screen = Nokogiri::HTML(open(merchant_url))
28
28
  @product_name = scraped_screen.search('#AuthorArtistTitle_productTitle').first.text
29
29
  @description = scraped_screen.search('#divDescription').first.text
30
- @list_price = scraped_screen.search('#spanMainListPrice').first.text.gsub(/[$]/, "").to_f
31
30
  @final_price = scraped_screen.search('#spanMainTotalPrice').first.text.gsub(/[$]/, "").to_f
32
- @image_url = scraped_screen.search('#ImageVideo_ImageRepeater_ctl00_Image').first.attributes["src"].value
33
- buy_url = "http://getdeeplink.linksynergy.com/createcustomlink.shtml?token=#{token}&mid=#{mid}&murl=#{merchant_url}"
34
- @details_url = Nokogiri::HTML(open(buy_url)).search("p").text# it needs token to retrive buy url
31
+ @list_price = scraped_screen.search('#spanMainListPrice').first ? scraped_screen.search('#spanMainListPrice').first.text.gsub(/[$]/, "").to_f : @final_price
32
+ @image_url = scraped_screen.search(".holder-image .item.image img").first.attributes["src"].value
33
+ @details_url = provide_buy_url(token, mid, merchant_url)
35
34
  @categories = scraped_screen.search('#anchorSimilarProds').first.text
36
35
  @response_object = scraped_screen
37
36
  @product_token = skuid
@@ -12,7 +12,7 @@ module TipsanityMerchantExtractor
12
12
  mid: 36342
13
13
  },
14
14
  {
15
- tigerdirect: "www.tigerdirect.com",
15
+ tiger_direct: "www.tigerdirect.com",
16
16
  mid: 14028
17
17
  }
18
18
  ]
@@ -0,0 +1,51 @@
1
+ module TipsanityMerchantExtractor
2
+ module TigerDirect
3
+ include LinkShare
4
+
5
+ def self.extended(base)
6
+ if base == AttributeExtractor
7
+ base.send :include, TigerDirect
8
+ end
9
+ end
10
+
11
+ def is_merchant_linkshare_tiger_direct?(merchant_url)
12
+ URI(merchant_url).host
13
+ if URI(merchant_url).host == TipsanityMerchantExtractor::RegisteredMerchantList::REGISTERED_MERCHANT[:linkshare][1][:tiger_direct]
14
+ block_given? ? true : TipsanityMerchantExtractor::RegisteredMerchantList::REGISTERED_MERCHANT[:linkshare][1][:tiger_direct]
15
+ else
16
+ false
17
+ end
18
+ end
19
+
20
+ def find_product_tiger_direct merchant_url, token, mid
21
+ if is_merchant_linkshare_tiger_direct?(merchant_url){}
22
+ skuid_filter = URI.decode_www_form(URI(merchant_url).query).assoc("EdpNo")
23
+ skuid = skuid_filter ? skuid_filter.last : nil
24
+ if skuid
25
+ begin
26
+ scraped_screen = Nokogiri::HTML(open(merchant_url))
27
+ @product_name = scraped_screen.search("#ProductReview .rightCol .prodName h1").text
28
+ @description = scraped_screen.search("#WriteUp").text.strip
29
+ list_price = scraped_screen.search("#ProductReview .rightCol .prodInfo dd.priceList").first || scraped_screen.search("#ProductReview .rightCol .prodInfo dd.pricemapa").first
30
+ @list_price = list_price.text.gsub(/[$]/, "")#.to_f
31
+ final_price = scraped_screen.search("#ProductReview .rightCol .prodInfo .salePrice").first || list_price
32
+ @final_price = final_price.text.gsub(/[$]/,"")#.to_f
33
+ @image_url = scraped_screen.search("#ProductReview .leftCol .previewImgHolder a img").first.attributes["src"].value
34
+ @details_url = provide_buy_url(token, mid, merchant_url)
35
+ @categories = scraped_screen.search("#ProductReview .rightCol .breadCrumbs li a").first.text
36
+ @response_object = scraped_screen
37
+ @product_token = skuid
38
+ @errors = []
39
+ rescue
40
+ @errors << "Some errors from api information"
41
+ end
42
+ else
43
+ @errors << "Not valid Uri. Please make sure, Uri contain 'prod' and skuid."
44
+ end
45
+ else
46
+ block_given? ? yield("It is not bestbuy merchant connected with commission junction.") : "It is not bestbuy merchant connected with commission junction."
47
+ end
48
+ end
49
+
50
+ end
51
+ end
@@ -1,3 +1,3 @@
1
1
  module TipsanityMerchantExtractor
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -4,15 +4,16 @@ require 'nori'
4
4
  require 'nokogiri'
5
5
 
6
6
  module TipsanityMerchantExtractor
7
- autoload :UrlFormatter, 'tipsanity_merchant_extractor/url_formatter'
8
- autoload :AttributeExtractor, 'tipsanity_merchant_extractor/attribute_extractor'
9
- autoload :Amazon, 'tipsanity_merchant_extractor/amazon'
10
- autoload :RegisteredMerchantList, 'tipsanity_merchant_extractor/registered_merchant_list'
11
- autoload :LinkShare, 'tipsanity_merchant_extractor/linkshare'
12
- autoload :Cj, 'tipsanity_merchant_extractor/cj'
13
- autoload :Rakuten, 'tipsanity_merchant_extractor/rakuten'
14
- autoload :BestBuy, 'tipsanity_merchant_extractor/best_buy'
15
- autoload :OneEightThousandLighting,'tipsanity_merchant_extractor/1800lighting'
7
+ autoload :UrlFormatter, 'tipsanity_merchant_extractor/url_formatter'
8
+ autoload :AttributeExtractor, 'tipsanity_merchant_extractor/attribute_extractor'
9
+ autoload :Amazon, 'tipsanity_merchant_extractor/amazon'
10
+ autoload :RegisteredMerchantList, 'tipsanity_merchant_extractor/registered_merchant_list'
11
+ autoload :LinkShare, 'tipsanity_merchant_extractor/linkshare'
12
+ autoload :Cj, 'tipsanity_merchant_extractor/cj'
13
+ autoload :Rakuten, 'tipsanity_merchant_extractor/rakuten'
14
+ autoload :BestBuy, 'tipsanity_merchant_extractor/best_buy'
15
+ autoload :OneEightThousandLighting, 'tipsanity_merchant_extractor/1800lighting'
16
+ autoload :TigerDirect, 'tipsanity_merchant_extractor/tiger_direct'
16
17
 
17
18
  end
18
19
 
@@ -105,5 +105,17 @@ describe TipsanityMerchantExtractor::AttributeExtractor do
105
105
  # TipsanityMerchantExtractor::AttributeExtractor.is_merchant_linkshare_rakuten?("http://mambate.shop.rakuten.com/p/7-agptek-android-4-2-quad-core-1024-600-hd-screen-with-1gb-ddr3-4gb/251837691.html").should eq("www.rakuten.com")
106
106
  TipsanityMerchantExtractor::AttributeExtractor.who_is_merchant("http://mambate.shop.rakuten.com/p/7-agptek-android-4-2-quad-core-1024-600-hd-screen-with-1gb-ddr3-4gb/251837691.html").should eq("www.rakuten.com")
107
107
  end
108
+
109
+ it "checks whether it is tiger_direct url" do
110
+ TipsanityMerchantExtractor::AttributeExtractor.is_merchant_linkshare_tiger_direct?('http://www.tigerdirect.com/applications/SearchTools/item-details.asp?EdpNo=8208716&sku=A50-173318&cm_re=Homepage-_-Zone2_2-_-CatId_17_A50-173318'){}.should eq(true)
111
+ TipsanityMerchantExtractor::AttributeExtractor.is_merchant_linkshare_tiger_direct?('http://www.yahoo.com'){}.should eq(false)
112
+ TipsanityMerchantExtractor::AttributeExtractor.is_merchant_linkshare_tiger_direct?('http://www.tigerdirect.com/applications/SearchTools/item-details.asp?EdpNo=8208716&sku=A50-173318&cm_re=Homepage-_-Zone2_2-_-CatId_17_A50-173318').should eq("www.tigerdirect.com")
113
+ end
114
+
115
+ it "retrive api details from tiger direct" do
116
+ @tipsanity_instance = TipsanityMerchantExtractor::AttributeExtractor.new("http://www.tigerdirect.com/applications/SearchTools/item-details.asp?EdpNo=7876916&CatId=3616", linkshare:{token: "23bf03f93e1cbccd9009ab0b9128f2e57a6a245af6c2be5ebcfe6b7285ad9a79"})
117
+
118
+ @tipsanity_instance.list_price.should eql("229.95")
119
+ end
108
120
  end
109
121
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tipsanity_merchant_extractor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-13 00:00:00.000000000 Z
12
+ date: 2013-10-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: asin
16
- requirement: &83760440 !ruby/object:Gem::Requirement
16
+ requirement: &69418580 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *83760440
24
+ version_requirements: *69418580
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: commission_junction
27
- requirement: &83760100 !ruby/object:Gem::Requirement
27
+ requirement: &69418250 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *83760100
35
+ version_requirements: *69418250
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: linkshare
38
- requirement: &83759780 !ruby/object:Gem::Requirement
38
+ requirement: &69417170 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *83759780
46
+ version_requirements: *69417170
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: nokogiri
49
- requirement: &83758470 !ruby/object:Gem::Requirement
49
+ requirement: &69416480 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *83758470
57
+ version_requirements: *69416480
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: nori
60
- requirement: &83758020 !ruby/object:Gem::Requirement
60
+ requirement: &69415970 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *83758020
68
+ version_requirements: *69415970
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: hashie
71
- requirement: &83757420 !ruby/object:Gem::Requirement
71
+ requirement: &69415450 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *83757420
79
+ version_requirements: *69415450
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: httpclient
82
- requirement: &83756810 !ruby/object:Gem::Requirement
82
+ requirement: &69414690 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *83756810
90
+ version_requirements: *69414690
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rake
93
- requirement: &83756230 !ruby/object:Gem::Requirement
93
+ requirement: &69414220 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *83756230
101
+ version_requirements: *69414220
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rspec
104
- requirement: &83755630 !ruby/object:Gem::Requirement
104
+ requirement: &69413870 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *83755630
112
+ version_requirements: *69413870
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: httpclient
115
- requirement: &83755190 !ruby/object:Gem::Requirement
115
+ requirement: &69413550 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,7 +120,7 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *83755190
123
+ version_requirements: *69413550
124
124
  description: Tipsanity website uses this gem to extract their marchant related information
125
125
  email:
126
126
  - umeshblader@gmail.com
@@ -145,6 +145,7 @@ files:
145
145
  - lib/tipsanity_merchant_extractor/linkshare.rb
146
146
  - lib/tipsanity_merchant_extractor/rakuten.rb
147
147
  - lib/tipsanity_merchant_extractor/registered_merchant_list.rb
148
+ - lib/tipsanity_merchant_extractor/tiger_direct.rb
148
149
  - lib/tipsanity_merchant_extractor/url_formatter.rb
149
150
  - lib/tipsanity_merchant_extractor/version.rb
150
151
  - spec/spec_helper.rb