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.
Files changed (217) hide show
  1. data/.gitignore +18 -0
  2. data/.rvmrc +48 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +54 -0
  6. data/Rakefile +64 -0
  7. data/Roadmap.md +44 -0
  8. data/bin/dawn +106 -0
  9. data/codesake_dawn.gemspec +25 -0
  10. data/lib/codesake-dawn.rb +7 -0
  11. data/lib/codesake/dawn/engine.rb +144 -0
  12. data/lib/codesake/dawn/kb/basic_check.rb +93 -0
  13. data/lib/codesake/dawn/kb/cve_2011_2931.rb +32 -0
  14. data/lib/codesake/dawn/kb/cve_2012_2660.rb +30 -0
  15. data/lib/codesake/dawn/kb/cve_2012_2661.rb +29 -0
  16. data/lib/codesake/dawn/kb/cve_2012_2694.rb +31 -0
  17. data/lib/codesake/dawn/kb/cve_2012_2695.rb +29 -0
  18. data/lib/codesake/dawn/kb/cve_2012_3465.rb +28 -0
  19. data/lib/codesake/dawn/kb/cve_2012_6496.rb +30 -0
  20. data/lib/codesake/dawn/kb/cve_2012_6497.rb +30 -0
  21. data/lib/codesake/dawn/kb/cve_2013_0155.rb +30 -0
  22. data/lib/codesake/dawn/kb/cve_2013_0269.rb +29 -0
  23. data/lib/codesake/dawn/kb/cve_2013_0333.rb +33 -0
  24. data/lib/codesake/dawn/kb/cve_2013_1800.rb +28 -0
  25. data/lib/codesake/dawn/kb/cve_2013_1855.rb +20 -0
  26. data/lib/codesake/dawn/kb/cve_2013_1857.rb +22 -0
  27. data/lib/codesake/dawn/kb/dependency_check.rb +39 -0
  28. data/lib/codesake/dawn/kb/not_revised_code.rb +24 -0
  29. data/lib/codesake/dawn/kb/pattern_match_check.rb +60 -0
  30. data/lib/codesake/dawn/knowledge_base.rb +105 -0
  31. data/lib/codesake/dawn/rails.rb +17 -0
  32. data/lib/codesake/dawn/sinatra.rb +14 -0
  33. data/lib/codesake/dawn/version.rb +5 -0
  34. data/spec/lib/dawn/codesake_knowledgebase_spec.rb +100 -0
  35. data/spec/lib/dawn/codesake_sinatra_engine_spec.rb +80 -0
  36. data/spec/lib/kb/codesake_cve_2013_1800_spec.rb +66 -0
  37. data/spec/lib/kb/codesake_cve_2013_1855_spec.rb +16 -0
  38. data/spec/lib/kb/cve_2011_2931_spec.rb +7 -0
  39. data/spec/lib/kb/cve_2012_2660_spec.rb +9 -0
  40. data/spec/lib/kb/cve_2012_2661_spec.rb +7 -0
  41. data/spec/lib/kb/cve_2012_2694_spec.rb +7 -0
  42. data/spec/lib/kb/cve_2012_2695_spec.rb +7 -0
  43. data/spec/lib/kb/cve_2012_3465_spec.rb +7 -0
  44. data/spec/lib/kb/cve_2012_6496_spec.rb +7 -0
  45. data/spec/lib/kb/cve_2012_6497_spec.rb +7 -0
  46. data/spec/lib/kb/cve_2013_0155_spec.rb +7 -0
  47. data/spec/lib/kb/cve_2013_0269_spec.rb +7 -0
  48. data/spec/lib/kb/cve_2013_0333_spec.rb +7 -0
  49. data/spec/lib/kb/cve_2013_1857_spec.rb +13 -0
  50. data/spec/spec_helper.rb +1 -0
  51. data/spec/support/hello_world_3.0.19/.gitignore +4 -0
  52. data/spec/support/hello_world_3.0.19/Gemfile +31 -0
  53. data/spec/support/hello_world_3.0.19/README +256 -0
  54. data/spec/support/hello_world_3.0.19/Rakefile +7 -0
  55. data/spec/support/hello_world_3.0.19/app/controllers/application_controller.rb +3 -0
  56. data/spec/support/hello_world_3.0.19/app/helpers/application_helper.rb +2 -0
  57. data/spec/support/hello_world_3.0.19/app/views/layouts/application.html.erb +14 -0
  58. data/spec/support/hello_world_3.0.19/config.ru +4 -0
  59. data/spec/support/hello_world_3.0.19/config/application.rb +42 -0
  60. data/spec/support/hello_world_3.0.19/config/boot.rb +6 -0
  61. data/spec/support/hello_world_3.0.19/config/database.yml +22 -0
  62. data/spec/support/hello_world_3.0.19/config/environment.rb +5 -0
  63. data/spec/support/hello_world_3.0.19/config/environments/development.rb +26 -0
  64. data/spec/support/hello_world_3.0.19/config/environments/production.rb +49 -0
  65. data/spec/support/hello_world_3.0.19/config/environments/test.rb +35 -0
  66. data/spec/support/hello_world_3.0.19/config/initializers/backtrace_silencers.rb +7 -0
  67. data/spec/support/hello_world_3.0.19/config/initializers/inflections.rb +10 -0
  68. data/spec/support/hello_world_3.0.19/config/initializers/mime_types.rb +5 -0
  69. data/spec/support/hello_world_3.0.19/config/initializers/secret_token.rb +7 -0
  70. data/spec/support/hello_world_3.0.19/config/initializers/session_store.rb +8 -0
  71. data/spec/support/hello_world_3.0.19/config/locales/en.yml +5 -0
  72. data/spec/support/hello_world_3.0.19/config/routes.rb +58 -0
  73. data/spec/support/hello_world_3.0.19/db/seeds.rb +7 -0
  74. data/spec/support/hello_world_3.0.19/lib/tasks/.gitkeep +0 -0
  75. data/spec/support/hello_world_3.0.19/public/404.html +26 -0
  76. data/spec/support/hello_world_3.0.19/public/422.html +26 -0
  77. data/spec/support/hello_world_3.0.19/public/500.html +26 -0
  78. data/spec/support/hello_world_3.0.19/public/favicon.ico +0 -0
  79. data/spec/support/hello_world_3.0.19/public/images/rails.png +0 -0
  80. data/spec/support/hello_world_3.0.19/public/index.html +239 -0
  81. data/spec/support/hello_world_3.0.19/public/javascripts/application.js +2 -0
  82. data/spec/support/hello_world_3.0.19/public/javascripts/controls.js +965 -0
  83. data/spec/support/hello_world_3.0.19/public/javascripts/dragdrop.js +974 -0
  84. data/spec/support/hello_world_3.0.19/public/javascripts/effects.js +1123 -0
  85. data/spec/support/hello_world_3.0.19/public/javascripts/prototype.js +6001 -0
  86. data/spec/support/hello_world_3.0.19/public/javascripts/rails.js +202 -0
  87. data/spec/support/hello_world_3.0.19/public/robots.txt +5 -0
  88. data/spec/support/hello_world_3.0.19/public/stylesheets/.gitkeep +0 -0
  89. data/spec/support/hello_world_3.0.19/script/rails +6 -0
  90. data/spec/support/hello_world_3.0.19/test/performance/browsing_test.rb +9 -0
  91. data/spec/support/hello_world_3.0.19/test/test_helper.rb +13 -0
  92. data/spec/support/hello_world_3.0.19/vendor/plugins/.gitkeep +0 -0
  93. data/spec/support/hello_world_3.1.0/.gitignore +5 -0
  94. data/spec/support/hello_world_3.1.0/Gemfile +33 -0
  95. data/spec/support/hello_world_3.1.0/README +261 -0
  96. data/spec/support/hello_world_3.1.0/Rakefile +7 -0
  97. data/spec/support/hello_world_3.1.0/app/assets/images/rails.png +0 -0
  98. data/spec/support/hello_world_3.1.0/app/assets/javascripts/application.js +9 -0
  99. data/spec/support/hello_world_3.1.0/app/assets/stylesheets/application.css +7 -0
  100. data/spec/support/hello_world_3.1.0/app/controllers/application_controller.rb +3 -0
  101. data/spec/support/hello_world_3.1.0/app/helpers/application_helper.rb +2 -0
  102. data/spec/support/hello_world_3.1.0/app/mailers/.gitkeep +0 -0
  103. data/spec/support/hello_world_3.1.0/app/models/.gitkeep +0 -0
  104. data/spec/support/hello_world_3.1.0/app/views/layouts/application.html.erb +14 -0
  105. data/spec/support/hello_world_3.1.0/config.ru +4 -0
  106. data/spec/support/hello_world_3.1.0/config/application.rb +48 -0
  107. data/spec/support/hello_world_3.1.0/config/boot.rb +6 -0
  108. data/spec/support/hello_world_3.1.0/config/database.yml +25 -0
  109. data/spec/support/hello_world_3.1.0/config/environment.rb +5 -0
  110. data/spec/support/hello_world_3.1.0/config/environments/development.rb +30 -0
  111. data/spec/support/hello_world_3.1.0/config/environments/production.rb +60 -0
  112. data/spec/support/hello_world_3.1.0/config/environments/test.rb +42 -0
  113. data/spec/support/hello_world_3.1.0/config/initializers/backtrace_silencers.rb +7 -0
  114. data/spec/support/hello_world_3.1.0/config/initializers/inflections.rb +10 -0
  115. data/spec/support/hello_world_3.1.0/config/initializers/mime_types.rb +5 -0
  116. data/spec/support/hello_world_3.1.0/config/initializers/secret_token.rb +7 -0
  117. data/spec/support/hello_world_3.1.0/config/initializers/session_store.rb +8 -0
  118. data/spec/support/hello_world_3.1.0/config/initializers/wrap_parameters.rb +14 -0
  119. data/spec/support/hello_world_3.1.0/config/locales/en.yml +5 -0
  120. data/spec/support/hello_world_3.1.0/config/routes.rb +58 -0
  121. data/spec/support/hello_world_3.1.0/db/seeds.rb +7 -0
  122. data/spec/support/hello_world_3.1.0/lib/assets/.gitkeep +0 -0
  123. data/spec/support/hello_world_3.1.0/lib/tasks/.gitkeep +0 -0
  124. data/spec/support/hello_world_3.1.0/log/.gitkeep +0 -0
  125. data/spec/support/hello_world_3.1.0/public/404.html +26 -0
  126. data/spec/support/hello_world_3.1.0/public/422.html +26 -0
  127. data/spec/support/hello_world_3.1.0/public/500.html +26 -0
  128. data/spec/support/hello_world_3.1.0/public/favicon.ico +0 -0
  129. data/spec/support/hello_world_3.1.0/public/index.html +241 -0
  130. data/spec/support/hello_world_3.1.0/public/robots.txt +5 -0
  131. data/spec/support/hello_world_3.1.0/script/rails +6 -0
  132. data/spec/support/hello_world_3.1.0/test/fixtures/.gitkeep +0 -0
  133. data/spec/support/hello_world_3.1.0/test/functional/.gitkeep +0 -0
  134. data/spec/support/hello_world_3.1.0/test/integration/.gitkeep +0 -0
  135. data/spec/support/hello_world_3.1.0/test/performance/browsing_test.rb +12 -0
  136. data/spec/support/hello_world_3.1.0/test/test_helper.rb +13 -0
  137. data/spec/support/hello_world_3.1.0/test/unit/.gitkeep +0 -0
  138. data/spec/support/hello_world_3.1.0/vendor/assets/stylesheets/.gitkeep +0 -0
  139. data/spec/support/hello_world_3.1.0/vendor/plugins/.gitkeep +0 -0
  140. data/spec/support/hello_world_3.2.13/.gitignore +15 -0
  141. data/spec/support/hello_world_3.2.13/Gemfile +38 -0
  142. data/spec/support/hello_world_3.2.13/README.rdoc +261 -0
  143. data/spec/support/hello_world_3.2.13/Rakefile +7 -0
  144. data/spec/support/hello_world_3.2.13/app/assets/images/rails.png +0 -0
  145. data/spec/support/hello_world_3.2.13/app/assets/javascripts/application.js +15 -0
  146. data/spec/support/hello_world_3.2.13/app/assets/stylesheets/application.css +13 -0
  147. data/spec/support/hello_world_3.2.13/app/controllers/application_controller.rb +3 -0
  148. data/spec/support/hello_world_3.2.13/app/helpers/application_helper.rb +2 -0
  149. data/spec/support/hello_world_3.2.13/app/mailers/.gitkeep +0 -0
  150. data/spec/support/hello_world_3.2.13/app/models/.gitkeep +0 -0
  151. data/spec/support/hello_world_3.2.13/app/views/layouts/application.html.erb +14 -0
  152. data/spec/support/hello_world_3.2.13/config.ru +4 -0
  153. data/spec/support/hello_world_3.2.13/config/application.rb +62 -0
  154. data/spec/support/hello_world_3.2.13/config/boot.rb +6 -0
  155. data/spec/support/hello_world_3.2.13/config/database.yml +25 -0
  156. data/spec/support/hello_world_3.2.13/config/environment.rb +5 -0
  157. data/spec/support/hello_world_3.2.13/config/environments/development.rb +37 -0
  158. data/spec/support/hello_world_3.2.13/config/environments/production.rb +67 -0
  159. data/spec/support/hello_world_3.2.13/config/environments/test.rb +37 -0
  160. data/spec/support/hello_world_3.2.13/config/initializers/backtrace_silencers.rb +7 -0
  161. data/spec/support/hello_world_3.2.13/config/initializers/inflections.rb +15 -0
  162. data/spec/support/hello_world_3.2.13/config/initializers/mime_types.rb +5 -0
  163. data/spec/support/hello_world_3.2.13/config/initializers/secret_token.rb +7 -0
  164. data/spec/support/hello_world_3.2.13/config/initializers/session_store.rb +8 -0
  165. data/spec/support/hello_world_3.2.13/config/initializers/wrap_parameters.rb +14 -0
  166. data/spec/support/hello_world_3.2.13/config/locales/en.yml +5 -0
  167. data/spec/support/hello_world_3.2.13/config/routes.rb +58 -0
  168. data/spec/support/hello_world_3.2.13/db/seeds.rb +7 -0
  169. data/spec/support/hello_world_3.2.13/lib/assets/.gitkeep +0 -0
  170. data/spec/support/hello_world_3.2.13/lib/tasks/.gitkeep +0 -0
  171. data/spec/support/hello_world_3.2.13/log/.gitkeep +0 -0
  172. data/spec/support/hello_world_3.2.13/public/404.html +26 -0
  173. data/spec/support/hello_world_3.2.13/public/422.html +26 -0
  174. data/spec/support/hello_world_3.2.13/public/500.html +25 -0
  175. data/spec/support/hello_world_3.2.13/public/favicon.ico +0 -0
  176. data/spec/support/hello_world_3.2.13/public/index.html +241 -0
  177. data/spec/support/hello_world_3.2.13/public/robots.txt +5 -0
  178. data/spec/support/hello_world_3.2.13/script/rails +6 -0
  179. data/spec/support/hello_world_3.2.13/test/fixtures/.gitkeep +0 -0
  180. data/spec/support/hello_world_3.2.13/test/functional/.gitkeep +0 -0
  181. data/spec/support/hello_world_3.2.13/test/integration/.gitkeep +0 -0
  182. data/spec/support/hello_world_3.2.13/test/performance/browsing_test.rb +12 -0
  183. data/spec/support/hello_world_3.2.13/test/test_helper.rb +13 -0
  184. data/spec/support/hello_world_3.2.13/test/unit/.gitkeep +0 -0
  185. data/spec/support/hello_world_3.2.13/vendor/assets/javascripts/.gitkeep +0 -0
  186. data/spec/support/hello_world_3.2.13/vendor/assets/stylesheets/.gitkeep +0 -0
  187. data/spec/support/hello_world_3.2.13/vendor/plugins/.gitkeep +0 -0
  188. data/spec/support/lorem.txt +23 -0
  189. data/spec/support/sinatra-safe/.gems +4 -0
  190. data/spec/support/sinatra-safe/.gitignore +6 -0
  191. data/spec/support/sinatra-safe/Gemfile +18 -0
  192. data/spec/support/sinatra-safe/MIT-LICENSE +20 -0
  193. data/spec/support/sinatra-safe/README.rdoc +35 -0
  194. data/spec/support/sinatra-safe/Rakefile +32 -0
  195. data/spec/support/sinatra-safe/application.rb +23 -0
  196. data/spec/support/sinatra-safe/config.ru +11 -0
  197. data/spec/support/sinatra-safe/environment.rb +25 -0
  198. data/spec/support/sinatra-safe/lib/profile.rb +11 -0
  199. data/spec/support/sinatra-safe/public/main.css +52 -0
  200. data/spec/support/sinatra-safe/script/console +16 -0
  201. data/spec/support/sinatra-safe/views/layout.haml +14 -0
  202. data/spec/support/sinatra-safe/views/root.haml +4 -0
  203. data/spec/support/sinatra-vulnerable/.gems +4 -0
  204. data/spec/support/sinatra-vulnerable/.gitignore +6 -0
  205. data/spec/support/sinatra-vulnerable/Gemfile +17 -0
  206. data/spec/support/sinatra-vulnerable/MIT-LICENSE +20 -0
  207. data/spec/support/sinatra-vulnerable/README.rdoc +35 -0
  208. data/spec/support/sinatra-vulnerable/Rakefile +32 -0
  209. data/spec/support/sinatra-vulnerable/application.rb +28 -0
  210. data/spec/support/sinatra-vulnerable/config.ru +11 -0
  211. data/spec/support/sinatra-vulnerable/environment.rb +25 -0
  212. data/spec/support/sinatra-vulnerable/lib/profile.rb +11 -0
  213. data/spec/support/sinatra-vulnerable/public/main.css +52 -0
  214. data/spec/support/sinatra-vulnerable/script/console +16 -0
  215. data/spec/support/sinatra-vulnerable/views/layout.haml +14 -0
  216. data/spec/support/sinatra-vulnerable/views/root.haml +4 -0
  217. 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,11 @@
1
+ # example model file
2
+ class Profile
3
+ include DataMapper::Resource
4
+
5
+ property :id, Serial
6
+ property :name, String
7
+ property :created_at, DateTime
8
+ property :updated_at, DateTime
9
+
10
+ validates_presence_of :name
11
+ 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= "&mdash; &copy; #{Time.now.strftime('%Y')} #{SiteConfig.author} &mdash;"
@@ -0,0 +1,4 @@
1
+ %h2 Main Page
2
+ %p Here is some text.
3
+ %p Here is a <a href='/'>link</a>.
4
+ %p ttys!
@@ -0,0 +1,4 @@
1
+ data_mapper -v 1.0.0
2
+ dm-postgres-adapter
3
+ sinatra -v 1.0
4
+
@@ -0,0 +1,6 @@
1
+ *.db
2
+ *.sqlite3
3
+ .bundle/*
4
+ log/*
5
+ *.swp
6
+ *.swo
@@ -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