Sha256: f761b5b45e921f18e35b1fe3d640f401f5905e6295819960e6e828f9b1e03aa1

Contents?: true

Size: 924 Bytes

Versions: 4

Compression:

Stored size: 924 Bytes

Contents

class Autotest
  ##
  # Convert a path in a string, s, into a class name, changing
  # underscores to CamelCase, etc.
 
  def path_to_classname(s)
    sep = File::SEPARATOR
    f = s.sub(/^test#{sep}/, '').sub(/\.rb$/, '').split(sep)
    f = f.map { |path| path.split(/_|(\d+)/).map { |seg| seg.capitalize }.join }
    f = f.map { |path| path =~ /Test$/ ? path : "#{path}Test"  }
    f.join('::')
  end
end

Autotest.add_hook :initialize do |at|
  unless ARGV.empty?
    if ARGV[0] == '-d'
      at.find_directories = ARGV[1..-1].dup
    else
      at.find_directories = []
      at.extra_files = ARGV.dup
    end
  end
  
  # doesn't seem to work
  # at.clear_mappings
  
  at.add_mapping(/^lib\/.*\.rb$/) do |filename, _|
    possible = File.basename(filename, 'rb').gsub '_', '_?'
    files_matching %r%^test/.*#{possible}_test\.rb$%
  end

  at.add_mapping(/^test.*\/.*test\.rb$/) do |filename, _|
    filename
  end
end

Version data entries

4 entries across 4 versions & 3 rubygems

Version Path
sayso-permalink_fu-0.0.1.001 .autotest
sitemap_generator-0.1.1 .autotest
moneypools-sitemap_generator-0.1.0 .autotest
sitemap_generator-0.1.0 .autotest