kckstrt 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.md +7 -0
- data/README.md +32 -0
- data/Rakefile +8 -0
- data/bin/kckstrt +4 -0
- data/kckstrt.gemspec +30 -0
- data/lib/kckstrt/templates/Gemfile +24 -0
- data/lib/kckstrt/templates/Procfile +1 -0
- data/lib/kckstrt/templates/README.md.template +57 -0
- data/lib/kckstrt/templates/Rakefile +46 -0
- data/lib/kckstrt/templates/app/app.rb.template +18 -0
- data/lib/kckstrt/templates/app/assets/javascripts/heliom.coffee +40 -0
- data/lib/kckstrt/templates/app/assets/javascripts/scripts.coffee +1 -0
- data/lib/kckstrt/templates/app/assets/stylesheets/home.styl +1 -0
- data/lib/kckstrt/templates/app/assets/stylesheets/styles.styl +21 -0
- data/lib/kckstrt/templates/app/assets/stylesheets/variables.styl +0 -0
- data/lib/kckstrt/templates/app/helpers/helpers.rb +48 -0
- data/lib/kckstrt/templates/app/views/404.erb +1 -0
- data/lib/kckstrt/templates/app/views/index.erb.template +2 -0
- data/lib/kckstrt/templates/app/views/layouts/application.erb.template +28 -0
- data/lib/kckstrt/templates/config/application.rb.template +22 -0
- data/lib/kckstrt/templates/config/boot.rb.template +21 -0
- data/lib/kckstrt/templates/config/unicorn.rb +7 -0
- data/lib/kckstrt/templates/config.ru.template +27 -0
- data/lib/kckstrt/templates/script/setup +21 -0
- data/lib/kckstrt/version.rb +3 -0
- data/lib/kckstrt.rb +64 -0
- metadata +185 -0
data/LICENSE.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright (c) 2012 Heliom
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Kckstrt
|
2
|
+
> Even designers can kickstart a project.
|
3
|
+
|
4
|
+
Generate a Sinatra app in 4 easy steps:
|
5
|
+
|
6
|
+
```
|
7
|
+
kckstrt generate MyApp
|
8
|
+
cd my_app
|
9
|
+
script/setup
|
10
|
+
foreman start
|
11
|
+
```
|
12
|
+
|
13
|
+
## Features
|
14
|
+
- [Heroku]-ready
|
15
|
+
- One-step [installation script][installation]
|
16
|
+
- Sprockets ([Stylus][] & [Nib][] enabled)
|
17
|
+
- [Assets helpers][helpers]
|
18
|
+
|
19
|
+
## Credits
|
20
|
+
[Rafael][rafBM] & [Etienne][EtienneLem]
|
21
|
+
|
22
|
+
## Copyright
|
23
|
+
© 2012 Heliom. See [LICENSE][] for details.
|
24
|
+
|
25
|
+
[Heroku]: http://www.heroku.com
|
26
|
+
[installation]: lib/kckstrt/templates/script/setup
|
27
|
+
[Stylus]: https://github.com/learnBoost/stylus
|
28
|
+
[Nib]: https://github.com/visionmedia/nib
|
29
|
+
[helpers]: lib/kckstrt/templates/app/helpers/helpers.rb
|
30
|
+
[rafBM]: https://github.com/rafBM
|
31
|
+
[EtienneLem]: https://github.com/EtienneLem
|
32
|
+
[LICENSE]: LICENSE.md
|
data/Rakefile
ADDED
data/bin/kckstrt
ADDED
data/kckstrt.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# Ensure we require the local version and not one we might have installed already
|
2
|
+
require File.join([File.dirname(__FILE__),'lib','kckstrt','version.rb'])
|
3
|
+
|
4
|
+
spec = Gem::Specification.new do |s|
|
5
|
+
s.name = 'kckstrt'
|
6
|
+
s.authors = ['Etienne Lemay', 'Rafael Blais-Masson']
|
7
|
+
s.email = 'fellowship@heliom.ca'
|
8
|
+
s.homepage = 'https://github.com/heliom/kckstrt'
|
9
|
+
s.summary = 'Sinatra app generator'
|
10
|
+
|
11
|
+
s.version = Kckstrt::VERSION
|
12
|
+
s.platform = Gem::Platform::RUBY
|
13
|
+
|
14
|
+
s.files = %w(LICENSE.md README.md Rakefile kckstrt.gemspec)
|
15
|
+
s.files += Dir.glob("lib/**/*")
|
16
|
+
s.files += Dir.glob("bin/**/*")
|
17
|
+
s.files += Dir.glob("etc/**/*")
|
18
|
+
|
19
|
+
s.bindir = 'bin'
|
20
|
+
s.executables << 'kckstrt'
|
21
|
+
|
22
|
+
s.require_paths << 'lib'
|
23
|
+
s.add_dependency('erubis', '~> 2.7.0')
|
24
|
+
s.add_dependency('highline', '~> 1.6.15')
|
25
|
+
s.add_dependency('activesupport', '~> 3.2.11')
|
26
|
+
s.add_development_dependency('rake')
|
27
|
+
s.add_development_dependency('rspec', '~> 2.12.0')
|
28
|
+
s.add_development_dependency('rspec-mocks', '~> 2.12.0')
|
29
|
+
s.add_runtime_dependency('gli', '2.5.2')
|
30
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
source :rubygems
|
2
|
+
ruby '1.9.3'
|
3
|
+
|
4
|
+
# Server
|
5
|
+
gem 'unicorn'
|
6
|
+
|
7
|
+
# App
|
8
|
+
gem 'rake'
|
9
|
+
gem 'sinatra'
|
10
|
+
gem 'sinatra-contrib'
|
11
|
+
gem 'erubis'
|
12
|
+
|
13
|
+
# Development
|
14
|
+
group :development do
|
15
|
+
gem 'awesome_print'
|
16
|
+
end
|
17
|
+
|
18
|
+
# Assets
|
19
|
+
group :assets do
|
20
|
+
gem 'sprockets'
|
21
|
+
gem 'coffee-script'
|
22
|
+
gem 'stylus', '~> 0.7.1', :require => 'stylus/sprockets'
|
23
|
+
gem 'uglifier'
|
24
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# {{= @app_name }}
|
2
|
+
|
3
|
+
## Setup
|
4
|
+
Run `script/setup` for a one-step complete installation.
|
5
|
+
|
6
|
+
## Asset Helpers
|
7
|
+
### `asset_path`
|
8
|
+
```erb
|
9
|
+
<img src="<%= asset_path 'kckstrt.png' %>" alt="Kckstrt">
|
10
|
+
```
|
11
|
+
|
12
|
+
`asset_path` uses Sprockets’ `digest_path` to find the asset within `app/assets/(images|javascripts|stylesheets)`.
|
13
|
+
|
14
|
+
--
|
15
|
+
### `javascript_include_tag` & `stylesheet_link_tag`
|
16
|
+
```erb
|
17
|
+
<head>
|
18
|
+
<title>Kckstrt</title>
|
19
|
+
<%= stylesheet_link_tag :styles %>
|
20
|
+
<%# => <link rel="stylesheet" href="/assets/styles.css"> %>
|
21
|
+
</head>
|
22
|
+
<body>
|
23
|
+
<%= javascript_link_tag :scripts %>
|
24
|
+
<%# => <script src="/assets/scripts.js"></script> %>
|
25
|
+
</body>
|
26
|
+
```
|
27
|
+
|
28
|
+
--
|
29
|
+
### `inline_script_tag`
|
30
|
+
```erb
|
31
|
+
<%= inline_script_tag :scripts %>
|
32
|
+
<%# => <script>console.log('content of scripts.js')</script> %>
|
33
|
+
```
|
34
|
+
|
35
|
+
## Deployment
|
36
|
+
This app is [Heroku][]-ready.<br>
|
37
|
+
Don’t forget to set the `ENV['ASSET_HOST']` environment variable. We strongly suggest using [Amazon CloudFront][CloudFront] for a plug and play CDN host. Otherwise you’ll have to pre-compile your assets. Such script isn’t included.
|
38
|
+
|
39
|
+
### Staging
|
40
|
+
```sh
|
41
|
+
rake deploy:staging
|
42
|
+
```
|
43
|
+
Push `dev` to `origin/dev` & `staging/master`
|
44
|
+
|
45
|
+
### Production
|
46
|
+
```sh
|
47
|
+
rake deploy:production
|
48
|
+
```
|
49
|
+
Push `master` to `origin/master` & `production/master`
|
50
|
+
|
51
|
+
## Credits
|
52
|
+
[Rafael][rafBM] & [Etienne][EtienneLem]
|
53
|
+
|
54
|
+
[Heroku]: http://www.heroku.com
|
55
|
+
[CloudFront]: http://aws.amazon.com/cloudfront
|
56
|
+
[rafBM]: https://github.com/rafBM
|
57
|
+
[EtienneLem]: https://github.com/EtienneLem
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Command line helpers
|
4
|
+
def ask(question)
|
5
|
+
print "#{question} [Yn]: "
|
6
|
+
yield if STDIN.gets.chomp == 'Y'
|
7
|
+
puts
|
8
|
+
end
|
9
|
+
|
10
|
+
def prompt(question)
|
11
|
+
print "#{question} "
|
12
|
+
yield STDIN.gets.chomp
|
13
|
+
end
|
14
|
+
|
15
|
+
def call(command)
|
16
|
+
puts "\n=> Running: #{command}"
|
17
|
+
system command
|
18
|
+
end
|
19
|
+
|
20
|
+
# Actual task
|
21
|
+
def deploy!(environment)
|
22
|
+
branch = branches[environment]
|
23
|
+
return unless call "git push origin #{branch}"
|
24
|
+
|
25
|
+
call "git push #{environment} #{branch}:master --force"
|
26
|
+
end
|
27
|
+
|
28
|
+
def branches
|
29
|
+
{'staging' => 'dev', 'production' => 'master'}
|
30
|
+
end
|
31
|
+
|
32
|
+
# Rake stuff
|
33
|
+
namespace :deploy do
|
34
|
+
task(:production) { deploy! 'production' }
|
35
|
+
task(:staging) { deploy! 'staging' }
|
36
|
+
end
|
37
|
+
|
38
|
+
task :deploy do
|
39
|
+
prompt 'Which environment you wanna deploy?' do |environment|
|
40
|
+
if branches.keys.include? environment
|
41
|
+
deploy! environment
|
42
|
+
else
|
43
|
+
puts "Wut? Dunno about “#{environment}”..."
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class {{= @app_name }}::App < Sinatra::Base
|
2
|
+
# Filters
|
3
|
+
before do
|
4
|
+
if request.path.match /.+\/$/
|
5
|
+
redirect request.path.sub(/\/$/, ''), 301
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
# Routes
|
10
|
+
get '/' do
|
11
|
+
erb :index
|
12
|
+
end
|
13
|
+
|
14
|
+
# Errors
|
15
|
+
not_found do
|
16
|
+
erb :'404'
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
html = document.documentElement
|
2
|
+
|
3
|
+
# Global namespace
|
4
|
+
window.Heliom = {}
|
5
|
+
|
6
|
+
# Touch
|
7
|
+
Heliom.IS_TOUCH_DEVICE = window.ontouchend != undefined
|
8
|
+
|
9
|
+
# Transitions
|
10
|
+
Heliom.HAS_TRANSITIONS = false
|
11
|
+
prefixes = ['webkit', 'Moz', 'Ms', 'O']
|
12
|
+
for prefix in prefixes
|
13
|
+
if html.style["#{prefix}Transition"] != undefined
|
14
|
+
html.className += " #{prefix.toLowerCase()}"
|
15
|
+
Heliom.HAS_TRANSITIONS = true
|
16
|
+
Heliom.BROWSER = prefix.toLowerCase()
|
17
|
+
|
18
|
+
# SVG
|
19
|
+
Heliom.HAS_SVG = !!document.createElementNS && !!document.createElementNS('http://www.w3.org/2000/svg', 'svg').createSVGRect
|
20
|
+
|
21
|
+
# Retina
|
22
|
+
Heliom.IS_RETINA = `('devicePixelRatio' in window && devicePixelRatio > 1) || ('matchMedia' in window && matchMedia("(min-resolution:144dpi)").matches)`
|
23
|
+
|
24
|
+
# HTML classes
|
25
|
+
html.className = html.className.replace 'no-js', 'js'
|
26
|
+
html.className += if Heliom.IS_TOUCH_DEVICE then ' touch' else ' non-touch'
|
27
|
+
html.className += if Heliom.HAS_TRANSITIONS then ' has-transitions' else ''
|
28
|
+
html.className += if Heliom.HAS_SVG then ' has-svg' else ''
|
29
|
+
html.className += if Heliom.IS_RETINA then ' retina' else ''
|
30
|
+
html.className += ' ios ipad' if /\bipad\b/i.test navigator.userAgent
|
31
|
+
html.className += ' ios iphone' if /\biphone\b/i.test navigator.userAgent
|
32
|
+
if /safari/i.test navigator.userAgent
|
33
|
+
html.className += ' safari-4' if /version\/4/i.test navigator.userAgent
|
34
|
+
html.className += ' safari-5' if /version\/5/i.test navigator.userAgent
|
35
|
+
html.className += ' firefox-3' if /firefox\/3/i.test navigator.userAgent
|
36
|
+
html.className += ' chrome' if /Chrome/.test navigator.userAgent
|
37
|
+
|
38
|
+
# HTML5 Shiv
|
39
|
+
for elem in ['article', 'aside', 'canvas', 'details', 'figcaption', 'figure', 'footer', 'header', 'hgroup', 'mark', 'menu', 'nav', 'section', 'summary', 'time']
|
40
|
+
document.createElement elem
|
@@ -0,0 +1 @@
|
|
1
|
+
console.log 'scripts'
|
@@ -0,0 +1 @@
|
|
1
|
+
@import 'variables'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
//= require utils/reset
|
2
|
+
//= require_self
|
3
|
+
//= require home
|
4
|
+
|
5
|
+
@import 'utils/all'
|
6
|
+
@import 'variables'
|
7
|
+
|
8
|
+
// Base ----------------------------------------------------------------------
|
9
|
+
* { box-sizing: border-box }
|
10
|
+
|
11
|
+
html
|
12
|
+
font-size: 62.5%
|
13
|
+
|
14
|
+
body
|
15
|
+
position: relative
|
16
|
+
font-size: 1.8em
|
17
|
+
|
18
|
+
a { color: hotpink }
|
19
|
+
a:focus, a:hover { color: hotpink }
|
20
|
+
|
21
|
+
// General -------------------------------------------------------------------
|
File without changes
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# Assets helpers
|
2
|
+
def asset_path(file_name)
|
3
|
+
if ENV['RACK_ENV'] == 'development'
|
4
|
+
file_name = Assets[file_name].logical_path + '?body=1'
|
5
|
+
else
|
6
|
+
file_name = Assets[file_name].digest_path
|
7
|
+
end
|
8
|
+
|
9
|
+
"#{asset_host}/assets/#{file_name}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def dependencies_paths(file_name)
|
13
|
+
if ENV['RACK_ENV'] == 'development'
|
14
|
+
Assets[file_name].to_a.map { |dep| dep.logical_path + '?body=1' }
|
15
|
+
else
|
16
|
+
[Assets[file_name].digest_path]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def javascript_include_tag(file_name)
|
21
|
+
file_name = "#{file_name}.js"
|
22
|
+
dependencies_paths(file_name).map { |path| %(<script src="#{asset_host}/assets/#{path}"></script>) }.join
|
23
|
+
end
|
24
|
+
|
25
|
+
def stylesheet_link_tag(file_name)
|
26
|
+
file_name = "#{file_name}.css"
|
27
|
+
dependencies_paths(file_name).map { |path| %(<link rel="stylesheet" href="#{asset_host}/assets/#{path}">) }.join
|
28
|
+
end
|
29
|
+
|
30
|
+
def inline_script_tag(file_name)
|
31
|
+
file_name = "#{file_name}.js"
|
32
|
+
'<script>' + Assets[file_name].source + '</script>'
|
33
|
+
end
|
34
|
+
|
35
|
+
def asset_host
|
36
|
+
ENV['ASSET_HOST'] || ''
|
37
|
+
end
|
38
|
+
|
39
|
+
# View helpers
|
40
|
+
def partial(partial, locals={})
|
41
|
+
partial_view = "partials/_#{partial}".to_sym
|
42
|
+
erb partial_view, :layout => false, locals: locals
|
43
|
+
end
|
44
|
+
|
45
|
+
# URL helpers
|
46
|
+
def home_path
|
47
|
+
'/'
|
48
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<h1>No can’t do.</h1>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en" class="no-js">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>{{= @app_name }}</title>
|
6
|
+
<meta name="description" content="">
|
7
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
8
|
+
<%= stylesheet_link_tag :styles %>
|
9
|
+
<%= inline_script_tag :heliom %>
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
<header id="header" role="banner">
|
13
|
+
<nav role="navigation"></nav>
|
14
|
+
</header>
|
15
|
+
|
16
|
+
<section role="main">
|
17
|
+
<%= yield %>
|
18
|
+
</section>
|
19
|
+
|
20
|
+
<footer id="footer" role="contentinfo">
|
21
|
+
</footer>
|
22
|
+
|
23
|
+
<script>document.write('<script src="//cdnjs.cloudflare.com/ajax/libs/' +
|
24
|
+
('__proto__' in {} && !/firefox\/3/i.test(navigator.userAgent) ?
|
25
|
+
'zepto/1.0rc1/zepto.min.js' : 'jquery/1.9.0/jquery.min.js') + '"><\/script>')</script>
|
26
|
+
<%= javascript_include_tag :scripts %>
|
27
|
+
</body>
|
28
|
+
</html>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
class {{= @app_name }}::App < Sinatra::Base
|
4
|
+
set :root, File.expand_path('../../app', __FILE__)
|
5
|
+
set :public_folder, File.expand_path('../../public', __FILE__)
|
6
|
+
set :erb, :layout => :'layouts/application'
|
7
|
+
|
8
|
+
configure :development do
|
9
|
+
register Sinatra::Reloader
|
10
|
+
end
|
11
|
+
|
12
|
+
configure :production do
|
13
|
+
LAST_MODIFIED = Time.now
|
14
|
+
|
15
|
+
before do
|
16
|
+
cache_control :public, max_age: 86400
|
17
|
+
last_modified LAST_MODIFIED
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
require File.expand_path('../../app/app', __FILE__)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Set up gems listed in the Gemfile
|
2
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
3
|
+
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
|
4
|
+
|
5
|
+
if defined? Bundler
|
6
|
+
Bundler.require :default, :assets, ENV['RACK_ENV']
|
7
|
+
end
|
8
|
+
|
9
|
+
module {{= @app_name }}; end
|
10
|
+
|
11
|
+
# Require helper & lib files
|
12
|
+
def recursive_require(basepath)
|
13
|
+
Dir[File.expand_path("#{basepath}/**/*.rb", __FILE__)].each do |file|
|
14
|
+
dirname = File.dirname(file)
|
15
|
+
file_basename = File.basename(file, File.extname(file))
|
16
|
+
require "#{dirname}/#{file_basename}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
recursive_require('../../app/helpers')
|
21
|
+
recursive_require('../../lib')
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.expand_path('../config/application', __FILE__)
|
2
|
+
|
3
|
+
use Rack::Deflater
|
4
|
+
|
5
|
+
# Sprockets
|
6
|
+
map '/assets' do
|
7
|
+
Assets = Sprockets::Environment.new
|
8
|
+
|
9
|
+
Assets.append_path 'app/assets/images'
|
10
|
+
Assets.append_path 'app/assets/javascripts'
|
11
|
+
Assets.append_path 'app/assets/stylesheets'
|
12
|
+
|
13
|
+
Stylus.setup Assets
|
14
|
+
Stylus.nib = true
|
15
|
+
|
16
|
+
if ENV['RACK_ENV'] != 'development'
|
17
|
+
Assets.js_compressor = Uglifier.new(mangle: true)
|
18
|
+
Stylus.compress = true
|
19
|
+
end
|
20
|
+
|
21
|
+
run Assets
|
22
|
+
end
|
23
|
+
|
24
|
+
# Main application
|
25
|
+
map '/' do
|
26
|
+
run {{= @app_name }}::App
|
27
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Git
|
4
|
+
puts '=> Setuping Git'
|
5
|
+
`git init`
|
6
|
+
|
7
|
+
# Git submodules
|
8
|
+
puts '=> Adding Stylus-Utils [Submodule]'
|
9
|
+
`git submodule add https://github.com/heliom/stylus-utils.git app/assets/stylesheets/utils`
|
10
|
+
|
11
|
+
puts '=> Adding Nib [Submodule]'
|
12
|
+
`git submodule add https://github.com/visionmedia/nib.git node_modules/nib`
|
13
|
+
|
14
|
+
puts '=> Initializing Submodules'
|
15
|
+
`git submodule init && git submodule update`
|
16
|
+
|
17
|
+
# Bundler
|
18
|
+
puts '=> Installing Gems'
|
19
|
+
`bundle install`
|
20
|
+
|
21
|
+
puts '=> Done'
|
data/lib/kckstrt.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'gli'
|
4
|
+
require 'erubis'
|
5
|
+
require 'fileutils'
|
6
|
+
require 'kckstrt/version'
|
7
|
+
require 'highline/import'
|
8
|
+
require 'active_support/core_ext/string/inflections'
|
9
|
+
|
10
|
+
module Kckstrt
|
11
|
+
extend GLI::App
|
12
|
+
|
13
|
+
program_desc 'Sinatra app generator'
|
14
|
+
version Kckstrt::VERSION
|
15
|
+
|
16
|
+
desc 'Generate an app'
|
17
|
+
command :generate do |c|
|
18
|
+
c.desc 'Force generation'
|
19
|
+
c.switch [:f, :force]
|
20
|
+
|
21
|
+
c.action do |global_options, options, args|
|
22
|
+
@options = options
|
23
|
+
generate_app(args.first)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.generate_app(app_name)
|
28
|
+
return say('Please specify an app name. See `kckstrt generate --help`.') unless app_name
|
29
|
+
|
30
|
+
@dirname = app_name.underscore
|
31
|
+
@app_name = @dirname.camelize
|
32
|
+
|
33
|
+
mkdir(@dirname)
|
34
|
+
copy_templates(@dirname)
|
35
|
+
init_templates
|
36
|
+
|
37
|
+
say("=> cd #{@dirname} && script/setup")
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.mkdir(dirname)
|
41
|
+
return say("“#{dirname}” folder is not empty. Use the --force flag to overwrite.") if File.directory?(dirname) && !@options[:force]
|
42
|
+
|
43
|
+
FileUtils.rm_rf(dirname)
|
44
|
+
Dir.mkdir(dirname)
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.copy_templates(dest)
|
48
|
+
src = File.expand_path('../kckstrt/templates', __FILE__)
|
49
|
+
FileUtils.copy_entry(src, dest)
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.init_templates
|
53
|
+
Dir["#{@dirname}/**/*.template"].each do |file|
|
54
|
+
template = File.read(file)
|
55
|
+
content = Erubis::Eruby.new(template, pattern: '{{ }}').result(binding)
|
56
|
+
|
57
|
+
File.open(file, 'w+') do |f|
|
58
|
+
f.write(content)
|
59
|
+
end
|
60
|
+
|
61
|
+
File.rename(file, file.sub('.template', ''))
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
metadata
ADDED
@@ -0,0 +1,185 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kckstrt
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Etienne Lemay
|
9
|
+
- Rafael Blais-Masson
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2013-02-13 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: erubis
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ~>
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.7.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 2.7.0
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: highline
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ~>
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 1.6.15
|
39
|
+
type: :runtime
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 1.6.15
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: activesupport
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.2.11
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ~>
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 3.2.11
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: rake
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
type: :development
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
- !ruby/object:Gem::Dependency
|
80
|
+
name: rspec
|
81
|
+
requirement: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ~>
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 2.12.0
|
87
|
+
type: :development
|
88
|
+
prerelease: false
|
89
|
+
version_requirements: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ~>
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 2.12.0
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: rspec-mocks
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ~>
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 2.12.0
|
103
|
+
type: :development
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 2.12.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: gli
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
none: false
|
115
|
+
requirements:
|
116
|
+
- - '='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: 2.5.2
|
119
|
+
type: :runtime
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
none: false
|
123
|
+
requirements:
|
124
|
+
- - '='
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: 2.5.2
|
127
|
+
description:
|
128
|
+
email: fellowship@heliom.ca
|
129
|
+
executables:
|
130
|
+
- kckstrt
|
131
|
+
extensions: []
|
132
|
+
extra_rdoc_files: []
|
133
|
+
files:
|
134
|
+
- LICENSE.md
|
135
|
+
- README.md
|
136
|
+
- Rakefile
|
137
|
+
- kckstrt.gemspec
|
138
|
+
- lib/kckstrt/templates/app/app.rb.template
|
139
|
+
- lib/kckstrt/templates/app/assets/javascripts/heliom.coffee
|
140
|
+
- lib/kckstrt/templates/app/assets/javascripts/scripts.coffee
|
141
|
+
- lib/kckstrt/templates/app/assets/stylesheets/home.styl
|
142
|
+
- lib/kckstrt/templates/app/assets/stylesheets/styles.styl
|
143
|
+
- lib/kckstrt/templates/app/assets/stylesheets/variables.styl
|
144
|
+
- lib/kckstrt/templates/app/helpers/helpers.rb
|
145
|
+
- lib/kckstrt/templates/app/views/404.erb
|
146
|
+
- lib/kckstrt/templates/app/views/index.erb.template
|
147
|
+
- lib/kckstrt/templates/app/views/layouts/application.erb.template
|
148
|
+
- lib/kckstrt/templates/config/application.rb.template
|
149
|
+
- lib/kckstrt/templates/config/boot.rb.template
|
150
|
+
- lib/kckstrt/templates/config/unicorn.rb
|
151
|
+
- lib/kckstrt/templates/config.ru.template
|
152
|
+
- lib/kckstrt/templates/Gemfile
|
153
|
+
- lib/kckstrt/templates/Procfile
|
154
|
+
- lib/kckstrt/templates/Rakefile
|
155
|
+
- lib/kckstrt/templates/README.md.template
|
156
|
+
- lib/kckstrt/templates/script/setup
|
157
|
+
- lib/kckstrt/version.rb
|
158
|
+
- lib/kckstrt.rb
|
159
|
+
- bin/kckstrt
|
160
|
+
homepage: https://github.com/heliom/kckstrt
|
161
|
+
licenses: []
|
162
|
+
post_install_message:
|
163
|
+
rdoc_options: []
|
164
|
+
require_paths:
|
165
|
+
- lib
|
166
|
+
- lib
|
167
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
168
|
+
none: false
|
169
|
+
requirements:
|
170
|
+
- - ! '>='
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
173
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
174
|
+
none: false
|
175
|
+
requirements:
|
176
|
+
- - ! '>='
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '0'
|
179
|
+
requirements: []
|
180
|
+
rubyforge_project:
|
181
|
+
rubygems_version: 1.8.23
|
182
|
+
signing_key:
|
183
|
+
specification_version: 3
|
184
|
+
summary: Sinatra app generator
|
185
|
+
test_files: []
|