class GitSpec::File
Constants
- EXCLUDED_FILE_PATTERNS
TODO: Move this to the config
Attributes
configuration[R]
path[R]
Public Class Methods
new(filename, configuration = GitSpec.configuration)
click to toggle source
# File lib/git_spec/file.rb, line 8 def initialize(filename, configuration = GitSpec.configuration) @path = filename.strip @configuration = configuration end
Public Instance Methods
excluded?()
click to toggle source
# File lib/git_spec/file.rb, line 30 def excluded? return true, 'Invalid file type' unless is_ruby? filtered = should_filter?(path) if filtered return filtered, 'Excluded by file pattern match' else return filtered end end
is_ruby?()
click to toggle source
TODO: Make this a whitelisted file extension configuration
# File lib/git_spec/file.rb, line 42 def is_ruby? ::File.extname(path) == '.rb' end
should_filter?(filename)
click to toggle source
# File lib/git_spec/file.rb, line 46 def should_filter?(filename) should_exclude = false EXCLUDED_FILE_PATTERNS.each do |pattern| match = filename =~ pattern unless match.nil? should_exclude = true break end end should_exclude end
spec_path()
click to toggle source
# File lib/git_spec/file.rb, line 13 def spec_path # TODO: Get test dir from config # TODO: Get spec naming convention from config @spec_path ||= begin filename = path filename = "spec/" << filename filename.gsub!(".rb", "_spec.rb") filename.gsub!(configuration.src_root, "") filename end rescue => e # TODO: Log helpful info when this happens raise end