napa 0.1.26 → 0.1.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/bin/napa +1 -1
- data/lib/napa.rb +2 -1
- data/lib/napa/cli.rb +37 -8
- data/lib/napa/generators.rb +1 -0
- data/lib/napa/generators/api_generator.rb +0 -1
- data/lib/napa/generators/migration_generator.rb +26 -0
- data/lib/napa/generators/templates/api/app/apis/%name_tableize%_api.rb.tt +1 -1
- data/lib/napa/generators/templates/api/app/entities/%name_underscore%_entity.rb.tt +1 -1
- data/lib/napa/generators/templates/migration/%migration_filename%.rb.tt +7 -0
- data/lib/napa/grape_extenders.rb +1 -1
- data/lib/napa/grape_extensions/entity.rb +11 -0
- data/lib/napa/identity.rb +9 -2
- data/lib/napa/middleware/app_monitor.rb +1 -1
- data/lib/napa/version.rb +1 -1
- data/lib/tasks/db.rake +0 -30
- data/spec/identity_spec.rb +2 -2
- metadata +5 -3
- data/lib/napa/activerecord.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 921842df68ddfd43053accc0281962d797225ced
|
4
|
+
data.tar.gz: 892d34f1952b7e73dba7dff8f485d2930d6b39ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b9c94ad04f33374ffc54ec532ef07de33e915f03c5353e50d0ad43e823ff22d0dd731c2b8fd1917faf747945e68a43cc4f73fb6b401b75d37de3ea89bae4c46
|
7
|
+
data.tar.gz: 651d69ad11fa10824d704f0c87b268f9e4a5c997b7408f483e04472f8c54d0a8844d9789d9b6a27317d5a1a191559ae721ae8f1cfcc4e0786024253acbde1c02
|
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
[![Build Status](https://travis-ci.org/bellycard/napa.png?branch=master)](https://travis-ci.org/bellycard/napa)
|
2
|
+
[![Dependency Status](https://gemnasium.com/bellycard/napa.png)](https://gemnasium.com/bellycard/napa)
|
2
3
|
|
3
4
|
# Napa
|
4
5
|
|
@@ -195,4 +196,4 @@ The Health Check middleware will add an endpoint at `/health` that will return s
|
|
195
196
|
|
196
197
|
## Todo/Feature Requests
|
197
198
|
|
198
|
-
* Add specs for logger and logging middleware
|
199
|
+
* Add specs for logger and logging middleware
|
data/bin/napa
CHANGED
data/lib/napa.rb
CHANGED
@@ -4,6 +4,7 @@ require 'dotenv'
|
|
4
4
|
require 'logging'
|
5
5
|
require 'octokit'
|
6
6
|
require 'grape'
|
7
|
+
require 'grape-entity'
|
7
8
|
require 'json'
|
8
9
|
|
9
10
|
# require internal files
|
@@ -17,12 +18,12 @@ require 'napa/stats'
|
|
17
18
|
require 'napa/active_record_extensions/filter_by_hash'
|
18
19
|
require 'napa/grape_extensions/error_formatter'
|
19
20
|
require 'napa/grape_extensions/error_presenter'
|
21
|
+
require 'napa/grape_extensions/entity'
|
20
22
|
require 'napa/grape_extenders'
|
21
23
|
require 'napa/middleware/logger'
|
22
24
|
require 'napa/middleware/app_monitor'
|
23
25
|
require 'napa/middleware/authentication'
|
24
26
|
require 'napa/middleware/request_stats'
|
25
|
-
require 'napa/activerecord'
|
26
27
|
require 'napa/authentication'
|
27
28
|
|
28
29
|
# load rake tasks if Rake installed
|
data/lib/napa/cli.rb
CHANGED
@@ -1,16 +1,45 @@
|
|
1
1
|
require 'thor'
|
2
2
|
require 'napa/generators'
|
3
|
+
require 'napa/version'
|
3
4
|
|
4
5
|
module Napa
|
5
|
-
class CLI
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
class CLI
|
7
|
+
class Generate < Thor
|
8
|
+
register(
|
9
|
+
Generators::ApiGenerator,
|
10
|
+
'api',
|
11
|
+
'api <api_name>',
|
12
|
+
'Create a Grape API, Model and Entity'
|
13
|
+
)
|
14
|
+
|
15
|
+
register(
|
16
|
+
Generators::MigrationGenerator,
|
17
|
+
'migration',
|
18
|
+
'migration <migration_name>',
|
19
|
+
'Create a Database Migration'
|
20
|
+
)
|
9
21
|
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class CLI
|
25
|
+
class Base < Thor
|
26
|
+
desc "version", "Shows the Napa version number"
|
27
|
+
def version
|
28
|
+
say Napa::VERSION
|
29
|
+
end
|
10
30
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
31
|
+
register(
|
32
|
+
Generators::ScaffoldGenerator,
|
33
|
+
'new',
|
34
|
+
'new <app_name> [app_path]',
|
35
|
+
'Create a scaffold for a new Napa service'
|
36
|
+
)
|
37
|
+
|
38
|
+
desc "generate api <api_name>", "Create a Grape API, Model and Entity"
|
39
|
+
subcommand "generate api", Napa::CLI::Generate
|
40
|
+
|
41
|
+
desc "generate migration <migration_name>", "Create a Database Migration"
|
42
|
+
subcommand "generate", Napa::CLI::Generate
|
43
|
+
end
|
15
44
|
end
|
16
45
|
end
|
data/lib/napa/generators.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'active_support/all'
|
3
|
+
|
4
|
+
module Napa
|
5
|
+
module Generators
|
6
|
+
class MigrationGenerator < Thor::Group
|
7
|
+
include Thor::Actions
|
8
|
+
argument :migration_name
|
9
|
+
|
10
|
+
def version
|
11
|
+
Time.now.utc.to_s.gsub(':','').gsub('-','').gsub('UTC','').gsub(' ','')
|
12
|
+
end
|
13
|
+
|
14
|
+
def migration_filename
|
15
|
+
"#{version}_#{migration_name}"
|
16
|
+
end
|
17
|
+
|
18
|
+
def migration
|
19
|
+
self.class.source_root "#{File.dirname(__FILE__)}/templates/migration"
|
20
|
+
say 'Generating migration...'
|
21
|
+
directory '.', './db/migrate'
|
22
|
+
say 'Done!', :green
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -34,7 +34,7 @@ class <%= name.classify.pluralize %>Api < Grape::API
|
|
34
34
|
put do
|
35
35
|
# fetch <%= name.underscore %> record and update attributes. exceptions caught in app.rb
|
36
36
|
<%= name.underscore %> = <%= name.classify %>.find(params[:id])
|
37
|
-
<%= name.underscore %>.update_attributes!(declared(params, include_missing: false)
|
37
|
+
<%= name.underscore %>.update_attributes!(declared(params, include_missing: false)
|
38
38
|
present <%= name.underscore %>, with: <%= name.classify %>Entity
|
39
39
|
end
|
40
40
|
end
|
data/lib/napa/grape_extenders.rb
CHANGED
@@ -9,7 +9,7 @@ module Napa
|
|
9
9
|
rack_response(Napa::JsonError.new(:record_not_found, 'record not found').to_json, 404)
|
10
10
|
end
|
11
11
|
modified_class.rescue_from ::ActiveRecord::RecordInvalid do |e|
|
12
|
-
rack_response(Napa::JsonError.new(:record_invalid, 'record not found').to_json,
|
12
|
+
rack_response(Napa::JsonError.new(:record_invalid, 'record not found').to_json, 400)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
data/lib/napa/identity.rb
CHANGED
@@ -7,7 +7,7 @@ module Napa
|
|
7
7
|
revision: revision,
|
8
8
|
pid: pid,
|
9
9
|
parent_pid: parent_pid,
|
10
|
-
|
10
|
+
platform: platform
|
11
11
|
}
|
12
12
|
end
|
13
13
|
|
@@ -31,7 +31,14 @@ module Napa
|
|
31
31
|
@ppid ||= Process.ppid
|
32
32
|
end
|
33
33
|
|
34
|
-
def self.
|
34
|
+
def self.platform
|
35
|
+
{
|
36
|
+
version: platform_revision,
|
37
|
+
name: "Napa"
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.platform_revision
|
35
42
|
Napa::VERSION
|
36
43
|
end
|
37
44
|
end
|
data/lib/napa/version.rb
CHANGED
data/lib/tasks/db.rake
CHANGED
@@ -36,36 +36,6 @@ unless defined?(Rails)
|
|
36
36
|
Rake::Task["db:schema:load"].invoke
|
37
37
|
end
|
38
38
|
|
39
|
-
namespace :generate do
|
40
|
-
desc "Generate a migration with given name. Specify migration name with NAME=my_migration_name"
|
41
|
-
task :migration => :environment do
|
42
|
-
raise "Please specify desired migration name with NAME=my_migration_name" unless ENV['NAME']
|
43
|
-
|
44
|
-
# Find migration name from env
|
45
|
-
migration_name = ENV['NAME'].strip.chomp
|
46
|
-
|
47
|
-
# Define migrations path (needed later)
|
48
|
-
migrations_path = './db/migrate'
|
49
|
-
|
50
|
-
# timestamp the migration
|
51
|
-
version = Time.now.utc.to_s.gsub(':','').gsub('-','').gsub('UTC','').gsub(' ','')
|
52
|
-
|
53
|
-
# Use the migration template to fill the body of the migration
|
54
|
-
migration_content = Napa::ActiveRecord.migration_template(migration_name.camelize)
|
55
|
-
|
56
|
-
# Generate migration filename
|
57
|
-
migration_filename = "#{version}_#{migration_name}.rb"
|
58
|
-
|
59
|
-
# Write the migration
|
60
|
-
File.open(File.join(migrations_path, migration_filename), "w+") do |migration|
|
61
|
-
migration.puts migration_content
|
62
|
-
end
|
63
|
-
|
64
|
-
# Done!
|
65
|
-
puts "Successfully created migration #{migration_filename}"
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
39
|
namespace :schema do
|
70
40
|
desc "Create a db/schema.rb file that can be portably used against any DB supported by AR"
|
71
41
|
task :dump => :environment do
|
data/spec/identity_spec.rb
CHANGED
@@ -42,9 +42,9 @@ describe Napa::Identity do
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
context '#
|
45
|
+
context '#platform_revision' do
|
46
46
|
it 'returns the current version of the platform gem' do
|
47
|
-
Napa::Identity.
|
47
|
+
Napa::Identity.platform_revision.should == Napa::VERSION
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: napa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.28
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darby Frey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -252,15 +252,16 @@ files:
|
|
252
252
|
- bin/napa
|
253
253
|
- lib/napa.rb
|
254
254
|
- lib/napa/active_record_extensions/filter_by_hash.rb
|
255
|
-
- lib/napa/activerecord.rb
|
256
255
|
- lib/napa/authentication.rb
|
257
256
|
- lib/napa/cli.rb
|
258
257
|
- lib/napa/generators.rb
|
259
258
|
- lib/napa/generators/api_generator.rb
|
259
|
+
- lib/napa/generators/migration_generator.rb
|
260
260
|
- lib/napa/generators/scaffold_generator.rb
|
261
261
|
- lib/napa/generators/templates/api/app/apis/%name_tableize%_api.rb.tt
|
262
262
|
- lib/napa/generators/templates/api/app/entities/%name_underscore%_entity.rb.tt
|
263
263
|
- lib/napa/generators/templates/api/app/models/%name_underscore%.rb.tt
|
264
|
+
- lib/napa/generators/templates/migration/%migration_filename%.rb.tt
|
264
265
|
- lib/napa/generators/templates/scaffold/.env.test.tt
|
265
266
|
- lib/napa/generators/templates/scaffold/.env.tt
|
266
267
|
- lib/napa/generators/templates/scaffold/.gitignore.tt
|
@@ -281,6 +282,7 @@ files:
|
|
281
282
|
- lib/napa/generators/templates/scaffold/spec/factories/.gitkeep
|
282
283
|
- lib/napa/generators/templates/scaffold/spec/spec_helper.rb
|
283
284
|
- lib/napa/grape_extenders.rb
|
285
|
+
- lib/napa/grape_extensions/entity.rb
|
284
286
|
- lib/napa/grape_extensions/error_formatter.rb
|
285
287
|
- lib/napa/grape_extensions/error_presenter.rb
|
286
288
|
- lib/napa/identity.rb
|
data/lib/napa/activerecord.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
module Napa
|
2
|
-
class ActiveRecord
|
3
|
-
class << self
|
4
|
-
def migration_template(migration_class)
|
5
|
-
<<-MIGRATION
|
6
|
-
class #{migration_class} < ActiveRecord::Migration
|
7
|
-
def up
|
8
|
-
# create_table :foo do |t|
|
9
|
-
# t.string :name, :null => false
|
10
|
-
# end
|
11
|
-
end
|
12
|
-
|
13
|
-
def down
|
14
|
-
# drop_table :foo
|
15
|
-
end
|
16
|
-
end
|
17
|
-
MIGRATION
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|