Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial commit.

  • Loading branch information...
commit 129faebcba636424c90afd61dd81df0983582f87 0 parents
@sprysoft authored
1  .gitignore
@@ -0,0 +1 @@
+.DS_Store
1  .rspec
@@ -0,0 +1 @@
+--color
15 Gemfile
@@ -0,0 +1,15 @@
+source :rubygems
+
+gem 'sinatra', "1.2.1"
+gem 'sinatra-mongoid', :require => 'sinatra/mongoid'
+gem "bson_ext", "1.2.4"
+gem 'slim'
+gem 'haml'
+
+group :test do
+ gem "rspec"
+ gem "cucumber-sinatra"
+ gem "cucumber"
+ gem "rack-test"
+ gem "capybara"
+end
103 Gemfile.lock
@@ -0,0 +1,103 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ activesupport (2.3.11)
+ bson (1.2.4)
+ bson_ext (1.2.4)
+ builder (2.1.2)
+ capybara (0.4.1.2)
+ celerity (>= 0.7.9)
+ culerity (>= 0.2.4)
+ mime-types (>= 1.16)
+ nokogiri (>= 1.3.3)
+ rack (>= 1.0.0)
+ rack-test (>= 0.5.4)
+ selenium-webdriver (>= 0.0.27)
+ xpath (~> 0.1.3)
+ celerity (0.8.8)
+ childprocess (0.1.8)
+ ffi (~> 1.0.6)
+ cucumber (0.10.0)
+ builder (>= 2.1.2)
+ diff-lcs (~> 1.1.2)
+ gherkin (~> 2.3.2)
+ json (~> 1.4.6)
+ term-ansicolor (~> 1.0.5)
+ cucumber-sinatra (0.3.0)
+ templater (>= 1.0.0)
+ culerity (0.2.15)
+ diff-lcs (1.1.2)
+ durran-validatable (2.0.1)
+ extlib (0.9.15)
+ ffi (1.0.7)
+ rake (>= 0.8.7)
+ gherkin (2.3.3)
+ json (~> 1.4.6)
+ haml (3.0.25)
+ highline (1.6.1)
+ json (1.4.6)
+ json_pure (1.5.1)
+ mime-types (1.16)
+ mongo (1.2.4)
+ bson (>= 1.2.4)
+ mongo_ext (0.19.3)
+ mongoid (1.9.5)
+ activesupport (< 3.0.0)
+ bson (~> 1.2.1)
+ durran-validatable (>= 2.0.1)
+ mongo (~> 1.2.1)
+ will_paginate (< 2.9)
+ nokogiri (1.4.4)
+ rack (1.2.2)
+ rack-test (0.5.7)
+ rack (>= 1.0)
+ rake (0.8.7)
+ rspec (2.5.0)
+ rspec-core (~> 2.5.0)
+ rspec-expectations (~> 2.5.0)
+ rspec-mocks (~> 2.5.0)
+ rspec-core (2.5.1)
+ rspec-expectations (2.5.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.5.0)
+ rubyzip (0.9.4)
+ selenium-webdriver (0.1.4)
+ childprocess (>= 0.1.7)
+ ffi (>= 1.0.7)
+ json_pure
+ rubyzip
+ sinatra (1.2.1)
+ rack (~> 1.1)
+ tilt (>= 1.2.2, < 2.0)
+ sinatra-mongoid (0.0.2)
+ mongo_ext
+ mongoid
+ sinatra
+ slim (0.9.1)
+ temple (~> 0.1.8)
+ tilt (~> 1.2)
+ templater (1.0.0)
+ diff-lcs (>= 1.1.2)
+ extlib (>= 0.9.5)
+ highline (>= 1.4.0)
+ temple (0.1.8)
+ term-ansicolor (1.0.5)
+ tilt (1.2.2)
+ will_paginate (2.3.15)
+ xpath (0.1.3)
+ nokogiri (~> 1.3)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ bson_ext (= 1.2.4)
+ capybara
+ cucumber
+ cucumber-sinatra
+ haml
+ rack-test
+ rspec
+ sinatra (= 1.2.1)
+ sinatra-mongoid
+ slim
28 README.md
@@ -0,0 +1,28 @@
+Sinatra Prototype (in development)
+==================================
+
+A Sinatra application
+---------------------
+
+This is a simple sinatra application for rapid web app prototyping which
+has been configured to be hosted on the amazing [Heroku Platform](http://heroku.com/),
+bamboo-mri-1.9.2 stack. I will be testing on additional heroku stacks too.
+
+The application comes with jQuery 1.5.1 loaded from Google Ajax Libraries
+
+Current Gems
+------------
+* Sinatra
+* Sinatra-mongoid
+* Bson_ext ( for mongoDB performance )
+* Haml ( for SASS )
+* Slim
+* Rspec 2
+* Cucumber
+* Capybara
+* Rack-Test
+
+Licence
+-------
+
+This application is released under the MIT licence.
9 Rakefile
@@ -0,0 +1,9 @@
+require 'rspec/core/rake_task'
+
+namespace :spec do
+ desc "Run all examples"
+ RSpec::Core::RakeTask.new('all')
+
+end
+task :spec => 'spec:all'
+task :default => :spec
31 application.rb
@@ -0,0 +1,31 @@
+Dir["./models/**/*.rb"].each { |model| require model }
+class Application < Sinatra::Base
+
+ configure do
+ set :root, File.dirname(__FILE__)
+ set :static, true
+
+ set :template, :slim
+ # Haml & Sass options
+ set :sass, :style => :compressed
+ end
+
+ Mongoid.configure do |config|
+ if ENV['MONGOHQ_URL']
+ conn = Mongo::Connection.from_uri(ENV['MONGOHQ_URL'])
+ uri = URI.parse(ENV['MONGOHQ_URL'])
+ config.master = conn.db(uri.path.gsub(/^\//, ''))
+ else
+ config.master = Mongo::Connection.from_uri("mongodb://localhost:27017").db('test')
+ end
+ end
+
+ get '/' do
+ slim :index
+ end
+
+ get '/stylesheets/application.css' do
+ sass :application
+ end
+
+end
9 config.ru
@@ -0,0 +1,9 @@
+require 'rubygems'
+require 'sinatra'
+require 'slim'
+require 'haml'
+require 'mongoid'
+require './application'
+
+
+run Application
8 features/application.feature
@@ -0,0 +1,8 @@
+Feature: View root page
+ In order for our app to function correctly
+ As a user
+ I want to load the home page
+
+ Scenario: View home page
+ Given I am viewing the home page
+ Then I should see "Sinatra, Mongoid prototyping application"
7 features/step_definitions/application_steps.rb
@@ -0,0 +1,7 @@
+Given /^I am viewing the home page$/ do
+ visit('/')
+end
+
+Then /^I should see "([^"]*)"$/ do |text|
+ page.should have_content(text)
+end
19 features/support/env.rb
@@ -0,0 +1,19 @@
+require 'rubygems'
+require 'sinatra'
+require 'slim'
+require 'haml'
+require 'mongoid'
+
+require File.join(File.dirname(__FILE__), '..', '..', 'application.rb')
+require 'capybara'
+require 'capybara/cucumber'
+require 'rspec'
+
+Application.set(:environment, :test)
+
+World do
+ Capybara.app = Application
+ include Capybara
+ include RSpec::Expectations
+ include RSpec::Matchers
+end
29 features/support/paths.rb
@@ -0,0 +1,29 @@
+# Taken from the cucumber-rails project.
+
+module NavigationHelpers
+ # Maps a name to a path. Used by the
+ #
+ # When /^I go to (.+)$/ do |page_name|
+ #
+ # step definition in web_steps.rb
+ #
+ def path_to(page_name)
+ case page_name
+
+ when /the home\s?page/
+ '/'
+
+ # Add more mappings here.
+ # Here is an example that pulls values out of the Regexp:
+ #
+ # when /^(.*)'s profile page$/i
+ # user_profile_path(User.find_by_login($1))
+
+ else
+ raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
+ "Now, go and add a mapping in #{__FILE__}"
+ end
+ end
+end
+
+World(NavigationHelpers)
3  public/javascripts/application.js
@@ -0,0 +1,3 @@
+$(document).ready(function(){
+
+});
1  public/stylesheets/grid.css
@@ -0,0 +1 @@
+body{min-width:960px}.container_12,.container_16{margin-left:auto;margin-right:auto;width:960px}.grid_1,.grid_2,.grid_3,.grid_4,.grid_5,.grid_6,.grid_7,.grid_8,.grid_9,.grid_10,.grid_11,.grid_12,.grid_13,.grid_14,.grid_15,.grid_16{display:inline;float:left;margin-left:10px;margin-right:10px}.push_1,.pull_1,.push_2,.pull_2,.push_3,.pull_3,.push_4,.pull_4,.push_5,.pull_5,.push_6,.pull_6,.push_7,.pull_7,.push_8,.pull_8,.push_9,.pull_9,.push_10,.pull_10,.push_11,.pull_11,.push_12,.pull_12,.push_13,.pull_13,.push_14,.pull_14,.push_15,.pull_15{position:relative}.container_12 .grid_3,.container_16 .grid_4{width:220px}.container_12 .grid_6,.container_16 .grid_8{width:460px}.container_12 .grid_9,.container_16 .grid_12{width:700px}.container_12 .grid_12,.container_16 .grid_16{width:940px}.alpha{margin-left:0}.omega{margin-right:0}.container_12 .grid_1{width:60px}.container_12 .grid_2{width:140px}.container_12 .grid_4{width:300px}.container_12 .grid_5{width:380px}.container_12 .grid_7{width:540px}.container_12 .grid_8{width:620px}.container_12 .grid_10{width:780px}.container_12 .grid_11{width:860px}.container_16 .grid_1{width:40px}.container_16 .grid_2{width:100px}.container_16 .grid_3{width:160px}.container_16 .grid_5{width:280px}.container_16 .grid_6{width:340px}.container_16 .grid_7{width:400px}.container_16 .grid_9{width:520px}.container_16 .grid_10{width:580px}.container_16 .grid_11{width:640px}.container_16 .grid_13{width:760px}.container_16 .grid_14{width:820px}.container_16 .grid_15{width:880px}.container_12 .prefix_3,.container_16 .prefix_4{padding-left:240px}.container_12 .prefix_6,.container_16 .prefix_8{padding-left:480px}.container_12 .prefix_9,.container_16 .prefix_12{padding-left:720px}.container_12 .prefix_1{padding-left:80px}.container_12 .prefix_2{padding-left:160px}.container_12 .prefix_4{padding-left:320px}.container_12 .prefix_5{padding-left:400px}.container_12 .prefix_7{padding-left:560px}.container_12 .prefix_8{padding-left:640px}.container_12 .prefix_10{padding-left:800px}.container_12 .prefix_11{padding-left:880px}.container_16 .prefix_1{padding-left:60px}.container_16 .prefix_2{padding-left:120px}.container_16 .prefix_3{padding-left:180px}.container_16 .prefix_5{padding-left:300px}.container_16 .prefix_6{padding-left:360px}.container_16 .prefix_7{padding-left:420px}.container_16 .prefix_9{padding-left:540px}.container_16 .prefix_10{padding-left:600px}.container_16 .prefix_11{padding-left:660px}.container_16 .prefix_13{padding-left:780px}.container_16 .prefix_14{padding-left:840px}.container_16 .prefix_15{padding-left:900px}.container_12 .suffix_3,.container_16 .suffix_4{padding-right:240px}.container_12 .suffix_6,.container_16 .suffix_8{padding-right:480px}.container_12 .suffix_9,.container_16 .suffix_12{padding-right:720px}.container_12 .suffix_1{padding-right:80px}.container_12 .suffix_2{padding-right:160px}.container_12 .suffix_4{padding-right:320px}.container_12 .suffix_5{padding-right:400px}.container_12 .suffix_7{padding-right:560px}.container_12 .suffix_8{padding-right:640px}.container_12 .suffix_10{padding-right:800px}.container_12 .suffix_11{padding-right:880px}.container_16 .suffix_1{padding-right:60px}.container_16 .suffix_2{padding-right:120px}.container_16 .suffix_3{padding-right:180px}.container_16 .suffix_5{padding-right:300px}.container_16 .suffix_6{padding-right:360px}.container_16 .suffix_7{padding-right:420px}.container_16 .suffix_9{padding-right:540px}.container_16 .suffix_10{padding-right:600px}.container_16 .suffix_11{padding-right:660px}.container_16 .suffix_13{padding-right:780px}.container_16 .suffix_14{padding-right:840px}.container_16 .suffix_15{padding-right:900px}.container_12 .push_3,.container_16 .push_4{left:240px}.container_12 .push_6,.container_16 .push_8{left:480px}.container_12 .push_9,.container_16 .push_12{left:720px}.container_12 .push_1{left:80px}.container_12 .push_2{left:160px}.container_12 .push_4{left:320px}.container_12 .push_5{left:400px}.container_12 .push_7{left:560px}.container_12 .push_8{left:640px}.container_12 .push_10{left:800px}.container_12 .push_11{left:880px}.container_16 .push_1{left:60px}.container_16 .push_2{left:120px}.container_16 .push_3{left:180px}.container_16 .push_5{left:300px}.container_16 .push_6{left:360px}.container_16 .push_7{left:420px}.container_16 .push_9{left:540px}.container_16 .push_10{left:600px}.container_16 .push_11{left:660px}.container_16 .push_13{left:780px}.container_16 .push_14{left:840px}.container_16 .push_15{left:900px}.container_12 .pull_3,.container_16 .pull_4{left:-240px}.container_12 .pull_6,.container_16 .pull_8{left:-480px}.container_12 .pull_9,.container_16 .pull_12{left:-720px}.container_12 .pull_1{left:-80px}.container_12 .pull_2{left:-160px}.container_12 .pull_4{left:-320px}.container_12 .pull_5{left:-400px}.container_12 .pull_7{left:-560px}.container_12 .pull_8{left:-640px}.container_12 .pull_10{left:-800px}.container_12 .pull_11{left:-880px}.container_16 .pull_1{left:-60px}.container_16 .pull_2{left:-120px}.container_16 .pull_3{left:-180px}.container_16 .pull_5{left:-300px}.container_16 .pull_6{left:-360px}.container_16 .pull_7{left:-420px}.container_16 .pull_9{left:-540px}.container_16 .pull_10{left:-600px}.container_16 .pull_11{left:-660px}.container_16 .pull_13{left:-780px}.container_16 .pull_14{left:-840px}.container_16 .pull_15{left:-900px}.clear{clear:both;display:block;overflow:hidden;visibility:hidden;width:0;height:0}.clearfix:before,.clearfix:after{content:'\0020';display:block;overflow:hidden;visibility:hidden;width:0;height:0}.clearfix:after{clear:both}.clearfix{zoom:1}
95 public/stylesheets/reset.css
@@ -0,0 +1,95 @@
+
+html, body, div, span, object, iframe,
+h1, h2, h3, h4, h5, h6, p, blockquote, pre,
+abbr, address, cite, code,
+del, dfn, em, img, ins, kbd, q, samp,
+small, strong, sub, sup, var,
+b, i,
+dl, dt, dd, ol, ul, li,
+fieldset, form, label, legend,
+table, caption, tbody, tfoot, thead, tr, th, td,
+article, aside, canvas, details, figcaption, figure,
+footer, header, hgroup, menu, nav, section, summary,
+time, mark, audio, video {
+ margin:0;
+ padding:0;
+ border:0;
+ outline:0;
+ font-size:100%;
+ vertical-align:baseline;
+ background:transparent;
+}
+
+body {
+ line-height:1;
+}
+
+article,aside,details,figcaption,figure,
+footer,header,hgroup,menu,nav,section {
+ display:block;
+}
+
+nav ul {
+ list-style:none;
+}
+
+blockquote, q {
+ quotes:none;
+}
+
+blockquote:before, blockquote:after,
+q:before, q:after {
+ content:'';
+ content:none;
+}
+
+a {
+ margin:0;
+ padding:0;
+ font-size:100%;
+ vertical-align:baseline;
+ background:transparent;
+}
+
+/* change colours to suit your needs */
+ins {
+ background-color:#ff9;
+ color:#000;
+ text-decoration:none;
+}
+
+/* change colours to suit your needs */
+mark {
+ background-color:#ff9;
+ color:#000;
+ font-style:italic;
+ font-weight:bold;
+}
+
+del {
+ text-decoration: line-through;
+}
+
+abbr[title], dfn[title] {
+ border-bottom:1px dotted;
+ cursor:help;
+}
+
+table {
+ border-collapse:collapse;
+ border-spacing:0;
+}
+
+/* change border colour to suit your needs */
+hr {
+ display:block;
+ height:1px;
+ border:0;
+ border-top:1px solid #cccccc;
+ margin:1em 0;
+ padding:0;
+}
+
+input, select {
+ vertical-align:middle;
+}
10 spec/application_spec.rb
@@ -0,0 +1,10 @@
+require File.dirname(__FILE__) + '/spec_helper'
+
+describe "Application" do
+
+ it "should respond to /" do
+ get "/"
+ last_response.status.should == 200
+ end
+
+end
20 spec/spec_helper.rb
@@ -0,0 +1,20 @@
+require 'rubygems'
+require 'sinatra'
+require 'slim'
+require 'haml'
+require 'mongoid'
+
+require File.join(File.dirname(__FILE__), '..', 'application.rb')
+
+require 'rack/test'
+require 'rspec'
+
+
+RSpec.configure do |config|
+
+ config.include Rack::Test::Methods
+
+ def app
+ Application
+ end
+end
96 views/application.sass
@@ -0,0 +1,96 @@
+
+$blue: #207FCA
+
+/* Base
+
+body
+ background-color: #F6F6F6
+
+
+/* Fonts
+
+body
+ font: 13px/1.5 'Helvetica Neue',Arial,'Liberation Sans',FreeSans,sans-serif
+
+a
+ color: $blue
+
+a:focus
+ outline: 1px dotted
+
+hr
+ border: 0 #D9D9D9 solid
+ border-top-width: 1px
+ clear: both
+ height: 0
+
+h1
+ font-size: 25px
+h2
+ font-size: 24px
+h3
+ font-size: 17px
+h4
+ font-size: 19px
+h5
+ font-size: 17px
+h6
+ font-size: 15px
+
+h1, h2
+ font-weight: normal
+ color: #555
+ text-shadow: 2px 2px 1px #FFF
+
+h3
+ font-weight: normal
+ color: #303030
+
+ol
+ list-style: decimal
+ul
+ list-style: disc
+li
+ margin-left: 30px
+
+p,dl,hr,h1,h2,h3,h4,h5,
+h6,ol,ul,pre,table,address,
+fieldset,figure
+ margin-bottom: 20px
+
+/* Css classes
+
+.blue
+ color: $blue
+
+/* Page
+
+
+header
+ .black_header
+ background-color: #353535
+ height: 60px
+ h3#logo
+ font-weight: normal
+ color: #FFF
+ font-size: 30px
+ margin: 10px 0 0 0
+
+ nav
+ ol
+ list-style: none
+ margin: 0
+ li
+ display: inline
+ margin: 0
+ a
+ float: left
+ display: block
+ padding: 15px 35px 15px 0
+ color: #303030
+ font-weight: bold
+ text-decoration: none
+ -webkit-transition-duration: .2s
+
+ &:hover, &.selected
+ color: $blue
1  views/index.slim
@@ -0,0 +1 @@
+p Home page content
36 views/layout.slim
@@ -0,0 +1,36 @@
+doctype html
+html lang="en"
+ head
+ title
+ = "Sinatra Mongoid prototyping application."
+ meta http-equiv="Content-Type" content="text/html; charset=utf-8"
+ meta name="language" content="en"
+ meta name="viewport" content="width=1024,maximum-scale=1.0"
+
+ link href="/stylesheets/reset.css" media="screen" rel="stylesheet" type="text/css"
+ link href="/stylesheets/grid.css" media="screen" rel="stylesheet" type="text/css"
+ link href="/stylesheets/application.css" media="screen" rel="stylesheet" type="text/css"
+
+ /![if IE]
+ script type="text/javascript" src="http://html5shiv.googlecode.com/svn/trunk/html5.js"
+ /![if lt IE 9]
+ script type="text/javascript" src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"
+
+ body
+
+ header
+ .container_12
+ nav.grid_12
+ ol
+ li
+ a.selected href="/"
+ hr/
+
+ .container_12
+ section.welcome.grid_12
+ h1 Sinatra + Mongoid prototyping application.
+ hr
+ = yield
+
+ script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"
+ script type="text/javascript" src="/javascripts/application.js"
Please sign in to comment.
Something went wrong with that request. Please try again.