scapeshift 1.0.1rg0

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.
@@ -0,0 +1,189 @@
1
+ require 'helper'
2
+
3
+ class TestSingleCrawler < Test::Unit::TestCase
4
+ context "The Single crawler" do
5
+ should "respond to crawl" do
6
+ assert_respond_to Scapeshift::Crawlers::Single.new(:name => "fake"), :crawl
7
+ end
8
+
9
+ context "when no name is supplied" do
10
+ should "raise the proper exception" do
11
+ assert_raise Scapeshift::Errors::InsufficientOptions do
12
+ crawler = Scapeshift::Crawlers::Single.new
13
+ crawler.crawl
14
+ end
15
+ end
16
+ end
17
+
18
+ context "when an ambiguous card name is supplied" do
19
+ should "raise the proper exception" do
20
+ assert_raise Scapeshift::Errors::CardNameAmbiguousOrNotFound do
21
+ crawler = Scapeshift::Crawlers::Single.new :name => "vial"
22
+ crawler.crawl
23
+ end
24
+ end
25
+ end
26
+
27
+ context "when an invalid card name is supplied" do
28
+ should "raise the proper exception" do
29
+ assert_raise Scapeshift::Errors::CardNameAmbiguousOrNotFound do
30
+ # Vulgar, but we can be assured that this search
31
+ # will always be empty.
32
+ crawler = Scapeshift::Crawlers::Single.new :name => "fuck"
33
+ crawler.crawl
34
+ end
35
+ end
36
+ end
37
+
38
+ context "when a valid name is supplied" do
39
+ setup do
40
+ @card = Scapeshift::Crawler.crawl :single, :name => "Akroma, Angel of Wrath"
41
+ end
42
+
43
+ should "return a Card object" do
44
+ assert_instance_of Scapeshift::Card, @card
45
+ end
46
+
47
+ should "return the proper Card" do
48
+ assert_equal "Akroma, Angel of Wrath", @card.name
49
+ assert_equal "5WWW", @card.cost
50
+ assert_equal "Legendary Creature - Angel", @card.types
51
+ assert_equal "Flying, first strike, vigilance, trample, haste, protection from black and from red", @card.text
52
+ assert_equal "\"Wrath is no vice when inflicted upon the deserving.\"", @card.flavour_text
53
+ assert_equal "Duel Decks: Divine vs. Demonic", @card.set
54
+ assert_equal "Mythic Rare", @card.rarity
55
+ assert_equal [["Duel Decks: Divine vs. Demonic", "Mythic Rare"], ["Legions", "Rare"],
56
+ ['Time Spiral "Timeshifted"', "Special"]], @card.sets
57
+ assert_equal "http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=193871&type=card", @card.image_uri
58
+ assert_equal "193871", @card.multiverse_id
59
+ assert_equal "6", @card.pow
60
+ assert_equal "6", @card.tgh
61
+ assert_equal nil, @card.loyalty
62
+ assert_equal "Chippy", @card.artist
63
+ assert_equal "1", @card.number
64
+ end
65
+ end
66
+
67
+ context "when a planeswalker name is supplied" do
68
+ setup do
69
+ @card = Scapeshift::Crawler.crawl :single, :name => "Jace Beleren"
70
+ end
71
+
72
+ should "return a Card object" do
73
+ assert_instance_of Scapeshift::Card, @card
74
+ end
75
+
76
+ should "correclty set the loyalty" do
77
+ assert_equal "3", @card.loyalty
78
+ end
79
+
80
+ should "return the proper Card" do
81
+ assert_equal "Jace Beleren", @card.name
82
+ assert_equal "1UU", @card.cost
83
+ assert_equal "Planeswalker - Jace", @card.types
84
+ assert_equal "+2: Each player draws a card.\n-1: Target player draws a card.\n-10: Target player puts the top twenty cards of his or her library into his or her graveyard.", @card.text
85
+ assert_equal "Magic 2011", @card.set
86
+ assert_equal "Mythic Rare", @card.rarity
87
+ assert_equal [["Magic 2011", "Mythic Rare"], ["Magic 2010", "Mythic Rare"], ["Lorwyn", "Rare"],
88
+ ["Duel Decks: Jace vs. Chandra", "Mythic Rare"]], @card.sets
89
+ assert_equal "http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=205960&type=card", @card.image_uri
90
+ assert_equal "205960", @card.multiverse_id
91
+ assert_equal nil, @card.pow
92
+ assert_equal nil, @card.tgh
93
+ assert_equal "3", @card.loyalty
94
+ assert_equal "Aleksi Briclot", @card.artist
95
+ assert_equal "58", @card.number
96
+ end
97
+ end
98
+
99
+ context "when a card with two or color mana is supplied" do
100
+ setup do
101
+ @card = Scapeshift::Crawler.crawl :single, :name => "Beseech the Queen"
102
+ end
103
+
104
+ should "return a Card object" do
105
+ assert_instance_of Scapeshift::Card, @card
106
+ end
107
+
108
+ should "correclty set the mana cost" do
109
+ assert_equal "(2/B)(2/B)(2/B)", @card.cost
110
+ end
111
+
112
+ should "return the proper Card" do
113
+ assert_equal "Beseech the Queen", @card.name
114
+ assert_equal "(2/B)(2/B)(2/B)", @card.cost
115
+ assert_equal "Sorcery", @card.types
116
+ assert_equal "( (2/B) can be paid with any two mana or with B . This card's converted mana cost is 6.)\nSearch your library for a card with converted mana cost less than or equal to the number of lands you control, reveal it, and put it into your hand. Then shuffle your library.", @card.text
117
+ assert_equal "Planechase", @card.set
118
+ assert_equal "Uncommon", @card.rarity
119
+ assert_equal [["Planechase", "Uncommon"], ["Shadowmoor", "Uncommon"]], @card.sets
120
+ assert_equal "http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=205399&type=card", @card.image_uri
121
+ assert_equal "205399", @card.multiverse_id
122
+ assert_equal nil, @card.pow
123
+ assert_equal nil, @card.tgh
124
+ assert_equal nil, @card.loyalty
125
+ assert_equal "Jason Chan", @card.artist
126
+ assert_equal "19", @card.number
127
+ end
128
+ end
129
+
130
+ context "when a card with phyrexian mana is supplied" do
131
+ setup do
132
+ @card = Scapeshift::Crawler.crawl :single, :name => "Act of Aggression"
133
+ end
134
+
135
+ should "return a Card object" do
136
+ assert_instance_of Scapeshift::Card, @card
137
+ end
138
+
139
+ should "correclty set the mana cost" do
140
+ assert_equal "3(R/P)(R/P)", @card.cost
141
+ end
142
+
143
+ should "return the proper Card" do
144
+ assert_equal "Act of Aggression", @card.name
145
+ assert_equal "3(R/P)(R/P)", @card.cost
146
+ assert_equal "Instant", @card.types
147
+ assert_equal "( (R/P) can be paid with either R or 2 life.)\nGain control of target creature an opponent controls until end of turn. Untap that creature. It gains haste until end of turn.", @card.text
148
+ assert_equal "New Phyrexia", @card.set
149
+ assert_equal "Uncommon", @card.rarity
150
+ assert_equal [["New Phyrexia", "Uncommon"]], @card.sets
151
+ assert_equal "http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=230076&type=card", @card.image_uri
152
+ assert_equal "230076", @card.multiverse_id
153
+ assert_equal nil, @card.pow
154
+ assert_equal nil, @card.tgh
155
+ assert_equal nil, @card.loyalty
156
+ assert_equal "Whit Brachna", @card.artist
157
+ assert_equal "78", @card.number
158
+ end
159
+ end
160
+
161
+ context "when a card with snow mana is supplied" do
162
+ setup do
163
+ @card = Scapeshift::Crawler.crawl :single, :name => "Adarkar Windform"
164
+ end
165
+
166
+ should "return a Card object" do
167
+ assert_instance_of Scapeshift::Card, @card
168
+ end
169
+
170
+ should "return the proper Card" do
171
+ assert_equal "Adarkar Windform", @card.name
172
+ assert_equal "4U", @card.cost
173
+ assert_equal "Snow Creature - Illusion", @card.types
174
+ assert_equal "Flying\n 1S}i : Target creature loses flying until end of turn.( S}i can be paid with one mana from a snow permanent.)", @card.text
175
+ assert_equal "Coldsnap", @card.set
176
+ assert_equal "Uncommon", @card.rarity
177
+ assert_equal [["Coldsnap", "Uncommon"]], @card.sets
178
+ assert_equal "http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=121268&type=card", @card.image_uri
179
+ assert_equal "121268", @card.multiverse_id
180
+ assert_equal "3", @card.pow
181
+ assert_equal "3", @card.tgh
182
+ assert_equal nil, @card.loyalty
183
+ assert_equal "Randy Gallegos", @card.artist
184
+ assert_equal "26", @card.number
185
+ end
186
+ end
187
+ end
188
+ end
189
+
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: scapeshift
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1rg0
5
+ prerelease: 5
6
+ platform: ruby
7
+ authors:
8
+ - Josh Lindsey
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2010-04-15 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: &26911344 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *26911344
25
+ - !ruby/object:Gem::Dependency
26
+ name: nokogiri
27
+ requirement: &26911056 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *26911056
36
+ description: ! 'Magic: The Gathering Oracle web scraper.'
37
+ email: joshua.s.lindsey@gmail.com
38
+ executables: []
39
+ extensions: []
40
+ extra_rdoc_files:
41
+ - LICENSE
42
+ - README.md
43
+ files:
44
+ - .document
45
+ - .gitignore
46
+ - .yardopts
47
+ - Gemfile
48
+ - Gemfile.lock
49
+ - LICENSE
50
+ - README.md
51
+ - Rakefile
52
+ - VERSION
53
+ - lib/scapeshift.rb
54
+ - lib/scapeshift/card.rb
55
+ - lib/scapeshift/crawler.rb
56
+ - lib/scapeshift/crawlers.rb
57
+ - lib/scapeshift/crawlers/base.rb
58
+ - lib/scapeshift/crawlers/cards.rb
59
+ - lib/scapeshift/crawlers/meta.rb
60
+ - lib/scapeshift/crawlers/single.rb
61
+ - lib/scapeshift/errors.rb
62
+ - scapeshift.gemspec
63
+ - test/helper.rb
64
+ - test/test_base_crawler.rb
65
+ - test/test_card.rb
66
+ - test/test_card_crawler.rb
67
+ - test/test_crawler_main.rb
68
+ - test/test_meta_crawler.rb
69
+ - test/test_single_crawler.rb
70
+ homepage: http://github.com/Karunamon/scapeshift
71
+ licenses: []
72
+ post_install_message:
73
+ rdoc_options:
74
+ - --charset=UTF-8
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 1.7.2
92
+ signing_key:
93
+ specification_version: 3
94
+ summary: ! 'Magic: The Gathering Oracle web scraper'
95
+ test_files:
96
+ - test/test_card.rb
97
+ - test/helper.rb
98
+ - test/test_crawler_main.rb
99
+ - test/test_single_crawler.rb
100
+ - test/test_meta_crawler.rb
101
+ - test/test_card_crawler.rb
102
+ - test/test_base_crawler.rb