winery 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 +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +10 -0
- data/Rakefile +2 -0
- data/bin/winery +14 -0
- data/lib/winery.rb +1 -0
- data/lib/winery/cli.rb +43 -0
- data/lib/winery/extensions.rb +37 -0
- data/lib/winery/version.rb +3 -0
- data/templates/app/.gitignore +4 -0
- data/templates/app/Gemfile +14 -0
- data/templates/app/Procfile +1 -0
- data/templates/app/Rakefile +9 -0
- data/templates/app/app.rb.tt +24 -0
- data/templates/app/app/api.rb.tt +17 -0
- data/templates/app/app/api/v1/.gitkeep +0 -0
- data/templates/app/app/models.rb.tt +8 -0
- data/templates/app/app/models/.gitkeep +0 -0
- data/templates/app/config.ru.tt +3 -0
- data/templates/app/config/boot.rb.tt +11 -0
- data/templates/app/config/unicorn.rb +21 -0
- data/templates/app/db/migrations/.gitkeep +0 -0
- data/templates/app/lib/tasks/db.rb.tt +25 -0
- data/winery.gemspec +25 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9ce5aad4be3d8c648ec4ee58537389f0a0625f39
|
4
|
+
data.tar.gz: 714bca965f004a76620089ced6b7ab71876b5380
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 05abee1cd58f9f363bafdb335e1109af950e864313336f9b6b5b39c2f4ad3cad68a613607c46f39a0fa536866f2f4c839178950adfdb533ce422e69f29c8cf38
|
7
|
+
data.tar.gz: 0572368c35c117f141f1d79b6ba20f7cf4561ffd0ad4318fed386062379f0fb82016a15ad1ac8a16fef79a6841b07904720a8606d10bbdd693b35cf41f61259d
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Artyom Keydunov
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
data/bin/winery
ADDED
data/lib/winery.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "winery/version"
|
data/lib/winery/cli.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'thor'
|
4
|
+
require 'thor/group'
|
5
|
+
require 'winery/extensions'
|
6
|
+
|
7
|
+
module Winery
|
8
|
+
class CLI < Thor::Group
|
9
|
+
include Thor::Actions
|
10
|
+
|
11
|
+
def self.source_root
|
12
|
+
File.expand_path('../../../templates', __FILE__)
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Creates a new Grape application"
|
16
|
+
argument :name, :type => :string, :desc => "The name of the new application"
|
17
|
+
|
18
|
+
def setup
|
19
|
+
@app_path = name.directory_name
|
20
|
+
@name = name.file_name
|
21
|
+
|
22
|
+
options.each do |key, value|
|
23
|
+
instance_variable_set "@#{key.to_s}".to_sym, value
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def create_app
|
28
|
+
directory 'app', @app_path
|
29
|
+
end
|
30
|
+
|
31
|
+
def initialize_git_repo
|
32
|
+
inside(@app_path) do
|
33
|
+
run('git init .')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def install_dependencies
|
38
|
+
inside(@app_path) do
|
39
|
+
run('bundle')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Winery
|
2
|
+
module Extensions
|
3
|
+
module String
|
4
|
+
def camel_case
|
5
|
+
return self.gsub(/^./) { |l| l.capitalize } if !match(/[_-]/)
|
6
|
+
altered_self = self.downcase.capitalize
|
7
|
+
altered_self.scan(/[_-][a-zA-Z]/).each do |match|
|
8
|
+
altered_self.gsub!(match, match[1].upcase)
|
9
|
+
end
|
10
|
+
|
11
|
+
altered_self
|
12
|
+
end
|
13
|
+
|
14
|
+
def camel_case!
|
15
|
+
self.replace camel_case
|
16
|
+
end
|
17
|
+
|
18
|
+
def directory_name
|
19
|
+
self.downcase.gsub(/[^a-z|\-|\_]/, '')
|
20
|
+
end
|
21
|
+
|
22
|
+
def file_name
|
23
|
+
self.gsub(/[\-| ]/, '_').
|
24
|
+
gsub(/([A-Z]+|[A-Z][a-z])/) { |x| "_#{x}" }.
|
25
|
+
sub(/^_/, "").
|
26
|
+
gsub(/_{2,}+/, "_").
|
27
|
+
downcase
|
28
|
+
end
|
29
|
+
|
30
|
+
def file_name!
|
31
|
+
self.replace file_name
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
String.send(:include, Winery::Extensions::String)
|
@@ -0,0 +1 @@
|
|
1
|
+
web: bundle exec unicorn -c ./config/unicorn.rb
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler.require
|
3
|
+
|
4
|
+
# Setup load paths
|
5
|
+
$: << File.expand_path('../', __FILE__)
|
6
|
+
|
7
|
+
require 'config/boot'
|
8
|
+
require 'app/api'
|
9
|
+
require 'app/models'
|
10
|
+
|
11
|
+
module <%= @name.camel_case %>
|
12
|
+
App = Rack::Builder.new do
|
13
|
+
use Rack::Cors do
|
14
|
+
allow do
|
15
|
+
origins "*"
|
16
|
+
resource '*', headers: :any, :methods => [:get, :post, :put, :patch, :delete, :options]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
run API::Root
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
include <%= @name.camel_case %>::Models
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module <%= @name.camel_case %>
|
2
|
+
module API
|
3
|
+
module V1
|
4
|
+
# Other APIs:
|
5
|
+
# autoload :Posts, 'app/api/v1/posts'
|
6
|
+
end
|
7
|
+
|
8
|
+
class Root < Grape::API
|
9
|
+
format :json
|
10
|
+
|
11
|
+
# mount APIs:
|
12
|
+
# version 'v1', using: :path do
|
13
|
+
# mount V1::Posts
|
14
|
+
# end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module <%= @name.camel_case %>
|
2
|
+
def self.root
|
3
|
+
@root ||= File.expand_path("../", __FILE__)
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.env
|
7
|
+
@env ||= (ENV['RACK_ENV'] || 'development').to_sym
|
8
|
+
end
|
9
|
+
|
10
|
+
DB = Sequel.connect ENV["DATABASE_URL"] || "postgres://localhost:5432/<%= @name.file_name %>_#{env}"
|
11
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
worker_processes Integer(ENV['UNICORN_WORKERS'] || 4)
|
2
|
+
timeout 30
|
3
|
+
preload_app true
|
4
|
+
listen(ENV['PORT'] || 3000, :backlog => Integer(ENV['UNICORN_BACKLOG'] || 200))
|
5
|
+
|
6
|
+
before_fork do |server, worker|
|
7
|
+
Signal.trap 'TERM' do
|
8
|
+
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
|
9
|
+
Process.kill 'QUIT', Process.pid
|
10
|
+
end
|
11
|
+
|
12
|
+
if defined?(Sequel::Model)
|
13
|
+
Sequel::DATABASES.each{ |db| db.disconnect }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
after_fork do |server, worker|
|
18
|
+
Signal.trap 'TERM' do
|
19
|
+
puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to sent QUIT'
|
20
|
+
end
|
21
|
+
end
|
File without changes
|
@@ -0,0 +1,25 @@
|
|
1
|
+
namespace :db do
|
2
|
+
desc 'Run DB migrations'
|
3
|
+
task :migrate => :app do
|
4
|
+
require 'sequel/extensions/migration'
|
5
|
+
|
6
|
+
Sequel::Migrator.apply(<%= @name.camel_case %>::DB, 'db/migrations')
|
7
|
+
end
|
8
|
+
|
9
|
+
desc 'Rollback migration'
|
10
|
+
task :rollback => :app do
|
11
|
+
require 'sequel/extensions/migration'
|
12
|
+
database = <%= @name.camel_case %>::DB
|
13
|
+
|
14
|
+
version = (row = database[:schema_info].first) ? row[:version] : nil
|
15
|
+
Sequel::Migrator.apply(database, 'db/migrations', version - 1)
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'Dump the database schema'
|
19
|
+
task :dump => :app do
|
20
|
+
database = <%= @name.camel_case %>::DB
|
21
|
+
|
22
|
+
`sequel -d #{database.url} > db/schema.rb`
|
23
|
+
`pg_dump --schema-only #{database.url} > db/schema.sql`
|
24
|
+
end
|
25
|
+
end
|
data/winery.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 'winery/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "winery"
|
8
|
+
spec.version = Winery::VERSION
|
9
|
+
spec.authors = ["Artyom Keydunov"]
|
10
|
+
spec.email = ["artyom.keydunov@gmail.com"]
|
11
|
+
spec.summary = %q{Generator for building APIs with Grape.}
|
12
|
+
spec.description = %q{Generator for building APIs with Grape.}
|
13
|
+
spec.homepage = "http://github.com/keydunov/winery"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
|
24
|
+
spec.add_dependency 'thor'
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: winery
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Artyom Keydunov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-18 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.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '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'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Generator for building APIs with Grape.
|
56
|
+
email:
|
57
|
+
- artyom.keydunov@gmail.com
|
58
|
+
executables:
|
59
|
+
- winery
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/winery
|
69
|
+
- lib/winery.rb
|
70
|
+
- lib/winery/cli.rb
|
71
|
+
- lib/winery/extensions.rb
|
72
|
+
- lib/winery/version.rb
|
73
|
+
- templates/app/.gitignore
|
74
|
+
- templates/app/Gemfile
|
75
|
+
- templates/app/Procfile
|
76
|
+
- templates/app/Rakefile
|
77
|
+
- templates/app/app.rb.tt
|
78
|
+
- templates/app/app/api.rb.tt
|
79
|
+
- templates/app/app/api/v1/.gitkeep
|
80
|
+
- templates/app/app/models.rb.tt
|
81
|
+
- templates/app/app/models/.gitkeep
|
82
|
+
- templates/app/config.ru.tt
|
83
|
+
- templates/app/config/boot.rb.tt
|
84
|
+
- templates/app/config/unicorn.rb
|
85
|
+
- templates/app/db/migrations/.gitkeep
|
86
|
+
- templates/app/lib/tasks/db.rb.tt
|
87
|
+
- winery.gemspec
|
88
|
+
homepage: http://github.com/keydunov/winery
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.2.2
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: Generator for building APIs with Grape.
|
112
|
+
test_files: []
|