File: stats.rb

package info (click to toggle)
ruby-hitimes 1.3.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 388 kB
  • sloc: ruby: 1,196; ansic: 418; java: 265; makefile: 15
file content (31 lines) | stat: -rw-r--r-- 593 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#
# this is all here in case this example is run from the examples directory
#
begin
  require 'hitimes'
rescue LoadError => le
  %w[ ext lib ].each do |p|
    path = File.expand_path( File.join( File.dirname( __FILE__ ), "..", p ) )
    if $:.include?( path ) then
      raise le
    end
    $: << path
  end
  retry
end

s = Hitimes::Stats.new
dir = ARGV.shift || Dir.pwd
Dir.entries( dir ).each do |entry|
  fs = File.stat( entry )
  if fs.file? then
    s.update( fs.size )
  end
end

Hitimes::Stats::STATS.each do |m|
  puts "#{m.rjust(6)} : #{s.send( m ) }"
end

puts s.to_hash.inspect