warranty-check 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,9 @@
1
+ *~
2
+ *.cache
3
+ *.log
4
+ *.pid
5
+ tmp/**/*
6
+ .DS_Store
7
+ *.tmproj
8
+ *.sw?
9
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format documentation
3
+ --debug
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://www.rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,54 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ warranty-check (1.1.5)
5
+ nokogiri
6
+
7
+ GEM
8
+ remote: http://www.rubygems.org/
9
+ specs:
10
+ archive-tar-minitar (0.5.2)
11
+ coderay (0.9.8)
12
+ columnize (0.3.4)
13
+ diff-lcs (1.1.3)
14
+ linecache19 (0.5.13)
15
+ ruby_core_source (>= 0.1.4)
16
+ method_source (0.6.7)
17
+ ruby_parser (>= 2.3.1)
18
+ nokogiri (1.5.0)
19
+ pry (0.9.7.4)
20
+ coderay (~> 0.9.8)
21
+ method_source (~> 0.6.7)
22
+ ruby_parser (>= 2.3.1)
23
+ slop (~> 2.1.0)
24
+ rspec (2.7.0)
25
+ rspec-core (~> 2.7.0)
26
+ rspec-expectations (~> 2.7.0)
27
+ rspec-mocks (~> 2.7.0)
28
+ rspec-core (2.7.1)
29
+ rspec-expectations (2.7.0)
30
+ diff-lcs (~> 1.1.2)
31
+ rspec-mocks (2.7.0)
32
+ ruby-debug-base19 (0.11.26)
33
+ columnize (>= 0.3.1)
34
+ linecache19 (>= 0.5.11)
35
+ ruby_core_source (>= 0.1.4)
36
+ ruby-debug19 (0.11.6)
37
+ columnize (>= 0.3.1)
38
+ linecache19 (>= 0.5.11)
39
+ ruby-debug-base19 (>= 0.11.19)
40
+ ruby_core_source (0.1.5)
41
+ archive-tar-minitar (>= 0.5.2)
42
+ ruby_parser (2.3.1)
43
+ sexp_processor (~> 3.0)
44
+ sexp_processor (3.0.7)
45
+ slop (2.1.0)
46
+
47
+ PLATFORMS
48
+ ruby
49
+
50
+ DEPENDENCIES
51
+ pry
52
+ rspec
53
+ ruby-debug19
54
+ warranty-check!
@@ -0,0 +1,7 @@
1
+ # warranty-check
2
+
3
+ ## HP notebooks
4
+
5
+ hp = WarrantyCheck::HP.new("serial number")
6
+ hp.check
7
+ puts hp.warranties.inspect
@@ -0,0 +1,5 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ RSpec::Core::RakeTask.new('spec')
4
+
5
+ task :default => :spec
data/TODO ADDED
@@ -0,0 +1,3 @@
1
+ TODO
2
+ ====
3
+ - sanitize HP's output (too many \t and \n)
@@ -0,0 +1,19 @@
1
+ module WarrantyCheck
2
+
3
+ VENDOR_PATTERNS = {
4
+
5
+ WarrantyCheck::HP => ["^[a-zA-Z]{3}[0-9]{3}[0-9a-zA-Z]{4}$"], # 10
6
+ WarrantyCheck::DELL => ["^[0-9a-zA-Z]{5,7}$"], # 5-7
7
+ WarrantyCheck::IBM => ["^[0-9a-zA-Z]{7}$", "^[0-9a-zA-Z]{10}$", "^[0-9a-zA-Z]{12}$"], # 7,10,12
8
+ }
9
+
10
+ def self.classify(sn)
11
+ matched = []
12
+ VENDOR_PATTERNS.each_pair do |vendor, regexps|
13
+ matched << vendor if regexps.count { |rstr| r = Regexp.new(rstr); !r.match(sn).nil? } > 0
14
+ end
15
+
16
+ matched
17
+ end
18
+
19
+ end
@@ -0,0 +1,42 @@
1
+ module WarrantyCheck
2
+
3
+ class APPLE < BaseVendor
4
+
5
+ def service_base_url
6
+ "https://selfsolve.apple.com"
7
+ end
8
+
9
+ def service_uri
10
+ "/warrantyChecker.do?sn=%s"
11
+ end
12
+
13
+ def json
14
+ @json ||= JSON.parse(html.slice(5, html.length - 6))
15
+ end
16
+
17
+ def check
18
+ @warranties = []
19
+
20
+ if json["ERROR_CODE"].nil?
21
+
22
+ @warranties << {
23
+ :description => sprintf("%s - %s", json["PROD_DESCR"].strip, json["PH_SUPPORT_COVERAGE_SUBHEADER"].split(':').first.strip),
24
+ :expired => json["PH_SUPPORT_COVERAGE_SUBHEADER"].split(':').last.strip == "Expired",
25
+ :expire_date => (" " * 10),
26
+ :details => json
27
+ }
28
+
29
+ @warranties << {
30
+ :description => sprintf("%s - %s", json["PROD_DESCR"].strip, json["HW_REPAIR_COVERAGE_SUBHEADER"].split(':').first.strip),
31
+ :expired => json["HW_REPAIR_COVERAGE_SUBHEADER"].split(':').last.strip == "Expired",
32
+ :expire_date => (" " * 10),
33
+ :details => json
34
+ }
35
+
36
+ end
37
+ end
38
+
39
+
40
+ end
41
+
42
+ end
@@ -0,0 +1,78 @@
1
+ require 'net/http'
2
+ require 'uri'
3
+ require 'nokogiri'
4
+ require 'json'
5
+ require 'time'
6
+
7
+ require 'pry'
8
+
9
+ module WarrantyCheck
10
+
11
+ class BaseVendor
12
+
13
+ attr_reader :html
14
+ attr_reader :dom
15
+ attr_reader :warranties
16
+
17
+ def initialize(sn)
18
+ @sn = sn
19
+ @warranties = []
20
+ end
21
+
22
+ def check
23
+ nil
24
+ end
25
+
26
+ def service_base_url
27
+ "http://www.example.com"
28
+ end
29
+
30
+ def service_uri
31
+ "/%s"
32
+ end
33
+
34
+ def http_method
35
+ :get
36
+ end
37
+
38
+ def url
39
+ @url ||= URI.parse(service_base_url)
40
+ end
41
+
42
+ def uri
43
+ @uri ||= sprintf(service_uri, @sn)
44
+ end
45
+
46
+ def html
47
+ @html ||= get_html
48
+ end
49
+
50
+ def dom
51
+ @dom ||= Nokogiri::HTML(html)
52
+ end
53
+
54
+ private # -----------
55
+
56
+ def get_html
57
+ http = Net::HTTP.new(url.host, url.port)
58
+ http.use_ssl = true if url.port == 443
59
+
60
+ res = case http_method
61
+ when :get
62
+ http.get(uri)
63
+ when :post
64
+ u = URI.parse(uri)
65
+ http.post(u.path, u.query)
66
+ end
67
+
68
+ if (res.code == "302")
69
+ @uri = res["location"]
70
+ get_html
71
+ else
72
+ res.body
73
+ end
74
+ end
75
+
76
+ end
77
+
78
+ end
@@ -0,0 +1,46 @@
1
+ module WarrantyCheck
2
+
3
+ class DELL < BaseVendor
4
+
5
+ def service_base_url
6
+ "http://support.dell.com"
7
+ end
8
+
9
+ def service_uri
10
+ "/support/topics/global.aspx/support/my_systems_info/details?c=us&cs=08&l=en&s=pub&servicetag=%s"
11
+ end
12
+
13
+ def check
14
+ @warranties = []
15
+
16
+ table = dom.search("table.contract_table")
17
+ table.search("tr")[1..-1].to_a.each do |elem|
18
+ tds = elem.search("td")
19
+
20
+ details_description = tds[0].text.strip
21
+ details_provider = tds[1].text.strip
22
+ details_start_date = Time.strptime(tds[2].text.strip, "%m/%d/%Y")
23
+ details_end_date = Time.strptime(tds[3].text.strip, "%m/%d/%Y")
24
+ details_days_left = tds[4].text.strip.to_i
25
+
26
+ warranty = {
27
+ :description => "#{details_description} (#{details_provider})",
28
+ :expired => (details_days_left == 0 ? true : false),
29
+ :expire_date => details_end_date,
30
+
31
+ :details => {
32
+ :description => details_description,
33
+ :provider => details_provider ,
34
+ :start_date => details_start_date ,
35
+ :end_date => details_end_date ,
36
+ :days_left => details_days_left
37
+ }
38
+ }
39
+
40
+ @warranties << warranty
41
+ end
42
+ end
43
+
44
+ end
45
+
46
+ end
@@ -0,0 +1,42 @@
1
+ module WarrantyCheck
2
+
3
+ class FUJITSU < BaseVendor
4
+
5
+ def service_base_url
6
+ "http://sali.uk.ts.fujitsu.com"
7
+ end
8
+
9
+ def service_uri
10
+ "/ServiceEntitlement/service.asp?snr=%s&x=0&y=0&command=search"
11
+ end
12
+
13
+ def http_method
14
+ :post
15
+ end
16
+
17
+ def check
18
+ @warranties = []
19
+
20
+ table = dom.search("table").to_a[3]
21
+ return unless table.search("tr").to_a.count == 4
22
+
23
+ td1 = table.search("tr").to_a[1].search("td").to_a[1].text.strip
24
+ td2 = table.search("tr").to_a[2].search("td").to_a[1].text.strip
25
+ td3 = table.search("tr").to_a[3].search("td").to_a[1].text.strip
26
+
27
+ return if td1 =~ /^Error/
28
+
29
+ expiration_date = Time.strptime(td3, "%d/%m/%Y")
30
+
31
+ warranty = {
32
+ :description => sprintf("%s - %s", td1, td2),
33
+ :expired => (expiration_date < Time.now ? true : false),
34
+ :expire_date => expiration_date
35
+ }
36
+
37
+ @warranties << warranty
38
+ end
39
+
40
+ end
41
+
42
+ end
@@ -0,0 +1,55 @@
1
+ module WarrantyCheck
2
+
3
+ class HP < BaseVendor
4
+
5
+ def service_base_url
6
+ "http://h20000.www2.hp.com"
7
+ end
8
+
9
+ def service_uri
10
+ "/bizsupport/TechSupport/WarrantyResults.jsp?nickname=&sn=%s&pn=&country=CA&lang=en&cc=us"
11
+ end
12
+
13
+ def check
14
+ @warranties = []
15
+
16
+ table = dom.search("td td table:nth-child(3)")
17
+ table.search("tr")[1..-1].to_a.each do |elem|
18
+ tds = elem.search("td")
19
+
20
+ next if !(6..7).include?(tds.count)
21
+
22
+ @warranty_type ||= (tds.size == 7 ? tds[0].text.strip : nil)
23
+ n = (tds.size == 7 ? 0 : -1)
24
+
25
+ details_warranty_type = @warranty_type
26
+ details_service_type = tds[n+1].text.strip
27
+ details_start_date = Time.strptime(tds[n+2].text.strip, "%d %b %Y")
28
+ details_end_date = Time.strptime(tds[n+3].text.strip, "%d %b %Y")
29
+ details_status = tds[n+4].text.strip
30
+ details_service_level = tds[n+5].text.strip
31
+ details_deliverables = tds[n+6].text.strip
32
+
33
+ warranty = {
34
+ :description => "#{details_warranty_type} - #{details_service_type}",
35
+ :expired => (details_status == "Expired" ? true : false),
36
+ :expire_date => details_end_date,
37
+
38
+ :details => {
39
+ :warranty_type => details_warranty_type,
40
+ :service_type => details_service_type ,
41
+ :start_date => details_start_date ,
42
+ :end_date => details_end_date ,
43
+ :status => details_status ,
44
+ :service_level => details_service_level,
45
+ :deliverables => details_deliverables ,
46
+ }
47
+ }
48
+
49
+ @warranties << warranty
50
+ end
51
+ end
52
+
53
+ end
54
+
55
+ end
@@ -0,0 +1,48 @@
1
+ module WarrantyCheck
2
+
3
+ class IBM < BaseVendor
4
+
5
+ def service_base_url
6
+ "http://support.lenovo.com"
7
+ end
8
+
9
+ def service_uri
10
+ "/templatedata/Web%%20Content/JSP/warrantyLookup.jsp?sysSerial=%s"
11
+ end
12
+
13
+ def check
14
+ @warranties = []
15
+
16
+ table = dom.search("div table:nth-child(2)")
17
+
18
+ return if table.search("tr").to_a.count == 0
19
+
20
+ tds1 = table.search("tr").to_a[1].search("td")
21
+ tds2 = table.search("tr").to_a[5].search("td")
22
+
23
+ details_product_id = tds1[0].text.strip
24
+ details_type_model = tds1[2].text.strip
25
+ details_serial_number = tds1[4].text.strip
26
+ details_location = tds2[0].text.strip
27
+ details_expiration_date = Time.strptime(tds2[2].text.strip, "%Y-%m-%d")
28
+
29
+ warranty = {
30
+ :description => "",
31
+ :expired => (details_expiration_date < Time.now ? true : false),
32
+ :expire_date => details_expiration_date,
33
+
34
+ :details => {
35
+ :product_id => details_product_id ,
36
+ :type_model => details_type_model ,
37
+ :serial_number => details_serial_number ,
38
+ :location => details_location ,
39
+ :expiration_date => details_expiration_date,
40
+ }
41
+ }
42
+
43
+ @warranties << warranty
44
+ end
45
+
46
+ end
47
+
48
+ end
@@ -0,0 +1,8 @@
1
+ require 'vendors/base_vendor'
2
+ require 'vendors/hp_vendor'
3
+ require 'vendors/dell_vendor'
4
+ require 'vendors/ibm_vendor'
5
+ require 'vendors/apple_vendor'
6
+ require 'vendors/fujitsu_vendor'
7
+
8
+ require 'classify'
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+
3
+ describe WarrantyCheck::APPLE do
4
+
5
+ before(:all) do
6
+ @sn = "W88530XF1GK"
7
+ # @sn = "8211276UA4S"
8
+ # @sn = "CQ12905CZ38"
9
+
10
+ @vendor = WarrantyCheck::APPLE.new(@sn)
11
+ end
12
+
13
+ it "gets content" do
14
+ @vendor.html =~ Regexp.new(@sn)
15
+ end
16
+
17
+ it "parses json" do
18
+ @vendor.json.class.should == Hash
19
+ end
20
+
21
+ it "does not check bad warranty" do
22
+ bad_vendor = WarrantyCheck::APPLE.new("XXXXXXXXXX")
23
+ bad_vendor.check
24
+ bad_vendor.warranties.size.should == 0
25
+ end
26
+
27
+ it "checks warranty" do
28
+ @vendor.check
29
+ @vendor.warranties.size.should == 2
30
+
31
+ w1, w2 = @vendor.warranties
32
+
33
+ w1[:description].should == "MacBook Pro (15-inch, Late 2008) - Telephone Technical Support"
34
+ w1[:expired].should == true
35
+ w1[:expire_date].should == (" " * 10)
36
+
37
+
38
+ w2[:description].should == "MacBook Pro (15-inch, Late 2008) - Repairs and Service Coverage"
39
+ w2[:expired].should == true
40
+ w2[:expire_date].should == (" " * 10)
41
+ end
42
+
43
+ it "checks warranty for other serial numbers" do
44
+ custom_vendor = WarrantyCheck::APPLE.new("CQ12905CZ38")
45
+ custom_vendor.check
46
+ custom_vendor.warranties.size.should == 2
47
+
48
+ w1, w2 = custom_vendor.warranties
49
+
50
+ w1[:description].should == "iPad - Telephone Technical Support"
51
+ w1[:expired].should == true
52
+ w1[:expire_date].should == (" " * 10)
53
+
54
+
55
+ w2[:description].should == "iPad - Repairs and Service Coverage"
56
+ w2[:expired].should == true
57
+ w2[:expire_date].should == (" " * 10)
58
+ end
59
+
60
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe WarrantyCheck::BaseVendor do
4
+
5
+ it "checks warranty" do
6
+ vendor = WarrantyCheck::BaseVendor.new("test")
7
+ vendor.check
8
+ vendor.warranties.size.should == 0
9
+ end
10
+
11
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe "WarrantyCheck#classify" do
4
+
5
+ it "classifies serial numbers" do
6
+ WarrantyCheck::classify("CND003107K").should == [WarrantyCheck::HP, WarrantyCheck::IBM]
7
+ WarrantyCheck::classify("F34G9").should == [WarrantyCheck::DELL]
8
+ WarrantyCheck::classify("1qmqjh1").should == [WarrantyCheck::DELL, WarrantyCheck::IBM]
9
+ WarrantyCheck::classify("LR18166").should == [WarrantyCheck::DELL, WarrantyCheck::IBM]
10
+ WarrantyCheck::classify("LR18166333").should == [WarrantyCheck::IBM]
11
+ end
12
+
13
+ end
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe WarrantyCheck::DELL do
4
+
5
+ before(:all) do
6
+ @sn = "F34G9"
7
+
8
+ @vendor = WarrantyCheck::DELL.new(@sn)
9
+ end
10
+
11
+ it "gets html" do
12
+ @vendor.html =~ Regexp.new(@sn)
13
+ end
14
+
15
+ it "parses html" do
16
+ @vendor.dom.class.should == Nokogiri::HTML::Document
17
+ end
18
+
19
+ it "checks warranty" do
20
+ @vendor.check
21
+ @vendor.warranties.size.should == 1
22
+
23
+ w1 = @vendor.warranties.first
24
+
25
+ w1[:description].should == "Rapid Response Depot (IBM)"
26
+ w1[:expired].should == true
27
+ w1[:expire_date].should == Time.strptime("8/31/2001", "%m/%d/%Y")
28
+
29
+ w1[:details][:description].should == "Rapid Response Depot"
30
+ w1[:details][:provider].should == "IBM"
31
+ w1[:details][:start_date].should == Time.strptime("9/1/1999", "%m/%d/%Y")
32
+ w1[:details][:end_date].should == Time.strptime("8/31/2001", "%m/%d/%Y")
33
+ w1[:details][:days_left].should == 0
34
+ end
35
+
36
+ it "checks warranty for found serial numbers" do
37
+ custom_vendor = WarrantyCheck::DELL.new("HND96D1")
38
+ custom_vendor.check
39
+ custom_vendor.warranties.size.should == 1
40
+ end
41
+
42
+ it "does not check bad warranty" do
43
+ bad_vendor = WarrantyCheck::DELL.new("ZZZZZ")
44
+ bad_vendor.check
45
+ bad_vendor.warranties.size.should == 0
46
+ end
47
+
48
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe WarrantyCheck::FUJITSU do
4
+
5
+ before(:all) do
6
+ @sn = "YBMP017114"
7
+
8
+ @vendor = WarrantyCheck::FUJITSU.new(@sn)
9
+ end
10
+
11
+ it "gets html" do
12
+ @vendor.html =~ Regexp.new(@sn)
13
+ end
14
+
15
+ it "parses html" do
16
+ @vendor.dom.class.should == Nokogiri::HTML::Document
17
+ end
18
+
19
+ it "checks warranty" do
20
+ @vendor.check
21
+ @vendor.warranties.size.should == 1
22
+
23
+ w1 = @vendor.warranties.first
24
+
25
+ w1[:description].should == "LIFEBOOK S7010 BT Supreme - The system has no warranty. The system was scraped"
26
+ w1[:expired].should == true
27
+ w1[:expire_date].should == Time.strptime("25/09/2004", "%d/%m/%Y")
28
+ end
29
+
30
+ it "does not check bad warranty" do
31
+ bad_vendor = WarrantyCheck::FUJITSU.new("X")
32
+ bad_vendor.check
33
+ bad_vendor.warranties.size.should == 0
34
+ end
35
+
36
+ end
@@ -0,0 +1,62 @@
1
+ require 'spec_helper'
2
+
3
+ describe WarrantyCheck::HP do
4
+
5
+ before(:all) do
6
+ @sn = "CND003107K"
7
+
8
+ @vendor = WarrantyCheck::HP.new(@sn)
9
+ end
10
+
11
+ it "gets html" do
12
+ @vendor.html =~ Regexp.new(@sn)
13
+ end
14
+
15
+ it "parses html" do
16
+ @vendor.dom.class.should == Nokogiri::HTML::Document
17
+ end
18
+
19
+ it "does not check bad warranty" do
20
+ bad_vendor = WarrantyCheck::HP.new("XXXXXXXXXX")
21
+ bad_vendor.check
22
+ bad_vendor.warranties.size.should == 0
23
+ end
24
+
25
+ it "checks warranty" do
26
+ @vendor.check
27
+ @vendor.warranties.size.should == 2
28
+
29
+ w1, w2 = @vendor.warranties
30
+
31
+ w1[:description].should == "Base Warranty - Wty: HP HW Maintenance Offsite Support"
32
+ w1[:expired].should == true
33
+ w1[:expire_date].should == Time.strptime("19 Feb 2011", "%d %b %Y")
34
+
35
+ w1[:details][:service_type].should == "Wty: HP HW Maintenance Offsite Support"
36
+ w1[:details][:start_date].should == Time.strptime("21 Jan 2010", "%d %b %Y")
37
+ w1[:details][:end_date].should == Time.strptime("19 Feb 2011", "%d %b %Y")
38
+ w1[:details][:status].should == "Expired"
39
+ w1[:details][:service_level].should == "Std Office Hrs Std Office Days, Std Office Hrs Std Office Days, Global Coverage, Standard Material Handling, Standard Parts Logistics, Customer delivers to RepairCtr, No Usage Limitation, Customer Pickup at RepairCtr, 5 Business Days Turn-Around"
40
+ w1[:details][:deliverables].should == "Hardware Problem Diagnosis, Offsite Support & Materials"
41
+
42
+
43
+ w2[:description].should == "Base Warranty - Wty: HP Support for Initial Setup"
44
+ w2[:expired].should == true
45
+ w2[:expire_date].should == Time.strptime("20 May 2010", "%d %b %Y")
46
+
47
+ w2[:details][:warranty_type].should == "Base Warranty"
48
+ w2[:details][:service_type].should == "Wty: HP Support for Initial Setup"
49
+ w2[:details][:start_date].should == Time.strptime("21 Jan 2010", "%d %b %Y")
50
+ w2[:details][:end_date].should == Time.strptime("20 May 2010", "%d %b %Y")
51
+ w2[:details][:status].should == "Expired"
52
+ w2[:details][:service_level].should == "NextAvail TechResource Remote, Std Office Hrs Std Office Days, 2 Hr Remote Response, Unlimited Named Callers"
53
+ w2[:details][:deliverables].should == "Initial Setup Assistance"
54
+ end
55
+
56
+ it "checks warranty for found serial numbers" do
57
+ custom_vendor = WarrantyCheck::HP.new("CNU8270B6C")
58
+ custom_vendor.check
59
+ custom_vendor.warranties.size.should == 3
60
+ end
61
+
62
+ end
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ describe WarrantyCheck::IBM do
4
+
5
+ before(:all) do
6
+ @sn = "LR18166"
7
+
8
+ @vendor = WarrantyCheck::IBM.new(@sn)
9
+ end
10
+
11
+ it "gets html" do
12
+ @vendor.html =~ Regexp.new(@sn)
13
+ end
14
+
15
+ it "parses html" do
16
+ @vendor.dom.class.should == Nokogiri::HTML::Document
17
+ end
18
+
19
+ it "checks warranty" do
20
+ @vendor.check
21
+ @vendor.warranties.size.should == 1
22
+
23
+ w1 = @vendor.warranties.first
24
+
25
+ w1[:description].should == ""
26
+ w1[:expired].should == true
27
+ w1[:expire_date].should == Time.strptime("2010-03-06", "%Y-%m-%d")
28
+
29
+ w1[:details][:product_id].should == "2511H7U"
30
+ w1[:details][:type_model].should == "2511-H7U"
31
+ w1[:details][:serial_number].should == "LR18166"
32
+ w1[:details][:location].should == "Canada"
33
+ w1[:details][:expiration_date].should == Time.strptime("2010-03-06", "%Y-%m-%d")
34
+ end
35
+
36
+ it "does not check bad warranty" do
37
+ bad_vendor = WarrantyCheck::IBM.new("XXXXXXX")
38
+ bad_vendor.check
39
+ bad_vendor.warranties.size.should == 0
40
+ end
41
+
42
+ end
@@ -0,0 +1,9 @@
1
+ require 'bundler/setup'
2
+
3
+ require 'warranty-check'
4
+
5
+ RSpec.configure do |config|
6
+ config.treat_symbols_as_metadata_keys_with_true_values = true
7
+ config.filter_run :focus => true
8
+ config.run_all_when_everything_filtered = true
9
+ end
@@ -0,0 +1,22 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'warranty-check'
3
+ s.version = '1.1.5'
4
+ s.date = '2011-11-29'
5
+ s.summary = "Warranty check"
6
+ s.description = "The library retrieves warrany information from various vendor websites based in provided SN/PN"
7
+ s.authors = ["Ahmed Al Hafoudh"]
8
+ s.email = ["alhafoudh@freevision.sk"]
9
+ s.homepage = "http://github.com/freevision/warranty-check"
10
+
11
+ s.files = `git ls-files`.split("\n")
12
+
13
+ s.test_files = `git ls-files -- spec/*`.split("\n")
14
+
15
+ s.require_paths = ["lib"]
16
+
17
+ s.add_dependency 'nokogiri'
18
+
19
+ s.add_development_dependency 'rspec'
20
+ s.add_development_dependency 'ruby-debug19'
21
+ s.add_development_dependency 'pry'
22
+ end
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: warranty-check
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.5
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ahmed Al Hafoudh
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-11-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: nokogiri
16
+ requirement: &70230596480640 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70230596480640
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ requirement: &70230596476580 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70230596476580
36
+ - !ruby/object:Gem::Dependency
37
+ name: ruby-debug19
38
+ requirement: &70230596472620 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70230596472620
47
+ - !ruby/object:Gem::Dependency
48
+ name: pry
49
+ requirement: &70230596465780 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70230596465780
58
+ description: The library retrieves warrany information from various vendor websites
59
+ based in provided SN/PN
60
+ email:
61
+ - alhafoudh@freevision.sk
62
+ executables: []
63
+ extensions: []
64
+ extra_rdoc_files: []
65
+ files:
66
+ - .gitignore
67
+ - .rspec
68
+ - Gemfile
69
+ - Gemfile.lock
70
+ - README.md
71
+ - Rakefile
72
+ - TODO
73
+ - lib/classify.rb
74
+ - lib/vendors/apple_vendor.rb
75
+ - lib/vendors/base_vendor.rb
76
+ - lib/vendors/dell_vendor.rb
77
+ - lib/vendors/fujitsu_vendor.rb
78
+ - lib/vendors/hp_vendor.rb
79
+ - lib/vendors/ibm_vendor.rb
80
+ - lib/warranty-check.rb
81
+ - spec/apple_vendor_spec.rb
82
+ - spec/base_vendor_spec.rb
83
+ - spec/classify_spec.rb
84
+ - spec/dell_vendor_spec.rb
85
+ - spec/fujitsu_vendor_spec.rb
86
+ - spec/hp_vendor_spec.rb
87
+ - spec/ibm_vendor_spec.rb
88
+ - spec/spec_helper.rb
89
+ - warranty-check.gemspec
90
+ homepage: http://github.com/freevision/warranty-check
91
+ licenses: []
92
+ post_install_message:
93
+ rdoc_options: []
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - ! '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 1.8.12
111
+ signing_key:
112
+ specification_version: 3
113
+ summary: Warranty check
114
+ test_files:
115
+ - spec/apple_vendor_spec.rb
116
+ - spec/base_vendor_spec.rb
117
+ - spec/classify_spec.rb
118
+ - spec/dell_vendor_spec.rb
119
+ - spec/fujitsu_vendor_spec.rb
120
+ - spec/hp_vendor_spec.rb
121
+ - spec/ibm_vendor_spec.rb
122
+ - spec/spec_helper.rb
123
+ has_rdoc: