sinatra-cmd 0.0.13 → 0.0.14
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 +4 -4
- data/.rspec +2 -0
- data/lib/sinatra_cmd/generator.rb +1 -0
- data/lib/sinatra_cmd/version.rb +1 -1
- data/sinatra-cmd.gemspec +7 -2
- data/spec/generate_spec.rb +6 -0
- data/spec/spec_helper.rb +72 -0
- data/templates/Gemfile +3 -0
- data/templates/README.md.erb +8 -0
- data/templates/config/boot.rb.erb +31 -5
- data/templates/config/mongo_mapper.yml.erb +13 -0
- data/templates/helpers/application.rb.erb +0 -14
- data/templates/helpers/error_handling.rb.erb +3 -3
- metadata +67 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95d75b257f0a1af3176b310e93b31b8e62c688f6
|
4
|
+
data.tar.gz: 16b5f043a1c0d26d7c84db82aeecd7ffa381545d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c4d7bcb36e9af360ac5761d520963a4039353f76c89de8310e8f9791af488b2f9ab7c2a5d9b119e34b5177d67b94067156539ec7cc6bb683fe4e9778ace5007
|
7
|
+
data.tar.gz: c39c119c60985df380801a6dbfdb09b1e39804672739c1f960e8f5363ccfe1f375c7d4ada5a24f79037b1c38c4f6b4bc2584ba7cb185da4d400da327275ebf10
|
data/.rspec
ADDED
@@ -30,6 +30,7 @@ module SinatraCmd
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def setup_config
|
33
|
+
template "config/mongo_mapper.yml.erb", "#{app_name}/config/mongo_mapper.yml"
|
33
34
|
template "config/application.rb.erb", "#{app_name}/config/application.rb"
|
34
35
|
template "config/boot.rb.erb", "#{app_name}/config/boot.rb"
|
35
36
|
copy_file "config/environment.rb", "#{app_name}/config/environment.rb"
|
data/lib/sinatra_cmd/version.rb
CHANGED
data/sinatra-cmd.gemspec
CHANGED
@@ -6,8 +6,8 @@ require 'sinatra_cmd/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "sinatra-cmd"
|
8
8
|
spec.version = SinatraCmd::VERSION
|
9
|
-
spec.authors = ["
|
10
|
-
spec.email = ["
|
9
|
+
spec.authors = ["wluo"]
|
10
|
+
spec.email = ["luowei---010101@163.com"]
|
11
11
|
|
12
12
|
spec.summary = %q{Command for generating sinatra project}
|
13
13
|
spec.description = %q{Generate a sinatra project.}
|
@@ -24,4 +24,9 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_development_dependency "bundler", "~> 1.9"
|
25
25
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
26
|
spec.add_development_dependency "thor", "~> 0.19"
|
27
|
+
|
28
|
+
spec.add_development_dependency "rspec", "~> 3.2"
|
29
|
+
spec.add_development_dependency "pry", "~> 0.10"
|
30
|
+
spec.add_development_dependency "pry-stack_explorer", "~> 0.4"
|
31
|
+
spec.add_development_dependency "pry-byebug", "~> 3.0"
|
27
32
|
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
Bundler.setup
|
3
|
+
|
4
|
+
require 'sinatra_cmd' # and any other gems you need
|
5
|
+
|
6
|
+
require 'pry' # for debuge
|
7
|
+
|
8
|
+
RSpec.configure do |config|
|
9
|
+
# config.include Capybara::DSL,:type=>:request
|
10
|
+
# The settings below are suggested to provide a good initial experience
|
11
|
+
# with RSpec, but feel free to customize to your heart's content.
|
12
|
+
#=begin
|
13
|
+
# These two settings work together to allow you to limit a spec run
|
14
|
+
# to individual examples or groups you care about by tagging them with
|
15
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
16
|
+
# get run.
|
17
|
+
# config.filter_run :focus
|
18
|
+
# config.run_all_when_everything_filtered = true
|
19
|
+
|
20
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
21
|
+
# file, and it's useful to allow more verbose output when running an
|
22
|
+
# individual spec file.
|
23
|
+
# if config.files_to_run.one?
|
24
|
+
# Use the documentation formatter for detailed output,
|
25
|
+
# unless a formatter has already been configured
|
26
|
+
# (e.g. via a command-line flag).
|
27
|
+
# config.default_formatter = 'doc'
|
28
|
+
# end
|
29
|
+
|
30
|
+
# Print the 10 slowest examples and example groups at the
|
31
|
+
# end of the spec run, to help surface which specs are running
|
32
|
+
# particularly slow.
|
33
|
+
config.profile_examples = 10
|
34
|
+
|
35
|
+
# Run specs in random order to surface order dependencies. If you find an
|
36
|
+
# order dependency and want to debug it, you can fix the order by providing
|
37
|
+
# the seed, which is printed after each run.
|
38
|
+
# --seed 1234
|
39
|
+
config.order = :random
|
40
|
+
|
41
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
42
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
43
|
+
# test failures related to randomization by passing the same `--seed` value
|
44
|
+
# as the one that triggered the failure.
|
45
|
+
Kernel.srand config.seed
|
46
|
+
|
47
|
+
# rspec-expectations config goes here. You can use an alternate
|
48
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
49
|
+
# assertions if you prefer.
|
50
|
+
config.expect_with :rspec do |expectations|
|
51
|
+
# Enable only the newer, non-monkey-patching expect syntax.
|
52
|
+
# For more details, see:
|
53
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
54
|
+
expectations.syntax = :expect
|
55
|
+
|
56
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
57
|
+
end
|
58
|
+
|
59
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
60
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
61
|
+
config.mock_with :rspec do |mocks|
|
62
|
+
# Enable only the newer, non-monkey-patching expect syntax.
|
63
|
+
# For more details, see:
|
64
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
65
|
+
mocks.syntax = :expect
|
66
|
+
|
67
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
68
|
+
# a real object. This is generally recommended.
|
69
|
+
mocks.verify_partial_doubles = true
|
70
|
+
end
|
71
|
+
#=end
|
72
|
+
end
|
data/templates/Gemfile
CHANGED
data/templates/README.md.erb
CHANGED
@@ -4,28 +4,54 @@ require 'bundler/setup'
|
|
4
4
|
Bundler.require
|
5
5
|
require 'pry' if development? or test?
|
6
6
|
|
7
|
-
require 'sinatra/reloader'
|
7
|
+
require 'sinatra/reloader'
|
8
8
|
require 'sinatra/namespace'
|
9
9
|
require 'sinatra/json'
|
10
|
+
require 'sinatra/custom_logger'
|
11
|
+
|
12
|
+
require 'fileutils'
|
10
13
|
|
11
14
|
module <%= app_name.split(/\-|\_/).map(&:capitalize).join('') %>
|
12
15
|
API_VERSION = '1'
|
13
16
|
|
14
17
|
class App < Sinatra::Base
|
15
|
-
register Sinatra::Namespace
|
16
18
|
helpers Sinatra::JSON
|
19
|
+
helpers Sinatra::CustomLogger
|
20
|
+
|
21
|
+
register Sinatra::Namespace
|
22
|
+
|
17
23
|
# language automatic changed by params['locale']
|
18
24
|
register Sinatra::R18n
|
19
25
|
|
20
|
-
|
26
|
+
configure :development do
|
27
|
+
register Sinatra::Reloader
|
28
|
+
end
|
21
29
|
|
22
30
|
configure do
|
23
|
-
#
|
24
|
-
|
31
|
+
# db_file = File.join(File.expand_path('../mongo_mapper.yml', __FILE__))
|
32
|
+
|
33
|
+
# Mongoid load config file
|
34
|
+
# Mongoid.load!(File.expand_path('../mongoid.yml', __FILE__))
|
35
|
+
|
36
|
+
# MongoMapper setup condig file
|
37
|
+
# mongo_config = YAML::load(ERB.new(File.read(db_file)).result)
|
38
|
+
# MongoMapper.setup(mongo_config, ENV['RACK_ENV'])
|
39
|
+
|
40
|
+
# R18n::I18n.default = 'en-us'
|
25
41
|
|
26
42
|
# Error blocks don't trigger in development mode.
|
27
43
|
# https://github.com/sinatra/sinatra/issues/578
|
28
44
|
set :show_exceptions, :after_handler
|
29
45
|
end
|
46
|
+
|
47
|
+
configure :development, :production do
|
48
|
+
file_path = File.join(File.expand_path('../../log', __FILE__))
|
49
|
+
FileUtils.mkdir_p(file_path)
|
50
|
+
|
51
|
+
# RACK_ENV default to development
|
52
|
+
logger = Logger.new(File.join(file_path, "#{ENV['RACK_ENV']}.log"), 'daily')
|
53
|
+
logger.level = Logger::DEBUG if development?
|
54
|
+
set :logger, logger
|
55
|
+
end
|
30
56
|
end
|
31
57
|
end
|
@@ -2,19 +2,5 @@ require 'fileutils'
|
|
2
2
|
|
3
3
|
module <%= app_name.split(/\-|\_/).map(&:capitalize).join('') %>
|
4
4
|
module ApplicationHelper
|
5
|
-
def logger
|
6
|
-
return @logger unless @logger.nil?
|
7
|
-
|
8
|
-
file_path = File.join(File.expand_path('../../log', __FILE__))
|
9
|
-
FileUtils.mkdir_p(file_path)
|
10
|
-
|
11
|
-
@logger = Logger.new(File.join(file_path, "#{ENV['RACK_ENV']}.log"), 'daily')
|
12
|
-
@logger.level = Logger::INFO
|
13
|
-
@logger.datetime_format = "%Y-%m-%d %H:%M:%S"
|
14
|
-
@logger.formatter = proc {|severity, datetime, default_field , msg|
|
15
|
-
"#{severity[0..0]}, #{datetime}, #{severity} -- #{msg}\n"
|
16
|
-
}
|
17
|
-
@logger
|
18
|
-
end
|
19
5
|
end
|
20
6
|
end
|
@@ -48,9 +48,9 @@ module <%= app_name.split(/\-|\_/).map(&:capitalize).join('') %>
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def halt_with_500
|
51
|
-
|
52
|
-
logger.error("500, #{message}")
|
53
|
-
halt 500, json({code: 500, error: message})
|
51
|
+
err = env['sinatra.error']
|
52
|
+
logger.error("500, #{err.message} \n #{err.backtrace.join("\n")}")
|
53
|
+
halt 500, json({code: 500, error: "#{t.error_handling.internal_server_error}: #{err.message}"})
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-cmd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- wluo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
@@ -52,15 +52,72 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0.19'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.2'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.2'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.10'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.10'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry-stack_explorer
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.4'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.4'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry-byebug
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.0'
|
55
111
|
description: Generate a sinatra project.
|
56
112
|
email:
|
57
|
-
-
|
113
|
+
- luowei---010101@163.com
|
58
114
|
executables:
|
59
115
|
- sinatra
|
60
116
|
extensions: []
|
61
117
|
extra_rdoc_files: []
|
62
118
|
files:
|
63
119
|
- ".gitignore"
|
120
|
+
- ".rspec"
|
64
121
|
- CODE_OF_CONDUCT.md
|
65
122
|
- Gemfile
|
66
123
|
- LICENSE.txt
|
@@ -71,6 +128,8 @@ files:
|
|
71
128
|
- lib/sinatra_cmd/generator.rb
|
72
129
|
- lib/sinatra_cmd/version.rb
|
73
130
|
- sinatra-cmd.gemspec
|
131
|
+
- spec/generate_spec.rb
|
132
|
+
- spec/spec_helper.rb
|
74
133
|
- templates/.gitignore
|
75
134
|
- templates/.rspec
|
76
135
|
- templates/Gemfile
|
@@ -82,6 +141,7 @@ files:
|
|
82
141
|
- templates/config/environment.rb
|
83
142
|
- templates/config/i18n/en-us.yml
|
84
143
|
- templates/config/i18n/zh-cn.yml
|
144
|
+
- templates/config/mongo_mapper.yml.erb
|
85
145
|
- templates/helpers/application.rb.erb
|
86
146
|
- templates/helpers/error_handling.rb.erb
|
87
147
|
- templates/routes/demo.rb.erb
|
@@ -106,8 +166,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
166
|
version: '0'
|
107
167
|
requirements: []
|
108
168
|
rubyforge_project:
|
109
|
-
rubygems_version: 2.4.
|
169
|
+
rubygems_version: 2.4.6
|
110
170
|
signing_key:
|
111
171
|
specification_version: 4
|
112
172
|
summary: Command for generating sinatra project
|
113
|
-
test_files:
|
173
|
+
test_files:
|
174
|
+
- spec/generate_spec.rb
|
175
|
+
- spec/spec_helper.rb
|