Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Re-organize some of the files to make it a little less silly to add m…

…ore into the SauceTV module
  • Loading branch information...
commit de5021823b2a9f70a82239c11fecadc906ea6a52 1 parent 729bb11
R. Tyler Croy authored
3  features/support/env.rb
View
@@ -4,6 +4,7 @@
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../../lib')
-require 'saucetv'
+require 'saucetv/app'
+require 'saucetv/api'
Capybara.app = SauceTV::Application
33 lib/saucetv.rb
View
@@ -1,35 +1,2 @@
-require 'sinatra'
-
-
module SauceTV
- class Application < Sinatra::Base
- enable :sessions
-
- def authenticated?
- session[:username] && session[:api_key]
- end
-
- get '/' do
- 'Welcome to SauceLabs.tv'
- end
-
- get '/login' do
- haml :login
- end
-
- post '/login' do
- session[:username] = params[:username]
- session[:api_key] = params[:api_key]
- redirect to('/watch')
- end
-
- get '/watch' do
- unless authenticated?
- redirect to('/login')
- end
-
- haml :watch, :locals => {:username => session[:username]}
- end
-
- end
end
16 lib/saucetv/api.rb
View
@@ -0,0 +1,16 @@
+
+module SauceTV
+ class API
+ attr_accessor :username
+ attr_writer :api_key
+
+ def initialize(username, api_key)
+ @username = username
+ @api_key = api_key
+ end
+
+ def recent_jobs
+ []
+ end
+ end
+end
40 lib/saucetv/app.rb
View
@@ -0,0 +1,40 @@
+require 'sinatra'
+require 'saucetv/api'
+
+module SauceTV
+ class Application < Sinatra::Base
+ enable :sessions
+
+ def authenticated?
+ session[:username] && session[:api_key]
+ end
+
+ get '/' do
+ 'Welcome to SauceLabs.tv'
+ end
+
+ get '/login' do
+ haml :login
+ end
+
+ post '/login' do
+ session[:username] = params[:username]
+ session[:api_key] = params[:api_key]
+ redirect to('/watch')
+ end
+
+ get '/watch' do
+ unless authenticated?
+ redirect to('/login')
+ end
+
+ api = SauceTV::API.new(session[:username], session[:api_key])
+
+ haml :watch, :locals => {
+ :username => session[:username],
+ :jobs => api.recent_jobs
+ }
+ end
+
+ end
+end
0  lib/views/login.haml → lib/saucetv/views/login.haml
View
File renamed without changes
0  lib/views/watch.haml → lib/saucetv/views/watch.haml
View
File renamed without changes
Please sign in to comment.
Something went wrong with that request. Please try again.