mvc_one 0.1.0.pre.rc7 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.idea/mvc_one.iml +5 -33
- data/.rubocop.yml +9 -32
- data/CHANGELOG.md +0 -1
- data/Gemfile +6 -7
- data/Gemfile.lock +3 -89
- data/Rakefile +3 -3
- data/exe/mvc_one +7 -86
- data/lib/mvc_one/version.rb +1 -1
- data/lib/mvc_one.rb +3 -3
- data/mvc_one.gemspec +15 -25
- metadata +8 -156
- data/lib/mvc_one/application.rb +0 -56
- data/lib/mvc_one/contracts/application_contract.rb +0 -9
- data/lib/mvc_one/controllers/application_controller.rb +0 -75
- data/lib/mvc_one/models/application_model.rb +0 -13
- data/lib/mvc_one/regexp_router.rb +0 -131
- data/lib/mvc_one/repositories/application_relation.rb +0 -37
- data/lib/mvc_one/repositories/application_repository.rb +0 -20
- data/lib/mvc_one/serializers/application_serializer.rb +0 -143
- data/lib/mvc_one/views/404.slim +0 -12
- data/templates/app/application_layout.slim +0 -9
- data/templates/app/controller_template.erb +0 -50
- data/templates/app/model_template.erb +0 -5
- data/templates/app/welcome_controller_rb.erb +0 -7
- data/templates/app/welcome_index.slim +0 -2
- data/templates/config/routes_rb.erb +0 -12
- data/templates/general/application_rb.erb +0 -7
- data/templates/general/config_ru.erb +0 -11
- data/templates/general/database_yml.erb +0 -12
- data/templates/general/gemfile.erb +0 -7
- data/templates/general/rakefile.erb +0 -75
- data/templates/general/secrets_yml.erb +0 -4
data/lib/mvc_one/views/404.slim
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Controller for <%= name.capitalize%>
|
4
|
-
class <%= name.capitalize%>Controller < ApplicationController
|
5
|
-
def index
|
6
|
-
projects = <%= name.capitalize%>Repository.all
|
7
|
-
# serialize here
|
8
|
-
end
|
9
|
-
|
10
|
-
def create
|
11
|
-
contract = <%= name.capitalize%>Contract.new.call(request_params)
|
12
|
-
if contract.failure?
|
13
|
-
return render(
|
14
|
-
code: 422, body: contract.errors.to_h.to_json,
|
15
|
-
headers: { 'content-type' => 'application/json' }
|
16
|
-
)
|
17
|
-
end
|
18
|
-
|
19
|
-
<%= name%> = <%= name.capitalize%>Repository.create(contract.to_h)
|
20
|
-
render code: 201, body: <%= name%>.to_h.to_json, headers: { 'content-type' => 'application/json' }
|
21
|
-
end
|
22
|
-
|
23
|
-
def update
|
24
|
-
contract = <%= name.capitalize%>Contract.new.call(request_params)
|
25
|
-
if contract.success?
|
26
|
-
<%= name.capitalize%>Repository.update(params[:id], contract.to_h)
|
27
|
-
|
28
|
-
head 204
|
29
|
-
else
|
30
|
-
render code: 422, body: contract.errors
|
31
|
-
end
|
32
|
-
rescue ApplicationRepository::NotFoundRecord
|
33
|
-
head 404
|
34
|
-
end
|
35
|
-
|
36
|
-
def delete
|
37
|
-
<%= name.capitalize%>Repository.delete(params[:id])
|
38
|
-
|
39
|
-
head 204
|
40
|
-
rescue ApplicationRepository::NotFoundRecord
|
41
|
-
head 404
|
42
|
-
end
|
43
|
-
|
44
|
-
def show
|
45
|
-
<%= name%> = <%= name%>Repository.find(id: params[:id])
|
46
|
-
#serialize here
|
47
|
-
rescue ApplicationRepository::NotFoundRecord
|
48
|
-
head 404
|
49
|
-
end
|
50
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
lambda do
|
4
|
-
any to: 'welcome#index'
|
5
|
-
|
6
|
-
# Example
|
7
|
-
# get '/api/v1/users', to: 'api#v1#users#index'
|
8
|
-
# get '/api/v1/users/:id', to: 'api#v1#users#show'
|
9
|
-
# patch '/api/v1/users/:id', to: 'api#v1#users#update'
|
10
|
-
# delete '/api/v1/users/:id', to: 'api#v1#users#delete'
|
11
|
-
# post '/api/v1/users', to: 'api#v1#users#create'
|
12
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
development:
|
2
|
-
db:
|
3
|
-
name: '<%= name_normalized%>.db'
|
4
|
-
adapter: 'sqlite'
|
5
|
-
connection_line: 'sqlite://db/<%= name_normalized%>.db'
|
6
|
-
path: './db/<%= name_normalized%>.db'
|
7
|
-
test:
|
8
|
-
db:
|
9
|
-
name: '<%= name_normalized%>.db'
|
10
|
-
adapter: 'sqlite'
|
11
|
-
connection_line: 'sqlite://db/test_<%= name_normalized%>.db'
|
12
|
-
path: './db/test_<%= name_normalized%>.db'
|
@@ -1,75 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'bundler'
|
4
|
-
|
5
|
-
Bundler.require
|
6
|
-
|
7
|
-
require './application'
|
8
|
-
|
9
|
-
task :default do
|
10
|
-
puts 'Hello from default task!'
|
11
|
-
end
|
12
|
-
|
13
|
-
namespace :db do
|
14
|
-
# http://sequel.jeremyevans.net/documentation.html
|
15
|
-
desc 'Create database'
|
16
|
-
task :create do
|
17
|
-
SQLite3::Database.open(ApplicationRepository.db_config['db']['path'])
|
18
|
-
end
|
19
|
-
|
20
|
-
desc 'Drop database'
|
21
|
-
task :drop do
|
22
|
-
File.delete(ApplicationRepository.db_config['db']['path'])
|
23
|
-
end
|
24
|
-
|
25
|
-
desc 'Migrate database'
|
26
|
-
task :migrate do
|
27
|
-
Sequel.extension :migration
|
28
|
-
Sequel::Migrator.run(ApplicationRepository::DB, 'db/migrations')
|
29
|
-
end
|
30
|
-
|
31
|
-
desc 'Rollback database'
|
32
|
-
task :rollback do
|
33
|
-
Sequel.extension :migration
|
34
|
-
steps = ENV['STEPS'].nil? ? 1 : ENV['STEPS'].to_i
|
35
|
-
Sequel::Migrator.run(ApplicationRepository::DB, 'db/migrations', relative: steps * -1)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
namespace :app do
|
40
|
-
desc 'Run controllers test'
|
41
|
-
task :console do
|
42
|
-
require 'rubygems'
|
43
|
-
require 'bundler'
|
44
|
-
require 'securerandom'
|
45
|
-
require 'irb'
|
46
|
-
|
47
|
-
Bundler.require
|
48
|
-
|
49
|
-
require './application'
|
50
|
-
|
51
|
-
ARGV.clear
|
52
|
-
IRB.start
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
namespace :test do
|
57
|
-
require 'rake'
|
58
|
-
require 'rspec/core/rake_task'
|
59
|
-
|
60
|
-
desc 'Run all test'
|
61
|
-
task :all do
|
62
|
-
RSpec::Core::RakeTask.new(:spec) do |t|
|
63
|
-
t.pattern = 'spec/**/*_spec.rb'
|
64
|
-
end
|
65
|
-
Rake::Task['spec'].execute
|
66
|
-
end
|
67
|
-
|
68
|
-
desc 'Run controllers test'
|
69
|
-
task :controllers do
|
70
|
-
RSpec::Core::RakeTask.new(:spec) do |t|
|
71
|
-
t.pattern = 'spec/controllers/**/*_spec.rb'
|
72
|
-
end
|
73
|
-
Rake::Task['spec'].execute
|
74
|
-
end
|
75
|
-
end
|
@@ -1,4 +0,0 @@
|
|
1
|
-
development:
|
2
|
-
session_cookie: "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
|
3
|
-
test:
|
4
|
-
session_cookie: "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
|