Giter Site home page Giter Site logo

gxbsst / sinatra-template Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shell/sinatra-template

0.0 1.0 0.0 154 KB

Preconfigured sinatra template with essentials like: HAML, ActiveRecord, Rspec testing suite

Home Page: http://penkin.co.uk

sinatra-template's Introduction

Sinatra Template Build Status Code Climate

About

Recently I found myself doing a very simple services for my cliens with Sinatra. There is a lot of guides, tutorials and FAQs around the internet. But it seems that there is no good Sinatra template with testing coverate, basic files structure, etc. So I made one.

App

  • HTTP basic authentication
  • ActiveRecord orm
  • Sqlite3 for development, Mysql2 for production
  • 2 very basic but associated models
  • HAML, blueprint, jquery
  • User and Admin interfaces
  • Scroller with products
  • Full rake tasks for db management(hacked sinatra-activerecord gem)
  • Testing suite out of the box(RSpec)
  • Some essential Rails helpers
  • Ready for deploy with passenger(/config/setup_load_paths.rb)

You can switch environments with RACK_ENV=test If you have old version of rake installed in gemset, you need to prepend all rake commands with bundle exec

Some prefer to extract controllers, models, helpers in corresponding folders and split them over files. It is a matter of taste, bit if you have a lot of files, consider using Rails instead.

HTML

  • HAML
  • jquery
  • blueprint
  • basic forms for models
  • kitten placeholders - everything is better with bluetooth(or Kittens)

Helpers

  • link_to - it is not full copy of Rails's link_to, this version produces only anchor tag with parameters
  • in_groups_of - iteration over collection by groups
  • options_for_select

Rake

$ rake -T

rake db:create
rake db:create_migration
rake db:drop
rake db:migrate
rake db:reset
rake db:rollback
rake db:seed

Installation

$ git clone https://github.com/shell/sinatra-template.git
$ cd sinatra-template
$ rake db:create && rake db:migrate
$ ruby app.rb

Testing

Testing suite include overall application behaviour(/spec/app_spec.rb) and model specific testing(products_spec.rb, categories_spec.rb). Specific test include unit testing for model and actions tests for app

Do not forget to create and migrate testing database before:

$ RACK_ENV=test rake db:create
$ RACK_ENV=test rake db:migrate

Run tests once

$ rspec spec/

Autotest friendly

$ ./autotest

Testing coverate generated with SimpleCov flavor

  $ open coverage/index.html

Deploy

Deploy it as regular rack/rails application. Just point root to /app/public and set RACK_ENV variable

Todo

  • additional essential rails helpers
  • might need to use a Spork

Author

Vladimir Penkin

sinatra-template's People

Contributors

shell avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.