myway 0.1.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.
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/bin/mw +4 -0
- data/lib/myway.rb +94 -0
- data/lib/myway/templates/app/app.tt +32 -0
- data/lib/myway/templates/app/version.tt +3 -0
- data/lib/myway/templates/config.ru.tt +15 -0
- data/lib/myway/templates/config/deploy.rb.tt +51 -0
- data/lib/myway/templates/config/unicorn.tt +48 -0
- data/lib/myway/templates/gemfile.tt +4 -0
- data/lib/myway/templates/gemspec.tt +24 -0
- data/lib/myway/templates/gitignore.tt +17 -0
- data/lib/myway/templates/rakefile.tt +2 -0
- data/lib/myway/templates/readme.tt +0 -0
- data/lib/myway/version.rb +3 -0
- data/myway.gemspec +19 -0
- metadata +82 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Fazle Taher
|
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
|
+
# Myway
|
2
|
+
|
3
|
+
My way was popular frank sinatra song during 1969 and was top on billboard chart during that time. Now myway here
|
4
|
+
provides basic sinatra scaffolding project for everyone to use. It comes with capistrano and unicorn integrated. By
|
5
|
+
default the sinatra app uses haml as it's templating engine.
|
6
|
+
|
7
|
+
## Installation and Usage
|
8
|
+
|
9
|
+
Install it yourself as:
|
10
|
+
|
11
|
+
$ rake install
|
12
|
+
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ mw
|
17
|
+
|
18
|
+
And to start a new sinatra project:
|
19
|
+
|
20
|
+
$ mw new "ProjectName"
|
21
|
+
|
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 'Added some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/mw
ADDED
data/lib/myway.rb
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
require "myway/version"
|
2
|
+
require "thor"
|
3
|
+
|
4
|
+
class String
|
5
|
+
def camelize(first_letter_in_uppercase = true)
|
6
|
+
if first_letter_in_uppercase
|
7
|
+
self.to_s.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }
|
8
|
+
else
|
9
|
+
self.first + camelize(self)[1..-1]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module Myway
|
15
|
+
class Frank < Thor
|
16
|
+
include Thor::Actions
|
17
|
+
attr_accessor :name
|
18
|
+
|
19
|
+
def self.source_root
|
20
|
+
File.dirname(__FILE__)
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "new [NAME]", "Creates new sinatra projects, use 'sinatra:new help' for more."
|
24
|
+
def new(name=nil)
|
25
|
+
@name = name
|
26
|
+
if @name.nil?
|
27
|
+
puts "You must provide a name for your project"
|
28
|
+
exit 0
|
29
|
+
end
|
30
|
+
|
31
|
+
user_info
|
32
|
+
|
33
|
+
empty_directory "#{name}/app/routes"
|
34
|
+
empty_directory "#{name}/app/views"
|
35
|
+
empty_directory "#{name}/app/models"
|
36
|
+
empty_directory "#{name}/config"
|
37
|
+
empty_directory "#{name}/assets/js"
|
38
|
+
empty_directory "#{name}/assets/css"
|
39
|
+
empty_directory "#{name}/spec"
|
40
|
+
|
41
|
+
template "myway/templates/app/version.tt", "#{name}/app/version.rb"
|
42
|
+
template "myway/templates/app/app.tt", "#{name}/app/#{name}.rb"
|
43
|
+
template "myway/templates/config/unicorn.tt", "#{name}/config/unicorn.rb"
|
44
|
+
template "myway/templates/config.ru.tt", "#{name}/config.ru"
|
45
|
+
template "myway/templates/gemspec.tt", "#{name}/#{name}.gemspec"
|
46
|
+
template "myway/templates/gemfile.tt", "#{name}/Gemfile"
|
47
|
+
template "myway/templates/rakefile.tt", "#{name}/Rakefile"
|
48
|
+
template "myway/templates/readme.tt", "#{name}/README.md"
|
49
|
+
template "myway/templates/gitignore.tt", "#{name}/.gitignore"
|
50
|
+
|
51
|
+
Dir.chdir(File.join(Dir.pwd, name))
|
52
|
+
|
53
|
+
init_git
|
54
|
+
init_bundle
|
55
|
+
init_capistrano
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
no_tasks do
|
60
|
+
def in_app?
|
61
|
+
File.exists?('./app') && File.directory?('./app')
|
62
|
+
end
|
63
|
+
|
64
|
+
def user_info
|
65
|
+
@user = IO.popen("git config --global user.name").read.gsub("\n", "")
|
66
|
+
@email = IO.popen("git config --global user.email").read.gsub("\n", "")
|
67
|
+
end
|
68
|
+
|
69
|
+
def method_missing(meth, *args, &block)
|
70
|
+
return init($1.to_sym) if meth.to_s =~ /^init_(.*)/
|
71
|
+
super
|
72
|
+
end
|
73
|
+
|
74
|
+
def init(op)
|
75
|
+
case op
|
76
|
+
when :git
|
77
|
+
say "Initialing git repo in #{name}"
|
78
|
+
`git init`
|
79
|
+
`git add .`
|
80
|
+
when :bundle
|
81
|
+
say "Installing gems for #{name}"
|
82
|
+
`bundle install`
|
83
|
+
when :capistrano
|
84
|
+
say "If you use capistrano for deployment edit this file"
|
85
|
+
template "myway/templates/config/deploy.rb.tt", "#{name}/config/deploy.rb"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class <%= name.camelize %> < Sinatra::Base
|
2
|
+
|
3
|
+
set :app_path, '/'
|
4
|
+
|
5
|
+
set :logging, true
|
6
|
+
set :method_override, true
|
7
|
+
set :assets, Sprockets::Environment.new
|
8
|
+
|
9
|
+
# Configure sprockets
|
10
|
+
settings.assets.append_path "assets/js"
|
11
|
+
settings.assets.append_path "assets/css"
|
12
|
+
|
13
|
+
# For compressed JS and CSS output
|
14
|
+
require "yui/compressor"
|
15
|
+
settings.assets.js_compressor = YUI::JavaScriptCompressor.new
|
16
|
+
settings.assets.css_compressor = YUI::CssCompressor.new
|
17
|
+
|
18
|
+
get "/" do
|
19
|
+
haml :index
|
20
|
+
end
|
21
|
+
|
22
|
+
get "/js/:file.js" do
|
23
|
+
content_type "application/javascript"
|
24
|
+
settings.assets["#{params[:file]}.js"]
|
25
|
+
end
|
26
|
+
|
27
|
+
get "/css/:file.css" do
|
28
|
+
content_type "text/css"
|
29
|
+
settings.assets["#{params[:file]}.css"]
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "sinatra/base"
|
2
|
+
require "sprockets"
|
3
|
+
require "haml"
|
4
|
+
|
5
|
+
|
6
|
+
APP_ROOT = File.expand_path(File.dirname(__FILE__))
|
7
|
+
$: << "#{APP_ROOT}/app/"
|
8
|
+
|
9
|
+
# <%= name %> - app
|
10
|
+
|
11
|
+
require "<%= name %>"
|
12
|
+
|
13
|
+
map <%= name.camelize %>.app_path do
|
14
|
+
run <%= name.camelize %>
|
15
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
load 'deploy' if respond_to?(:namespace)
|
2
|
+
|
3
|
+
set :domain, "your application domain"
|
4
|
+
set :application, "<%= name %>"
|
5
|
+
|
6
|
+
set :scm, :git
|
7
|
+
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
|
8
|
+
|
9
|
+
set :repository, "git@github.com:some-user/<%= name %>.git"
|
10
|
+
|
11
|
+
set :deploy_via, :remote_cache
|
12
|
+
set :deploy_to, "/var/www/#{application}"
|
13
|
+
set :user, "your deployment user"
|
14
|
+
set :use_sudo, false
|
15
|
+
|
16
|
+
|
17
|
+
role :web, domain # Your HTTP server, Apache/etc
|
18
|
+
role :app, domain # This may be the same as your `Web` server
|
19
|
+
role :db, domain, :primary => true # This is where Rails migrations will run
|
20
|
+
|
21
|
+
# if you want to clean up old releases on each deploy uncomment this:
|
22
|
+
# after "deploy:restart", "deploy:cleanup"
|
23
|
+
|
24
|
+
# If you are using Passenger mod_rails uncomment this:
|
25
|
+
# namespace :deploy do
|
26
|
+
# task :start do ; end
|
27
|
+
# task :stop do ; end
|
28
|
+
# task :restart, :roles => :app, :except => { :no_release => true } do
|
29
|
+
# run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
|
30
|
+
# end
|
31
|
+
# end
|
32
|
+
#set :sin_env, :production
|
33
|
+
|
34
|
+
# Where will it be located on a server?
|
35
|
+
|
36
|
+
#set :unicorn_conf, "#{deploy_to}/config/unicorn.rb"
|
37
|
+
#set :unicorn_pid, "#{deploy_to}/pids/unicorn.pid"
|
38
|
+
|
39
|
+
# Unicorn control tasks
|
40
|
+
#namespace :deploy do
|
41
|
+
# task :restart do
|
42
|
+
# run "if [ -f #{unicorn_pid} ]; then kill -USR2 `cat #{unicorn_pid}`; else cd #{deploy_to} && bundle exec unicorn -c #{unicorn_conf} -E #{sin_env} -D; fi"
|
43
|
+
# end
|
44
|
+
# task :start do
|
45
|
+
# run "cd #{deploy_to} && bundle exec unicorn -c #{unicorn_conf} -E #{sin_env} -D"
|
46
|
+
# end
|
47
|
+
# task :stop do
|
48
|
+
# run "if [ -f #{unicorn_pid} ]; then kill -QUIT `cat #{unicorn_pid}`; fi"
|
49
|
+
# end
|
50
|
+
#
|
51
|
+
#end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# define paths and filenames
|
2
|
+
deploy_to = "/var/www/<%=name %>"
|
3
|
+
sin_root = "#{deploy_to}/current"
|
4
|
+
pid_file = "#{deploy_to}/shared/pids/unicorn.pid"
|
5
|
+
socket_file= "#{deploy_to}/shared/unicorn.sock"
|
6
|
+
log_file = "#{sin_root}/log/unicorn.log"
|
7
|
+
err_log = "#{sin_root}/log/unicorn_error.log"
|
8
|
+
old_pid = pid_file + '.oldbin'
|
9
|
+
|
10
|
+
timeout 30
|
11
|
+
worker_processes 2 # increase or decrease
|
12
|
+
listen socket_file, :backlog => 1024
|
13
|
+
|
14
|
+
pid pid_file
|
15
|
+
stderr_path err_log
|
16
|
+
stdout_path log_file
|
17
|
+
|
18
|
+
# make forks faster
|
19
|
+
preload_app true
|
20
|
+
|
21
|
+
# make sure that Bundler finds the Gemfile
|
22
|
+
before_exec do |server|
|
23
|
+
ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', File.dirname(__FILE__))
|
24
|
+
end
|
25
|
+
|
26
|
+
=begin
|
27
|
+
before_fork do |server, worker|
|
28
|
+
defined?(ActiveRecord::Base) and
|
29
|
+
ActiveRecord::Base.connection.disconnect!
|
30
|
+
|
31
|
+
# zero downtime deploy magic:
|
32
|
+
# if unicorn is already running, ask it to start a new process and quit.
|
33
|
+
if File.exists?(old_pid) && server.pid != old_pid
|
34
|
+
begin
|
35
|
+
Process.kill("QUIT", File.read(old_pid).to_i)
|
36
|
+
rescue Errno::ENOENT, Errno::ESRCH
|
37
|
+
# someone else did our job for us
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
after_fork do |server, worker|
|
43
|
+
|
44
|
+
# re-establish activerecord connections.
|
45
|
+
defined?(ActiveRecord::Base) and
|
46
|
+
ActiveRecord::Base.establish_connection
|
47
|
+
end
|
48
|
+
=end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.expand_path('./app/version', __FILE__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.authors = ["<%= @user %>"]
|
5
|
+
gem.email = ["<%= @email %>"]
|
6
|
+
gem.description = %q{Todo: Write application description}
|
7
|
+
gem.summary = %q{Todo: Write application summary}
|
8
|
+
gem.homepage = ""
|
9
|
+
|
10
|
+
gem.files = `git ls-files`.split($\)
|
11
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
12
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
13
|
+
gem.name = "<%= name %>"
|
14
|
+
gem.require_paths = ["app"]
|
15
|
+
gem.version = <%= name.camelize %>::VERSION
|
16
|
+
gem.add_runtime_dependency "sinatra", ">= 1.3.2"
|
17
|
+
gem.add_runtime_dependency "unicorn"
|
18
|
+
gem.add_runtime_dependency "sprockets"
|
19
|
+
|
20
|
+
gem.add_development_dependency "capybara"
|
21
|
+
gem.add_development_dependency "rspec"
|
22
|
+
gem.add_development_dependency "capistrano"
|
23
|
+
gem.add_development_dependency "capistrano-ext"
|
24
|
+
end
|
File without changes
|
data/myway.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/myway/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Fazle Taher"]
|
6
|
+
gem.email = ["ftaher@gmail.com"]
|
7
|
+
gem.description = %q{Sinatra project generator for sinatra based web applications. Named after
|
8
|
+
Frank Sinatra's popular song during 1969 'My way'}
|
9
|
+
gem.summary = %q{Scaffolding application for Sinatra web applications}
|
10
|
+
gem.homepage = "http://github.com/mftaher/myway"
|
11
|
+
|
12
|
+
gem.files = `git ls-files`.split($\)
|
13
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
14
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
15
|
+
gem.name = "myway"
|
16
|
+
gem.require_paths = ["lib"]
|
17
|
+
gem.version = Myway::VERSION
|
18
|
+
gem.add_runtime_dependency "thor", ">= 0.15.2"
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: myway
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Fazle Taher
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-06-28 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: thor
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.15.2
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.15.2
|
30
|
+
description: ! "Sinatra project generator for sinatra based web applications. Named
|
31
|
+
after\n Frank Sinatra's popular song during 1969 'My way'"
|
32
|
+
email:
|
33
|
+
- ftaher@gmail.com
|
34
|
+
executables:
|
35
|
+
- mw
|
36
|
+
extensions: []
|
37
|
+
extra_rdoc_files: []
|
38
|
+
files:
|
39
|
+
- .gitignore
|
40
|
+
- Gemfile
|
41
|
+
- LICENSE
|
42
|
+
- README.md
|
43
|
+
- Rakefile
|
44
|
+
- bin/mw
|
45
|
+
- lib/myway.rb
|
46
|
+
- lib/myway/templates/app/app.tt
|
47
|
+
- lib/myway/templates/app/version.tt
|
48
|
+
- lib/myway/templates/config.ru.tt
|
49
|
+
- lib/myway/templates/config/deploy.rb.tt
|
50
|
+
- lib/myway/templates/config/unicorn.tt
|
51
|
+
- lib/myway/templates/gemfile.tt
|
52
|
+
- lib/myway/templates/gemspec.tt
|
53
|
+
- lib/myway/templates/gitignore.tt
|
54
|
+
- lib/myway/templates/rakefile.tt
|
55
|
+
- lib/myway/templates/readme.tt
|
56
|
+
- lib/myway/version.rb
|
57
|
+
- myway.gemspec
|
58
|
+
homepage: http://github.com/mftaher/myway
|
59
|
+
licenses: []
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 1.8.19
|
79
|
+
signing_key:
|
80
|
+
specification_version: 3
|
81
|
+
summary: Scaffolding application for Sinatra web applications
|
82
|
+
test_files: []
|