File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed
lib/rails/generators/rails/app Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change
1
+ * Commented out lines in .railsrc file should not be treated as arguments when using
2
+ rails new generator command. Update ARGVScrubber to ignore text after # symbols.
3
+
4
+ * Willian Tenfen*
5
+
1
6
* Skip CSS when generating APIs.
2
7
3
8
* Ruy Rocha*
Original file line number Diff line number Diff line change @@ -658,7 +658,7 @@ def railsrc(argv)
658
658
end
659
659
660
660
def read_rc_file ( railsrc )
661
- extra_args = File . readlines ( railsrc ) . flat_map ( & : split)
661
+ extra_args = File . readlines ( railsrc ) . flat_map . each { | line | line . split ( "#" , 2 ) . first . split }
662
662
puts "Using #{ extra_args . join ( " " ) } from #{ railsrc } "
663
663
extra_args
664
664
end
Original file line number Diff line number Diff line change @@ -108,6 +108,23 @@ def test_rc_whitespace_separated
108
108
file . unlink
109
109
end
110
110
111
+ def test_rc_lines_with_comments
112
+ file = Tempfile . new "myrcfile"
113
+ file . puts "--hello # --world"
114
+ file . puts "--love"
115
+ file . puts "# --hate"
116
+ file . flush
117
+
118
+ scrubber = Class . new ( ARGVScrubber ) {
119
+ define_method ( :puts ) { |msg | }
120
+ } . new [ "new" , "--rc=#{ file . path } " ]
121
+ args = scrubber . prepare!
122
+ assert_equal [ "--hello" , "--love" ] , args
123
+ ensure
124
+ file . close
125
+ file . unlink
126
+ end
127
+
111
128
def test_new_rc_option
112
129
file = Tempfile . new "myrcfile"
113
130
file . puts "--hello-world"
You can’t perform that action at this time.
0 commit comments