steam-prices 0.1.6 → 0.1.8
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.
- data/Gemfile +4 -0
- data/Gemfile.lock +24 -0
- data/README.md +13 -0
- data/lib/{steam_prices.rb → steam-prices.rb} +3 -0
- data/lib/steam_prices/steam_country.rb +2 -3
- data/lib/steam_prices/steam_game.rb +4 -3
- data/lib/steam_prices/steam_updater.rb +0 -0
- data/lib/steam_prices/version.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/steam_game_spec.rb +3 -2
- data/spec/steam_updater_spec.rb +88 -20
- metadata +54 -87
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.1.2)
|
5
|
+
i18n (0.6.0)
|
6
|
+
money (3.7.1)
|
7
|
+
i18n (~> 0.4)
|
8
|
+
nokogiri (1.5.0)
|
9
|
+
rspec (2.6.0)
|
10
|
+
rspec-core (~> 2.6.0)
|
11
|
+
rspec-expectations (~> 2.6.0)
|
12
|
+
rspec-mocks (~> 2.6.0)
|
13
|
+
rspec-core (2.6.4)
|
14
|
+
rspec-expectations (2.6.0)
|
15
|
+
diff-lcs (~> 1.1.2)
|
16
|
+
rspec-mocks (2.6.0)
|
17
|
+
|
18
|
+
PLATFORMS
|
19
|
+
ruby
|
20
|
+
|
21
|
+
DEPENDENCIES
|
22
|
+
money
|
23
|
+
nokogiri (= 1.5.0)
|
24
|
+
rspec
|
data/README.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
## changelog
|
2
2
|
|
3
|
+
**v0.1.8**
|
4
|
+
|
5
|
+
- issues with nokogiri
|
6
|
+
- saves sale prices in :original_price
|
7
|
+
|
8
|
+
**v0.1.7**
|
9
|
+
|
10
|
+
- dealing with free games
|
11
|
+
- limited countries
|
12
|
+
- trailing slash removed
|
13
|
+
- should update all prices if nil is passed
|
14
|
+
- special exception wasn't of Money class
|
15
|
+
|
3
16
|
**v0.1.6**
|
4
17
|
|
5
18
|
- forgot to handle a case for retribution, where it would update a single one
|
@@ -4,17 +4,18 @@ module SteamPrices
|
|
4
4
|
include Updater
|
5
5
|
|
6
6
|
attr_reader :app_id, :app_name, :store_link, :logo_link, :date_released, :status, :category
|
7
|
-
attr_accessor :price
|
7
|
+
attr_accessor :price, :original_price
|
8
8
|
|
9
|
-
def initialize(app_name = nil, app_id = nil, store_link = nil, logo_link = nil, date_released = nil, price = nil)
|
9
|
+
def initialize(app_name = nil, app_id = nil, store_link = nil, logo_link = nil, date_released = nil, price = nil, original_price = nil)
|
10
10
|
@app_id = app_id.to_i
|
11
11
|
@app_name = app_name.to_s
|
12
12
|
@store_link = store_link ||= "http://store.steampowered.com/app/12312312"
|
13
|
-
@category = (@store_link.match(/(.*store\.steampowered\.com\/app\/[\d]
|
13
|
+
@category = (@store_link.match(/(.*store\.steampowered\.com\/app\/[\d]+)/) ? GAME : PACK)
|
14
14
|
@logo_link = logo_link
|
15
15
|
@date_released = date_released
|
16
16
|
raise ArgumentError, "Expected: Money()" if price.class.name != 'Money' && price != nil
|
17
17
|
@price = price
|
18
|
+
@original_price = original_price
|
18
19
|
end
|
19
20
|
|
20
21
|
def update(currency = nil)
|
Binary file
|
data/lib/steam_prices/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
data/spec/steam_game_spec.rb
CHANGED
@@ -3,15 +3,16 @@ require 'spec_helper'
|
|
3
3
|
describe SteamPrices::Game do
|
4
4
|
|
5
5
|
it "should be able to have an app id, app name, logo, and store link" do
|
6
|
-
g = SteamPrices::Game.new('brink', 31314, '', '', '', Money.new(1499, 'USD'))
|
6
|
+
g = SteamPrices::Game.new('brink', 31314, '', '', '', Money.new(1499, 'USD'), Money.new(1299, 'USD'))
|
7
7
|
g.app_name.should == 'brink'
|
8
8
|
g.app_id.should == 31314
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should have a valid price of the money class" do
|
12
12
|
lambda { g = SteamPrices::Game.new('brink', 31314, '', '', '', '') }.should raise_error
|
13
|
-
g = SteamPrices::Game.new('brink', 31314, '', '', '', Money.new(1499, 'USD'))
|
13
|
+
g = SteamPrices::Game.new('brink', 31314, '', '', '', Money.new(1499, 'USD'), Money.new(1299, 'USD'))
|
14
14
|
g.price.should == 14.99
|
15
|
+
g.original_price.should == 12.99
|
15
16
|
end
|
16
17
|
|
17
18
|
|
data/spec/steam_updater_spec.rb
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
+
puts Nokogiri::VERSION_INFO
|
4
|
+
|
5
|
+
def find_game(games, currency, app_id, category = 998)
|
6
|
+
games[app_id].each do |game|
|
7
|
+
return game if (game[:game].price == nil || game[:game].price.currency.iso_code.upcase == currency.upcase) && game[:game].category == category
|
8
|
+
end
|
9
|
+
return nil
|
10
|
+
|
11
|
+
end
|
12
|
+
|
3
13
|
describe SteamPrices::Updater do
|
4
14
|
|
5
15
|
before(:each) do
|
@@ -13,10 +23,25 @@ describe SteamPrices::Updater do
|
|
13
23
|
URI.should_receive(:encode).exactly(1).times.and_return(File.dirname(__FILE__) + '/support/packs.html')
|
14
24
|
end
|
15
25
|
|
26
|
+
|
27
|
+
it "should not find any duplicates" do
|
28
|
+
games = SteamPrices::Game.update_all_packs('usd', false)
|
29
|
+
games.each do |k,v|
|
30
|
+
v.collect { |g| g[:game].category if g[:game].category == SteamPrices::Updater::PACK }.size.should == 1
|
31
|
+
v.collect { |g| g[:game].category if g[:game].category == SteamPrices::Updater::GAME }.size.should == 1
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should be able to tell whether it's a pack or a game" do
|
36
|
+
games = SteamPrices::Game.update_all_packs('usd', false)
|
37
|
+
find_game(games, 'usd', 6433, 996)[:type].should == SteamPrices::Updater::PACK
|
38
|
+
end
|
39
|
+
|
40
|
+
|
16
41
|
it "should be able to scrape steam and give a bunch of prices for a pack" do
|
17
42
|
games = SteamPrices::Game.update_all_packs('usd', false)
|
18
43
|
games.size.should == 25
|
19
|
-
games
|
44
|
+
find_game(games, 'usd', 6433, 996)[:game].price.should == 39.99
|
20
45
|
end
|
21
46
|
|
22
47
|
it "should be able to find a single pack" do
|
@@ -25,20 +50,46 @@ describe SteamPrices::Updater do
|
|
25
50
|
end
|
26
51
|
end
|
27
52
|
|
28
|
-
it "should be able to update EVERYTHING", :everything => true do
|
53
|
+
it "should be able to update EVERYTHING (usd)", :everything => true do
|
29
54
|
URI.should_receive(:encode).exactly(5).times.and_return(File.dirname(__FILE__) + '/support/us.html')
|
30
55
|
URI.should_receive(:encode).exactly(1).times.and_return(File.dirname(__FILE__) + '/support/packs.html')
|
31
56
|
games = SteamPrices::Game.update_everything('usd', false)
|
32
|
-
games.size.should == 25+
|
57
|
+
games.size.should == 25+18
|
33
58
|
#pack
|
34
|
-
games
|
35
|
-
games
|
59
|
+
find_game(games, 'usd', 6433, 996)[:game].price.to_f.should == 39.99
|
60
|
+
find_game(games, 'usd', 6433, 996)[:status].should == :ok
|
61
|
+
|
62
|
+
find_game(games, 'usd', 15540, 998)[:game].price.to_f.should == 8.99
|
63
|
+
find_game(games, 'usd', 15540, 998)[:status].should == :ok
|
36
64
|
#game
|
37
|
-
games
|
38
|
-
games
|
65
|
+
find_game(games, 'usd', 22350, 998)[:game].price.to_f.should == 49.99
|
66
|
+
find_game(games, 'usd', 22350, 998)[:status].should == :ok
|
39
67
|
|
40
68
|
end
|
41
69
|
|
70
|
+
it "should be able to update EVERYTHING (gbp)", :gbp => true do
|
71
|
+
URI.should_receive(:encode).exactly(1).times.and_return(File.dirname(__FILE__) + '/support/uk.html')
|
72
|
+
URI.should_receive(:encode).exactly(1).times.and_return(File.dirname(__FILE__) + '/support/packs.html')
|
73
|
+
games = SteamPrices::Game.update_everything('gbp', true)
|
74
|
+
# because thisis the total of theapp ids
|
75
|
+
games.size.should == 25+25-1
|
76
|
+
#pack
|
77
|
+
find_game(games, 'gbp', 15540, 998)[:game].price.to_f.should == 5.99
|
78
|
+
find_game(games, 'gbp', 15540, 998)[:status].should == :ok
|
79
|
+
#game
|
80
|
+
find_game(games, 'gbp', 12520, 998)[:game].price.to_f.should == 5.99
|
81
|
+
find_game(games, 'gbp', 12520, 998)[:status].should == :ok
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should be able to tell whether it's a pack or a game" do
|
86
|
+
URI.should_receive(:encode).exactly(1).times.and_return(File.dirname(__FILE__) + '/support/uk.html')
|
87
|
+
URI.should_receive(:encode).exactly(1).times.and_return(File.dirname(__FILE__) + '/support/packs.html')
|
88
|
+
games = SteamPrices::Game.update_everything('gbp', true)
|
89
|
+
find_game(games, 'gbp', 6433, 998)[:type].should == SteamPrices::Updater::GAME
|
90
|
+
find_game(games, 'gbp', 6433, 996)[:type].should == SteamPrices::Updater::PACK
|
91
|
+
end
|
92
|
+
|
42
93
|
context "all prices" do
|
43
94
|
|
44
95
|
before(:each) do
|
@@ -51,29 +102,36 @@ describe SteamPrices::Updater do
|
|
51
102
|
@games.size.should == 19
|
52
103
|
end
|
53
104
|
|
105
|
+
|
106
|
+
|
107
|
+
|
54
108
|
|
55
109
|
context "exceptions" do
|
56
110
|
it "should be able to handle games like lost coast, which are part of a pack only and list the pack price" do
|
57
|
-
@games
|
111
|
+
find_game(@games, 'usd', 340, 998)[:game].price.should == 0.00
|
112
|
+
find_game(@games, 'usd', 340, 998)[:game].price.class.name.should == "Money"
|
58
113
|
end
|
59
|
-
|
60
|
-
it "should
|
61
|
-
@games
|
114
|
+
|
115
|
+
it "should find games with a sale price" do
|
116
|
+
find_game(@games, 'usd', 39170, 998)[:game].price.should == 44.99
|
117
|
+
find_game(@games, 'usd', 39170, 998)[:game].original_price.should == 49.99
|
62
118
|
end
|
63
119
|
|
64
120
|
it "should have an ok status if the price is ok" do
|
65
|
-
@games
|
66
|
-
@games
|
121
|
+
find_game(@games, 'usd', 22350, 998)[:game].price.should == 49.99
|
122
|
+
find_game(@games, 'usd', 22350, 998)[:status].should == :ok
|
67
123
|
end
|
68
124
|
|
69
125
|
it "should have a not found status if the price is empty but the url is found (preorder)" do
|
70
|
-
@games
|
71
|
-
@games
|
126
|
+
find_game(@games, 'usd', 55150, 998)[:game].price.should == nil
|
127
|
+
find_game(@games, 'usd', 55150, 998)[:status].should == :not_found
|
72
128
|
end
|
73
129
|
|
74
130
|
|
131
|
+
|
132
|
+
|
75
133
|
it "should have a bad request status if the url is invalid or some other crazy error" do
|
76
|
-
@games['http://store.steampowered.com/sale/magic2011?snr=1_7_7_230_150_27'][
|
134
|
+
@games['http://store.steampowered.com/sale/magic2011?snr=1_7_7_230_150_27'][0][:status].should == :bad_request
|
77
135
|
end
|
78
136
|
|
79
137
|
end
|
@@ -89,6 +147,14 @@ describe SteamPrices::Updater do
|
|
89
147
|
end
|
90
148
|
|
91
149
|
|
150
|
+
it "should find games with a sale price" do
|
151
|
+
g = SteamPrices::Game.new('somename', 39170)
|
152
|
+
p = g.update('usd')['usd']
|
153
|
+
p[:original_price].should == 49.99
|
154
|
+
p[:price].should == 44.99
|
155
|
+
end
|
156
|
+
|
157
|
+
|
92
158
|
it "should be able to return a status if it was ok" do
|
93
159
|
g = SteamPrices::Game.new('brink', 22350)
|
94
160
|
p = g.update('usd')['usd']
|
@@ -96,13 +162,15 @@ describe SteamPrices::Updater do
|
|
96
162
|
p[:status].should == :ok
|
97
163
|
end
|
98
164
|
|
99
|
-
|
100
|
-
|
101
|
-
g = SteamPrices::Game.new('Warhammer® 40,000®: Dawn of War® II – Retribution™', 56400)
|
165
|
+
it "should be able to return a price even if the price was 0" do
|
166
|
+
g = SteamPrices::Game.new('brink', 10650)
|
102
167
|
p = g.update('usd')['usd']
|
103
|
-
p[:price].should ==
|
168
|
+
p[:price].should == 0.00
|
169
|
+
p[:status].should == :ok
|
104
170
|
end
|
105
171
|
|
172
|
+
|
173
|
+
|
106
174
|
it "should be able to return not found if it wasn't ok" do
|
107
175
|
g = SteamPrices::Game.new('Warhammer 40,000: Space Marine', 55150)
|
108
176
|
p = g.update('usd')['usd']
|
metadata
CHANGED
@@ -1,99 +1,75 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: steam-prices
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.8
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 6
|
10
|
-
version: 0.1.6
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- scott tesoriere
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2011-05-25 00:00:00 -04:00
|
12
|
+
date: 2011-07-02 00:00:00.000000000 -04:00
|
19
13
|
default_executable:
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
22
16
|
name: rspec
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
17
|
+
requirement: &2153226700 !ruby/object:Gem::Requirement
|
25
18
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 62196475
|
30
|
-
segments:
|
31
|
-
- 2
|
32
|
-
- 0
|
33
|
-
- 0
|
34
|
-
- beta
|
35
|
-
- 12
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
36
22
|
version: 2.0.0.beta.12
|
37
23
|
type: :development
|
38
|
-
version_requirements: *id001
|
39
|
-
- !ruby/object:Gem::Dependency
|
40
|
-
name: nokogiri
|
41
24
|
prerelease: false
|
42
|
-
|
25
|
+
version_requirements: *2153226700
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: nokogiri
|
28
|
+
requirement: &2153226040 !ruby/object:Gem::Requirement
|
43
29
|
none: false
|
44
|
-
requirements:
|
45
|
-
- -
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
|
48
|
-
segments:
|
49
|
-
- 0
|
50
|
-
version: "0"
|
30
|
+
requirements:
|
31
|
+
- - =
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.5.0
|
51
34
|
type: :development
|
52
|
-
version_requirements: *id002
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: money
|
55
35
|
prerelease: false
|
56
|
-
|
36
|
+
version_requirements: *2153226040
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: money
|
39
|
+
requirement: &2153221400 !ruby/object:Gem::Requirement
|
57
40
|
none: false
|
58
|
-
requirements:
|
59
|
-
- -
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
|
62
|
-
segments:
|
63
|
-
- 0
|
64
|
-
version: "0"
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
65
45
|
type: :development
|
66
|
-
version_requirements: *id003
|
67
|
-
- !ruby/object:Gem::Dependency
|
68
|
-
name: open-uri
|
69
46
|
prerelease: false
|
70
|
-
|
47
|
+
version_requirements: *2153221400
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: open-uri
|
50
|
+
requirement: &2153220820 !ruby/object:Gem::Requirement
|
71
51
|
none: false
|
72
|
-
requirements:
|
73
|
-
- -
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
|
76
|
-
segments:
|
77
|
-
- 0
|
78
|
-
version: "0"
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
79
56
|
type: :development
|
80
|
-
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: *2153220820
|
81
59
|
description:
|
82
|
-
email:
|
83
|
-
- scott@tesoriere.com
|
60
|
+
email: scott@tesoriere.com
|
84
61
|
executables: []
|
85
|
-
|
86
62
|
extensions: []
|
87
|
-
|
88
63
|
extra_rdoc_files: []
|
89
|
-
|
90
|
-
|
64
|
+
files:
|
65
|
+
- Gemfile
|
66
|
+
- Gemfile.lock
|
91
67
|
- README.md
|
68
|
+
- lib/steam-prices.rb
|
92
69
|
- lib/steam_prices/steam_country.rb
|
93
70
|
- lib/steam_prices/steam_game.rb
|
94
71
|
- lib/steam_prices/steam_updater.rb
|
95
72
|
- lib/steam_prices/version.rb
|
96
|
-
- lib/steam_prices.rb
|
97
73
|
- spec/spec_helper.rb
|
98
74
|
- spec/steam_country_spec.rb
|
99
75
|
- spec/steam_game_spec.rb
|
@@ -101,38 +77,29 @@ files:
|
|
101
77
|
has_rdoc: true
|
102
78
|
homepage: http://github.com/scottkf/steam_prices
|
103
79
|
licenses: []
|
104
|
-
|
105
80
|
post_install_message:
|
106
81
|
rdoc_options: []
|
107
|
-
|
108
|
-
require_paths:
|
82
|
+
require_paths:
|
109
83
|
- lib
|
110
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
85
|
none: false
|
112
|
-
requirements:
|
113
|
-
- -
|
114
|
-
- !ruby/object:Gem::Version
|
115
|
-
|
116
|
-
|
117
|
-
- 0
|
118
|
-
version: "0"
|
119
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
91
|
none: false
|
121
|
-
requirements:
|
122
|
-
- -
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
|
125
|
-
segments:
|
126
|
-
- 0
|
127
|
-
version: "0"
|
92
|
+
requirements:
|
93
|
+
- - ! '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
128
96
|
requirements: []
|
129
|
-
|
130
97
|
rubyforge_project:
|
131
98
|
rubygems_version: 1.6.2
|
132
99
|
signing_key:
|
133
100
|
specification_version: 3
|
134
101
|
summary: Prices for steam.
|
135
|
-
test_files:
|
102
|
+
test_files:
|
136
103
|
- spec/steam_country_spec.rb
|
137
104
|
- spec/steam_game_spec.rb
|
138
105
|
- spec/steam_updater_spec.rb
|