trevi 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/bin/trevi +14 -0
- data/lib/trevi.rb +5 -0
- data/lib/trevi/cli.rb +43 -0
- data/lib/trevi/extensions.rb +37 -0
- data/lib/trevi/version.rb +3 -0
- data/templates/app/.gitignore +4 -0
- data/templates/app/Gemfile +37 -0
- data/templates/app/Procfile +1 -0
- data/templates/app/Rakefile +9 -0
- data/templates/app/app.rb.tt +70 -0
- data/templates/app/app/assets/javascripts/layout.coffee +0 -0
- data/templates/app/app/assets/stylesheets/layout.css.styl +27 -0
- data/templates/app/app/assets/stylesheets/mixins.styl +116 -0
- data/templates/app/app/extensions.rb.tt +5 -0
- data/templates/app/app/extensions/assets.rb.tt +45 -0
- data/templates/app/app/helpers.rb.tt +4 -0
- data/templates/app/app/models.rb.tt +6 -0
- data/templates/app/app/routes.rb.tt +10 -0
- data/templates/app/app/routes/assets.rb.tt +10 -0
- data/templates/app/app/routes/base.rb.tt +23 -0
- data/templates/app/app/routes/static.rb.tt +30 -0
- data/templates/app/app/views/layouts/layout.erb.tt +15 -0
- data/templates/app/config.ru.tt +3 -0
- data/templates/app/config/unicorn.rb +21 -0
- data/templates/app/lib/tasks/assets.rb.tt +19 -0
- data/templates/app/lib/tasks/db.rb.tt +25 -0
- data/templates/app/public/favicon.ico +0 -0
- data/trevi.gemspec +25 -0
- metadata +120 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 252164e773802ebca667f307c81f8919ce45511c
|
4
|
+
data.tar.gz: 8b94ddbe67fe4508ac284ecdd04aa0afb9802cd9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f94f6c3deccabbfc60f766fffafd8a7794f2b9c6a5e64e601a9ef12235ccf6af519fdae4bcb2e32a620f69528c8568954174339f05257a101978d4e5005b6461
|
7
|
+
data.tar.gz: 5d9ef886f410fd246cc8fcfd3ffc3986f725e09ceff01fe56598364bd92151611e66d62300a46eed6a615335f08a8a7259ad677e8c5ea600557aa36ea0a9e9b1
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Alex MacCaw
|
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,29 @@
|
|
1
|
+
# Trevi
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'trevi'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install trevi
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/trevi
ADDED
data/lib/trevi.rb
ADDED
data/lib/trevi/cli.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'thor'
|
4
|
+
require 'thor/group'
|
5
|
+
require 'trevi/extensions'
|
6
|
+
|
7
|
+
module Trevi
|
8
|
+
class CLI < Thor::Group
|
9
|
+
include Thor::Actions
|
10
|
+
|
11
|
+
def self.source_root
|
12
|
+
File.expand_path('../../../templates', __FILE__)
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Creates a new Sinatra application"
|
16
|
+
argument :name, :type => :string, :desc => "The name of the new application"
|
17
|
+
|
18
|
+
def setup
|
19
|
+
@app_path = name.directory_name
|
20
|
+
@name = name.file_name
|
21
|
+
|
22
|
+
options.each do |key, value|
|
23
|
+
instance_variable_set "@#{key.to_s}".to_sym, value
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def create_app
|
28
|
+
directory 'app', @app_path
|
29
|
+
end
|
30
|
+
|
31
|
+
def initialize_git_repo
|
32
|
+
inside(@app_path) do
|
33
|
+
run('git init .')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def install_dependencies
|
38
|
+
inside(@app_path) do
|
39
|
+
run('bundle')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Trevi
|
2
|
+
module Extensions
|
3
|
+
module String
|
4
|
+
def camel_case
|
5
|
+
return self.gsub(/^./) { |l| l.capitalize } if !match(/[_-]/)
|
6
|
+
altered_self = self.downcase.capitalize
|
7
|
+
altered_self.scan(/[_-][a-zA-Z]/).each do |match|
|
8
|
+
altered_self.gsub!(match, match[1].upcase)
|
9
|
+
end
|
10
|
+
|
11
|
+
altered_self
|
12
|
+
end
|
13
|
+
|
14
|
+
def camel_case!
|
15
|
+
self.replace camel_case
|
16
|
+
end
|
17
|
+
|
18
|
+
def directory_name
|
19
|
+
self.downcase.gsub(/[^a-z|\-|\_]/, '')
|
20
|
+
end
|
21
|
+
|
22
|
+
def file_name
|
23
|
+
self.gsub(/[\-| ]/, '_').
|
24
|
+
gsub(/([A-Z]+|[A-Z][a-z])/) { |x| "_#{x}" }.
|
25
|
+
sub(/^_/, "").
|
26
|
+
gsub(/_{2,}+/, "_").
|
27
|
+
downcase
|
28
|
+
end
|
29
|
+
|
30
|
+
def file_name!
|
31
|
+
self.replace file_name
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
String.send(:include, Trevi::Extensions::String)
|
@@ -0,0 +1,37 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
ruby '2.0.0'
|
3
|
+
|
4
|
+
gem 'sinatra', require: 'sinatra/base'
|
5
|
+
gem 'sinatra-contrib', github: 'maccman/sinatra-contrib'
|
6
|
+
gem 'rack-standards'
|
7
|
+
gem 'unicorn'
|
8
|
+
gem 'erubis'
|
9
|
+
gem 'i18n'
|
10
|
+
gem 'activesupport'
|
11
|
+
gem 'rake'
|
12
|
+
gem 'builder'
|
13
|
+
gem 'json', '~> 1.7.7'
|
14
|
+
gem 'dotenv'
|
15
|
+
|
16
|
+
# Assets
|
17
|
+
gem 'sprockets'
|
18
|
+
gem 'sprockets-memcache-store'
|
19
|
+
gem 'uglifier'
|
20
|
+
gem 'closure-compiler'
|
21
|
+
gem 'yui-compressor'
|
22
|
+
gem 'coffee-script'
|
23
|
+
gem 'eco'
|
24
|
+
gem 'stylus'
|
25
|
+
gem 'stylus-source', '0.31.0'
|
26
|
+
gem 'dalli'
|
27
|
+
gem 'memcachier'
|
28
|
+
|
29
|
+
# DB
|
30
|
+
gem 'sequel'
|
31
|
+
gem 'sinatra-sequel'
|
32
|
+
gem 'pg'
|
33
|
+
|
34
|
+
group :development do
|
35
|
+
gem 'thin'
|
36
|
+
gem 'debugger', require: 'ruby-debug'
|
37
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
web: bundle exec unicorn -c ./config/unicorn.rb
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
|
4
|
+
# Setup load paths
|
5
|
+
Bundler.require
|
6
|
+
$: << File.expand_path('../', __FILE__)
|
7
|
+
$: << File.expand_path('../lib', __FILE__)
|
8
|
+
|
9
|
+
require 'dotenv'
|
10
|
+
Dotenv.load
|
11
|
+
|
12
|
+
# Require base
|
13
|
+
require 'sinatra/base'
|
14
|
+
require 'active_support/core_ext/string'
|
15
|
+
require 'active_support/core_ext/array'
|
16
|
+
require 'active_support/core_ext/hash'
|
17
|
+
require 'active_support/json'
|
18
|
+
|
19
|
+
libraries = Dir[File.expand_path('../lib/**/*.rb', __FILE__)]
|
20
|
+
libraries.each do |path_name|
|
21
|
+
require path_name
|
22
|
+
end
|
23
|
+
|
24
|
+
require 'app/extensions'
|
25
|
+
require 'app/models'
|
26
|
+
require 'app/helpers'
|
27
|
+
require 'app/routes'
|
28
|
+
|
29
|
+
module <%= @name.camel_case %>
|
30
|
+
class App < Sinatra::Application
|
31
|
+
configure do
|
32
|
+
set :database, lambda {
|
33
|
+
ENV['DATABASE_URL'] ||
|
34
|
+
"postgres://localhost:5432/<%= @name.file_name %>_#{environment}"
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
configure :development, :staging do
|
39
|
+
database.loggers << Logger.new(STDOUT)
|
40
|
+
end
|
41
|
+
|
42
|
+
configure do
|
43
|
+
disable :method_override
|
44
|
+
disable :static
|
45
|
+
|
46
|
+
set :erb, escape_html: true
|
47
|
+
|
48
|
+
set :sessions,
|
49
|
+
httponly: true,
|
50
|
+
secure: production?,
|
51
|
+
secure: false,
|
52
|
+
expire_after: 5.years,
|
53
|
+
secret: ENV['SESSION_SECRET']
|
54
|
+
end
|
55
|
+
|
56
|
+
use Rack::Deflater
|
57
|
+
use Rack::Standards
|
58
|
+
|
59
|
+
use Routes::Static
|
60
|
+
|
61
|
+
unless settings.production?
|
62
|
+
use Routes::Assets
|
63
|
+
end
|
64
|
+
|
65
|
+
# Other routes:
|
66
|
+
# use Routes::Posts
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
include <%= @name.camel_case %>::Models
|
File without changes
|
@@ -0,0 +1,27 @@
|
|
1
|
+
//= require_self
|
2
|
+
//= require_tree .
|
3
|
+
|
4
|
+
@import './mixins'
|
5
|
+
|
6
|
+
*, *:before, *:after {
|
7
|
+
box-sizing: border-box
|
8
|
+
}
|
9
|
+
|
10
|
+
body, html {
|
11
|
+
margin: 0
|
12
|
+
padding: 0
|
13
|
+
}
|
14
|
+
|
15
|
+
body {
|
16
|
+
-webkit-font-smoothing: antialiased
|
17
|
+
font-smoothing: antialiased
|
18
|
+
background: #FFF
|
19
|
+
|
20
|
+
color: #444
|
21
|
+
font: 19px/1.5em "HelveticaNeue", Helvetica, Arial, sans-serif
|
22
|
+
}
|
23
|
+
|
24
|
+
a {
|
25
|
+
text-decoration: underline
|
26
|
+
color: #4b525b
|
27
|
+
}
|
@@ -0,0 +1,116 @@
|
|
1
|
+
vendor(prop, args)
|
2
|
+
-webkit-{prop}: args
|
3
|
+
-moz-{prop}: args
|
4
|
+
-ms-{prop}: args
|
5
|
+
-o-{prop}: args
|
6
|
+
{prop}: args
|
7
|
+
|
8
|
+
border-radius()
|
9
|
+
vendor('border-radius', arguments)
|
10
|
+
|
11
|
+
linear-gradient()
|
12
|
+
add-property('background-image', '-webkit-linear-gradient(%s)' % unquote(join(', ', arguments)))
|
13
|
+
add-property('background-image', '-moz-linear-gradient(%s)' % unquote(join(', ', arguments)))
|
14
|
+
add-property('background-image', '-ms-linear-gradient(%s)' % unquote(join(', ', arguments)))
|
15
|
+
add-property('background-image', '-o-linear-gradient(%s)' % unquote(join(', ', arguments)))
|
16
|
+
s('linear-gradient(%s)' % unquote(join(', ', arguments)))
|
17
|
+
|
18
|
+
box-shadow()
|
19
|
+
vendor('box-shadow', arguments)
|
20
|
+
|
21
|
+
hfloat()
|
22
|
+
overflow: hidden
|
23
|
+
|
24
|
+
& > * {
|
25
|
+
float: left
|
26
|
+
}
|
27
|
+
|
28
|
+
box-flex(s = 0)
|
29
|
+
vendor('box-flex', s)
|
30
|
+
|
31
|
+
hbox()
|
32
|
+
display: -webkit-box
|
33
|
+
-webkit-box-orient: horizontal
|
34
|
+
-webkit-box-align: stretch
|
35
|
+
-webkit-box-pack: start
|
36
|
+
|
37
|
+
display: -moz-box
|
38
|
+
-moz-box-orient: horizontal
|
39
|
+
-moz-box-align: stretch
|
40
|
+
-moz-box-pack: start
|
41
|
+
|
42
|
+
vbox()
|
43
|
+
display: -webkit-box
|
44
|
+
-webkit-box-orient: vertical
|
45
|
+
-webkit-box-align: stretch
|
46
|
+
|
47
|
+
display: -moz-box
|
48
|
+
-moz-box-orient: vertical
|
49
|
+
-moz-box-align: stretch
|
50
|
+
|
51
|
+
box-sizing(v)
|
52
|
+
vendor('box-sizing', v)
|
53
|
+
|
54
|
+
border-box()
|
55
|
+
vendor('box-sizing', unquote('border-box'))
|
56
|
+
|
57
|
+
transition()
|
58
|
+
vendor('transition', arguments)
|
59
|
+
|
60
|
+
ellipsis()
|
61
|
+
text-overflow: ellipsis
|
62
|
+
overflow: hidden
|
63
|
+
white-space:nowrap
|
64
|
+
|
65
|
+
box-pack(type = center)
|
66
|
+
vendor('box-pack', arguments)
|
67
|
+
|
68
|
+
box-align(type = center)
|
69
|
+
vendor('box-align', arguments)
|
70
|
+
|
71
|
+
transform(tr)
|
72
|
+
vendor('transform', arguments)
|
73
|
+
|
74
|
+
animation()
|
75
|
+
vendor('animation', arguments)
|
76
|
+
|
77
|
+
animation-name()
|
78
|
+
vendor('animation-name', arguments)
|
79
|
+
|
80
|
+
animation-delay()
|
81
|
+
vendor('animation-delay', arguments)
|
82
|
+
|
83
|
+
animation-iteration-count()
|
84
|
+
vendor('animation-iteration-count', arguments)
|
85
|
+
|
86
|
+
animation-timing-function()
|
87
|
+
vendor('animation-timing-function', arguments)
|
88
|
+
|
89
|
+
animation-duration()
|
90
|
+
vendor('animation-duration', arguments)
|
91
|
+
|
92
|
+
appearance()
|
93
|
+
vendor('appearance', arguments)
|
94
|
+
|
95
|
+
user-select()
|
96
|
+
vendor('user-select', arguments)
|
97
|
+
|
98
|
+
filter()
|
99
|
+
vendor('filter', arguments)
|
100
|
+
|
101
|
+
flex-flow()
|
102
|
+
vendor('flex-flow', arguments)
|
103
|
+
|
104
|
+
justify-content()
|
105
|
+
vendor('justify-content', arguments)
|
106
|
+
|
107
|
+
align-items()
|
108
|
+
vendor('align-items', arguments)
|
109
|
+
|
110
|
+
flex()
|
111
|
+
vendor('flex', arguments)
|
112
|
+
|
113
|
+
displayFlex()
|
114
|
+
display: -webkit-flex;
|
115
|
+
display: -moz-flex;
|
116
|
+
display: flex;
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'sprockets'
|
2
|
+
require 'stylus/sprockets'
|
3
|
+
|
4
|
+
module <%= @name.camel_case %>
|
5
|
+
module Extensions
|
6
|
+
module Assets extend self
|
7
|
+
class UnknownAsset < StandardError; end
|
8
|
+
|
9
|
+
module Helpers
|
10
|
+
def asset_path(name)
|
11
|
+
asset = settings.assets[name]
|
12
|
+
raise UnknownAsset, "Unknown asset: #{name}" unless asset
|
13
|
+
"#{settings.asset_host}/assets/#{asset.digest_path}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def registered(app)
|
18
|
+
# Assets
|
19
|
+
app.set :assets, assets = Sprockets::Environment.new(app.settings.root)
|
20
|
+
|
21
|
+
assets.append_path('app/assets/javascripts')
|
22
|
+
assets.append_path('app/assets/stylesheets')
|
23
|
+
assets.append_path('app/assets/images')
|
24
|
+
assets.append_path('vendor/assets/javascripts')
|
25
|
+
assets.append_path('vendor/assets/stylesheets')
|
26
|
+
|
27
|
+
Stylus.setup(assets)
|
28
|
+
|
29
|
+
app.set :asset_host, ''
|
30
|
+
|
31
|
+
app.configure :development do
|
32
|
+
assets.cache = Sprockets::Cache::FileStore.new('./tmp')
|
33
|
+
end
|
34
|
+
|
35
|
+
app.configure :production do
|
36
|
+
assets.cache = Sprockets::Cache::MemcacheStore.new
|
37
|
+
assets.js_compressor = Closure::Compiler.new
|
38
|
+
assets.css_compressor = YUI::CssCompressor.new
|
39
|
+
end
|
40
|
+
|
41
|
+
app.helpers Helpers
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module <%= @name.camel_case %>
|
2
|
+
module Routes
|
3
|
+
class Base < Sinatra::Application
|
4
|
+
configure do
|
5
|
+
set :views, 'app/views'
|
6
|
+
set :root, File.expand_path('../../../', __FILE__)
|
7
|
+
|
8
|
+
disable :method_override
|
9
|
+
disable :protection
|
10
|
+
disable :static
|
11
|
+
|
12
|
+
set :erb, escape_html: true,
|
13
|
+
layout_options: {views: 'app/views/layouts'}
|
14
|
+
|
15
|
+
enable :use_code
|
16
|
+
end
|
17
|
+
|
18
|
+
register Extensions::Assets
|
19
|
+
helpers Helpers
|
20
|
+
helpers Sinatra::ContentFor
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module <%= @name.camel_case %>
|
2
|
+
module Routes
|
3
|
+
class Static < Sinatra::Application
|
4
|
+
configure do
|
5
|
+
set :views, 'app/views'
|
6
|
+
set :root, File.expand_path('../../../', __FILE__)
|
7
|
+
disable :method_override
|
8
|
+
disable :protection
|
9
|
+
enable :static
|
10
|
+
end
|
11
|
+
|
12
|
+
def static!
|
13
|
+
return if (public_dir = settings.public_folder).nil?
|
14
|
+
public_dir = File.expand_path(public_dir)
|
15
|
+
|
16
|
+
path = File.expand_path(public_dir + unescape(request.path_info))
|
17
|
+
return unless path.start_with?(public_dir) and File.file?(path)
|
18
|
+
|
19
|
+
env['sinatra.static_file'] = path
|
20
|
+
|
21
|
+
unless settings.development? || settings.test?
|
22
|
+
expires 1.year.to_i, :public, :max_age => 31536000
|
23
|
+
headers 'Date' => Time.current.httpdate
|
24
|
+
end
|
25
|
+
|
26
|
+
send_file path, :disposition => nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title><%= @name.camel_case %></title>
|
6
|
+
|
7
|
+
<link rel="stylesheet" type="text/css" href="<%%= asset_path 'layout.css' %>">
|
8
|
+
<script src="<%%= asset_path 'layout.js' %>"></script>
|
9
|
+
|
10
|
+
<%%== yield_content :head %>
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
<%%== yield %>
|
14
|
+
</body>
|
15
|
+
</html>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
worker_processes Integer(ENV['UNICORN_WORKERS'] || 4)
|
2
|
+
timeout 30
|
3
|
+
preload_app true
|
4
|
+
listen(ENV['PORT'] || 3000, :backlog => Integer(ENV['UNICORN_BACKLOG'] || 200))
|
5
|
+
|
6
|
+
before_fork do |server, worker|
|
7
|
+
Signal.trap 'TERM' do
|
8
|
+
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
|
9
|
+
Process.kill 'QUIT', Process.pid
|
10
|
+
end
|
11
|
+
|
12
|
+
if defined?(Sequel::Model)
|
13
|
+
Sequel::DATABASES.each{ |db| db.disconnect }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
after_fork do |server, worker|
|
18
|
+
Signal.trap 'TERM' do
|
19
|
+
puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to sent QUIT'
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
namespace :assets do
|
2
|
+
desc 'Precompile assets'
|
3
|
+
task :precompile => :app do
|
4
|
+
assets = <%= @name.camel_case %>::Routes::Base.assets
|
5
|
+
target = Pathname(<%= @name.camel_case %>::App.root) + 'public/assets'
|
6
|
+
|
7
|
+
assets.each_logical_path do |logical_path|
|
8
|
+
if asset = assets.find_asset(logical_path)
|
9
|
+
filename = target.join(asset.digest_path)
|
10
|
+
FileUtils.mkpath(filename.dirname)
|
11
|
+
asset.write_to(filename)
|
12
|
+
|
13
|
+
filename = target.join(logical_path)
|
14
|
+
FileUtils.mkpath(filename.dirname)
|
15
|
+
asset.write_to(filename)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
namespace :db do
|
2
|
+
desc 'Run DB migrations'
|
3
|
+
task :migrate => :app do
|
4
|
+
require 'sequel/extensions/migration'
|
5
|
+
|
6
|
+
Sequel::Migrator.apply(<%= @name.camel_case %>::App.database, 'db/migrations')
|
7
|
+
end
|
8
|
+
|
9
|
+
desc 'Rollback migration'
|
10
|
+
task :rollback => :app do
|
11
|
+
require 'sequel/extensions/migration'
|
12
|
+
database = <%= @name.camel_case %>::App.database
|
13
|
+
|
14
|
+
version = (row = database[:schema_info].first) ? row[:version] : nil
|
15
|
+
Sequel::Migrator.apply(database, 'db/migrations', version - 1)
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'Dump the database schema'
|
19
|
+
task :dump => :app do
|
20
|
+
database = <%= @name.camel_case %>::App.database
|
21
|
+
|
22
|
+
`sequel -d #{database.url} > db/schema.rb`
|
23
|
+
`pg_dump --schema-only #{database.url} > db/schema.sql`
|
24
|
+
end
|
25
|
+
end
|
File without changes
|
data/trevi.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'trevi/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "trevi"
|
8
|
+
spec.version = Trevi::VERSION
|
9
|
+
spec.authors = ["Alex MacCaw"]
|
10
|
+
spec.email = ["alex@alexmaccaw.com"]
|
11
|
+
spec.description = %q{An opinionated Sinatra structure}
|
12
|
+
spec.summary = %q{An opinionated Sinatra structure}
|
13
|
+
spec.homepage = "http://github.com/maccman/trevi"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
|
24
|
+
spec.add_dependency 'thor'
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: trevi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alex MacCaw
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: thor
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: An opinionated Sinatra structure
|
56
|
+
email:
|
57
|
+
- alex@alexmaccaw.com
|
58
|
+
executables:
|
59
|
+
- trevi
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/trevi
|
69
|
+
- lib/trevi.rb
|
70
|
+
- lib/trevi/cli.rb
|
71
|
+
- lib/trevi/extensions.rb
|
72
|
+
- lib/trevi/version.rb
|
73
|
+
- templates/app/.gitignore
|
74
|
+
- templates/app/Gemfile
|
75
|
+
- templates/app/Procfile
|
76
|
+
- templates/app/Rakefile
|
77
|
+
- templates/app/app.rb.tt
|
78
|
+
- templates/app/app/assets/javascripts/layout.coffee
|
79
|
+
- templates/app/app/assets/stylesheets/layout.css.styl
|
80
|
+
- templates/app/app/assets/stylesheets/mixins.styl
|
81
|
+
- templates/app/app/extensions.rb.tt
|
82
|
+
- templates/app/app/extensions/assets.rb.tt
|
83
|
+
- templates/app/app/helpers.rb.tt
|
84
|
+
- templates/app/app/models.rb.tt
|
85
|
+
- templates/app/app/routes.rb.tt
|
86
|
+
- templates/app/app/routes/assets.rb.tt
|
87
|
+
- templates/app/app/routes/base.rb.tt
|
88
|
+
- templates/app/app/routes/static.rb.tt
|
89
|
+
- templates/app/app/views/layouts/layout.erb.tt
|
90
|
+
- templates/app/config.ru.tt
|
91
|
+
- templates/app/config/unicorn.rb
|
92
|
+
- templates/app/lib/tasks/assets.rb.tt
|
93
|
+
- templates/app/lib/tasks/db.rb.tt
|
94
|
+
- templates/app/public/favicon.ico
|
95
|
+
- trevi.gemspec
|
96
|
+
homepage: http://github.com/maccman/trevi
|
97
|
+
licenses:
|
98
|
+
- MIT
|
99
|
+
metadata: {}
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
103
|
+
- lib
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - '>='
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - '>='
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
requirements: []
|
115
|
+
rubyforge_project:
|
116
|
+
rubygems_version: 2.0.3
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: An opinionated Sinatra structure
|
120
|
+
test_files: []
|