toychooser 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/manufacturer/bad-dragon.rb +5 -3
- data/lib/toychooser.rb +1 -1
- metadata +1 -1
@@ -22,10 +22,10 @@ class Chooser
|
|
22
22
|
net = Net::HTTP.new("bad-dragon.com",80)
|
23
23
|
toys = JSON.parser.new(net.get("/products/getproducts").body).parse
|
24
24
|
toys.reject!{|c|c["cat_id"].to_i!=1}
|
25
|
+
toys = toys.sort{|t1,t2|t1["release_date"].to_i <=> t2["release_date"].to_i}
|
25
26
|
toys.map!{|c|c["link_url"].sub(/.+bad-dragon.com/,"")}
|
26
27
|
toys.each do |t|
|
27
28
|
body = net.get(t).body
|
28
|
-
File.open("cole.html","w"){|f|f.print body}
|
29
29
|
html = Nokogiri::HTML.parse(body)
|
30
30
|
id = html.css("span[itemprop=productID]").first.text
|
31
31
|
name = html.css("span[itemprop=model]").first.text
|
@@ -56,6 +56,7 @@ class Chooser
|
|
56
56
|
col = t[0].downcase.sub(/meter of /,"_").sub(/umference of /,"_")
|
57
57
|
col.gsub!(" ","_")
|
58
58
|
col.gsub!(/_\(.+\)/,"")
|
59
|
+
col = remove_aliases(col)
|
59
60
|
inches = (t[i+1].to_f*100).round.to_i
|
60
61
|
query.store(col,inches)
|
61
62
|
end
|
@@ -79,10 +80,11 @@ class Chooser
|
|
79
80
|
def remove_aliases(column)
|
80
81
|
column = column.sub("usuable","usable").sub("avg._","")
|
81
82
|
column = column.sub(/(thickest|largest)_part_of_/,"")
|
82
|
-
column = column.sub(/
|
83
|
+
column = column.sub(/_base/,"")
|
83
84
|
# Other common aliases
|
84
|
-
column = column.sub("tip","head").sub("middle","shaft"
|
85
|
+
column = column.sub("tip","head").sub("middle","shaft").sub("bottom","knot")
|
85
86
|
column = column.sub("shaft_ridges","knot").sub("medial_ring","knot")
|
86
87
|
column = column.sub("bulb","knot")
|
88
|
+
return column
|
87
89
|
end
|
88
90
|
end
|
data/lib/toychooser.rb
CHANGED