Permalink
Browse files

Ming Jin: refactor some code

  • Loading branch information...
1 parent 9b6150f commit c6cf69463adbd9207c1a0e28bf1d3420f00546dc @mingjin committed Mar 22, 2012
Showing with 10 additions and 8 deletions.
  1. +1 −0 Gemfile
  2. +2 −1 Rakefile
  3. +4 −4 controllers/static_controller.rb
  4. +2 −2 controllers/websocket_controller.rb
  5. +1 −1 helpers/json_helper.rb
View
@@ -2,6 +2,7 @@ source :rubygems
gem 'rake'
gem 'rcov', '0.9.10'
+gem 'systemu'
gem 'rack'
gem 'rack-test'
View
@@ -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.
@@ -24,7 +25,7 @@ end
namespace :redis do
task :start do
sh 'redis-server'
- end
+ end
end
task :default => :spec
@@ -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
@@ -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 = {}
@@ -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|
@@ -1,6 +1,6 @@
require 'stringio'
require 'cramp'
-require 'yajl'
+require 'yajl'
require 'redis_connection'
require 'helpers/json_helper'
require 'lib/db_operator'
@@ -12,7 +12,7 @@ class WebsocketController < Cramp::Websocket
on_start :handle_join
on_data :handle_data
-
+
def handle_join
@@connections << self
end
View
@@ -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

0 comments on commit c6cf694

Please sign in to comment.