Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Spun off get_steam_id to SteamUtil module.

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