lib/riemann/dash/config.rb
# Controllers can be regular old one-file-per-class, but
# if you prefer a little more modularity, this method will allow you to
# define all controller methods in their own files.  For example, get
# "/posts/*/edit" can live in controller/posts/_/edit.rb. The sorting
# system provided here requires files in the correct order to handle
# wildcards appropriately.
Controllers can be regular old one-file-per-class, but
if you prefer a little more modularity, this method will allow you to
define all controller methods in their own files.
Controllers can be regular old one - file - per - class but if you prefer a little more modularity this method will allow you to define all controller methods in their own files .
def sorted_controller_list(dir)
    rbs = []
    Find.find(
      File.expand_path(dir)
    ) do |path|
      rbs << path if path =~ /\.rb$/
    end
    rbs.sort! do |a, b|
      as = a.split File::SEPARATOR
      bs = b.split File::SEPARATOR
      l = [as.size, bs.size].min
      catch :x do
        (0...l).each do |i|
          a, b = as[i], bs[i]
          if a[/^_/] and not b[/^_/]
            throw :x, 1
          elsif b[/^_/] and not a[/^_/]
            throw :x, -1
          elsif ord = (a <=> b) and ord != 0
            throw :x, ord
          end
        end
        if as.size > bs.size
          throw :x, -1
        elsif as.size < bs.size
          throw :x, -1
        else
          throw :x, 0
        end
      end
    end
  end
def sorted_controller_list ( dir ) rbs = [ ] Find . find ( File . expand_path ( dir ) ) do | path | rbs << path if path =~ / \. rb$ / end rbs . sort! do | a , b | as = a . split File :: SEPARATOR bs = b . split File :: SEPARATOR l = [ as . size , bs . size ] . min catch :x do ( 0 ... l ) . each do | i | a , b = as [ i ] , bs [ i ] if a [ / ^_ / ] and not b [ / ^_ / ] throw :x , 1 elsif b [ / ^_ / ] and not a [ / ^_ / ] throw :x , - 1 elsif ord = ( a <=> b ) and ord != 0 throw :x , ord end end if as . size > bs . size throw :x , - 1 elsif as . size < bs . size throw :x , - 1 else throw :x , 0 end end end end
Controllers can be regular old one-file-per-class, but
if you prefer a little more modularity, this method will allow you to
define all controller methods in their own files.
Controllers can be regular old one - file - per - class but if you prefer a little more modularity this method will allow you to define all controller methods in their own files .
# Sort paths with _ last, becase those are wildcards. # Compare common subpaths # All subpaths are identical; sort longest first
dir