Skip to content

Commit

Permalink
Ming Jin: refactor some code
Browse files Browse the repository at this point in the history
  • Loading branch information
skyairmj committed Mar 22, 2012
1 parent 9b6150f commit c6cf694
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ source :rubygems

gem 'rake'
gem 'rcov', '0.9.10'
gem 'systemu'

gem 'rack'
gem 'rack-test'
Expand Down
3 changes: 2 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'rake'
require 'rack'
require 'rspec/core/rake_task'
require 'systemu'

RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = "spec/ruby/**/*_spec.rb" # don't need this, it's default.
Expand All @@ -24,7 +25,7 @@ end
namespace :redis do
task :start do
sh 'redis-server'
end
end
end

task :default => :spec
Expand Down
8 changes: 4 additions & 4 deletions controllers/static_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ class StaticController < Sinatra::Base
post '/signin' do
unless params[:team].nil?
redirect "/#{params[:team]}", 303
end
end
end

post '/signup' do
unless params[:team].nil?
redirect "/#{params[:team]}", 303
end
end
end

get '/:team' do
Expand All @@ -42,7 +42,7 @@ class StaticController < Sinatra::Base
get '/:team/profile' do
"hello! #{params[:team]}"
end

get '/:team/existing_cards' do
@team = Team.find_by_name(params[:team]) || new_team_with_sections(params[:team])
team_hash = {}
Expand All @@ -52,7 +52,7 @@ class StaticController < Sinatra::Base
content_type :json
team_hash.to_json
end

def section_hash section
hash = {}
section.stickies.each do |sticky|
Expand Down
4 changes: 2 additions & 2 deletions controllers/websocket_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'stringio'
require 'cramp'
require 'yajl'
require 'yajl'
require 'redis_connection'
require 'helpers/json_helper'
require 'lib/db_operator'
Expand All @@ -12,7 +12,7 @@ class WebsocketController < Cramp::Websocket

on_start :handle_join
on_data :handle_data

def handle_join
@@connections << self
end
Expand Down
2 changes: 1 addition & 1 deletion helpers/json_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module JSonHelper
def encode_json(obj)
Yajl::Encoder.encode(obj)
end

def parse_json(str)
Yajl::Parser.parse(str, :symbolize_keys => true)
end
Expand Down

0 comments on commit c6cf694

Please sign in to comment.