-
Notifications
You must be signed in to change notification settings - Fork 3
/
rails-clean-architecture.rb
92 lines (82 loc) · 2.07 KB
/
rails-clean-architecture.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
gem 'hashie'
gem 'pg'
gem 'tilt'
gem 'tilt-handlebars'
gem 'unicorn'
gem_group :development, :test do
gem 'byebug'
gem 'rspec-rails'
end
gsub_file 'Gemfile', /^gem\s+["']sqlite3["'].*\n/, ''
gsub_file 'Gemfile', /^gem\s+["']jbuilder["'].*\n/, ''
gsub_file 'Gemfile', /^gem\s+["']sdoc["'].*\n/, ''
gsub_file 'Gemfile', /^#.*\n/, ''
gsub_file 'Gemfile', /^$\n/, ''
gsub_file 'Gemfile', /"/, '\''
environment <<-CODE
config.generators do |g|
g.orm :active_record
g.stylesheets false
g.javascripts false
g.controller :clean_controller
g.view_specs false
g.helper_specs false
end
CODE
# Remove assets/views
run 'rm -r app/assets app/models app/views lib/assets'
def source_paths
Array(super) +
[File.join(File.expand_path(File.dirname(__FILE__)),'rails_root')]
end
remove_file '.gitignore'
copy_file '.gitignore'
inside 'config' do
remove_file 'database.yml'
template 'database.example.yml'
run "ln -s database.example.yml database.yml"
end
inside 'lib' do
inside 'entities' do
copy_file 'entity.rb'
end
inside 'generators' do
inside 'entity' do
copy_file 'entity_generator.rb'
end
inside 'interactor' do
copy_file 'interactor_generator.rb'
end
end
inside 'interactors' do
copy_file 'interactor.rb'
end
copy_file 'request.rb'
copy_file 'response.rb'
inside 'templates' do
inside 'rails' do
inside 'controller' do
copy_file 'controller.rb'
end
end
end
end
inside 'spec' do
copy_file 'spec_helper.rb'
inside 'support' do
copy_file 'entity_shared_examples.rb'
copy_file 'interactor_shared_examples.rb'
end
end
puts
puts 'Clean Architecture Rails app generated!'
puts
puts 'Now you should:'
puts
puts '1. cd ' + @app_name
puts '2. bundle'
puts '3. Check config/database.yml'
puts '4. Generate entities with "rails generate entity *name*"'
puts '7. Generate interactors with "rails generate interactor *name*"'
puts '8. Add tests and production code and test with rspec'
puts '9. Add routes, controller actions, and handlebars templates'