[Rubygems-developers] Why does an install command an update
Jim Freeze
rubygems at freeze.org
Fri Jun 3 13:10:01 EDT 2005
* Hugh Sasse <hgs at dmu.ac.uk> [2005-06-03 17:21:09 +0100]:
> On Fri, 3 Jun 2005, Jim Weirich wrote:
>
> >Another option to reduce bandwidth is to toss the file lists in each of
> >the downloaded gem specs. [s/\n//; # hgs]
>
> You mean the bits like
>
> files:
> - lib/cgikit
> - lib/cgikit.rb
> - lib/cgikit/components
> - lib/cgikit/components/CKErrorPage
> - lib/cgikit/components/CKErrorPage/CKErrorPage.ckd
> - lib/cgikit/components/CKErrorPage/CKErrorPage.html
> - lib/cgikit/components/CKErrorPage/CKErrorPage.rb
>
> There must be a way to express this more concisely. Dir doesn't
> YAML::dump in such a way as to pass the name and the entries, but
> that can be changed by yaml_properties or something, can't it?.
> Not sure about backwards compatibility.....
FWIW, I coded up this little snippet:
-----------
files = {"files" =>
%w(
lib/cgikit
lib/cgikit.rb
lib/cgikit/components
lib/cgikit/components/CKErrorPage
lib/cgikit/components/CKErrorPage/CKErrorPage.ckd
lib/cgikit/components/CKErrorPage/CKErrorPage.html
lib/cgikit/components/CKErrorPage/CKErrorPage.rb
)
}
require 'yaml'
puts files.to_yaml
puts files.to_yaml.size
def optimize_file_list(files)
hash = Hash.new { |h,k| h[k] = [] }
files.each { |file|
dir = File.dirname(file)
filename = File.basename(file)
hash[dir] << filename
}
hash
end
files["files"] = optimize_file_list(files["files"])
puts files.to_yaml
puts files.to_yaml.size
----------
Running this gives:
% ruby ftest.rb
---
files:
- lib/cgikit
- lib/cgikit.rb
- lib/cgikit/components
- lib/cgikit/components/CKErrorPage
- lib/cgikit/components/CKErrorPage/CKErrorPage.ckd
- lib/cgikit/components/CKErrorPage/CKErrorPage.html
- lib/cgikit/components/CKErrorPage/CKErrorPage.rb
271
---
files:
lib/cgikit/components/CKErrorPage:
- CKErrorPage.ckd
- CKErrorPage.html
- CKErrorPage.rb
lib/cgikit/components:
- CKErrorPage
lib/cgikit:
- components
lib:
- cgikit
- cgikit.rb
229
A slight savings of 15%.
Not as much as I would have expected.
--
Jim Freeze
Theory and practice are the same, in theory. -- Ryan Davis
More information about the Rubygems-developers
mailing list