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
52
52
FileUtils . mkdir_p ( application . user_home )
53
53
FileUtils . rm_rf ( application . path ( "test/performance" ) )
54
54
55
- File . write ( application . gemfile , "#{ application . gemfile . read } gem 'spring', '#{ Spring ::VERSION } '\n " )
55
+ append_to_file ( application . gemfile , "gem 'spring', '#{ Spring ::VERSION } '" )
56
56
57
57
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
59
65
end
60
66
61
- File . write ( application . gemfile , application . gemfile . read . sub ( "https://rubygems.org" , "http://rubygems.org" ) )
62
67
63
68
if application . path ( "bin" ) . exist?
64
69
FileUtils . cp_r ( application . path ( "bin" ) , application . path ( "bin_original" ) )
65
70
end
66
71
end
67
72
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
+
68
81
def generate_if_missing
69
82
generate unless application . exists?
70
83
end
You can’t perform that action at this time.
0 commit comments