gatherer 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gatherer/client.rb +17 -4
- data/lib/gatherer/scraper.rb +3 -2
- data/lib/gatherer/version.rb +1 -1
- metadata +2 -2
data/lib/gatherer/client.rb
CHANGED
@@ -21,13 +21,26 @@ module Gatherer
|
|
21
21
|
Card.new_from_parser(parser)
|
22
22
|
end
|
23
23
|
|
24
|
-
def expansions(
|
25
|
-
|
26
|
-
doc = Nokogiri::HTML(
|
27
|
-
|
24
|
+
def expansions(homepage_file = nil, expansion_file = nil)
|
25
|
+
homepage_file ||= open('http://gatherer.wizards.com')
|
26
|
+
doc = Nokogiri::HTML(homepage_file)
|
27
|
+
expansion_titles = doc.css('select#ctl00_ctl00_MainContent_Content_SearchControls_setAddText')
|
28
28
|
.css('option')
|
29
29
|
.map {|option| option['value'] }
|
30
30
|
.select {|expansion| !expansion.empty?}
|
31
|
+
expansion_titles.map do |title|
|
32
|
+
Gatherer::Expansion.new(
|
33
|
+
title: title,
|
34
|
+
abbreviation: expansion_abbreviation_for(title, expansion_file)
|
35
|
+
)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def expansion_abbreviation_for(title, file = nil)
|
40
|
+
file ||= open(Scraper.new(expansion: title).url)
|
41
|
+
doc = Nokogiri::HTML(file)
|
42
|
+
set_images = doc.css('div#ctl00_ctl00_ctl00_MainContent_SubContent_SubContent_ctl00_listRepeater_ctl00_cardSetCurrent img')
|
43
|
+
abbreviation = set_images.first['src'].match(/&set=(.[^&]*)/)[1] unless set_images.empty?
|
31
44
|
end
|
32
45
|
end
|
33
46
|
end
|
data/lib/gatherer/scraper.rb
CHANGED
data/lib/gatherer/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gatherer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|