public
Fork of ctran/annotate_models
Description: Annotate ActiveRecord models
Homepage: http://agilewebdevelopment.com/plugins/annotate_models
Clone URL: git://github.com/JackDanger/annotate_models.git
output as binary files to enforce "unix command line" mode.

= In ruby, on windows =
* A text file with CRLF or LF line endings will be opened with UNIX (LF) 
line endings in ruby.
* When writing text to a file, ruby always uses CRLF line endings, 
regardless of the format of the line endings of the file to begin with.

This causes an automatic conversion of all LF files to CRLF.  If you check 
out a project that uses unix line endings, then run annotate_models 
(before this commit), you're SCM is going to want to commit every line of 
every model.

= In ruby, on *nix / osx =
- Strings are always read and written as text with LF line endings.

----

The end result is an endless tug-a-war over line-endings for collaborating 
windows and *nix developers.

If you specify to write the files as binary ("wb"), both windows and *nix 
will output the text with LF line endings.  Most editors on windows 
support this format, and if you're deploying to a linux server, you should 
be using this format anyways.  This has solved the tug-a-war for me.
timcharper (author)
Sat May 17 07:33:10 -0700 2008
commit  b81806401f9b0896d2a28fd3664d4017f1bc6a31
tree    681bc79efe8864b7a58cfb6254bd2f6b892504d9
parent  753091c5623cdce5a58daf97e5448dec8acbdb2a
...
63
64
65
66
 
67
68
69
...
73
74
75
76
 
77
78
79
...
63
64
65
 
66
67
68
69
...
73
74
75
 
76
77
78
79
0
@@ -63,7 +63,7 @@ module AnnotateModels
0
 
0
         # Write it back
0
         new_content = options[:position] == "after" ? (content + "\n" + info_block) : (info_block + content)
0
- File.open(file_name, "w") { |f| f.puts new_content }
0
+ File.open(file_name, "wb") { |f| f.puts new_content }
0
       end
0
     end
0
     
0
@@ -73,7 +73,7 @@ module AnnotateModels
0
 
0
         content.sub!(/^# #{PREFIX}.*?\n(#.*\n)*\n/, '')
0
         
0
- File.open(file_name, "w") { |f| f.puts content }
0
+ File.open(file_name, "wb") { |f| f.puts content }
0
       end
0
     end
0
 

Comments

    No one has commented yet.