Sha256: cafb01649e38f4200d184acfddb796bf787b418d942550c6b0f4939df6957e27
Contents?: true
Size: 746 Bytes
Versions: 3
Compression:
Stored size: 746 Bytes
Contents
require "pathname" module Rubycritic class SourceLocator RUBY_EXTENSION = ".rb" RUBY_FILES = File.join("**", "*#{RUBY_EXTENSION}") def initialize(paths) @user_paths = paths end def pathnames @pathnames ||= expand_paths end def paths @paths ||= pathnames.map(&:to_s) end private def expand_paths @user_paths.map do |path| if File.directory?(path) Pathname.glob(files_contained_in(path)) elsif File.exists?(path) && File.extname(path) == RUBY_EXTENSION Pathname.new(path) end end.flatten.compact.sort end def files_contained_in(path) (path == ".") ? RUBY_FILES : File.join(path, RUBY_FILES) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rubycritic-0.0.6 | lib/rubycritic/source_locator.rb |
rubycritic-0.0.5 | lib/rubycritic/source_locator.rb |
rubycritic-0.0.4 | lib/rubycritic/source_locator.rb |