Skip to content

Commit

Permalink
Fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
Maher4Ever committed Apr 19, 2012
1 parent d9e5346 commit b11bd77
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 44 deletions.
50 changes: 25 additions & 25 deletions lib/listen/directory_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ class DirectoryRecord
#
class << self

# Creates the ignoring pattrens from the default ignored
# directories and extensions. It memoizes the generated pattrens
# Creates the ignoring patterns from the default ignored
# directories and extensions. It memoizes the generated patterns
# to avoid unnecessary computation.
#
def generate_default_ignoring_pattrens
@@default_ignoring_pattrens ||= Array.new.tap do |default_pattrens|
def generate_default_ignoring_patterns
@@default_ignoring_patterns ||= Array.new.tap do |default_patterns|
# Add directories
ignored_directories = DEFAULT_IGNORED_DIRECTORIES.map { |d| Regexp.escape(d) }
default_pattrens << %r{^(?:#{ignored_directories.join('|')})/}
default_patterns << %r{^(?:#{ignored_directories.join('|')})/}

# Add extensions
ignored_extensions = DEFAULT_IGNORED_EXTENSIONS.map { |e| Regexp.escape(e) }
default_pattrens << %r{(?:#{ignored_extensions.join('|')})$}
default_patterns << %r{(?:#{ignored_extensions.join('|')})$}
end
end
end
Expand All @@ -44,42 +44,42 @@ def initialize(directory)
raise ArgumentError, "The path '#{directory}' is not a directory!" unless File.directory?(directory)

@directory = directory
@ignoring_pattrens = Set.new
@filtering_pattrens = Set.new
@ignoring_patterns = Set.new
@filtering_patterns = Set.new
@sha1_checksums = Hash.new

@ignoring_pattrens.merge(DirectoryRecord.generate_default_ignoring_pattrens)
@ignoring_patterns.merge(DirectoryRecord.generate_default_ignoring_patterns)
end

# Returns the ignoring pattrens in the record
# Returns the ignoring patterns in the record
#
# @return [Array<Regexp>] the ignoring pattrens
# @return [Array<Regexp>] the ignoring patterns
#
def ignoring_pattrens
@ignoring_pattrens.to_a
def ignoring_patterns
@ignoring_patterns.to_a
end

# Returns the filtering pattrens used in the record to know
# Returns the filtering patterns used in the record to know
# which paths should be stored.
#
# @return [Array<Regexp>] the filtering pattrens
# @return [Array<Regexp>] the filtering patterns
#
def filtering_pattrens
@filtering_pattrens.to_a
def filtering_patterns
@filtering_patterns.to_a
end

# Adds ignoring pattrens to the record.
# Adds ignoring patterns to the record.
#
# @example Ignore some paths
# ignore ".git", ".svn"
#
# @param [Regexp] regexp a pattren for ignoring paths
#
def ignore(*regexps)
@ignoring_pattrens.merge(regexps)
@ignoring_patterns.merge(regexps)
end

# Adds filtering pattrens to the listener.
# Adds filtering patterns to the listener.
#
# @example Filter some files
# ignore /\.txt$/, /.*\.zip/
Expand All @@ -89,7 +89,7 @@ def ignore(*regexps)
# @return [Listen::Listener] the listener itself
#
def filter(*regexps)
@filtering_pattrens.merge(regexps)
@filtering_patterns.merge(regexps)
end

# Returns whether a path should be ignored or not.
Expand All @@ -100,7 +100,7 @@ def filter(*regexps)
#
def ignored?(path)
path = relative_to_base(path)
@ignoring_pattrens.any? { |pattren| pattren =~ path }
@ignoring_patterns.any? { |pattren| pattren =~ path }
end

# Returns whether a path should be filtered or not.
Expand All @@ -110,11 +110,11 @@ def ignored?(path)
# @return [Boolean]
#
def filtered?(path)
# When no filtering pattrens are set, ALL files are stored.
return true if @filtering_pattrens.empty?
# When no filtering patterns are set, ALL files are stored.
return true if @filtering_patterns.empty?

path = relative_to_base(path)
@filtering_pattrens.any? { |pattren| pattren =~ path }
@filtering_patterns.any? { |pattren| pattren =~ path }
end

# Finds the paths that should be stored and adds them
Expand Down
4 changes: 2 additions & 2 deletions lib/listen/listener.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def paused?
!!@adapter && @adapter.paused == true
end

# Adds ignoring pattrens to the listener.
# Adds ignoring patterns to the listener.
#
# @param (see Listen::DirectoryRecord#ignore)
#
Expand All @@ -93,7 +93,7 @@ def ignore(*regexps)
self
end

# Adds filtering pattrens to the listener.
# Adds filtering patterns to the listener.
#
# @param (see Listen::DirectoryRecord#filter)
#
Expand Down
26 changes: 13 additions & 13 deletions spec/listen/directory_record_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

subject { described_class.new(base_directory) }

describe '.generate_default_ignoring_pattrens' do
it 'creates regexp pattrens from the default ignored directories and extensions' do
described_class.generate_default_ignoring_pattrens.should include(
describe '.generate_default_ignoring_patterns' do
it 'creates regexp patterns from the default ignored directories and extensions' do
described_class.generate_default_ignoring_patterns.should include(
%r{^(?:\.bundle|\.git|\.svn|log|tmp|vendor)/},
%r{(?:\.DS_Store)$}
)
end

it 'memoizes the generated results' do
described_class.generate_default_ignoring_pattrens.should equal described_class.generate_default_ignoring_pattrens
described_class.generate_default_ignoring_patterns.should equal described_class.generate_default_ignoring_patterns
end
end

Expand All @@ -23,12 +23,12 @@
subject.directory.should eq base_directory
end

it 'sets the default ignoring pattrens' do
subject.ignoring_pattrens.should =~ described_class.generate_default_ignoring_pattrens
it 'sets the default ignoring patterns' do
subject.ignoring_patterns.should =~ described_class.generate_default_ignoring_patterns
end

it 'sets the default filtering pattrens' do
subject.filtering_pattrens.should eq []
it 'sets the default filtering patterns' do
subject.filtering_patterns.should eq []
end

it 'raises an error when the passed path does not exist' do
Expand All @@ -43,14 +43,14 @@
describe '#ignore' do
it 'adds the passed paths to the list of ignoted paths in the record' do
subject.ignore(%r{^\.old/}, %r{\.pid$})
subject.ignoring_pattrens.should include(%r{^\.old/}, %r{\.pid$})
subject.ignoring_patterns.should include(%r{^\.old/}, %r{\.pid$})
end
end

describe '#filter' do
it 'adds the passed regexps to the list of filters that determine the stored paths' do
subject.filter(%r{\.(?:jpe?g|gif|png)}, %r{\.(?:mp3|ogg|a3c)})
subject.filtering_pattrens.should include(%r{\.(?:jpe?g|gif|png)}, %r{\.(?:mp3|ogg|a3c)})
subject.filtering_patterns.should include(%r{\.(?:jpe?g|gif|png)}, %r{\.(?:mp3|ogg|a3c)})
end
end

Expand Down Expand Up @@ -86,16 +86,16 @@
end
end

describe '#filterd?' do
describe '#filtered?' do
before { subject.stub(:relative_to_base) { |path| path } }

context 'when no filtering pattrens are set' do
context 'when no filtering patterns are set' do
it 'returns true for any path' do
subject.filtered?('file.txt').should be_true
end
end

context 'when filtering pattrens are set' do
context 'when filtering patterns are set' do
before { subject.filter(%r{\.(?:jpe?g|gif|png)}) }

it 'tests paths relative to the base directory' do
Expand Down
4 changes: 2 additions & 2 deletions spec/listen/listener_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
:latency => 0.5, :force_polling => true, :relative_paths => true) }

it 'passes the custom ignored paths to the directory record' do
subject.directory_record.ignoring_pattrens.should include /\.ssh/
subject.directory_record.ignoring_patterns.should include /\.ssh/
end

it 'passes the custom filters to the directory record' do
subject.directory_record.filtering_pattrens.should =~ [/.*\.rb/,/.*\.md/]
subject.directory_record.filtering_patterns.should =~ [/.*\.rb/,/.*\.md/]
end

it 'sets the cutom option for using relative paths in the callback' do
Expand Down
4 changes: 2 additions & 2 deletions spec/listen/multi_listener_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@

it 'passes the custom ignored paths to each directory record' do
subject.directories_records.each do |r|
r.ignoring_pattrens.should include /\.ssh/
r.ignoring_patterns.should include /\.ssh/
end
end

it 'passes the custom filters to each directory record' do
subject.directories_records.each do |r|
r.filtering_pattrens.should =~ [/.*\.rb/,/.*\.md/]
r.filtering_patterns.should =~ [/.*\.rb/,/.*\.md/]
end
end

Expand Down

0 comments on commit b11bd77

Please sign in to comment.