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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ee23e6d0369a54c958d548bf8c69497884303002
4
- data.tar.gz: 0e03622da8c384f10d581b119f614915acc62cee
3
+ metadata.gz: 95d75b257f0a1af3176b310e93b31b8e62c688f6
4
+ data.tar.gz: 16b5f043a1c0d26d7c84db82aeecd7ffa381545d
5
5
  SHA512:
6
- metadata.gz: 956439ae61b1e9cc6ee8b087fdb68c8b91fab7e7f92c599d775f2251001e8da5f584c9648f94cccd9f66abf65b4900e2a7cca97a3897b8a602c5906c628d35d4
7
- data.tar.gz: 5d71b93001342962f597f10c814ac9070906466dcdc955b7c82acfac437a005989456b359ffe9136efcac9cab6fba8102728a4b475ca77eed4a549c107559061
6
+ metadata.gz: 3c4d7bcb36e9af360ac5761d520963a4039353f76c89de8310e8f9791af488b2f9ab7c2a5d9b119e34b5177d67b94067156539ec7cc6bb683fe4e9778ace5007
7
+ data.tar.gz: c39c119c60985df380801a6dbfdb09b1e39804672739c1f960e8f5363ccfe1f375c7d4ada5a24f79037b1c38c4f6b4bc2584ba7cb185da4d400da327275ebf10
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -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"
@@ -1,3 +1,3 @@
1
1
  module SinatraCmd
2
- VERSION = '0.0.13'
2
+ VERSION = '0.0.14'
3
3
  end
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 = ["CBluowei"]
10
- spec.email = ["wei.luo@careerbuilder.com"]
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
@@ -0,0 +1,6 @@
1
+ describe SinatraCmd do
2
+ it "Generator sinatra" do
3
+ bin_path = File.join(File.expand_path('../../bin', __FILE__))
4
+ system("#{bin_path}/sinatra test-project")
5
+ end
6
+ end
@@ -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
@@ -6,6 +6,9 @@ gem 'sinatra'
6
6
  gem 'sinatra-contrib', require: false
7
7
  gem 'sinatra-r18n'
8
8
 
9
+ # gem 'mongo_mapper'
10
+ # gem 'bson_ext'
11
+
9
12
  group :test, :development do
10
13
  gem 'pry'
11
14
  gem 'pry-stack_explorer'
@@ -1,2 +1,10 @@
1
1
  <%= app_name.split(/\-|\_/).map(&:capitalize).join('') %>
2
2
  ====================
3
+
4
+ 1. start server
5
+
6
+ ```ruby
7
+ rackup
8
+ # or
9
+ thin start
10
+ ```
@@ -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' if development?
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
- set :logging, true
26
+ configure :development do
27
+ register Sinatra::Reloader
28
+ end
21
29
 
22
30
  configure do
23
- # Mongoid config file load
24
- # Mongoid.load!(File.expand_path('../database.yml', __FILE__))
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
@@ -0,0 +1,13 @@
1
+ development:
2
+ host: localhost
3
+ port: 27017
4
+ database: demo-dev
5
+ username:
6
+ password:
7
+
8
+ test:
9
+ host: localhost
10
+ port: 27017
11
+ database: demo-test
12
+ username:
13
+ password:
@@ -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
- message = "#{t.error_handling.internal_server_error}: #{env['sinatra.error'].message}"
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.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
- - CBluowei
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
- - wei.luo@careerbuilder.com
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.8
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