sinator 3.0.0

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 (57) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +5 -0
  3. data/.rspec +2 -0
  4. data/CHANGELOG.md +46 -0
  5. data/Gemfile +3 -0
  6. data/Gemfile.lock +33 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +126 -0
  9. data/bin/sinator +5 -0
  10. data/lib/sinator/command.rb +61 -0
  11. data/lib/sinator/generator.rb +106 -0
  12. data/lib/sinator/templates/Gemfile.erb +15 -0
  13. data/lib/sinator/templates/Rakefile.erb +33 -0
  14. data/lib/sinator/templates/app/routes/home.erb +6 -0
  15. data/lib/sinator/templates/app/views/home/index.erb +1 -0
  16. data/lib/sinator/templates/app/views/layout.erb +21 -0
  17. data/lib/sinator/templates/app.erb +71 -0
  18. data/lib/sinator/templates/assets/javascripts/app.js +2 -0
  19. data/lib/sinator/templates/assets/javascripts/main.js +1 -0
  20. data/lib/sinator/templates/assets/javascripts/plugins.js +24 -0
  21. data/lib/sinator/templates/assets/stylesheets/app.css.scss +1 -0
  22. data/lib/sinator/templates/assets/stylesheets/main.css.scss +8 -0
  23. data/lib/sinator/templates/config/application.rb +7 -0
  24. data/lib/sinator/templates/config/boot.rb +10 -0
  25. data/lib/sinator/templates/config/database.yml +8 -0
  26. data/lib/sinator/templates/config/puma/development.erb +7 -0
  27. data/lib/sinator/templates/config/puma/production.erb +16 -0
  28. data/lib/sinator/templates/config.ru.erb +5 -0
  29. data/lib/sinator/templates/db/migrations/000_example.rb +12 -0
  30. data/lib/sinator/templates/public/404.html +60 -0
  31. data/lib/sinator/templates/public/apple-touch-icon.png +0 -0
  32. data/lib/sinator/templates/public/browserconfig.xml +12 -0
  33. data/lib/sinator/templates/public/crossdomain.xml +15 -0
  34. data/lib/sinator/templates/public/favicon.ico +0 -0
  35. data/lib/sinator/templates/public/humans.txt +15 -0
  36. data/lib/sinator/templates/public/robots.txt +5 -0
  37. data/lib/sinator/templates/public/tile-wide.png +0 -0
  38. data/lib/sinator/templates/public/tile.png +0 -0
  39. data/lib/sinator/version.rb +3 -0
  40. data/lib/sinator.rb +1 -0
  41. data/sinator.gemspec +19 -0
  42. data/spec/fixtures/app_routes_home.txt +6 -0
  43. data/spec/fixtures/config/puma/development.txt +7 -0
  44. data/spec/fixtures/config/puma/production.txt +16 -0
  45. data/spec/fixtures/config_ru.txt +5 -0
  46. data/spec/fixtures/with_db/app.txt +50 -0
  47. data/spec/fixtures/with_db/gemfile.txt +13 -0
  48. data/spec/fixtures/with_db/rakefile.txt +32 -0
  49. data/spec/fixtures/without_db/app.txt +31 -0
  50. data/spec/fixtures/without_db/gemfile.txt +11 -0
  51. data/spec/fixtures/without_db/rakefile.txt +15 -0
  52. data/spec/helpers/generator.rb +46 -0
  53. data/spec/sinator/command_spec.rb +70 -0
  54. data/spec/sinator/generator_spec.rb +184 -0
  55. data/spec/sinator_spec.rb +1 -0
  56. data/spec/spec_helper.rb +29 -0
  57. metadata +128 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2b43b8566572040b2ff40282859004442ee2a439
4
+ data.tar.gz: 0b52f96d8ef24cd192757a9cf98fcecff1f91eb3
5
+ SHA512:
6
+ metadata.gz: 94b3958e6ff48c01b96a77642f22ea61aa43b9de9e9a34d86944fb57db3dba0f692d03a6f4763e9f91ed9a9e505d5bd3e8192f757caaedda6e8daf8e813cde6d
7
+ data.tar.gz: 4d196b9afe648b1a2db1d7767f720e0e35a91717f08d0ed3dfda8aafbe612821a0ccf30210d1409c724871b747bdc422f9651f5144aff2580fa5814c144c5bef
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *~
2
+ *.swp
3
+ *.swo
4
+ *.gem
5
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/CHANGELOG.md ADDED
@@ -0,0 +1,46 @@
1
+ 3.0.0:
2
+ * set explicit version to all required ruby gems
3
+ * replace sinatra-asset-pipeline with sprockets
4
+ * generate database.yml instead of database.yml.example
5
+ * add rake tasks to perform assets:precompile and assets:clean
6
+ * replace Thin web server with Puma web server
7
+ * rename project to Sinator
8
+
9
+ 2.0.1:
10
+ * prevent sinatra-contrib to be required on Gemfile. Sinatra contrib is interfering with Rake’s own namespace support
11
+
12
+ 2.0.0:
13
+ * remove Melodiest::Application, only focus on application boilerplate
14
+
15
+ 1.0.0:
16
+ * prevent tux to be required
17
+ * add sinatra assets pipeline extension
18
+ * restructure generated app
19
+ * use erb for app templates
20
+ * create Rakefile generator with and without database
21
+ * add new Sequel configuration when generating app with database
22
+ * add Sinatra::Cache extension
23
+ * remove Melodiest::Setting. Rename setup method to cookie_secret.
24
+ * restructure generated app
25
+ * add some configurations from h5bp
26
+
27
+ 0.4.0:
28
+ * add SQL logger to development environment
29
+ * generate public dir when running generator
30
+ * use tux as Sinatra console
31
+ * when has no option, melodiest command will use --help option
32
+
33
+ 0.3.0:
34
+ * remove Melodiest::Auth::Http module, it's better to use sinatra-authorization extension
35
+ * refactor Melodiest::Setting.setup so that it can be overridden via app and remove thin as dependency
36
+ * add generator for sequel orm and postgres sql
37
+ * use encrypted cookie
38
+ * add generator for Rack::Csrf
39
+
40
+ 0.2.x:
41
+ * add sinatra application boilerplate generator
42
+ * add melodiest command to run generator
43
+
44
+ 0.1.x:
45
+ * add http authorization module
46
+ * set thin as server
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,33 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ sinator (2.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.2.5)
10
+ rspec (3.2.0)
11
+ rspec-core (~> 3.2.0)
12
+ rspec-expectations (~> 3.2.0)
13
+ rspec-mocks (~> 3.2.0)
14
+ rspec-core (3.2.3)
15
+ rspec-support (~> 3.2.0)
16
+ rspec-expectations (3.2.1)
17
+ diff-lcs (>= 1.2.0, < 2.0)
18
+ rspec-support (~> 3.2.0)
19
+ rspec-mocks (3.2.1)
20
+ diff-lcs (>= 1.2.0, < 2.0)
21
+ rspec-support (~> 3.2.0)
22
+ rspec-support (3.2.2)
23
+
24
+ PLATFORMS
25
+ ruby
26
+
27
+ DEPENDENCIES
28
+ bundler (~> 1.7)
29
+ sinator!
30
+ rspec (= 3.2.0)
31
+
32
+ BUNDLED WITH
33
+ 1.15.3
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015-2016 Kunto Aji Kristianto
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.
data/README.md ADDED
@@ -0,0 +1,126 @@
1
+ # Background
2
+
3
+ Sinator is [Sinatra](http://www.sinatrarb.com/) application boilerplate. It provides generator and contains minimum configuration to develop web application with Sinatra.
4
+ The reasons behind this project because I want to create many small web application based on sinatra with other third party ruby gems as foundation.
5
+
6
+ # Features
7
+ * Generate Sinatra based web application without database
8
+ * Generate Sinatra based web application with PostgreSQL database configuration and Sequel as ORM
9
+
10
+ ### Installation
11
+
12
+ ```ruby
13
+ gem install sinator
14
+ ```
15
+
16
+ with Bundler, put this code in your Gemfile:
17
+
18
+ ```ruby
19
+ gem 'sinator'
20
+ ```
21
+
22
+ ### How to Use
23
+ generate app in current directory without database
24
+
25
+ ```
26
+ sinator -n my_app
27
+ ```
28
+
29
+ generate app in target directory without database
30
+
31
+ ```
32
+ sinator -n my_app -t target/dir
33
+ ```
34
+
35
+ generate app in current directory with database. `-d` option will generate app with `Sequel` ORM and PostgreSQL adapter.
36
+
37
+ ```
38
+ sinator -n my_app -d
39
+ ```
40
+
41
+ ### Example Usage
42
+ This example assume that PostgreSQL is already running and desired database is already exist.
43
+ For complete example see [github.com/kuntoaji/todo_sinator](https://github.com/kuntoaji/todo_sinator)
44
+ 1. run `sinator -n my_app -d`
45
+ 2. cd `my_app`
46
+ 3. run `bundle install`
47
+ 4. configure your database setting in `config/database.yml`
48
+ 5. create file `db/migrations/001_create_artists.rb` and put the following code:
49
+
50
+ ```ruby
51
+ Sequel.migration do
52
+ up do
53
+ create_table(:artists) do
54
+ primary_key :id
55
+ String :name, :null=>false
56
+ end
57
+ end
58
+
59
+ down do
60
+ drop_table(:artists)
61
+ end
62
+ end
63
+ ```
64
+
65
+ 6. run `rake db:migrate`
66
+ 7. create file `app/models/Artist.rb` and put the following code:
67
+
68
+ ```ruby
69
+ class Artist < Sequel::Model
70
+ end
71
+ ```
72
+
73
+ 8. create file `app/routes/artists.rb` and put the following code:
74
+
75
+ ```ruby
76
+ class MyApp
77
+ get '/artists' do
78
+ @artists = Artist.all
79
+ erb :"artists/index"
80
+ end
81
+
82
+ post '/artists' do
83
+ @artist = Artist.new
84
+ @artist.name = params[:name]
85
+ @artist.save
86
+
87
+ redirect '/artists'
88
+ end
89
+ end
90
+ ```
91
+
92
+ 9. create file `app/views/artists/index.erb` and put the following code:
93
+
94
+ ```erb
95
+ <h1>List of Artist</h1>
96
+ <ul>
97
+ <% @artists.each do |artist| %>
98
+ <li><%= artist.name %></li>
99
+ <% end %>
100
+ </ul>
101
+
102
+ <form action="/artists" method="post">
103
+ <%= Rack::Csrf.tag(env) %>
104
+ <input type="text" name="name" />
105
+ <button>Submit</button>
106
+ </form>
107
+ ```
108
+
109
+ 10. run the server `bundle exec puma`
110
+ 11. open url `localhost:3000/artists`
111
+
112
+ ### List of Ruby Gems
113
+
114
+ * sinatra
115
+ * sinatra-contrib
116
+ * encrypted_cookie
117
+ * `Sinatra::Reloader` in development environment only
118
+ * puma
119
+ * `Rack::Session::EncryptedCookie`
120
+ * `Rack::Csrf`
121
+ * sequel
122
+ * sequel_pg as PostgreSQL adapter
123
+ * sprockets
124
+ * sass
125
+ * uglifier
126
+ * tux for console
data/bin/sinator ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/sinator/command'
4
+
5
+ puts Sinator::Command.parse ARGV
@@ -0,0 +1,61 @@
1
+ require 'optparse'
2
+ require_relative 'generator'
3
+
4
+ module Sinator
5
+
6
+ class Command
7
+ def self.parse(options)
8
+ options = %w(--help) if options.empty? || options.nil?
9
+ args = {}
10
+ result = nil
11
+
12
+ option_parser = OptionParser.new do |opts|
13
+ opts.banner = "Usage: sinator [options]"
14
+
15
+ opts.on("-h", "--help", "Print this help") do
16
+ result = opts.to_s
17
+ end
18
+
19
+ opts.on("-v", "--version", "Show version") do
20
+ result = Sinator::VERSION
21
+ end
22
+
23
+ opts.on("-nNAME", "--name=NAME", "generate app with name from this option") do |name|
24
+ args[:name] = name
25
+ end
26
+
27
+ opts.on("-tDIR", "--target=DIR", "instead of current directory, generate app in target DIR") do |target|
28
+ args[:target] = target
29
+ end
30
+
31
+ opts.on("-d", "--database", "add sequel orm for postgres sql") do
32
+ args[:database] = true
33
+ end
34
+
35
+ end
36
+
37
+ option_parser.parse! options
38
+
39
+ result = run(args) unless args[:name].nil?
40
+
41
+ result
42
+ end
43
+
44
+ def self.run(args)
45
+ generator = Sinator::Generator.new args[:name],
46
+ destination: args[:target], with_database: args[:database]
47
+
48
+ generator.generate_app
49
+ generator.generate_rakefile
50
+ generator.generate_gemfile
51
+ generator.generate_bundle_config
52
+ generator.generate_puma_config
53
+
54
+ msg = "#{args[:name]} is successfully generated"
55
+ msg << " in #{args[:target]}" if args[:target]
56
+
57
+ msg
58
+ end
59
+ end
60
+
61
+ end
@@ -0,0 +1,106 @@
1
+ require 'fileutils'
2
+ require 'securerandom'
3
+ require 'erb'
4
+ require_relative 'version'
5
+
6
+ module Sinator
7
+
8
+ class Generator
9
+ attr_accessor :destination, :app_name, :app_class_name
10
+
11
+ def initialize(app_name, options={})
12
+ @app_name = app_name
13
+ @app_class_name = app_name.split("_").map{|s| s.capitalize }.join("")
14
+
15
+ destination = options[:destination] ? "#{options[:destination]}/#{@app_name}" : @app_name
16
+ @with_database = options[:with_database]
17
+
18
+ unless File.directory?(destination)
19
+ FileUtils.mkdir_p(destination)
20
+ end
21
+
22
+ @destination = File.expand_path(destination)
23
+ end
24
+
25
+ def generate_rakefile
26
+ gemfile = File.read File.expand_path("../templates/Rakefile.erb", __FILE__)
27
+ erb = ERB.new gemfile, 0, '-'
28
+
29
+ File.open "#{@destination}/Rakefile", "w" do |f|
30
+ f.write erb.result(binding)
31
+ end
32
+ end
33
+
34
+ def generate_gemfile
35
+ gemfile = File.read File.expand_path("../templates/Gemfile.erb", __FILE__)
36
+ erb = ERB.new gemfile, 0, '-'
37
+
38
+ File.open "#{@destination}/Gemfile", "w" do |f|
39
+ f.write erb.result(binding)
40
+ end
41
+ end
42
+
43
+ def generate_bundle_config
44
+ config_ru = File.read File.expand_path("../templates/config.ru.erb", __FILE__)
45
+ erb = ERB.new config_ru
46
+
47
+ File.open "#{@destination}/config.ru", "w" do |f|
48
+ f.write erb.result(binding)
49
+ end
50
+ end
51
+
52
+ def generate_puma_config
53
+ puma_development = File.read File.expand_path("../templates/config/puma/development.erb", __FILE__)
54
+ puma_production = File.read File.expand_path("../templates/config/puma/production.erb", __FILE__)
55
+
56
+ erb = ERB.new puma_development, 0, '-'
57
+ File.open "#{@destination}/config/puma/development.rb", "w" do |f|
58
+ f.write erb.result(binding)
59
+ end
60
+
61
+ erb = ERB.new puma_production, 0, '-'
62
+ File.open "#{@destination}/config/puma/production.rb", "w" do |f|
63
+ f.write erb.result(binding)
64
+ end
65
+ end
66
+
67
+ # https://github.com/sinatra/sinatra-book/blob/master/book/Organizing_your_application.markdown
68
+ def generate_app
69
+ copy_templates
70
+ app = File.read File.expand_path("../templates/app.erb", __FILE__)
71
+ erb = ERB.new app, 0, '-'
72
+
73
+ File.open "#{@destination}/#{@app_name}.rb", "w" do |f|
74
+ f.write erb.result(binding)
75
+ end
76
+
77
+ route = File.read File.expand_path("../templates/app/routes/home.erb", __FILE__)
78
+ erb = ERB.new route, 0, '-'
79
+
80
+ File.open "#{@destination}/app/routes/home.rb", "w" do |f|
81
+ f.write erb.result(binding)
82
+ end
83
+
84
+ FileUtils.rm "#{@destination}/app/routes/home.erb"
85
+ end
86
+
87
+ private
88
+
89
+ def copy_templates
90
+ FileUtils.cp_r File.expand_path("../templates/assets", __FILE__), @destination
91
+ FileUtils.cp_r File.expand_path("../templates/config", __FILE__), @destination
92
+ FileUtils.cp_r File.expand_path("../templates/public", __FILE__), @destination
93
+ FileUtils.cp_r File.expand_path("../templates/app", __FILE__), @destination
94
+ FileUtils.rm "#{@destination}/config/puma/development.erb"
95
+ FileUtils.rm "#{@destination}/config/puma/production.erb"
96
+
97
+ if @with_database
98
+ FileUtils.mkdir "#{@destination}/app/models"
99
+ FileUtils.cp_r File.expand_path("../templates/db", __FILE__), @destination
100
+ else
101
+ FileUtils.rm "#{@destination}/config/database.yml"
102
+ end
103
+ end
104
+ end
105
+
106
+ end
@@ -0,0 +1,15 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'sinatra', '2.0.0'
4
+ gem 'sinatra-contrib', '2.0.0', require: false
5
+ gem 'encrypted_cookie', '0.0.5'
6
+ gem 'rack_csrf', '2.6.0', require: 'rack/csrf'
7
+ gem 'puma', '3.11.0'
8
+ gem 'tux', '0.3.0', require: false
9
+ gem 'uglifier', '4.1.3', require: false
10
+ gem 'sass', '3.5.5', require: false
11
+ gem 'sprockets', '3.7.1'
12
+ <% if @with_database -%>
13
+ gem 'sequel', '5.4.0'
14
+ gem 'sequel_pg', '1.8.1', require: 'sequel'
15
+ <% end -%>
@@ -0,0 +1,33 @@
1
+ require_relative 'config/boot'
2
+ require_relative '<%= @app_name %>'
3
+
4
+ namespace :assets do
5
+ desc "Precompile assets"
6
+ task :precompile do
7
+ manifest = ::Sprockets::Manifest.new(<%= @app_class_name %>.assets.index, "#{<%= @app_class_name %>.public_folder}/assets")
8
+ manifest.compile(<%= @app_class_name %>.assets_manifest)
9
+ end
10
+
11
+ desc "Clean assets"
12
+ task :clean do
13
+ FileUtils.rm_rf("#{<%= @app_class_name %>.public_folder}/assets")
14
+ end
15
+ end
16
+ <% if @with_database %>
17
+ namespace :db do
18
+ desc "Run migrations"
19
+ task :migrate, [:version] do |t, args|
20
+ Sequel.extension :migration
21
+ db = Sequel.connect(YAML.load_file("#{Sinator::ROOT}/config/database.yml")[ENV['APP_ENV']])
22
+ migration_path = "#{Sinator::ROOT}/db/migrations"
23
+
24
+ if args[:version]
25
+ puts "Migrating to version #{args[:version]}"
26
+ Sequel::Migrator.run(db, migration_path, target: args[:version].to_i)
27
+ else
28
+ puts "Migrating to latest"
29
+ Sequel::Migrator.run(db, migration_path)
30
+ end
31
+ end
32
+ end
33
+ <% end %>
@@ -0,0 +1,6 @@
1
+ class <%= @app_class_name %>
2
+ get '/' do
3
+ @home = "Hello World from app/routes/home.rb"
4
+ erb :"home/index"
5
+ end
6
+ end
@@ -0,0 +1 @@
1
+ <%= @home %>
@@ -0,0 +1,21 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
6
+ <title>My Title</title>
7
+ <meta name="description" content="my description">
8
+ <meta name="viewport" content="width=device-width, initial-scale=1">
9
+
10
+ <link rel="apple-touch-icon" href="apple-touch-icon.png">
11
+ <link rel="stylesheet" type="text/css" href="assets/app.css">
12
+ <script src="assets/app.js"></script>
13
+ </head>
14
+ <body>
15
+ <!--[if lt IE 8]>
16
+ <p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
17
+ <![endif]-->
18
+
19
+ <%= yield %>
20
+ </body>
21
+ </html>
@@ -0,0 +1,71 @@
1
+ <%= "require 'yaml'\n\n" if @with_database -%>
2
+ class <%= @app_class_name %> < Sinatra::Application
3
+ use Rack::Session::EncryptedCookie,
4
+ secret: '<%= SecureRandom.hex 32 %>'
5
+
6
+ set :app_file, __FILE__
7
+ set :server, :puma
8
+ set :views, Proc.new { File.join(root, "app/views") }
9
+ set :assets, Sprockets::Environment.new
10
+ set :assets_manifest, %w(app.js app.css)
11
+ use Rack::Csrf, raise: true
12
+
13
+ <% if @with_database -%>
14
+ configure do
15
+ Sequel::Database.extension :pagination
16
+ Sequel::Model.plugin :timestamps
17
+ Sequel::Model.plugin :auto_validations,
18
+ not_null: :presence, unique_opts: { only_if_modified: true }
19
+
20
+ assets.append_path 'assets/stylesheets'
21
+ assets.append_path 'assets/javascripts'
22
+ end
23
+
24
+ configure :development do
25
+ require 'sinatra/reloader'
26
+ require 'logger'
27
+
28
+ register Sinatra::Reloader
29
+ Sequel.connect YAML.load_file(File.expand_path("../config/database.yml", __FILE__))['development'],
30
+ loggers: [Logger.new($stdout)]
31
+
32
+ get '/assets/*' do
33
+ env['PATH_INFO'].sub!('/assets', '')
34
+ settings.assets.call(env)
35
+ end
36
+ end
37
+
38
+ configure :test do
39
+ Sequel.connect YAML.load_file(File.expand_path("../config/database.yml", __FILE__))['test']
40
+ end
41
+
42
+ configure :production do
43
+ # Serve assets via Nginx or Apache
44
+ disable :static
45
+
46
+ assets.js_compressor = :uglify
47
+ assets.css_compressor = :sass
48
+ Sequel.connect YAML.load_file(File.expand_path("../config/database.yml", __FILE__))['production']
49
+ end
50
+ <% else -%>
51
+ configure do
52
+ assets.append_path 'assets/stylesheets'
53
+ assets.append_path 'assets/javascripts'
54
+ end
55
+
56
+ configure :development do
57
+ get '/assets/*' do
58
+ env['PATH_INFO'].sub!('/assets', '')
59
+ settings.assets.call(env)
60
+ end
61
+ end
62
+
63
+ configure :production do
64
+ # Serve assets via Nginx or Apache
65
+ disable :static
66
+
67
+ assets.js_compressor = :uglify
68
+ assets.css_compressor = :sass
69
+ end
70
+ <% end -%>
71
+ end
@@ -0,0 +1,2 @@
1
+ //= require plugins
2
+ //= require main
@@ -0,0 +1 @@
1
+ /* custom js */
@@ -0,0 +1,24 @@
1
+ // Avoid `console` errors in browsers that lack a console.
2
+ (function() {
3
+ var method;
4
+ var noop = function () {};
5
+ var methods = [
6
+ 'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
7
+ 'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
8
+ 'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
9
+ 'timeline', 'timelineEnd', 'timeStamp', 'trace', 'warn'
10
+ ];
11
+ var length = methods.length;
12
+ var console = (window.console = window.console || {});
13
+
14
+ while (length--) {
15
+ method = methods[length];
16
+
17
+ // Only stub undefined methods.
18
+ if (!console[method]) {
19
+ console[method] = noop;
20
+ }
21
+ }
22
+ }());
23
+
24
+ // Place any jQuery/helper plugins in here.
@@ -0,0 +1 @@
1
+ //= require main
@@ -0,0 +1,8 @@
1
+ /* custom css */
2
+
3
+ .browserupgrade {
4
+ margin: 0.2em 0;
5
+ background: #ccc;
6
+ color: #000;
7
+ padding: 0.2em 0;
8
+ }
@@ -0,0 +1,7 @@
1
+ %w{/app/models /app/helpers /app/routes}.each do |dir|
2
+ resource_dir = Sinator::ROOT + dir
3
+
4
+ Dir[File.join(resource_dir, '**/*.rb')].each do |file|
5
+ require file
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ ENV['RACK_ENV'] ||= 'development'
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+
6
+ Bundler.require :default, ENV['RACK_ENV'].to_sym
7
+
8
+ module Sinator
9
+ ROOT = File.expand_path('../../', __FILE__)
10
+ end
@@ -0,0 +1,8 @@
1
+ # http://sequel.jeremyevans.net/rdoc/files/doc/opening_databases_rdoc.html
2
+ #
3
+ development:
4
+ adapter: postgres
5
+ host: localhost
6
+ database: exampledb_development
7
+ username: exampleuser
8
+ password: examplepwd
@@ -0,0 +1,7 @@
1
+ threads 4, 4
2
+ workers 2
3
+ preload_app!
4
+
5
+ before_fork do
6
+ <%= @app_class_name %>::DB.disconnect if defined?(<%= @app_class_name %>::DB)
7
+ end