Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Spun off get_steam_id to SteamUtil module.

  • Loading branch information...
commit c01c05dfdb850c2a36e4bff23b99921fda5da4bd 1 parent 408c8d0
Joost Schuur authored
2  Gemfile
@@ -8,7 +8,7 @@ gem 'rails', '3.1.0'
8 8 gem 'mysql2'
9 9 gem 'steam-condenser'
10 10 gem 'sparklines'
11   -gem 'rmagick'
  11 +gem 'rmagick', :require => false
12 12 gem 'omniauth'
13 13 gem 'redis'
14 14 gem 'coffeebeans'
13 app/models/achievements.rb
... ... @@ -1,5 +1,6 @@
1 1 class Achievements
2 2 attr_reader :error, :id
  3 + include SteamUtil
3 4
4 5 def initialize(user, game)
5 6 if @achievements = load_game_achievements(user, game)
@@ -9,11 +10,7 @@ def initialize(user, game)
9 10 achievements_per_day = @unlocked.map(&:timestamp).compact.reduce(Hash.new(0)) { |hash, timestamp| hash[timestamp.strftime("%D")] += 1; hash }
10 11 @sparkline_history = (Date.today-28 .. Date.today).map { |d| achievements_per_day[d.strftime("%D")] }
11 12
12   - if user.to_i.to_s == user
13   - @id = SteamId.new(user.to_i)
14   - else
15   - @id = SteamId.new(user)
16   - end
  13 + @id = get_steam_id(user)
17 14 end
18 15 end
19 16
@@ -36,11 +33,7 @@ def load_game_achievements(user, game)
36 33 Marshal.load(cached_achievements)
37 34 else
38 35 begin
39   - if user.to_i.to_s == user
40   - id = SteamId.new(user.to_i)
41   - else
42   - id = SteamId.new(user)
43   - end
  36 + id = get_steam_id(user)
44 37
45 38 # Save any profile we did a lookup on for later
46 39 User.create_with_id(id)
9 app/models/friends.rb
... ... @@ -1,11 +1,8 @@
1 1 class Friends
  2 + include SteamUtil
  3 +
2 4 def initialize(user)
3   - if user.to_i.to_s == user
4   - id = SteamId.new(user.to_i)
5   - else
6   - id = SteamId.new(user)
7   - end
8   -
  5 + id = get_steam_id(user)
9 6 load_friends(id)
10 7 end
11 8
2  config/application.rb
@@ -16,7 +16,7 @@ class Application < Rails::Application
16 16 # -- all .rb files in that directory are automatically loaded.
17 17
18 18 # Custom directories with classes and modules you want to be autoloadable.
19   - # config.autoload_paths += %W(#{config.root}/extras)
  19 + config.autoload_paths += %W(#{config.root}/lib)
20 20
21 21 # Only load the plugins named here, in the order given (default is alphabetical).
22 22 # :all can be used as a placeholder for all plugins not explicitly named.
9 lib/steam_util.rb
... ... @@ -0,0 +1,9 @@
  1 +module SteamUtil
  2 + def get_steam_id(user)
  3 + if user.to_i.to_s == user
  4 + SteamId.new(user.to_i)
  5 + else
  6 + SteamId.new(user)
  7 + end
  8 + end
  9 +end

0 comments on commit c01c05d

Please sign in to comment.
Something went wrong with that request. Please try again.