File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -52,19 +52,32 @@ def generate_files
5252 FileUtils . mkdir_p ( application . user_home )
5353 FileUtils . rm_rf ( application . path ( "test/performance" ) )
5454
55- File . write ( application . gemfile , "#{ application . gemfile . read } gem 'spring', '#{ Spring ::VERSION } '\n " )
55+ append_to_file ( application . gemfile , "gem 'spring', '#{ Spring ::VERSION } '" )
5656
5757 if version . needs_testunit?
58- File . write ( application . gemfile , "#{ application . gemfile . read } gem 'spring-commands-testunit'\n " )
58+ append_to_file ( application . gemfile , "gem 'spring-commands-testunit'" )
59+ end
60+
61+ rewrite_file ( application . gemfile ) do |c |
62+ c . sub! ( "https://rubygems.org" , "http://rubygems.org" )
63+ c . gsub! ( /(gem '(byebug|web-console|sdoc|jbuilder)')/ , "# \\ 1" )
64+ c
5965 end
6066
61- File . write ( application . gemfile , application . gemfile . read . sub ( "https://rubygems.org" , "http://rubygems.org" ) )
6267
6368 if application . path ( "bin" ) . exist?
6469 FileUtils . cp_r ( application . path ( "bin" ) , application . path ( "bin_original" ) )
6570 end
6671 end
6772
73+ def rewrite_file ( file )
74+ File . write ( file , yield ( file . read ) )
75+ end
76+
77+ def append_to_file ( file , add )
78+ rewrite_file ( file ) { |c | c << "#{ add } \n " }
79+ end
80+
6881 def generate_if_missing
6982 generate unless application . exists?
7083 end
You can’t perform that action at this time.
0 commit comments