Skip to content

Commit

Permalink
added clans (Not tested yet)
Browse files Browse the repository at this point in the history
  • Loading branch information
junethack committed Jun 9, 2011
1 parent 511f409 commit bd524d8
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 19 deletions.
14 changes: 4 additions & 10 deletions Rakefile.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,16 +2,7 @@
require 'database' require 'database'
require 'fetch_games' require 'fetch_games'
require 'date' require 'date'
task :testthis do
bla = ["a","b","c","d"]
for name in bla
puts "executing task for #{name}"
Rake::Task['testexec'].invoke name
end
end
task :testexec do |t, args|
puts "called with #{args.inspect}"
end
namespace :bogus do namespace :bogus do


names = ["r4wrmage","ad3on","k3rio","bh44k","c4smith789", "st3nno"] #hi #junethack names = ["r4wrmage","ad3on","k3rio","bh44k","c4smith789", "st3nno"] #hi #junethack
Expand All @@ -24,6 +15,9 @@
end end
Rake::Task['bogus:add_game'].invoke 20 Rake::Task['bogus:add_game'].invoke 20
end end

task :add_server :name, :url, :xlogurl do |t, args|
Server.create(:name => args[:name], :url => args[:url], :xlogurl => args[:xlogurl]


task :add_servers do task :add_servers do
Server.create(:name => "test server 1", :url => "localhost", :xlogurl => "file://test_xlog.txt", :xloglastmodified => "1.1.1970", :xlogcurrentoffset => 0) Server.create(:name => "test server 1", :url => "localhost", :xlogurl => "file://test_xlog.txt", :xloglastmodified => "1.1.1970", :xlogcurrentoffset => 0)
Expand Down
1 change: 1 addition & 0 deletions Readme.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- haml - haml
- ruby-sqlite3 - ruby-sqlite3
- datamapper - datamapper
- dm-serializer


##Usage ##Usage
Run the sinatra server with Run the sinatra server with
Expand Down
1 change: 1 addition & 0 deletions database.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
require 'models/user' require 'models/user'
require 'models/account' require 'models/account'
require 'models/game' require 'models/game'
require 'models/clan'


DataMapper.finalize DataMapper.finalize
DataMapper.auto_upgrade! DataMapper.auto_upgrade!
19 changes: 17 additions & 2 deletions models/account.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,14 +3,29 @@ class Account #join model
include DataMapper::Resource include DataMapper::Resource


belongs_to :user, :key => true belongs_to :user, :key => true
belongs_to :server, :key => true belongs_to :server, :key => true, :lazy => false


belongs_to :clan, :required => false


property :name, String property :name, String
property :verified, Boolean, :default => false property :verified, Boolean, :default => false


property :invitations, Json

def get_games def get_games
self.server.games.select{|game| game.name == self.name} self.server.games.select{|game| game.name == self.name}
end end

def invite invitation
self.invitations.push invitation
self.save
end

def respond_invite invitation, accept
if clan = Clan.get(invitation['clan_id'])
invitation['status'] = accept ? 'accept' : 'decline'
clan.get_invitation_response invitation
end
end
end end


7 changes: 0 additions & 7 deletions server.rb

This file was deleted.

0 comments on commit bd524d8

Please sign in to comment.