Changeset 1085
- Timestamp:
- 12/12/07 19:28:14 (1 year ago)
- Files:
-
- trunk/lib/merb/core_ext/string.rb (modified) (1 diff)
- trunk/lib/merb/server.rb (modified) (1 diff)
- trunk/spec/merb/core_ext_spec.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/merb/core_ext/string.rb
r1046 r1085 49 49 # #=> " Hello\n Bob\n How are you?" 50 50 def indent(indentation) 51 lines = to_a 52 initial_indentation = lines.first.scan(/^(\s+)/).flatten.first 53 lines.map do |line| 54 if initial_indentation.nil? 55 " " * indentation + line 56 elsif line.index(initial_indentation) == 0 57 " " * indentation + line[initial_indentation.size..-1] 58 else 59 " " * indentation + line 60 end 61 end.join 51 match(/\s*/) && gsub(/^\s{0,#{$&.length}}/, " " * indentation) 62 52 end 63 64 53 end trunk/lib/merb/server.rb
r1070 r1085 179 179 options[:generate] = File.expand_path(argv.last) 180 180 end 181 181 182 182 # Load up the configuration from file, but keep the command line 183 183 # options that may have been chosen. Also, pass-through if we have trunk/spec/merb/core_ext_spec.rb
r1021 r1085 402 402 end.should_not raise_error(Timeout::Error) 403 403 end 404 405 it "should remove any indentation and add +indentation+ number of spaces" do 406 "foo\n bar\n".indent(3).should == " foo\n bar\n" 407 " foo\n bar\n".indent(3).should == " foo\n bar\n" 408 end 404 409 end 405 410
