napa 0.1.11 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. data/bin/napa +2 -14
  2. data/lib/napa/cli.rb +9 -0
  3. data/lib/napa/generators/scaffold_generator.rb +23 -0
  4. data/lib/{generators → napa/generators}/templates/scaffold/.env +0 -0
  5. data/lib/{generators → napa/generators}/templates/scaffold/.env.test +0 -0
  6. data/lib/{generators/templates/scaffold/.gitignore.tpl → napa/generators/templates/scaffold/.gitignore.tt} +1 -1
  7. data/lib/{generators → napa/generators}/templates/scaffold/.rubocop.yml +0 -0
  8. data/lib/{generators → napa/generators}/templates/scaffold/Gemfile +0 -0
  9. data/lib/{generators → napa/generators}/templates/scaffold/README.md +0 -0
  10. data/lib/{generators → napa/generators}/templates/scaffold/Rakefile +0 -0
  11. data/lib/{generators/templates/scaffold/app/apis/hello_api.rb → napa/generators/templates/scaffold/app/apis/hello_api.rb.tt} +2 -2
  12. data/lib/{generators → napa/generators}/templates/scaffold/app.rb +0 -0
  13. data/lib/{generators → napa/generators}/templates/scaffold/config/database.yml +0 -0
  14. data/lib/{generators → napa/generators}/templates/scaffold/config/initializers/active_record.rb +0 -0
  15. data/lib/{generators → napa/generators}/templates/scaffold/config/middleware/honeybadger.rb +0 -0
  16. data/lib/{generators/templates/scaffold/config.ru → napa/generators/templates/scaffold/config.ru.tt} +1 -1
  17. data/lib/{generators → napa/generators}/templates/scaffold/console +0 -0
  18. data/lib/{generators → napa/generators}/templates/scaffold/spec/apis/hello_api_spec.rb +0 -0
  19. data/lib/{generators → napa/generators}/templates/scaffold/spec/factories/.gitkeep +0 -0
  20. data/lib/{generators → napa/generators}/templates/scaffold/spec/spec_helper.rb +0 -0
  21. data/lib/napa/generators.rb +1 -0
  22. data/lib/napa/middleware/request_stats.rb +30 -0
  23. data/lib/napa/stats.rb +23 -0
  24. data/lib/napa/version.rb +1 -1
  25. data/lib/napa.rb +0 -1
  26. data/napa.gemspec +2 -0
  27. data/spec/middleware/request_stats_spec.rb +28 -0
  28. data/spec/stats_spec.rb +42 -0
  29. metadata +114 -47
  30. checksums.yaml +0 -7
  31. data/lib/generators/scaffold.rb +0 -68
data/bin/napa CHANGED
@@ -1,17 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'napa'
3
+ require 'napa/cli'
4
4
 
5
- actions = ['new']
6
-
7
- if actions.include?(ARGV[0])
8
- if ARGV[0] == 'new'
9
- if ARGV[1].nil?
10
- STDOUT.write "Missing App Name, Exiting\n"
11
- else
12
- Napa::Generators::Scaffold.new(ARGV[1], ARGV[2])
13
- end
14
- end
15
- else
16
- STDOUT.write "Unknown Action, Exiting.\n"
17
- end
5
+ Napa::CLI.start(ARGV)
data/lib/napa/cli.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'thor'
2
+ require 'napa/generators'
3
+
4
+ module Napa
5
+ class CLI < Thor
6
+ register(Generators::ScaffoldGenerator, 'new', 'new <app_name> [app_path]',
7
+ 'Create a new Napa scaffold')
8
+ end
9
+ end
@@ -0,0 +1,23 @@
1
+ require 'thor'
2
+ require 'active_support/core_ext/string'
3
+
4
+ module Napa
5
+ module Generators
6
+ class ScaffoldGenerator < Thor::Group
7
+ include Thor::Actions
8
+
9
+ source_root "#{File.dirname(__FILE__)}/templates/scaffold"
10
+
11
+ argument :app_name
12
+ argument :app_path, optional: true
13
+
14
+ def generate
15
+ say 'Generating scaffold...'
16
+
17
+ directory ".", (app_path || app_name)
18
+
19
+ say 'Done!', :green
20
+ end
21
+ end
22
+ end
23
+ end
@@ -8,4 +8,4 @@
8
8
  log/*
9
9
  tmp/*
10
10
  coverage
11
- !.keep
11
+ !.keep
@@ -1,11 +1,11 @@
1
- module HelloService
1
+ module <%= app_name.classify %>
2
2
  class API < Grape::API
3
3
  format :json
4
4
 
5
5
  resource :hello do
6
6
  desc 'Return a Hello World message'
7
7
  get do
8
- { message: 'Hello Wonderful World!' }
8
+ { message: 'Hello Wonderful World, from <%= app_name.classify %>!' }
9
9
  end
10
10
  end
11
11
 
@@ -14,5 +14,5 @@ use Napa::Middleware::AppMonitor
14
14
  use Napa::Middleware::Authentication
15
15
  use ActiveRecord::ConnectionAdapters::ConnectionManagement
16
16
 
17
- run HelloService::API # <-- boot your service here --
17
+ run <%= app_name.classify %>::API # <-- boot your service here --
18
18
 
@@ -0,0 +1 @@
1
+ require 'napa/generators/scaffold_generator'
@@ -0,0 +1,30 @@
1
+ module Napa
2
+ class Middleware
3
+ class RequestStats
4
+ def initialize(app)
5
+ @app = app
6
+ end
7
+
8
+ def call(env)
9
+ # Mark the request time
10
+ start = Time.now
11
+
12
+ # Process the request
13
+ status, headers, body = @app.call(env)
14
+
15
+ # Mark the response time
16
+ stop = Time.now
17
+
18
+ # Calculate total response time
19
+ response_time = stop - start
20
+
21
+ # Emit stats to StatsD
22
+ Napa::Stats.emitter.increment('api_requests')
23
+ Napa::Stats.emitter.timing('api_response_time', response_time)
24
+
25
+ # Return the results
26
+ [status, headers, body]
27
+ end
28
+ end
29
+ end
30
+ end
data/lib/napa/stats.rb ADDED
@@ -0,0 +1,23 @@
1
+ require 'statsd'
2
+ module Napa
3
+ class Stats
4
+ class << self
5
+ def emitter=(emitter)
6
+ @emitter = emitter
7
+ end
8
+
9
+ def emitter
10
+ unless @emitter
11
+ # Log an error if StatsD settings are not configured
12
+ message = 'StatsD host and port not configured in environment variables, using default settings'
13
+ Napa::Logger.logger.warn message unless ENV['STATSD_HOST'] && ENV['STATSD_PORT']
14
+
15
+ # Create a new StatsD emitter with the service name as the namespace
16
+ # Defaults to localhost port 8125 if env vars are nil
17
+ @emitter = Statsd.new(ENV['STATSD_HOST'], ENV['STATSD_PORT']).tap { |sd| sd.namespace = Napa::Identity.name }
18
+ end
19
+ @emitter
20
+ end
21
+ end
22
+ end
23
+ end
data/lib/napa/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Napa
2
- VERSION = '0.1.11'
2
+ VERSION = '0.1.12'
3
3
 
4
4
  class Version
5
5
  class << self
data/lib/napa.rb CHANGED
@@ -20,7 +20,6 @@ require 'napa/middleware/authentication'
20
20
  require 'napa/activerecord'
21
21
  require 'napa/authentication'
22
22
  require 'napa/grape_api'
23
- require 'generators/scaffold'
24
23
 
25
24
  # load rake tasks if Rake installed
26
25
  if defined?(Rake)
data/napa.gemspec CHANGED
@@ -20,10 +20,12 @@ Gem::Specification.new do |gem|
20
20
  gem.add_dependency 'logging'
21
21
  gem.add_dependency 'dotenv'
22
22
  gem.add_dependency 'octokit', '~> 1.25'
23
+ gem.add_dependency 'thor'
23
24
  gem.add_dependency 'virtus'
24
25
  gem.add_dependency 'grape'
25
26
  gem.add_dependency 'grape-swagger'
26
27
  gem.add_dependency 'unicorn'
28
+ gem.add_dependency 'statsd-ruby'
27
29
 
28
30
  gem.add_development_dependency "rspec"
29
31
  gem.add_development_dependency "pry"
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+ require 'napa/middleware/request_stats'
3
+
4
+ describe Napa::Middleware::RequestStats do
5
+ before do
6
+ # Delete any prevous instantiations of the emitter and set valid statsd env vars
7
+ Napa::Stats.emitter = nil
8
+ ENV['STATSD_HOST'] = 'localhost'
9
+ ENV['STATSD_PORT'] = '8125'
10
+ end
11
+
12
+ it 'should increment api_requests counter' do
13
+ Napa::Stats.emitter.should_receive(:increment).with('api_requests')
14
+ app = lambda { |env| [200, { 'Content-Type' => 'application/json' }, Array.new] }
15
+ middleware = Napa::Middleware::RequestStats.new(app)
16
+ env = Rack::MockRequest.env_for('/test')
17
+ middleware.call(env)
18
+ end
19
+
20
+ it 'should send the api_response_time' do
21
+ Napa::Stats.emitter.should_receive(:timing).with('api_response_time', an_instance_of(Float))
22
+ app = lambda { |env| [200, { 'Content-Type' => 'application/json'}, Array.new] }
23
+ middleware = Napa::Middleware::RequestStats.new(app)
24
+ env = Rack::MockRequest.env_for('/test')
25
+ middleware.call(env)
26
+ end
27
+
28
+ end
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+ require 'napa/stats'
3
+
4
+ describe Napa::Stats do
5
+ before do
6
+ # Delete any prevous instantiations of the emitter
7
+ Napa::Stats.emitter = nil
8
+ # Stub out logging since there is no log to output to
9
+ Napa::Logger.stub_chain(:logger, :warn)
10
+ end
11
+
12
+ it 'should log an error if StatsD env variables are not configured' do
13
+ ENV['STATSD_HOST'] = nil
14
+ ENV['STATSD_PORT'] = nil
15
+ message = 'StatsD host and port not configured in environment variables, using default settings'
16
+ Napa::Logger.logger.should_receive(:warn).with(message)
17
+ Napa::Stats.emitter
18
+ end
19
+
20
+ it 'should default statsd to localhost port 8125 if env vars are not specified' do
21
+ ENV['STATSD_HOST'] = nil
22
+ ENV['STATSD_PORT'] = nil
23
+ expect(Napa::Stats.emitter.host).to eq('127.0.0.1')
24
+ expect(Napa::Stats.emitter.port).to eq(8125)
25
+ end
26
+
27
+ it 'should return a StatsD client object' do
28
+ expect(Napa::Stats.emitter.class.name).to eq('Statsd')
29
+ end
30
+
31
+ it 'the namespace of the StatsD client object should equal the service name' do
32
+ ENV['SERVICE_NAME'] = 'my-service'
33
+ expect(Napa::Stats.emitter.namespace).to eq('my-service')
34
+ end
35
+
36
+ it 'should use env variables to set statsd host and port' do
37
+ ENV['STATSD_HOST'] = 'localhost'
38
+ ENV['STATSD_PORT'] = '9000'
39
+ expect(Napa::Stats.emitter.host).to eq('localhost')
40
+ expect(Napa::Stats.emitter.port).to eq('9000')
41
+ end
42
+ end
metadata CHANGED
@@ -1,60 +1,68 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: napa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.12
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Darby Frey
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-12-23 00:00:00.000000000 Z
12
+ date: 2013-12-30 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rake
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - '>='
19
+ - - ! '>='
18
20
  - !ruby/object:Gem::Version
19
21
  version: '0'
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - '>='
27
+ - - ! '>='
25
28
  - !ruby/object:Gem::Version
26
29
  version: '0'
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: logging
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - '>='
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: '0'
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - '>='
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
45
  version: '0'
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: dotenv
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - '>='
51
+ - - ! '>='
46
52
  - !ruby/object:Gem::Version
47
53
  version: '0'
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
- - - '>='
59
+ - - ! '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: '0'
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: octokit
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
67
  - - ~>
60
68
  - !ruby/object:Gem::Version
@@ -62,120 +70,169 @@ dependencies:
62
70
  type: :runtime
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
75
  - - ~>
67
76
  - !ruby/object:Gem::Version
68
77
  version: '1.25'
78
+ - !ruby/object:Gem::Dependency
79
+ name: thor
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
69
94
  - !ruby/object:Gem::Dependency
70
95
  name: virtus
71
96
  requirement: !ruby/object:Gem::Requirement
97
+ none: false
72
98
  requirements:
73
- - - '>='
99
+ - - ! '>='
74
100
  - !ruby/object:Gem::Version
75
101
  version: '0'
76
102
  type: :runtime
77
103
  prerelease: false
78
104
  version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
79
106
  requirements:
80
- - - '>='
107
+ - - ! '>='
81
108
  - !ruby/object:Gem::Version
82
109
  version: '0'
83
110
  - !ruby/object:Gem::Dependency
84
111
  name: grape
85
112
  requirement: !ruby/object:Gem::Requirement
113
+ none: false
86
114
  requirements:
87
- - - '>='
115
+ - - ! '>='
88
116
  - !ruby/object:Gem::Version
89
117
  version: '0'
90
118
  type: :runtime
91
119
  prerelease: false
92
120
  version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
93
122
  requirements:
94
- - - '>='
123
+ - - ! '>='
95
124
  - !ruby/object:Gem::Version
96
125
  version: '0'
97
126
  - !ruby/object:Gem::Dependency
98
127
  name: grape-swagger
99
128
  requirement: !ruby/object:Gem::Requirement
129
+ none: false
100
130
  requirements:
101
- - - '>='
131
+ - - ! '>='
102
132
  - !ruby/object:Gem::Version
103
133
  version: '0'
104
134
  type: :runtime
105
135
  prerelease: false
106
136
  version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
107
138
  requirements:
108
- - - '>='
139
+ - - ! '>='
109
140
  - !ruby/object:Gem::Version
110
141
  version: '0'
111
142
  - !ruby/object:Gem::Dependency
112
143
  name: unicorn
113
144
  requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ type: :runtime
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ - !ruby/object:Gem::Dependency
159
+ name: statsd-ruby
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
114
162
  requirements:
115
- - - '>='
163
+ - - ! '>='
116
164
  - !ruby/object:Gem::Version
117
165
  version: '0'
118
166
  type: :runtime
119
167
  prerelease: false
120
168
  version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
121
170
  requirements:
122
- - - '>='
171
+ - - ! '>='
123
172
  - !ruby/object:Gem::Version
124
173
  version: '0'
125
174
  - !ruby/object:Gem::Dependency
126
175
  name: rspec
127
176
  requirement: !ruby/object:Gem::Requirement
177
+ none: false
128
178
  requirements:
129
- - - '>='
179
+ - - ! '>='
130
180
  - !ruby/object:Gem::Version
131
181
  version: '0'
132
182
  type: :development
133
183
  prerelease: false
134
184
  version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
135
186
  requirements:
136
- - - '>='
187
+ - - ! '>='
137
188
  - !ruby/object:Gem::Version
138
189
  version: '0'
139
190
  - !ruby/object:Gem::Dependency
140
191
  name: pry
141
192
  requirement: !ruby/object:Gem::Requirement
193
+ none: false
142
194
  requirements:
143
- - - '>='
195
+ - - ! '>='
144
196
  - !ruby/object:Gem::Version
145
197
  version: '0'
146
198
  type: :development
147
199
  prerelease: false
148
200
  version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
149
202
  requirements:
150
- - - '>='
203
+ - - ! '>='
151
204
  - !ruby/object:Gem::Version
152
205
  version: '0'
153
206
  - !ruby/object:Gem::Dependency
154
207
  name: git
155
208
  requirement: !ruby/object:Gem::Requirement
209
+ none: false
156
210
  requirements:
157
- - - '>='
211
+ - - ! '>='
158
212
  - !ruby/object:Gem::Version
159
213
  version: '0'
160
214
  type: :development
161
215
  prerelease: false
162
216
  version_requirements: !ruby/object:Gem::Requirement
217
+ none: false
163
218
  requirements:
164
- - - '>='
219
+ - - ! '>='
165
220
  - !ruby/object:Gem::Version
166
221
  version: '0'
167
222
  - !ruby/object:Gem::Dependency
168
223
  name: rubocop
169
224
  requirement: !ruby/object:Gem::Requirement
225
+ none: false
170
226
  requirements:
171
- - - '>='
227
+ - - ! '>='
172
228
  - !ruby/object:Gem::Version
173
229
  version: '0'
174
230
  type: :development
175
231
  prerelease: false
176
232
  version_requirements: !ruby/object:Gem::Requirement
233
+ none: false
177
234
  requirements:
178
- - - '>='
235
+ - - ! '>='
179
236
  - !ruby/object:Gem::Version
180
237
  version: '0'
181
238
  description: A simple framework for building APIs with Grape
@@ -193,27 +250,29 @@ files:
193
250
  - README.md
194
251
  - Rakefile
195
252
  - bin/napa
196
- - lib/generators/scaffold.rb
197
- - lib/generators/templates/scaffold/.env
198
- - lib/generators/templates/scaffold/.env.test
199
- - lib/generators/templates/scaffold/.gitignore.tpl
200
- - lib/generators/templates/scaffold/.rubocop.yml
201
- - lib/generators/templates/scaffold/Gemfile
202
- - lib/generators/templates/scaffold/README.md
203
- - lib/generators/templates/scaffold/Rakefile
204
- - lib/generators/templates/scaffold/app.rb
205
- - lib/generators/templates/scaffold/app/apis/hello_api.rb
206
- - lib/generators/templates/scaffold/config.ru
207
- - lib/generators/templates/scaffold/config/database.yml
208
- - lib/generators/templates/scaffold/config/initializers/active_record.rb
209
- - lib/generators/templates/scaffold/config/middleware/honeybadger.rb
210
- - lib/generators/templates/scaffold/console
211
- - lib/generators/templates/scaffold/spec/apis/hello_api_spec.rb
212
- - lib/generators/templates/scaffold/spec/factories/.gitkeep
213
- - lib/generators/templates/scaffold/spec/spec_helper.rb
214
253
  - lib/napa.rb
215
254
  - lib/napa/activerecord.rb
216
255
  - lib/napa/authentication.rb
256
+ - lib/napa/cli.rb
257
+ - lib/napa/generators.rb
258
+ - lib/napa/generators/scaffold_generator.rb
259
+ - lib/napa/generators/templates/scaffold/.env
260
+ - lib/napa/generators/templates/scaffold/.env.test
261
+ - lib/napa/generators/templates/scaffold/.gitignore.tt
262
+ - lib/napa/generators/templates/scaffold/.rubocop.yml
263
+ - lib/napa/generators/templates/scaffold/Gemfile
264
+ - lib/napa/generators/templates/scaffold/README.md
265
+ - lib/napa/generators/templates/scaffold/Rakefile
266
+ - lib/napa/generators/templates/scaffold/app.rb
267
+ - lib/napa/generators/templates/scaffold/app/apis/hello_api.rb.tt
268
+ - lib/napa/generators/templates/scaffold/config.ru.tt
269
+ - lib/napa/generators/templates/scaffold/config/database.yml
270
+ - lib/napa/generators/templates/scaffold/config/initializers/active_record.rb
271
+ - lib/napa/generators/templates/scaffold/config/middleware/honeybadger.rb
272
+ - lib/napa/generators/templates/scaffold/console
273
+ - lib/napa/generators/templates/scaffold/spec/apis/hello_api_spec.rb
274
+ - lib/napa/generators/templates/scaffold/spec/factories/.gitkeep
275
+ - lib/napa/generators/templates/scaffold/spec/spec_helper.rb
217
276
  - lib/napa/grape_api.rb
218
277
  - lib/napa/grape_extensions/error_formatter.rb
219
278
  - lib/napa/grape_extensions/error_presenter.rb
@@ -224,6 +283,8 @@ files:
224
283
  - lib/napa/middleware/app_monitor.rb
225
284
  - lib/napa/middleware/authentication.rb
226
285
  - lib/napa/middleware/logger.rb
286
+ - lib/napa/middleware/request_stats.rb
287
+ - lib/napa/stats.rb
227
288
  - lib/napa/version.rb
228
289
  - lib/tasks/db.rake
229
290
  - lib/tasks/deploy.rake
@@ -236,31 +297,34 @@ files:
236
297
  - spec/json_error_spec.rb
237
298
  - spec/logger/log_transaction_spec.rb
238
299
  - spec/middleware/authentication_spec.rb
300
+ - spec/middleware/request_stats_spec.rb
239
301
  - spec/spec_helper.rb
302
+ - spec/stats_spec.rb
240
303
  - spec/version_spec.rb
241
304
  - tasks/version.rake
242
305
  homepage: ''
243
306
  licenses: []
244
- metadata: {}
245
307
  post_install_message:
246
308
  rdoc_options: []
247
309
  require_paths:
248
310
  - lib
249
311
  required_ruby_version: !ruby/object:Gem::Requirement
312
+ none: false
250
313
  requirements:
251
- - - '>='
314
+ - - ! '>='
252
315
  - !ruby/object:Gem::Version
253
316
  version: '0'
254
317
  required_rubygems_version: !ruby/object:Gem::Requirement
318
+ none: false
255
319
  requirements:
256
- - - '>='
320
+ - - ! '>='
257
321
  - !ruby/object:Gem::Version
258
322
  version: '0'
259
323
  requirements: []
260
324
  rubyforge_project:
261
- rubygems_version: 2.1.11
325
+ rubygems_version: 1.8.25
262
326
  signing_key:
263
- specification_version: 4
327
+ specification_version: 3
264
328
  summary: A simple framework for building APIs with Grape
265
329
  test_files:
266
330
  - spec/authentication_spec.rb
@@ -269,5 +333,8 @@ test_files:
269
333
  - spec/json_error_spec.rb
270
334
  - spec/logger/log_transaction_spec.rb
271
335
  - spec/middleware/authentication_spec.rb
336
+ - spec/middleware/request_stats_spec.rb
272
337
  - spec/spec_helper.rb
338
+ - spec/stats_spec.rb
273
339
  - spec/version_spec.rb
340
+ has_rdoc:
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: fd6b925472644eaf0393cce14068d151df8ae98c
4
- data.tar.gz: 6cd4fa2e481c78ffe9a11bca8784ef67c24b0fe0
5
- SHA512:
6
- metadata.gz: 4f950b660d847ea59bc2313c767ea55b3b49bad90f39839a9219f62ce3a8c66264930d3e8b7e8ce19af6b6c5680f4bbd19e6e038f07a26993fc837f62665e085
7
- data.tar.gz: c076d3ca205321e6ba86db23bdf944d873ba069ad3507ce636db6c60e278a536349f648be2783c6fa7a3f92ea476fecb8a1aad6e5f7e0661e63a5ef25430fffc
@@ -1,68 +0,0 @@
1
- module Napa
2
- module Generators
3
- class Scaffold
4
- def initialize(app_name, app_path = nil)
5
- @app_name = app_name
6
- @app_path = app_path.nil? ? app_name : app_path
7
- @template_path = File.expand_path(File.join(File.dirname(__FILE__), 'templates/scaffold'))
8
- @files = file_list
9
-
10
- create_files!
11
-
12
- STDOUT.write "Generator Finished!\n"
13
- end
14
-
15
- def file_list
16
- [
17
- 'app/apis/hello_api.rb',
18
- 'app/models/.keep',
19
- 'config/database.yml',
20
- 'config/initializers/active_record.rb',
21
- 'config/middleware/honeybadger.rb',
22
- 'db/migrate/.keep',
23
- 'lib/tasks/.keep',
24
- 'log/.keep',
25
- 'public/.keep',
26
- 'spec/spec_helper.rb',
27
- 'spec/apis/hello_api_spec.rb',
28
- 'tmp/.keep',
29
- '.env',
30
- '.env.test',
31
- '.rubocop.yml',
32
- '.gitignore.tpl',
33
- 'app.rb',
34
- 'config.ru',
35
- 'console',
36
- 'Gemfile',
37
- 'Rakefile',
38
- 'README.md'
39
- ]
40
- end
41
-
42
- def create_files!
43
- @files.each do |file|
44
- create_file_with_template(file)
45
- end
46
- end
47
-
48
- def create_file_with_template(file)
49
- template_file = [@template_path, file].join('/')
50
- new_file = [@app_name, file.gsub(/.tpl$/, '')].join('/')
51
-
52
- FileUtils.mkdir_p(File.dirname(new_file))
53
-
54
- if File.exists?(template_file)
55
- file_content = File.read(template_file)
56
-
57
- # replace template variables
58
- file_content.gsub!(/{{app_name}}/, @app_name)
59
- File.open(new_file, 'w') { |f| f.write(file_content) }
60
- else
61
- FileUtils.touch(new_file)
62
- end
63
-
64
- STDOUT.write "Creating File: #{new_file}\n"
65
- end
66
- end
67
- end
68
- end