Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start to play and structure the application
- Loading branch information
David Henry
committed
Oct 20, 2011
1 parent
cccb0a1
commit aa56107
Showing
15 changed files
with
193 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
log/* | ||
*.swp | ||
*.swo | ||
*.un~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rvm use --install --create 1.9.2-p180@workflow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
require File.join(File.dirname(__FILE__), 'application') | ||
require 'rubygems' | ||
require File.join(File.dirname(__FILE__), 'lib', 'workflow.rb') | ||
|
||
set :run, false | ||
set :environment, :production | ||
|
||
FileUtils.mkdir_p 'log' unless File.exists?('log') | ||
log = File.new("log/sinatra.log", "a+") | ||
$stdout.reopen(log) | ||
$stderr.reopen(log) | ||
# FileUtils.mkdir_p 'log' unless File.exists?('log') | ||
# log = File.new("log/sinatra.log", "a+") | ||
# $stdout.reopen(log) | ||
# $stderr.reopen(log) | ||
|
||
run Sinatra::Application | ||
run Workflow::Routes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,26 @@ | ||
require 'rubygems' | ||
require 'bundler/setup' | ||
require 'dm-core' | ||
require 'dm-timestamps' | ||
require 'dm-validations' | ||
require 'dm-aggregates' | ||
require 'dm-migrations' | ||
require 'haml' | ||
require 'ostruct' | ||
|
||
require 'sinatra' unless defined?(Sinatra) | ||
|
||
configure do | ||
SiteConfig = OpenStruct.new( | ||
:title => 'Your Application Name', | ||
:author => 'Your Name', | ||
:url_base => 'http://localhost:4567/' | ||
) | ||
|
||
# load models | ||
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/lib") | ||
Dir.glob("#{File.dirname(__FILE__)}/lib/*.rb") { |lib| require File.basename(lib, '.*') } | ||
|
||
DataMapper.setup(:default, (ENV["DATABASE_URL"] || "sqlite3:///#{File.expand_path(File.dirname(__FILE__))}/#{Sinatra::Base.environment}.db")) | ||
end | ||
# require 'rubygems' | ||
# require 'bundler/setup' | ||
# require 'dm-core' | ||
# require 'dm-timestamps' | ||
# require 'dm-validations' | ||
# require 'dm-aggregates' | ||
# require 'dm-migrations' | ||
# require 'haml' | ||
# require 'ostruct' | ||
# | ||
# require 'sinatra' unless defined?(Sinatra) | ||
# | ||
# configure do | ||
# SiteConfig = OpenStruct.new( | ||
# :title => 'Your Application Name', | ||
# :author => 'Your Name', | ||
# :url_base => 'http://localhost:4567/' | ||
# ) | ||
# | ||
# # load models | ||
# $LOAD_PATH.unshift("#{File.dirname(__FILE__)}/lib") | ||
# Dir.glob("#{File.dirname(__FILE__)}/lib/*.rb") { |lib| require File.basename(lib, '.*') } | ||
# | ||
# DataMapper.setup(:default, (ENV["DATABASE_URL"] || "sqlite3:///#{File.expand_path(File.dirname(__FILE__))}/#{Sinatra::Base.environment}.db")) | ||
# end | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
$LOAD_PATH.unshift(File.dirname(__FILE__)) | ||
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) | ||
|
||
require 'sinatra' | ||
require 'sinatra/namespace' | ||
require 'json' | ||
# require 'mongoid' | ||
# require 'airbrake' | ||
|
||
require 'workflow/workflow' | ||
require 'workflow/routes' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
SiteConfig = OpenStruct.new( | ||
:title => 'Workflow Monitor', | ||
:author => 'David Henry', | ||
:url_base => 'http://workflow-monitor.herokuapp.com/' | ||
) | ||
|
||
module Workflow | ||
class Routes < Sinatra::Base | ||
configure do |config| | ||
# mongo_env = YAML.load_file(File.join(File.dirname(__FILE__) ,'..', '..', 'config', 'mongoid.yml'))[config.environment.to_s] | ||
# Mongoid.config do |config| | ||
# mongo_connection = Mongo::Connection.new(mongo_env["host"]).db(mongo_env["database"]) | ||
# mongo_connection.authenticate(mongo_env["user"], mongo_env["password"]) if mongo_env["user"] | ||
# config.master = mongo_connection | ||
# end | ||
|
||
end | ||
|
||
require 'workflow/routes/root' | ||
use Root | ||
|
||
require 'workflow/routes/process' | ||
use Process | ||
|
||
require 'workflow/routes/tasks' | ||
use Tasks | ||
end | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module Workflow | ||
class Routes | ||
class Process < Sinatra::Base | ||
register Sinatra::Namespace | ||
|
||
namespace '/process' do | ||
get '' do | ||
haml :'tasks/index' | ||
end | ||
|
||
get '/:id/show' do | ||
haml 'show process' | ||
end | ||
|
||
namespace '/:process_id/tasks' do | ||
get '/new' do | ||
haml 'new task' | ||
end | ||
|
||
post '/create' do | ||
haml 'create task' | ||
end | ||
|
||
delete '/:id' do | ||
haml 'delete task' | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module Workflow | ||
class Routes | ||
class Root < Sinatra::Base | ||
set :public, 'public/' | ||
|
||
get '/application.css' do | ||
sass :style | ||
end | ||
|
||
get '/' do | ||
@name, @ruby_version, @gems = self.class.sysinfo | ||
haml :sysinfo | ||
end | ||
|
||
def self.sysinfo | ||
[name, ruby_version, gems] | ||
end | ||
|
||
private | ||
def self.name | ||
to_s | ||
end | ||
|
||
def self.ruby_version | ||
%x[ruby --version] | ||
end | ||
|
||
def self.gems | ||
gems = %x[bundle list] | ||
gems.split('*')[1..-1] | ||
end | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module Workflow | ||
class Routes | ||
class Tasks < Sinatra::Base | ||
register Sinatra::Namespace | ||
|
||
namespace '/tasks' do | ||
get '' do | ||
haml :'tasks/index' | ||
end | ||
|
||
get '/new' do | ||
haml 'new record??' | ||
end | ||
|
||
post '/create' do | ||
haml 'create' | ||
end | ||
|
||
get '/show/:id' do | ||
haml 'show' | ||
end | ||
|
||
get '/edit/:id' do | ||
haml 'edit' | ||
end | ||
|
||
put '/update/:id' do | ||
haml 'update' | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module Workflow | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.project_name Project name: #{@name} | ||
.ruby_version Ruby version: #{@ruby_version} | ||
.gems | ||
Gems: | ||
%ul | ||
- @gems.each do |gem| | ||
%li= gem | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
this is a index |