I haven''t been able to find the answer to my question by Googling, possibly because "gzip" is everywhere on the web. The context of my question is: deploying a Ruby on Rails application onto a system with limited (flash) storage. I am aware of the various compressed filesystems available, but I''m considering other approaches. Is it possible to deploy a Rails application with all/some of it''s source .rb, .rhtml, .css and .js files gzipped to save space? e.g. If foo.rb can''t be found, foo.rb.gz should be read instead. So long as the .rb and .rhtml files do need to be accessed randomly, there should be no need to gunzip the file in place. These are text files, so 3:1 compression may be possible. I have a feeling (as functions are first class objects in Ruby) that it may be possible to redefine a few IO functions to achieve this. Any hints would be welcome. Regards, Chris. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Chris Dew wrote:> I haven''t been able to find the answer to my question by Googling, > possibly because "gzip" is everywhere on the web. > > The context of my question is: deploying a Ruby on Rails application > onto a system with limited (flash) storage. I am aware of the various > compressed filesystems available, but I''m considering other > approaches. > > Is it possible to deploy a Rails application with all/some of it''s > source .rb, .rhtml, .css and .js files gzipped to save space?Try looking at changing methods def read_template_file(template_path, extension) or def render_template(template_extension, template, file_path = nil, local_assigns = {}) #:nodoc: in actionpack/lib/action_view/base.rb> > e.g. If foo.rb can''t be found, foo.rb.gz should be read instead. So > long as the .rb and .rhtml files do need to be accessed randomly, > there should be no need to gunzip the file in place.You lost me with that one. I''m looking at ActionPack version 1.12.5 here. You may have a different version. Maybe it''s a one-liner. Stephan -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Feb 27, 11:02 pm, Stephan Wehner <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Chris Dew wrote: > > I haven''t been able to find the answer to my question by Googling, > > possibly because "gzip" is everywhere on the web. > > > The context of my question is: deploying a Ruby on Rails application > > onto a system with limited (flash) storage. I am aware of the various > > compressed filesystems available, but I''m considering other > > approaches. > > > Is it possible to deploy a Rails application with all/some of it''s > > source .rb, .rhtml, .css and .js files gzipped to save space? > > Try looking at changing methods > > def read_template_file(template_path, extension) > > or > > def render_template(template_extension, template, file_path = nil, > local_assigns = {}) #:nodoc: > > in > > actionpack/lib/action_view/base.rb > > > > > e.g. If foo.rb can''t be found, foo.rb.gz should be read instead. So > > long as the .rb and .rhtml files do need to be accessed randomly, > > there should be no need to gunzip the file in place. > > You lost me with that one.If you just read a short file into memory, you can just gunzip the contents as you read them, not changing anything on disk. If you need random access (read or write), you would need to gunzip the file to temporary storage (perhaps the disk), perform the operations, then gzip the file up again when finished.> > I''m looking at ActionPack version 1.12.5 here. You may have a different > version. > > Maybe it''s a one-liner. > > Stephan > > -- > Posted viahttp://www.ruby-forum.com/.Thanks for your reply, Chris. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I think you''ll find the Output Compression plugin [ http://wiki.rubyonrails.org/rails/pages/Output+Compression+Plugin] does what you''re looking for. I was playing around with it and looking at the results in Firebug and it looked good. RSL On 2/27/07, Chris Dew <cmsdew-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> > > I haven''t been able to find the answer to my question by Googling, > possibly because "gzip" is everywhere on the web. > > The context of my question is: deploying a Ruby on Rails application > onto a system with limited (flash) storage. I am aware of the various > compressed filesystems available, but I''m considering other > approaches. > > Is it possible to deploy a Rails application with all/some of it''s > source .rb, .rhtml, .css and .js files gzipped to save space? > > e.g. If foo.rb can''t be found, foo.rb.gz should be read instead. So > long as the .rb and .rhtml files do need to be accessed randomly, > there should be no need to gunzip the file in place. > > These are text files, so 3:1 compression may be possible. > > I have a feeling (as functions are first class objects in Ruby) that > it may be possible to redefine a few IO functions to achieve this. > Any hints would be welcome. > > Regards, > > Chris. > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 28 Feb 2007, at 13:47, Russell Norris wrote:> I think you''ll find the Output Compression plugin [http:// > wiki.rubyonrails.org/rails/pages/Output+Compression+Plugin] does > what you''re looking for. I was playing around with it and looking > at the results in Firebug and it looked good.If you want output compression for serving files, you can just use Apache''s deflate module: # Deflate AddOutputFilterByType DEFLATE text/html text/plain text/css text/ javascript # ... text/xml application/xml application/xhtml+xml text/javascript BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4.0[678] no-gzip BrowserMatch \bMSIE !no-gzip !gzip-only-text/html However, the original poster was looking for a way to compress his files on the server itself, decompressing them in memory before sending it through the ruby interpreter. Best regards Peter De Berdt --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Chris Dew wrote:> On Feb 27, 11:02 pm, Stephan Wehner <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: >> > source .rb, .rhtml, .css and .js files gzipped to save space? >> in >> >> actionpack/lib/action_view/base.rb >> >> >> >> > e.g. If foo.rb can''t be found, foo.rb.gz should be read instead. So >> > long as the .rb and .rhtml files do need to be accessed randomly, >> > there should be no need to gunzip the file in place. >> >> You lost me with that one. > > > If you just read a short file into memory, you can just gunzip the > contents as you read them, not changing anything on disk. > > If you need random access (read or write), you would need to gunzip > the file to temporary storage (perhaps the disk), perform the > operations, then gzip the file up again when finished. >I see now. Actually you may be able to redefine the File methods that come into play, where File.exists? returns also true if filename + .gz exists, and File.read will read from filename + .gz if filename doesn''t exist. This would then be on the Ruby level, not Rails. Don''t know all the methods that would need redefining. Don''t know how the Ruby interpreter loads files (through the File class, or not?) Why wouldn''t you use a compression-file-system? Stephan> >> >> I''m looking at ActionPack version 1.12.5 here. You may have a different >> version. >> >> Maybe it''s a one-liner. >> >> Stephan >> >> -- >> Posted viahttp://www.ruby-forum.com/. > > Thanks for your reply, > > Chris.-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 28 Feb 2007, at 17:31, Stephan Wehner wrote:> Actually you may be able to redefine the File methods that come into > play, where File.exists? returns also true if filename + .gz > exists, and > File.read will read from filename + .gz if filename doesn''t exist. > > This would then be on the Ruby level, not Rails. > > Don''t know all the methods that would need redefining. Don''t know how > the Ruby interpreter loads files (through the File class, or not?) > > Why wouldn''t you use a compression-file-system?My impression is that the original poster is trying to host a Rails application on a very small shared hosting account (or a free hosting account). The total size of a fairly large Rails project rapidly exceeds 50 MB. My advise if this is indeed the case would be to just pay a little bit more for a decent hosting provider instead of trying to solve a problem that in the end will cost you more (timewise) then it will cost you to get a better hosting account. Best regards Peter De Berdt --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---