Skip to content

Commit c0cdb12

Browse files
Remove api only Gemfile (#54)
* Remove api only Gemfile
1 parent 2443c93 commit c0cdb12

File tree

6 files changed

+19
-72
lines changed

6 files changed

+19
-72
lines changed

lib/file_modifier.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
def api_only_modifications
44
api_remove_files
5+
modify_gemfile_for_api
56
gsub_file "app/controllers/application_controller.rb", /Base/, "API"
67
gsub_file "app/controllers/application_controller.rb", /protect/, "# protect"
78
end
@@ -36,6 +37,18 @@ def api_remove_files
3637
remove_dir "app/assets/stylesheets"
3738
end
3839

40+
def modify_gemfile_for_api
41+
inject_into_file 'Gemfile', after: /taperole.*\n/ do
42+
<<-RUBY
43+
# Use serializers to format json data
44+
# gem 'active_model_serializers'
45+
# Use rack-cors to make CORS requests from the browser client
46+
# gem 'rack-cors', require: 'rack/cors'
47+
RUBY
48+
end
49+
gsub_file 'Gemfile', /.*SCSS.*\n.*\n/, ''
50+
end
51+
3952
def remove_turbolinks
4053
gsub_file 'app/assets/javascripts/application.js', /= require turbolinks/, ''
4154
gsub_file 'app/views/layouts/application.html.erb', /, 'data-turbolinks-track' => true/, ""

lib/files/Gemfile

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
source 'https://rubygems.org'
22

3-
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
43
gem 'rails', '~> 5.0'
54
# Use postgresql as the database for Active Record
65
gem 'pg'
@@ -10,17 +9,14 @@ gem 'sass-rails', '~> 5.0'
109
gem 'uglifier', '>= 1.3.0'
1110
# Use CoffeeScript for .coffee assets and views
1211
gem 'coffee-rails', '~> 4.1.0'
13-
# See https://github.com/rails/execjs#readme for more supported runtimes
1412
# Use jquery as the JavaScript library
1513
gem 'jquery-rails'
16-
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
17-
# gem 'jbuilder', '~> 2.0'
18-
# bundle exec rake doc:rails generates the API under doc/api.
19-
gem 'sdoc', '~> 0.4.0', group: :doc
2014
# Use Puma as the app server
2115
gem 'puma'
2216
# Use Taperole for deployment
2317
gem 'taperole', '~> 2.0'
18+
# Use active_interaction to manage business logic in a service layer
19+
# gem 'active_interaction'
2420

2521
group :development, :test do
2622
# Use rspec as the testing framework

lib/files/Gemfile_api_only

Lines changed: 0 additions & 57 deletions
This file was deleted.

lib/gemfile_configurator.rb

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
require_relative './file_creator.rb'
22

33
def remove_gemfile
4-
remove_file "Gemfile"
4+
remove_file 'Gemfile'
55
end
66

7-
def api_gemfile
8-
file "Gemfile", render_file(path("Gemfile_api_only"))
9-
end
10-
11-
def integrated_app_gemfile
12-
file "Gemfile", render_file(path("Gemfile"))
7+
def render_gemfile
8+
file 'Gemfile', render_file(path('Gemfile'))
139
end
1410

1511
def rails_4_gemfile

lib/installer.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ def api_with_admin_install
1313
end
1414

1515
def integrated_app_install
16-
integrated_app_gemfile
1716
remove_turbolinks
1817
devise?
1918
cucumber_capybara?

template.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
# CREATE TEMPLATE
1010
# -----------------------------
1111
remove_gemfile
12+
render_gemfile
1213
# -----------------------------
1314
# API ONLY APP?
1415
# -----------------------------
1516
if yes?("Is this an API app? (y/n)")
16-
api_gemfile
1717
rails_4_gemfile if rails_4_app?
1818
if yes?("Does this API app have an admin interface? (y/n)")
1919
api_with_admin_install

0 commit comments

Comments
 (0)