├── .gitignore ├── Gemfile ├── LICENSE ├── README.md ├── Rakefile ├── bin └── simba ├── lib ├── simba.rb └── simba │ ├── command.rb │ ├── templates │ ├── Gemfile │ ├── Linnerfile │ ├── Rakefile │ ├── app │ │ ├── assets │ │ │ ├── images │ │ │ │ └── logo.png │ │ │ ├── scripts │ │ │ │ ├── app.coffee │ │ │ │ └── welcome.coffee │ │ │ └── styles │ │ │ │ └── app.scss │ │ ├── helpers │ │ │ └── helper.rb │ │ ├── models │ │ │ └── user.rb │ │ ├── routes │ │ │ └── app.rb │ │ └── views │ │ │ ├── home │ │ │ └── index.slim │ │ │ └── layout.slim │ ├── config.ru │ ├── config │ │ ├── boot.rb.tt │ │ └── database.yml │ ├── lib │ │ └── tasks │ │ │ └── assets.rake │ └── test │ │ ├── factory │ │ └── user_factory.rb │ │ ├── functional │ │ └── user_controller_test.rb │ │ ├── test_helper.rb │ │ └── unit │ │ └── user_test.rb │ └── version.rb └── simba.gemspec /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | .bundle 4 | .config 5 | .yardoc 6 | .Ds_Store 7 | .sass-cache/ 8 | *.db 9 | Gemfile.lock 10 | InstalledFiles 11 | _yardoc 12 | coverage 13 | doc/ 14 | lib/bundler/man 15 | pkg 16 | rdoc 17 | spec/reports 18 | test/tmp 19 | test/version_tmp 20 | tmp 21 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | # Specify your gem"s dependencies in simba.gemspec 4 | gemspec 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Saito 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Simba 2 | 3 | Simba is a generator for Sinatra applications. 4 | 5 | Simba chooses slim + sinatra + activerecord to build your awesome apps. 6 | 7 | Simba's aim is to help you to use best practices when not using ruby on rails. 8 | 9 | ## Installation 10 | 11 | $ gem install simba 12 | 13 | ## Usage 14 | 15 | $ simba new appname 16 | 17 | $ # development 18 | $ bundle exec rackup 19 | 20 | $ # production 21 | $ rake asset:precompile 22 | $ bundle exec rackup -E production 23 | 24 | ## More 25 | 26 | Simba uses [Linner](https://github.com/SaitoWu/linner) as its asset packaging system, 27 | You can star it on the github page. 28 | 29 | ## Contributing 30 | 31 | 1. Fork it 32 | 2. Create your feature branch (`git checkout -b my-new-feature`) 33 | 3. Commit your changes (`git commit -am "Added some feature"`) 34 | 4. Push to the branch (`git push origin my-new-feature`) 35 | 5. Create new Pull Request 36 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rake 2 | require "bundler/gem_tasks" 3 | -------------------------------------------------------------------------------- /bin/simba: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require File.dirname(__FILE__) + "/../lib/simba" 4 | Simba::Command.start 5 | -------------------------------------------------------------------------------- /lib/simba.rb: -------------------------------------------------------------------------------- 1 | require "simba/command" 2 | require "simba/version" 3 | 4 | module Simba 5 | end 6 | -------------------------------------------------------------------------------- /lib/simba/command.rb: -------------------------------------------------------------------------------- 1 | require "thor" 2 | require "securerandom" 3 | 4 | module Simba 5 | class Command < Thor 6 | include Thor::Actions 7 | map "-v" => :version 8 | 9 | def self.source_root 10 | File.dirname(__FILE__) 11 | end 12 | 13 | desc "version", "show version" 14 | def version 15 | puts Simba::VERSION 16 | end 17 | 18 | desc "new", "create the skeleton of project" 19 | def new(name) 20 | @secret = SecureRandom.hex 32 21 | directory("templates", name) 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /lib/simba/templates/Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gem "rake" 4 | gem "sqlite3" 5 | gem "slim", "~> 2.0.1" 6 | gem "sinatra", "~> 1.4.3" 7 | gem "sinatra-contrib", "~> 1.4.1" 8 | gem "sinatra-activerecord", "~> 1.2.3" 9 | 10 | # If you want to use mail 11 | # gem "pony" 12 | 13 | group :development do 14 | gem "therubyracer", "~> 0.12.0" 15 | gem "linner", "~> 0.7", require: false 16 | end 17 | 18 | group :production do 19 | gem "puma" 20 | end 21 | 22 | group :test do 23 | gem "pry" 24 | gem "rack-test" 25 | gem "factory_girl" 26 | gem "database_cleaner" 27 | end 28 | -------------------------------------------------------------------------------- /lib/simba/templates/Linnerfile: -------------------------------------------------------------------------------- 1 | paths: 2 | app: "app/assets" 3 | public: "public" 4 | groups: 5 | scripts: 6 | paths: 7 | - app/assets/scripts 8 | concat: 9 | "/assets/app.js": "{app/assets/scripts,vendor}/**/*.{js,coffee}" 10 | order: 11 | - "vendor/jquery.js" 12 | - "..." 13 | - "app/scripts/app.coffee" 14 | styles: 15 | paths: 16 | - app/assets/styles 17 | concat: 18 | "/assets/app.css": "{app/assets/styles,vendor}/**/[a-z]*.{css,scss,sass}" 19 | images: 20 | paths: 21 | - app/assets/images 22 | sprite: 23 | "../app/assets/styles/icons.scss": "app/assets/images/**/*.png" 24 | modules: 25 | wrapper: "cmd" 26 | ignored: "vendor/**/*" 27 | definition: "/assets/app.js" 28 | sprites: 29 | selector: ".icon-" 30 | path: "/assets/images/" 31 | url: "/assets/images/" 32 | revision: 33 | manifest: manifest.yml 34 | notification: true 35 | bundles: 36 | jquery.js: 37 | version: 1.11.0 38 | url: http://code.jquery.com/jquery-1.11.0.js 39 | -------------------------------------------------------------------------------- /lib/simba/templates/Rakefile: -------------------------------------------------------------------------------- 1 | # load rake tasks 2 | require "sinatra/activerecord/rake" 3 | 4 | Dir["./lib/tasks/**/*.rake"].sort.each { |ext| load ext } 5 | 6 | require "./config/boot.rb" 7 | -------------------------------------------------------------------------------- /lib/simba/templates/app/assets/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SaitoWu/simba/6684566ca9774b7b23d53a558c25a093fe121ee3/lib/simba/templates/app/assets/images/logo.png -------------------------------------------------------------------------------- /lib/simba/templates/app/assets/scripts/app.coffee: -------------------------------------------------------------------------------- 1 | welcome = require "welcome" 2 | 3 | $ -> 4 | welcome() 5 | -------------------------------------------------------------------------------- /lib/simba/templates/app/assets/scripts/welcome.coffee: -------------------------------------------------------------------------------- 1 | module.exports = -> 2 | console.info "Aha! Simba!" 3 | -------------------------------------------------------------------------------- /lib/simba/templates/app/assets/styles/app.scss: -------------------------------------------------------------------------------- 1 | @import "compass/reset"; 2 | 3 | .hero-unit { 4 | text-align: center; 5 | 6 | .icon-logo { 7 | margin: 0 auto; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /lib/simba/templates/app/helpers/helper.rb: -------------------------------------------------------------------------------- 1 | helpers do 2 | def asset_path file 3 | if settings.development? 4 | file 5 | else 6 | settings.manifest[file] 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/simba/templates/app/models/user.rb: -------------------------------------------------------------------------------- 1 | class User < ActiveRecord::Base 2 | end 3 | -------------------------------------------------------------------------------- /lib/simba/templates/app/routes/app.rb: -------------------------------------------------------------------------------- 1 | get "/" do 2 | slim :"home/index" 3 | end 4 | -------------------------------------------------------------------------------- /lib/simba/templates/app/views/home/index.slim: -------------------------------------------------------------------------------- 1 | .hero-unit 2 | .icon-logo 3 | h3 Welcome to Simba! 4 | -------------------------------------------------------------------------------- /lib/simba/templates/app/views/layout.slim: -------------------------------------------------------------------------------- 1 | doctype html 2 | html 3 | head 4 | title Simba 5 | meta name="keywords" content="website" 6 | link rel="stylesheet" href=asset_path("/assets/app.css") 7 | body 8 | == yield 9 | script src=asset_path("/assets/app.js") 10 | script =="require(\"app\")" 11 | -------------------------------------------------------------------------------- /lib/simba/templates/config.ru: -------------------------------------------------------------------------------- 1 | require "./config/boot.rb" 2 | 3 | Process.fork do 4 | exec "bundle exec linner watch" 5 | end if settings.development? 6 | 7 | run Sinatra::Application 8 | -------------------------------------------------------------------------------- /lib/simba/templates/config/boot.rb.tt: -------------------------------------------------------------------------------- 1 | require "bundler" 2 | require "yaml" 3 | 4 | # require "bundle gems" 5 | ENV["RACK_ENV"] ||= "development" 6 | Bundler.require(:default, ENV["RACK_ENV"].to_sym) 7 | 8 | # init sinatra 9 | set :root, File.expand_path(".") 10 | set :sessions, true 11 | set :session_secret, "<%= @secret %>" 12 | set :views, settings.root + "/app/views" 13 | set :database_file, settings.root + "/config/database.yml" 14 | 15 | if production? 16 | set :manifest, YAML::load(File.read(settings.root + "/public/manifest.yml")) 17 | end 18 | 19 | # sinatra reloader 20 | if development? 21 | require "sinatra/reloader" 22 | also_reload "lib/**/*.rb", "app/{models,helpers}/**/*.rb" 23 | end 24 | 25 | # require project files 26 | Dir.glob "./{lib,app/{models,helpers,routes}}/**/*.rb" do |f| 27 | require f 28 | end 29 | -------------------------------------------------------------------------------- /lib/simba/templates/config/database.yml: -------------------------------------------------------------------------------- 1 | development: 2 | adapter: sqlite3 3 | database: db/development.sqlite3 4 | pool: 5 5 | timeout: 5000 6 | 7 | test: 8 | adapter: sqlite3 9 | database: db/test.sqlite3 10 | pool: 5 11 | timeout: 5000 12 | 13 | production: 14 | adapter: sqlite3 15 | database: db/production.sqlite3 16 | pool: 5 17 | timeout: 5000 18 | -------------------------------------------------------------------------------- /lib/simba/templates/lib/tasks/assets.rake: -------------------------------------------------------------------------------- 1 | namespace :assets do 2 | desc "precompile assets" 3 | task :precompile do 4 | exec "bundle exec linner build" 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /lib/simba/templates/test/factory/user_factory.rb: -------------------------------------------------------------------------------- 1 | # https://github.com/thoughtbot/factory_girl/wiki/Usage 2 | FactoryGirl.define do 3 | factory :user do 4 | name "simba" 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /lib/simba/templates/test/functional/user_controller_test.rb: -------------------------------------------------------------------------------- 1 | require_relative "../test_helper" 2 | 3 | class UserControllerTest < FunctionalTestCase 4 | end 5 | -------------------------------------------------------------------------------- /lib/simba/templates/test/test_helper.rb: -------------------------------------------------------------------------------- 1 | ENV["RACK_ENV"] ||= "test" 2 | require_relative "../config/boot.rb" 3 | 4 | # factory_girl 5 | dir = File.expand_path File.dirname(__FILE__) 6 | Dir.glob "#{dir}/factory/**/*_factory.rb" do |f| 7 | require f 8 | end 9 | 10 | require "minitest/autorun" 11 | require "rack/test" 12 | DatabaseCleaner.strategy = :truncation 13 | 14 | class TestCase < MiniTest::Unit::TestCase 15 | include FactoryGirl::Syntax::Methods 16 | def initialize *xs 17 | super 18 | DatabaseCleaner.clean 19 | end 20 | end 21 | 22 | class FunctionalTestCase < TestCase 23 | include Rack::Test::Methods 24 | def app 25 | Sinatra::Application 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /lib/simba/templates/test/unit/user_test.rb: -------------------------------------------------------------------------------- 1 | require_relative "../test_helper" 2 | 3 | class UserTest < TestCase 4 | def setup 5 | @user = build :user 6 | end 7 | 8 | def test_user_name 9 | # dummy 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /lib/simba/version.rb: -------------------------------------------------------------------------------- 1 | module Simba 2 | VERSION = "0.8.1" 3 | end 4 | -------------------------------------------------------------------------------- /simba.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | require File.expand_path("../lib/simba/version", __FILE__) 3 | 4 | Gem::Specification.new do |gem| 5 | gem.authors = ["Saito"] 6 | gem.email = ["saitowu@gmail.com"] 7 | gem.description = %q{simba is a generator for sinatra applications.} 8 | gem.summary = %q{simba aim to set up ruby off rails best practice.} 9 | gem.homepage = "https://github.com/SaitoWu/simba" 10 | 11 | gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } 12 | gem.files = `git ls-files`.split("\n") 13 | gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") 14 | gem.name = "simba" 15 | gem.require_paths = ["lib"] 16 | gem.version = Simba::VERSION 17 | 18 | gem.add_dependency("thor", "~> 0.18") 19 | end 20 | --------------------------------------------------------------------------------