Permalink
Browse files

Allow multiple paths and extensions to be passed to append/prepend

  • Loading branch information...
1 parent df16e25 commit 88450097f7cdbbb8e6c0dfc0ccaa9b2b30dd7493 @josh josh committed Jul 18, 2011
Showing with 18 additions and 24 deletions.
  1. +14 −10 lib/hike/trail.rb
  2. +4 −14 test/test_trail.rb
View
@@ -58,33 +58,37 @@ def root
end
# Prepend `path` to `Paths` collection
- def prepend_path(path)
- paths.unshift(path)
+ def prepend_paths(*paths)
+ self.paths.unshift(*paths)
end
+ alias_method :prepend_path, :prepend_paths
# Append `path` to `Paths` collection
- def append_path(path)
- paths.push(path)
+ def append_paths(*paths)
+ self.paths.push(*paths)
end
+ alias_method :append_path, :append_paths
# Remove `path` from `Paths` collection
def remove_path(path)
- paths.delete(path)
+ self.paths.delete(path)
end
# Prepend `extension` to `Extensions` collection
- def prepend_extension(extension)
- extensions.unshift(extension)
+ def prepend_extensions(*extensions)
+ self.extensions.unshift(*extensions)
end
+ alias_method :prepend_extension, :prepend_extensions
# Append `extension` to `Extensions` collection
- def append_extension(extension)
- extensions.push(extension)
+ def append_extensions(*extensions)
+ self.extensions.push(*extensions)
end
+ alias_method :append_extension, :append_extensions
# Remove `extension` from `Extensions` collection
def remove_extension(extension)
- extensions.delete(extension)
+ self.extensions.delete(extension)
end
# Alias `new_extension` to `old_extension`
View
@@ -238,13 +238,8 @@ class TrailTest < Test::Unit::TestCase
def new_trail
trail = Hike::Trail.new(FIXTURE_ROOT)
- trail.append_path "app/views"
- trail.append_path "vendor/plugins/signal_id/app/views"
- trail.append_path "."
- trail.append_extension "builder"
- trail.append_extension "coffee"
- trail.append_extension "str"
- trail.append_extension ".erb"
+ trail.append_paths "app/views", "vendor/plugins/signal_id/app/views", "."
+ trail.append_extensions "builder", "coffee", "str", ".erb"
trail.alias_extension "htm", "html"
trail.alias_extension "xhtml", "html"
trail.alias_extension "php", "html"
@@ -281,13 +276,8 @@ class IndexTest < Test::Unit::TestCase
def new_trail
trail = Hike::Trail.new(FIXTURE_ROOT)
- trail.append_path "app/views"
- trail.append_path "vendor/plugins/signal_id/app/views"
- trail.append_path "."
- trail.append_extension "builder"
- trail.append_extension "coffee"
- trail.append_extension "str"
- trail.append_extension ".erb"
+ trail.append_paths "app/views", "vendor/plugins/signal_id/app/views", "."
+ trail.append_extensions "builder", "coffee", "str", ".erb"
trail.alias_extension "htm", "html"
trail.alias_extension "xhtml", "html"
trail.alias_extension "php", "html"

0 comments on commit 8845009

Please sign in to comment.