codesake-dawn 0.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +18 -0
- data/.rvmrc +48 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +54 -0
- data/Rakefile +64 -0
- data/Roadmap.md +44 -0
- data/bin/dawn +106 -0
- data/codesake_dawn.gemspec +25 -0
- data/lib/codesake-dawn.rb +7 -0
- data/lib/codesake/dawn/engine.rb +144 -0
- data/lib/codesake/dawn/kb/basic_check.rb +93 -0
- data/lib/codesake/dawn/kb/cve_2011_2931.rb +32 -0
- data/lib/codesake/dawn/kb/cve_2012_2660.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2012_2661.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2012_2694.rb +31 -0
- data/lib/codesake/dawn/kb/cve_2012_2695.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2012_3465.rb +28 -0
- data/lib/codesake/dawn/kb/cve_2012_6496.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2012_6497.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2013_0155.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2013_0269.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2013_0333.rb +33 -0
- data/lib/codesake/dawn/kb/cve_2013_1800.rb +28 -0
- data/lib/codesake/dawn/kb/cve_2013_1855.rb +20 -0
- data/lib/codesake/dawn/kb/cve_2013_1857.rb +22 -0
- data/lib/codesake/dawn/kb/dependency_check.rb +39 -0
- data/lib/codesake/dawn/kb/not_revised_code.rb +24 -0
- data/lib/codesake/dawn/kb/pattern_match_check.rb +60 -0
- data/lib/codesake/dawn/knowledge_base.rb +105 -0
- data/lib/codesake/dawn/rails.rb +17 -0
- data/lib/codesake/dawn/sinatra.rb +14 -0
- data/lib/codesake/dawn/version.rb +5 -0
- data/spec/lib/dawn/codesake_knowledgebase_spec.rb +100 -0
- data/spec/lib/dawn/codesake_sinatra_engine_spec.rb +80 -0
- data/spec/lib/kb/codesake_cve_2013_1800_spec.rb +66 -0
- data/spec/lib/kb/codesake_cve_2013_1855_spec.rb +16 -0
- data/spec/lib/kb/cve_2011_2931_spec.rb +7 -0
- data/spec/lib/kb/cve_2012_2660_spec.rb +9 -0
- data/spec/lib/kb/cve_2012_2661_spec.rb +7 -0
- data/spec/lib/kb/cve_2012_2694_spec.rb +7 -0
- data/spec/lib/kb/cve_2012_2695_spec.rb +7 -0
- data/spec/lib/kb/cve_2012_3465_spec.rb +7 -0
- data/spec/lib/kb/cve_2012_6496_spec.rb +7 -0
- data/spec/lib/kb/cve_2012_6497_spec.rb +7 -0
- data/spec/lib/kb/cve_2013_0155_spec.rb +7 -0
- data/spec/lib/kb/cve_2013_0269_spec.rb +7 -0
- data/spec/lib/kb/cve_2013_0333_spec.rb +7 -0
- data/spec/lib/kb/cve_2013_1857_spec.rb +13 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/support/hello_world_3.0.19/.gitignore +4 -0
- data/spec/support/hello_world_3.0.19/Gemfile +31 -0
- data/spec/support/hello_world_3.0.19/README +256 -0
- data/spec/support/hello_world_3.0.19/Rakefile +7 -0
- data/spec/support/hello_world_3.0.19/app/controllers/application_controller.rb +3 -0
- data/spec/support/hello_world_3.0.19/app/helpers/application_helper.rb +2 -0
- data/spec/support/hello_world_3.0.19/app/views/layouts/application.html.erb +14 -0
- data/spec/support/hello_world_3.0.19/config.ru +4 -0
- data/spec/support/hello_world_3.0.19/config/application.rb +42 -0
- data/spec/support/hello_world_3.0.19/config/boot.rb +6 -0
- data/spec/support/hello_world_3.0.19/config/database.yml +22 -0
- data/spec/support/hello_world_3.0.19/config/environment.rb +5 -0
- data/spec/support/hello_world_3.0.19/config/environments/development.rb +26 -0
- data/spec/support/hello_world_3.0.19/config/environments/production.rb +49 -0
- data/spec/support/hello_world_3.0.19/config/environments/test.rb +35 -0
- data/spec/support/hello_world_3.0.19/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/support/hello_world_3.0.19/config/initializers/inflections.rb +10 -0
- data/spec/support/hello_world_3.0.19/config/initializers/mime_types.rb +5 -0
- data/spec/support/hello_world_3.0.19/config/initializers/secret_token.rb +7 -0
- data/spec/support/hello_world_3.0.19/config/initializers/session_store.rb +8 -0
- data/spec/support/hello_world_3.0.19/config/locales/en.yml +5 -0
- data/spec/support/hello_world_3.0.19/config/routes.rb +58 -0
- data/spec/support/hello_world_3.0.19/db/seeds.rb +7 -0
- data/spec/support/hello_world_3.0.19/lib/tasks/.gitkeep +0 -0
- data/spec/support/hello_world_3.0.19/public/404.html +26 -0
- data/spec/support/hello_world_3.0.19/public/422.html +26 -0
- data/spec/support/hello_world_3.0.19/public/500.html +26 -0
- data/spec/support/hello_world_3.0.19/public/favicon.ico +0 -0
- data/spec/support/hello_world_3.0.19/public/images/rails.png +0 -0
- data/spec/support/hello_world_3.0.19/public/index.html +239 -0
- data/spec/support/hello_world_3.0.19/public/javascripts/application.js +2 -0
- data/spec/support/hello_world_3.0.19/public/javascripts/controls.js +965 -0
- data/spec/support/hello_world_3.0.19/public/javascripts/dragdrop.js +974 -0
- data/spec/support/hello_world_3.0.19/public/javascripts/effects.js +1123 -0
- data/spec/support/hello_world_3.0.19/public/javascripts/prototype.js +6001 -0
- data/spec/support/hello_world_3.0.19/public/javascripts/rails.js +202 -0
- data/spec/support/hello_world_3.0.19/public/robots.txt +5 -0
- data/spec/support/hello_world_3.0.19/public/stylesheets/.gitkeep +0 -0
- data/spec/support/hello_world_3.0.19/script/rails +6 -0
- data/spec/support/hello_world_3.0.19/test/performance/browsing_test.rb +9 -0
- data/spec/support/hello_world_3.0.19/test/test_helper.rb +13 -0
- data/spec/support/hello_world_3.0.19/vendor/plugins/.gitkeep +0 -0
- data/spec/support/hello_world_3.1.0/.gitignore +5 -0
- data/spec/support/hello_world_3.1.0/Gemfile +33 -0
- data/spec/support/hello_world_3.1.0/README +261 -0
- data/spec/support/hello_world_3.1.0/Rakefile +7 -0
- data/spec/support/hello_world_3.1.0/app/assets/images/rails.png +0 -0
- data/spec/support/hello_world_3.1.0/app/assets/javascripts/application.js +9 -0
- data/spec/support/hello_world_3.1.0/app/assets/stylesheets/application.css +7 -0
- data/spec/support/hello_world_3.1.0/app/controllers/application_controller.rb +3 -0
- data/spec/support/hello_world_3.1.0/app/helpers/application_helper.rb +2 -0
- data/spec/support/hello_world_3.1.0/app/mailers/.gitkeep +0 -0
- data/spec/support/hello_world_3.1.0/app/models/.gitkeep +0 -0
- data/spec/support/hello_world_3.1.0/app/views/layouts/application.html.erb +14 -0
- data/spec/support/hello_world_3.1.0/config.ru +4 -0
- data/spec/support/hello_world_3.1.0/config/application.rb +48 -0
- data/spec/support/hello_world_3.1.0/config/boot.rb +6 -0
- data/spec/support/hello_world_3.1.0/config/database.yml +25 -0
- data/spec/support/hello_world_3.1.0/config/environment.rb +5 -0
- data/spec/support/hello_world_3.1.0/config/environments/development.rb +30 -0
- data/spec/support/hello_world_3.1.0/config/environments/production.rb +60 -0
- data/spec/support/hello_world_3.1.0/config/environments/test.rb +42 -0
- data/spec/support/hello_world_3.1.0/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/support/hello_world_3.1.0/config/initializers/inflections.rb +10 -0
- data/spec/support/hello_world_3.1.0/config/initializers/mime_types.rb +5 -0
- data/spec/support/hello_world_3.1.0/config/initializers/secret_token.rb +7 -0
- data/spec/support/hello_world_3.1.0/config/initializers/session_store.rb +8 -0
- data/spec/support/hello_world_3.1.0/config/initializers/wrap_parameters.rb +14 -0
- data/spec/support/hello_world_3.1.0/config/locales/en.yml +5 -0
- data/spec/support/hello_world_3.1.0/config/routes.rb +58 -0
- data/spec/support/hello_world_3.1.0/db/seeds.rb +7 -0
- data/spec/support/hello_world_3.1.0/lib/assets/.gitkeep +0 -0
- data/spec/support/hello_world_3.1.0/lib/tasks/.gitkeep +0 -0
- data/spec/support/hello_world_3.1.0/log/.gitkeep +0 -0
- data/spec/support/hello_world_3.1.0/public/404.html +26 -0
- data/spec/support/hello_world_3.1.0/public/422.html +26 -0
- data/spec/support/hello_world_3.1.0/public/500.html +26 -0
- data/spec/support/hello_world_3.1.0/public/favicon.ico +0 -0
- data/spec/support/hello_world_3.1.0/public/index.html +241 -0
- data/spec/support/hello_world_3.1.0/public/robots.txt +5 -0
- data/spec/support/hello_world_3.1.0/script/rails +6 -0
- data/spec/support/hello_world_3.1.0/test/fixtures/.gitkeep +0 -0
- data/spec/support/hello_world_3.1.0/test/functional/.gitkeep +0 -0
- data/spec/support/hello_world_3.1.0/test/integration/.gitkeep +0 -0
- data/spec/support/hello_world_3.1.0/test/performance/browsing_test.rb +12 -0
- data/spec/support/hello_world_3.1.0/test/test_helper.rb +13 -0
- data/spec/support/hello_world_3.1.0/test/unit/.gitkeep +0 -0
- data/spec/support/hello_world_3.1.0/vendor/assets/stylesheets/.gitkeep +0 -0
- data/spec/support/hello_world_3.1.0/vendor/plugins/.gitkeep +0 -0
- data/spec/support/hello_world_3.2.13/.gitignore +15 -0
- data/spec/support/hello_world_3.2.13/Gemfile +38 -0
- data/spec/support/hello_world_3.2.13/README.rdoc +261 -0
- data/spec/support/hello_world_3.2.13/Rakefile +7 -0
- data/spec/support/hello_world_3.2.13/app/assets/images/rails.png +0 -0
- data/spec/support/hello_world_3.2.13/app/assets/javascripts/application.js +15 -0
- data/spec/support/hello_world_3.2.13/app/assets/stylesheets/application.css +13 -0
- data/spec/support/hello_world_3.2.13/app/controllers/application_controller.rb +3 -0
- data/spec/support/hello_world_3.2.13/app/helpers/application_helper.rb +2 -0
- data/spec/support/hello_world_3.2.13/app/mailers/.gitkeep +0 -0
- data/spec/support/hello_world_3.2.13/app/models/.gitkeep +0 -0
- data/spec/support/hello_world_3.2.13/app/views/layouts/application.html.erb +14 -0
- data/spec/support/hello_world_3.2.13/config.ru +4 -0
- data/spec/support/hello_world_3.2.13/config/application.rb +62 -0
- data/spec/support/hello_world_3.2.13/config/boot.rb +6 -0
- data/spec/support/hello_world_3.2.13/config/database.yml +25 -0
- data/spec/support/hello_world_3.2.13/config/environment.rb +5 -0
- data/spec/support/hello_world_3.2.13/config/environments/development.rb +37 -0
- data/spec/support/hello_world_3.2.13/config/environments/production.rb +67 -0
- data/spec/support/hello_world_3.2.13/config/environments/test.rb +37 -0
- data/spec/support/hello_world_3.2.13/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/support/hello_world_3.2.13/config/initializers/inflections.rb +15 -0
- data/spec/support/hello_world_3.2.13/config/initializers/mime_types.rb +5 -0
- data/spec/support/hello_world_3.2.13/config/initializers/secret_token.rb +7 -0
- data/spec/support/hello_world_3.2.13/config/initializers/session_store.rb +8 -0
- data/spec/support/hello_world_3.2.13/config/initializers/wrap_parameters.rb +14 -0
- data/spec/support/hello_world_3.2.13/config/locales/en.yml +5 -0
- data/spec/support/hello_world_3.2.13/config/routes.rb +58 -0
- data/spec/support/hello_world_3.2.13/db/seeds.rb +7 -0
- data/spec/support/hello_world_3.2.13/lib/assets/.gitkeep +0 -0
- data/spec/support/hello_world_3.2.13/lib/tasks/.gitkeep +0 -0
- data/spec/support/hello_world_3.2.13/log/.gitkeep +0 -0
- data/spec/support/hello_world_3.2.13/public/404.html +26 -0
- data/spec/support/hello_world_3.2.13/public/422.html +26 -0
- data/spec/support/hello_world_3.2.13/public/500.html +25 -0
- data/spec/support/hello_world_3.2.13/public/favicon.ico +0 -0
- data/spec/support/hello_world_3.2.13/public/index.html +241 -0
- data/spec/support/hello_world_3.2.13/public/robots.txt +5 -0
- data/spec/support/hello_world_3.2.13/script/rails +6 -0
- data/spec/support/hello_world_3.2.13/test/fixtures/.gitkeep +0 -0
- data/spec/support/hello_world_3.2.13/test/functional/.gitkeep +0 -0
- data/spec/support/hello_world_3.2.13/test/integration/.gitkeep +0 -0
- data/spec/support/hello_world_3.2.13/test/performance/browsing_test.rb +12 -0
- data/spec/support/hello_world_3.2.13/test/test_helper.rb +13 -0
- data/spec/support/hello_world_3.2.13/test/unit/.gitkeep +0 -0
- data/spec/support/hello_world_3.2.13/vendor/assets/javascripts/.gitkeep +0 -0
- data/spec/support/hello_world_3.2.13/vendor/assets/stylesheets/.gitkeep +0 -0
- data/spec/support/hello_world_3.2.13/vendor/plugins/.gitkeep +0 -0
- data/spec/support/lorem.txt +23 -0
- data/spec/support/sinatra-safe/.gems +4 -0
- data/spec/support/sinatra-safe/.gitignore +6 -0
- data/spec/support/sinatra-safe/Gemfile +18 -0
- data/spec/support/sinatra-safe/MIT-LICENSE +20 -0
- data/spec/support/sinatra-safe/README.rdoc +35 -0
- data/spec/support/sinatra-safe/Rakefile +32 -0
- data/spec/support/sinatra-safe/application.rb +23 -0
- data/spec/support/sinatra-safe/config.ru +11 -0
- data/spec/support/sinatra-safe/environment.rb +25 -0
- data/spec/support/sinatra-safe/lib/profile.rb +11 -0
- data/spec/support/sinatra-safe/public/main.css +52 -0
- data/spec/support/sinatra-safe/script/console +16 -0
- data/spec/support/sinatra-safe/views/layout.haml +14 -0
- data/spec/support/sinatra-safe/views/root.haml +4 -0
- data/spec/support/sinatra-vulnerable/.gems +4 -0
- data/spec/support/sinatra-vulnerable/.gitignore +6 -0
- data/spec/support/sinatra-vulnerable/Gemfile +17 -0
- data/spec/support/sinatra-vulnerable/MIT-LICENSE +20 -0
- data/spec/support/sinatra-vulnerable/README.rdoc +35 -0
- data/spec/support/sinatra-vulnerable/Rakefile +32 -0
- data/spec/support/sinatra-vulnerable/application.rb +28 -0
- data/spec/support/sinatra-vulnerable/config.ru +11 -0
- data/spec/support/sinatra-vulnerable/environment.rb +25 -0
- data/spec/support/sinatra-vulnerable/lib/profile.rb +11 -0
- data/spec/support/sinatra-vulnerable/public/main.css +52 -0
- data/spec/support/sinatra-vulnerable/script/console +16 -0
- data/spec/support/sinatra-vulnerable/views/layout.haml +14 -0
- data/spec/support/sinatra-vulnerable/views/root.haml +4 -0
- metadata +519 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2009 Nick Plante
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
= Sinatra Application Template
|
|
2
|
+
|
|
3
|
+
A base Sinatra application template. Just fork and build. Yay!
|
|
4
|
+
Includes Bundler, DataMapper, RSpec2, and Haml, all ready to go.
|
|
5
|
+
|
|
6
|
+
Works with both Ruby 1.8.7 and Ruby 1.9.2.
|
|
7
|
+
|
|
8
|
+
== Configuration
|
|
9
|
+
|
|
10
|
+
Dependencies and all configuration is done in <tt>environment.rb</tt>. Your database is also set up here. DataMapper will use sqlite3 by default. Tests use the sqlite3-memory adapter (no configuration needed).
|
|
11
|
+
|
|
12
|
+
Add your controller actions in <tt>application.rb</tt>. Views for these actions are placed in the <tt>views</tt> directory. Static files, including a stock stylesheet, go in the <tt>public</tt> directory. Models go in the <tt>lib</tt> directory and are auto-loaded.
|
|
13
|
+
|
|
14
|
+
== Testing
|
|
15
|
+
|
|
16
|
+
Add your specs in <tt>spec</tt>; just require <tt>spec_helper.rb</tt> to pre-configure the test environment. A number of samples are provided (including a sample model, which can be removed). To run the specs:
|
|
17
|
+
|
|
18
|
+
rake spec
|
|
19
|
+
|
|
20
|
+
== Getting Started
|
|
21
|
+
|
|
22
|
+
bundle install
|
|
23
|
+
rake db:migrate
|
|
24
|
+
ruby application.rb
|
|
25
|
+
|
|
26
|
+
== Thanks
|
|
27
|
+
|
|
28
|
+
This project includes contributions from the following developers:
|
|
29
|
+
|
|
30
|
+
* garrensmith
|
|
31
|
+
* bryanwoods
|
|
32
|
+
* flexd
|
|
33
|
+
* mcollina
|
|
34
|
+
|
|
35
|
+
(c) 2011 Nick Plante. This code is distributed under the MIT license.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'bundler/setup'
|
|
3
|
+
require 'rspec/core/rake_task'
|
|
4
|
+
|
|
5
|
+
task :default => :test
|
|
6
|
+
task :test => :spec
|
|
7
|
+
|
|
8
|
+
if !defined?(RSpec)
|
|
9
|
+
puts "spec targets require RSpec"
|
|
10
|
+
else
|
|
11
|
+
desc "Run all examples"
|
|
12
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
|
13
|
+
#t.pattern = 'spec/**/*_spec.rb' # not needed this is default
|
|
14
|
+
t.rspec_opts = ['-cfs']
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
namespace :db do
|
|
19
|
+
desc 'Auto-migrate the database (destroys data)'
|
|
20
|
+
task :migrate => :environment do
|
|
21
|
+
DataMapper.auto_migrate!
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
desc 'Auto-upgrade the database (preserves data)'
|
|
25
|
+
task :upgrade => :environment do
|
|
26
|
+
DataMapper.auto_upgrade!
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
task :environment do
|
|
31
|
+
require File.join(File.dirname(__FILE__), 'environment')
|
|
32
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'bundler/setup'
|
|
3
|
+
require 'sinatra'
|
|
4
|
+
require File.join(File.dirname(__FILE__), 'environment')
|
|
5
|
+
|
|
6
|
+
configure do
|
|
7
|
+
set :views, "#{File.dirname(__FILE__)}/views"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
error do
|
|
11
|
+
e = request.env['sinatra.error']
|
|
12
|
+
Kernel.puts e.backtrace.join("\n")
|
|
13
|
+
'Application error'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
helpers do
|
|
17
|
+
# add your helpers here
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# root page
|
|
21
|
+
get '/' do
|
|
22
|
+
haml :root
|
|
23
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'application')
|
|
2
|
+
|
|
3
|
+
set :run, false
|
|
4
|
+
set :environment, :production
|
|
5
|
+
|
|
6
|
+
FileUtils.mkdir_p 'log' unless File.exists?('log')
|
|
7
|
+
log = File.new("log/sinatra.log", "a+")
|
|
8
|
+
$stdout.reopen(log)
|
|
9
|
+
$stderr.reopen(log)
|
|
10
|
+
|
|
11
|
+
run Sinatra::Application
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'bundler/setup'
|
|
3
|
+
require 'dm-core'
|
|
4
|
+
require 'dm-timestamps'
|
|
5
|
+
require 'dm-validations'
|
|
6
|
+
require 'dm-aggregates'
|
|
7
|
+
require 'dm-migrations'
|
|
8
|
+
require 'haml'
|
|
9
|
+
require 'ostruct'
|
|
10
|
+
|
|
11
|
+
require 'sinatra' unless defined?(Sinatra)
|
|
12
|
+
|
|
13
|
+
configure do
|
|
14
|
+
SiteConfig = OpenStruct.new(
|
|
15
|
+
:title => 'Your Application Name',
|
|
16
|
+
:author => 'Your Name',
|
|
17
|
+
:url_base => 'http://localhost:4567/'
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
# load models
|
|
21
|
+
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/lib")
|
|
22
|
+
Dir.glob("#{File.dirname(__FILE__)}/lib/*.rb") { |lib| require File.basename(lib, '.*') }
|
|
23
|
+
|
|
24
|
+
DataMapper.setup(:default, (ENV["DATABASE_URL"] || "sqlite3:///#{File.expand_path(File.dirname(__FILE__))}/#{Sinatra::Base.environment}.db"))
|
|
25
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
body {
|
|
2
|
+
background: #FFF;
|
|
3
|
+
color: #1B1B1B;
|
|
4
|
+
font-family: Verdana, Arial, Helvetica, sans-serif;
|
|
5
|
+
}
|
|
6
|
+
#container {
|
|
7
|
+
margin: 0 auto;
|
|
8
|
+
width: 800px;
|
|
9
|
+
}
|
|
10
|
+
#header {
|
|
11
|
+
padding: 0.5em 0 0 0;
|
|
12
|
+
margin: 0;
|
|
13
|
+
text-align: center;
|
|
14
|
+
border-bottom: 3px solid #000;
|
|
15
|
+
}
|
|
16
|
+
#content {
|
|
17
|
+
padding: 0;
|
|
18
|
+
margin: 0;
|
|
19
|
+
}
|
|
20
|
+
#footer {
|
|
21
|
+
padding: 0;
|
|
22
|
+
margin: 0;
|
|
23
|
+
font-size: 0.7em;
|
|
24
|
+
text-align: center;
|
|
25
|
+
border-top: 3px solid #000;
|
|
26
|
+
}
|
|
27
|
+
h1, h2, h3, h4, h5, h6 {
|
|
28
|
+
margin-top: 0em;
|
|
29
|
+
margin-bottom: .25em;
|
|
30
|
+
font-weight: bold;
|
|
31
|
+
}
|
|
32
|
+
h1 { font-size: 2.2em; }
|
|
33
|
+
h2 { font-size: 1.6em; }
|
|
34
|
+
h3 { font-size: 1.4em; }
|
|
35
|
+
h4 { font-size: 1.3em; }
|
|
36
|
+
h5 { font-size: 1.2em; }
|
|
37
|
+
h6 { font-size: 1.1em; }
|
|
38
|
+
p {
|
|
39
|
+
margin-bottom: 1em;
|
|
40
|
+
line-height: 1.3;
|
|
41
|
+
}
|
|
42
|
+
a {
|
|
43
|
+
color: #095EAE;
|
|
44
|
+
font-weight: bold;
|
|
45
|
+
text-decoration: none;
|
|
46
|
+
}
|
|
47
|
+
a:hover {
|
|
48
|
+
text-decoration: underline;
|
|
49
|
+
}
|
|
50
|
+
#logo a:hover {
|
|
51
|
+
text-decoration: none;
|
|
52
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#! /usr/bin/env ruby
|
|
2
|
+
# This console script adapted from:rake
|
|
3
|
+
# http://barkingiguana.com/blog/2009/01/25/scriptconsole-for-your-application/
|
|
4
|
+
|
|
5
|
+
libs = []
|
|
6
|
+
libs << "irb/completion"
|
|
7
|
+
libs << File.dirname(__FILE__) + '/../environment.rb'
|
|
8
|
+
|
|
9
|
+
command_line = []
|
|
10
|
+
command_line << "irb"
|
|
11
|
+
command_line << libs.inject("") { |acc, lib| acc + %( -r "#{lib}") }
|
|
12
|
+
command_line << "--simple-prompt"
|
|
13
|
+
command = command_line.join(" ")
|
|
14
|
+
|
|
15
|
+
puts "Welcome to the sinatra console interface."
|
|
16
|
+
exec command
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
!!!
|
|
2
|
+
%html
|
|
3
|
+
%head
|
|
4
|
+
%title= @title || SiteConfig.title
|
|
5
|
+
%link{:href => '/main.css', :rel => 'stylesheet', :type => 'text/css'}
|
|
6
|
+
%body
|
|
7
|
+
#container
|
|
8
|
+
#header
|
|
9
|
+
#logo
|
|
10
|
+
%h1
|
|
11
|
+
%a{:href => '/'}= SiteConfig.title
|
|
12
|
+
#content= yield
|
|
13
|
+
#footer
|
|
14
|
+
%p#legal= "— © #{Time.now.strftime('%Y')} #{SiteConfig.author} —"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
source :rubygems
|
|
2
|
+
gem 'sinatra', '>= 1.0'
|
|
3
|
+
gem 'crack'
|
|
4
|
+
gem 'rake'
|
|
5
|
+
gem 'data_mapper'
|
|
6
|
+
gem 'dm-core'
|
|
7
|
+
gem 'dm-sqlite-adapter'
|
|
8
|
+
gem 'dm-timestamps'
|
|
9
|
+
gem 'dm-validations'
|
|
10
|
+
gem 'dm-aggregates'
|
|
11
|
+
gem 'dm-migrations'
|
|
12
|
+
gem 'haml'
|
|
13
|
+
|
|
14
|
+
group :test do
|
|
15
|
+
gem 'rspec', :require => 'spec'
|
|
16
|
+
gem 'rack-test'
|
|
17
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2009 Nick Plante
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
= Sinatra Application Template
|
|
2
|
+
|
|
3
|
+
A base Sinatra application template. Just fork and build. Yay!
|
|
4
|
+
Includes Bundler, DataMapper, RSpec2, and Haml, all ready to go.
|
|
5
|
+
|
|
6
|
+
Works with both Ruby 1.8.7 and Ruby 1.9.2.
|
|
7
|
+
|
|
8
|
+
== Configuration
|
|
9
|
+
|
|
10
|
+
Dependencies and all configuration is done in <tt>environment.rb</tt>. Your database is also set up here. DataMapper will use sqlite3 by default. Tests use the sqlite3-memory adapter (no configuration needed).
|
|
11
|
+
|
|
12
|
+
Add your controller actions in <tt>application.rb</tt>. Views for these actions are placed in the <tt>views</tt> directory. Static files, including a stock stylesheet, go in the <tt>public</tt> directory. Models go in the <tt>lib</tt> directory and are auto-loaded.
|
|
13
|
+
|
|
14
|
+
== Testing
|
|
15
|
+
|
|
16
|
+
Add your specs in <tt>spec</tt>; just require <tt>spec_helper.rb</tt> to pre-configure the test environment. A number of samples are provided (including a sample model, which can be removed). To run the specs:
|
|
17
|
+
|
|
18
|
+
rake spec
|
|
19
|
+
|
|
20
|
+
== Getting Started
|
|
21
|
+
|
|
22
|
+
bundle install
|
|
23
|
+
rake db:migrate
|
|
24
|
+
ruby application.rb
|
|
25
|
+
|
|
26
|
+
== Thanks
|
|
27
|
+
|
|
28
|
+
This project includes contributions from the following developers:
|
|
29
|
+
|
|
30
|
+
* garrensmith
|
|
31
|
+
* bryanwoods
|
|
32
|
+
* flexd
|
|
33
|
+
* mcollina
|
|
34
|
+
|
|
35
|
+
(c) 2011 Nick Plante. This code is distributed under the MIT license.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'bundler/setup'
|
|
3
|
+
require 'rspec/core/rake_task'
|
|
4
|
+
|
|
5
|
+
task :default => :test
|
|
6
|
+
task :test => :spec
|
|
7
|
+
|
|
8
|
+
if !defined?(RSpec)
|
|
9
|
+
puts "spec targets require RSpec"
|
|
10
|
+
else
|
|
11
|
+
desc "Run all examples"
|
|
12
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
|
13
|
+
#t.pattern = 'spec/**/*_spec.rb' # not needed this is default
|
|
14
|
+
t.rspec_opts = ['-cfs']
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
namespace :db do
|
|
19
|
+
desc 'Auto-migrate the database (destroys data)'
|
|
20
|
+
task :migrate => :environment do
|
|
21
|
+
DataMapper.auto_migrate!
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
desc 'Auto-upgrade the database (preserves data)'
|
|
25
|
+
task :upgrade => :environment do
|
|
26
|
+
DataMapper.auto_upgrade!
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
task :environment do
|
|
31
|
+
require File.join(File.dirname(__FILE__), 'environment')
|
|
32
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'bundler/setup'
|
|
3
|
+
require 'sinatra'
|
|
4
|
+
require File.join(File.dirname(__FILE__), 'environment')
|
|
5
|
+
|
|
6
|
+
configure do
|
|
7
|
+
set :views, "#{File.dirname(__FILE__)}/views"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
error do
|
|
11
|
+
e = request.env['sinatra.error']
|
|
12
|
+
Kernel.puts e.backtrace.join("\n")
|
|
13
|
+
'Application error'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
helpers do
|
|
17
|
+
# add your helpers here
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# root page
|
|
21
|
+
get '/' do
|
|
22
|
+
haml :root
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# FIXME: I must raise an error here
|
|
26
|
+
get '/foo' do
|
|
27
|
+
haml :bar
|
|
28
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'application')
|
|
2
|
+
|
|
3
|
+
set :run, false
|
|
4
|
+
set :environment, :production
|
|
5
|
+
|
|
6
|
+
FileUtils.mkdir_p 'log' unless File.exists?('log')
|
|
7
|
+
log = File.new("log/sinatra.log", "a+")
|
|
8
|
+
$stdout.reopen(log)
|
|
9
|
+
$stderr.reopen(log)
|
|
10
|
+
|
|
11
|
+
run Sinatra::Application
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'bundler/setup'
|
|
3
|
+
require 'dm-core'
|
|
4
|
+
require 'dm-timestamps'
|
|
5
|
+
require 'dm-validations'
|
|
6
|
+
require 'dm-aggregates'
|
|
7
|
+
require 'dm-migrations'
|
|
8
|
+
require 'haml'
|
|
9
|
+
require 'ostruct'
|
|
10
|
+
|
|
11
|
+
require 'sinatra' unless defined?(Sinatra)
|
|
12
|
+
|
|
13
|
+
configure do
|
|
14
|
+
SiteConfig = OpenStruct.new(
|
|
15
|
+
:title => 'Your Application Name',
|
|
16
|
+
:author => 'Your Name',
|
|
17
|
+
:url_base => 'http://localhost:4567/'
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
# load models
|
|
21
|
+
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/lib")
|
|
22
|
+
Dir.glob("#{File.dirname(__FILE__)}/lib/*.rb") { |lib| require File.basename(lib, '.*') }
|
|
23
|
+
|
|
24
|
+
DataMapper.setup(:default, (ENV["DATABASE_URL"] || "sqlite3:///#{File.expand_path(File.dirname(__FILE__))}/#{Sinatra::Base.environment}.db"))
|
|
25
|
+
end
|