sinatra-cmd 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +1 -0
- data/bin/sinatra +5 -0
- data/lib/sinatra/cmd/generator.rb +55 -0
- data/lib/sinatra/cmd/version.rb +5 -0
- data/lib/sinatra/cmd.rb +7 -0
- data/sinatra-cmd.gemspec +25 -0
- data/templates/.gitignore +8 -0
- data/templates/.rspec +2 -0
- data/templates/Gemfile +22 -0
- data/templates/README.md.erb +15 -0
- data/templates/Rakefile +9 -0
- data/templates/config/application.rb.erb +34 -0
- data/templates/config/boot.rb.erb +33 -0
- data/templates/config/database.yml.erb +84 -0
- data/templates/config/environment.rb +3 -0
- data/templates/config/i18n/en-us.yml +9 -0
- data/templates/config/i18n/zh-cn.yml +9 -0
- data/templates/config/scheduler.rb +6 -0
- data/templates/config.ru.erb +3 -0
- data/templates/helpers/application.rb.erb +15 -0
- data/templates/helpers/error_handling.rb.erb +67 -0
- data/templates/routes/demo.rb.erb +14 -0
- data/templates/spec/spec_helper.rb +29 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a391f9e9a1c5b4cd67a34aac17f5d01e34377e61
|
4
|
+
data.tar.gz: 2b038a42e0b2f668745a51dcad1bfdff234315a1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 43e5d17382202a34e7be6aec43ef18e84172b83a719346743c1f4ce3843b8663f756bdeb9d0548a258272c4200bc0d8cd43370867fece47717c55627db4f2387
|
7
|
+
data.tar.gz: 978fc43be4594b59f002bec5990ac313fbeb73cbebc1da86848c11fc387609f68a2edb20c1bbb488c0a9646c88d6f9e5a897ac8b334b9a36d48eeeed64dd7fe2
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 CBluowei
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Sinatra::Cmd
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/sinatra/cmd`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'sinatra-cmd'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install sinatra-cmd
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Default db is mongoid.
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
1. Fork it ( https://github.com/[my-github-username]/sinatra-cmd/fork )
|
36
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/sinatra
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require "thor"
|
2
|
+
|
3
|
+
module Sinatra
|
4
|
+
module CLI
|
5
|
+
class Generator < Thor::Group
|
6
|
+
include Thor::Actions
|
7
|
+
|
8
|
+
argument :app_name
|
9
|
+
|
10
|
+
def self.source_root
|
11
|
+
File.join(File.dirname(__FILE__), "../../../", "templates")
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_models_dir
|
15
|
+
keep_file "#{app_name}/app/models"
|
16
|
+
end
|
17
|
+
|
18
|
+
def create_routes_dir
|
19
|
+
keep_file "#{app_name}/app/routes"
|
20
|
+
template "routes/demo.rb.erb", "#{app_name}/routes/demo.rb"
|
21
|
+
end
|
22
|
+
|
23
|
+
def create_config
|
24
|
+
template "config/database.yml.erb", "#{app_name}/config/database.yml"
|
25
|
+
template "config/application.rb.erb", "#{app_name}/config/application.rb"
|
26
|
+
template "config/boot.rb.erb", "#{app_name}/config/boot.rb"
|
27
|
+
copy_file "config/environment.rb", "#{app_name}/config/environment.rb"
|
28
|
+
copy_file "config/scheduler.rb", "#{app_name}/config/scheduler.rb"
|
29
|
+
end
|
30
|
+
|
31
|
+
def create_appfile
|
32
|
+
copy_file ".gitignore", "#{app_name}/.gitignore"
|
33
|
+
copy_file "Gemfile", "#{app_name}/Gemfile"
|
34
|
+
copy_file "Rakefile", "#{app_name}/Rakefile"
|
35
|
+
template "config.ru.erb", "#{app_name}/config.ru"
|
36
|
+
template "README.md.erb", "#{app_name}/README.md"
|
37
|
+
end
|
38
|
+
|
39
|
+
def setup_rspec
|
40
|
+
copy_file "sepc/spec_helper.rb", "#{app_name}/sepc/spec_helper.rb"
|
41
|
+
copy_file ".rspec", "#{app_name}/.rspec"
|
42
|
+
end
|
43
|
+
|
44
|
+
def bundle_install
|
45
|
+
system "cd #{app_name} && bundle install && cd ../"
|
46
|
+
end
|
47
|
+
|
48
|
+
protected
|
49
|
+
|
50
|
+
def keep_file(destination)
|
51
|
+
create_file "#{destination}/.keep"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/sinatra/cmd.rb
ADDED
data/sinatra-cmd.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 'sinatra/cmd/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "sinatra-cmd"
|
8
|
+
spec.version = Sinatra::Cmd::VERSION
|
9
|
+
spec.authors = ["CBluowei"]
|
10
|
+
spec.email = ["wei.luo@careerbuilder.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{A CLI of generate sinatra project.}
|
13
|
+
spec.description = %q{Generate a sinatra project}
|
14
|
+
spec.homepage = "https://github.com/hilotus/sinatra-cli"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "thor", "~> 0.19"
|
25
|
+
end
|
data/templates/.rspec
ADDED
data/templates/Gemfile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
gem 'sinatra', '~> 1.4.6'
|
4
|
+
gem 'sinatra-contrib', '~> 1.4.2', require: false
|
5
|
+
gem 'sinatra-r18n', '~> 2.0.3'
|
6
|
+
|
7
|
+
gem 'mongoid', '~> 4.0.1'
|
8
|
+
|
9
|
+
gem 'rufus-scheduler', '~> 3.0.9'
|
10
|
+
|
11
|
+
group :test, :development do
|
12
|
+
gem 'pry', '~> 0.10.1'
|
13
|
+
gem 'pry-stack_explorer', '~> 0.4.9.2'
|
14
|
+
gem 'pry-byebug', '~> 3.1.0'
|
15
|
+
end
|
16
|
+
|
17
|
+
group :test do
|
18
|
+
gem 'rspec', '~> 3.2.0'
|
19
|
+
gem 'ci_reporter_rspec', '~> 1.0.0'
|
20
|
+
gem 'simplecov', '~> 0.9.2', :require => false
|
21
|
+
gem 'simplecov-rcov', '~> 0.2.3', :require => false
|
22
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<%= app_name %>
|
2
|
+
====================
|
3
|
+
|
4
|
+
##How to use pry
|
5
|
+
create .pryrc file in `/Users/username` folder.
|
6
|
+
```shell
|
7
|
+
#!/usr/bin/ruby
|
8
|
+
|
9
|
+
if defined?(PryByebug)
|
10
|
+
Pry.commands.alias_command 'c', 'continue'
|
11
|
+
Pry.commands.alias_command 's', 'step'
|
12
|
+
Pry.commands.alias_command 'n', 'next'
|
13
|
+
Pry.commands.alias_command 'f', 'finish'
|
14
|
+
end
|
15
|
+
```
|
data/templates/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path('../boot', __FILE__)
|
4
|
+
|
5
|
+
Dir[File.expand_path('../../helpers/*.rb', __FILE__)].each { |f| require f }
|
6
|
+
Dir[File.expand_path('../../models/*.rb', __FILE__)].each { |f| require f }
|
7
|
+
Dir[File.expand_path('../../routes/*.rb', __FILE__)].each { |f| require f }
|
8
|
+
|
9
|
+
require File.expand_path('../scheduler', __FILE__)
|
10
|
+
|
11
|
+
module <%= app_name %>
|
12
|
+
class App
|
13
|
+
# custome register
|
14
|
+
register ErrorHandling
|
15
|
+
|
16
|
+
# custome helpers
|
17
|
+
helpers ApplicationHelper
|
18
|
+
|
19
|
+
before do
|
20
|
+
origin = request.env['HTTP_ORIGIN']
|
21
|
+
headers("Access-Control-Allow-Origin" => origin ) if !origin.nil?
|
22
|
+
# headers("Access-Control-Allow-Origin" => "*" )
|
23
|
+
headers("Access-Control-Allow-Credentials" => "true")
|
24
|
+
headers("Cache-Control" => "no-cache, no-store, private")
|
25
|
+
headers("Content-Type" => "application/json; charset=UTF-8")
|
26
|
+
headers("Access-Control-Allow-Methods" => "POST, GET, PUT, DELETE, OPTION")
|
27
|
+
|
28
|
+
# For options
|
29
|
+
halt 200 if request.request_method == 'OPTIONS'
|
30
|
+
|
31
|
+
halt_with_401 unless %w(127.0.0.1 27.111.214.254 52.74.58.186).include?(request.ip)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
Bundler.require
|
5
|
+
require 'pry' if development? or test?
|
6
|
+
|
7
|
+
require 'sinatra/reloader' if development?
|
8
|
+
require 'sinatra/namespace'
|
9
|
+
require 'sinatra/json'
|
10
|
+
|
11
|
+
# sinatra and rake namespace global method conflict.
|
12
|
+
module Sinatra::Namespace::SharedMethods
|
13
|
+
alias :sinatra_namespace :namespace
|
14
|
+
remove_method :namespace
|
15
|
+
end
|
16
|
+
|
17
|
+
module <%= app_name %>
|
18
|
+
API_V1 = '/App/1'
|
19
|
+
|
20
|
+
class App < Sinatra::Application
|
21
|
+
register Sinatra::Namespace
|
22
|
+
helpers Sinatra::JSON
|
23
|
+
|
24
|
+
configure do
|
25
|
+
# Mongoid config file load
|
26
|
+
Mongoid.load!(File.expand_path('../database.yml', __FILE__))
|
27
|
+
|
28
|
+
# Error blocks don't trigger in development mode.
|
29
|
+
# https://github.com/sinatra/sinatra/issues/578
|
30
|
+
set :show_exceptions, :after_handler
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
development:
|
2
|
+
# Configure available database sessions. (required)
|
3
|
+
sessions:
|
4
|
+
# Defines the default session. (required)
|
5
|
+
default:
|
6
|
+
# Defines the name of the default database that Mongoid can connect to.
|
7
|
+
# (required).
|
8
|
+
database: <%= app_name %>_dev
|
9
|
+
# Provides the hosts the default session can connect to. Must be an array
|
10
|
+
# of host:port pairs. (required)
|
11
|
+
hosts:
|
12
|
+
- localhost:27017
|
13
|
+
options:
|
14
|
+
|
15
|
+
# Change whether the session persists in safe mode by default.
|
16
|
+
# (default: false)
|
17
|
+
# safe: false
|
18
|
+
|
19
|
+
# Change the default consistency model to :eventual or :strong.
|
20
|
+
# :eventual will send reads to secondaries, :strong sends everything
|
21
|
+
# to master. (default: :eventual)
|
22
|
+
# consistency: :eventual
|
23
|
+
|
24
|
+
# How many times Moped should attempt to retry an operation after
|
25
|
+
# failure. (default: 30)
|
26
|
+
# max_retries: 30
|
27
|
+
|
28
|
+
# The time in seconds that Moped should wait before retrying an
|
29
|
+
# operation on failure. (default: 1)
|
30
|
+
# retry_interval: 1
|
31
|
+
# Configure Mongoid specific options. (optional)
|
32
|
+
options:
|
33
|
+
raise_not_found_error: false
|
34
|
+
# Configuration for whether or not to allow access to fields that do
|
35
|
+
# not have a field definition on the model. (default: true)
|
36
|
+
# allow_dynamic_fields: true
|
37
|
+
|
38
|
+
# Enable the identity map, needed for eager loading. (default: false)
|
39
|
+
# identity_map_enabled: false
|
40
|
+
|
41
|
+
# Includes the root model name in json serialization. (default: false)
|
42
|
+
# include_root_in_json: false
|
43
|
+
|
44
|
+
# Include the _type field in serializaion. (default: false)
|
45
|
+
# include_type_for_serialization: false
|
46
|
+
|
47
|
+
# Preload all models in development, needed when models use
|
48
|
+
# inheritance. (default: false)
|
49
|
+
# preload_models: false
|
50
|
+
|
51
|
+
# Protect id and type from mass assignment. (default: true)
|
52
|
+
# protect_sensitive_fields: true
|
53
|
+
|
54
|
+
# Raise an error when performing a #find and the document is not found.
|
55
|
+
# (default: true)
|
56
|
+
# raise_not_found_error: true
|
57
|
+
|
58
|
+
# Raise an error when defining a scope with the same name as an
|
59
|
+
# existing method. (default: false)
|
60
|
+
# scope_overwrite_exception: false
|
61
|
+
|
62
|
+
# Skip the database version check, used when connecting to a db without
|
63
|
+
# admin access. (default: false)
|
64
|
+
# skip_version_check: false
|
65
|
+
|
66
|
+
# User Active Support's time zone in conversions. (default: true)
|
67
|
+
# use_activesupport_time_zone: true
|
68
|
+
|
69
|
+
# Ensure all times are UTC in the app side. (default: false)
|
70
|
+
# use_utc: false
|
71
|
+
test:
|
72
|
+
sessions:
|
73
|
+
default:
|
74
|
+
database: <%= app_name %>_test
|
75
|
+
hosts:
|
76
|
+
- localhost:27017
|
77
|
+
options:
|
78
|
+
consistency: :strong
|
79
|
+
# In the test environment we lower the retries and retry interval to
|
80
|
+
# low amounts for fast failures.
|
81
|
+
max_retries: 1
|
82
|
+
retry_interval: 0
|
83
|
+
options:
|
84
|
+
raise_not_found_error: false
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module <%= app_name %>
|
2
|
+
module ApplicationHelper
|
3
|
+
def logger
|
4
|
+
return @logger unless @logger.nil?
|
5
|
+
|
6
|
+
@logger = Logger.new(File.join(File.expand_path('../../log', __FILE__), "#{ENV['RACK_ENV']}.log"), 'daily')
|
7
|
+
@logger.level = Logger::INFO
|
8
|
+
@logger.datetime_format = "%Y-%m-%d %H:%M:%S"
|
9
|
+
@logger.formatter = proc {|severity, datetime, default_field , msg|
|
10
|
+
"#{severity[0..0]}, #{datetime}, #{severity} -- #{msg}\n"
|
11
|
+
}
|
12
|
+
@logger
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module <%= app_name %>
|
2
|
+
module ErrorHandling
|
3
|
+
module Helpers
|
4
|
+
def halt_with_400(message=nil)
|
5
|
+
message ||= t.error_handling.bad_request
|
6
|
+
logger.error("400, #{message}")
|
7
|
+
halt 400, json({code: 400, message: message})
|
8
|
+
end
|
9
|
+
|
10
|
+
def halt_with_401(message=nil)
|
11
|
+
message ||= t.error_handling.authorization_required
|
12
|
+
logger.error("401, #{message}")
|
13
|
+
halt 401, json({code: 401, message: message})
|
14
|
+
end
|
15
|
+
|
16
|
+
def halt_with_403(message=nil)
|
17
|
+
message ||= t.error_handling.forbidden
|
18
|
+
logger.error("403, #{message}")
|
19
|
+
halt 403, json({code: 403, message: message})
|
20
|
+
end
|
21
|
+
|
22
|
+
def halt_with_404
|
23
|
+
message = t.error_handling.not_found
|
24
|
+
logger.error("404, #{message}")
|
25
|
+
halt 404, json({code: 404, message: message})
|
26
|
+
end
|
27
|
+
|
28
|
+
# unprocessable_entity
|
29
|
+
def halt_with_422
|
30
|
+
errors = []
|
31
|
+
resource = env['sinatra.error'].record.class.to_s
|
32
|
+
env['sinatra.error'].record.errors.each do |attribute, message|
|
33
|
+
code = case message
|
34
|
+
when "can't be blank"
|
35
|
+
"missing_field"
|
36
|
+
when "has already been taken"
|
37
|
+
"already_exists"
|
38
|
+
else
|
39
|
+
"invalid"
|
40
|
+
end
|
41
|
+
|
42
|
+
errors << {resource: resource, field: attribute, code: code}
|
43
|
+
end
|
44
|
+
logger.error("422, Validation failed")
|
45
|
+
halt 422, json({code: 422, message: "Validation failed", errors: errors})
|
46
|
+
end
|
47
|
+
|
48
|
+
def halt_with_500
|
49
|
+
message = "#{t.error_handling.internal_server_error}: #{env['sinatra.error'].message}"
|
50
|
+
logger.error("500, #{message}")
|
51
|
+
halt 500, json({code: 500, message: message})
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.registered(app)
|
56
|
+
app.helpers ErrorHandling::Helpers
|
57
|
+
|
58
|
+
app.error MultiJson::DecodeError do
|
59
|
+
halt_with_400(t.error_handling.multi_json.decode)
|
60
|
+
end
|
61
|
+
|
62
|
+
app.error 500 do
|
63
|
+
halt_with_500
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
ENV['RACK_ENV'] ||= 'test'
|
8
|
+
require 'rspec'
|
9
|
+
require 'rack/test'
|
10
|
+
require File.expand_path("../../config/environment", __FILE__)
|
11
|
+
|
12
|
+
require 'simplecov'
|
13
|
+
require 'simplecov-rcov'
|
14
|
+
SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
|
15
|
+
SimpleCov.start
|
16
|
+
|
17
|
+
RSpec.configure do |config|
|
18
|
+
config.run_all_when_everything_filtered = true
|
19
|
+
config.filter_run :focus
|
20
|
+
|
21
|
+
# Run specs in random order to surface order dependencies. If you find an
|
22
|
+
# order dependency and want to debug it, you can fix the order by providing
|
23
|
+
# the seed, which is printed after each run.
|
24
|
+
# --seed 1234
|
25
|
+
config.order = 'random'
|
26
|
+
|
27
|
+
# this should give us Rack test methods
|
28
|
+
config.include Rack::Test::Methods
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sinatra-cmd
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- CBluowei
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-15 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.9'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.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.19'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.19'
|
55
|
+
description: Generate a sinatra project
|
56
|
+
email:
|
57
|
+
- wei.luo@careerbuilder.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- CODE_OF_CONDUCT.md
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/sinatra
|
69
|
+
- lib/sinatra/cmd.rb
|
70
|
+
- lib/sinatra/cmd/generator.rb
|
71
|
+
- lib/sinatra/cmd/version.rb
|
72
|
+
- sinatra-cmd.gemspec
|
73
|
+
- templates/.gitignore
|
74
|
+
- templates/.rspec
|
75
|
+
- templates/Gemfile
|
76
|
+
- templates/README.md.erb
|
77
|
+
- templates/Rakefile
|
78
|
+
- templates/config.ru.erb
|
79
|
+
- templates/config/application.rb.erb
|
80
|
+
- templates/config/boot.rb.erb
|
81
|
+
- templates/config/database.yml.erb
|
82
|
+
- templates/config/environment.rb
|
83
|
+
- templates/config/i18n/en-us.yml
|
84
|
+
- templates/config/i18n/zh-cn.yml
|
85
|
+
- templates/config/scheduler.rb
|
86
|
+
- templates/helpers/application.rb.erb
|
87
|
+
- templates/helpers/error_handling.rb.erb
|
88
|
+
- templates/routes/demo.rb.erb
|
89
|
+
- templates/spec/spec_helper.rb
|
90
|
+
homepage: https://github.com/hilotus/sinatra-cli
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 2.2.2
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: A CLI of generate sinatra project.
|
114
|
+
test_files: []
|