Permalink
Browse files

Adding ability to ignore files so they dont' throw warnings

  • Loading branch information...
1 parent d89bcf2 commit 4c60aaaf8f74277ec1842fde920f41d476771f25 @marksim marksim committed Mar 1, 2012
Showing with 25 additions and 0 deletions.
  1. +8 −0 lib/constantinople.rb
  2. +1 −0 spec/config/.constantinopleignore
  3. +4 −0 spec/config/error.yml
  4. +12 −0 spec/lib/constantinople_spec.rb
View
@@ -19,8 +19,10 @@ def self.reload!
def self.load_from_directory(dir)
env = environment
result = Map.new
+ ignore_files = files_to_ignore(dir)
['.yml.default', '.yml', '.yml.override'].each do |ext|
Dir.glob(File.join(dir,"*#{ext}")) do |path|
+ next if ignore_files.include?(File.basename(path))
filename = File.basename(path,ext)
sub = load_yaml_or_warn(path)
if sub
@@ -74,6 +76,12 @@ def self.caller_directories
end
end
+ def self.files_to_ignore(dir)
+ File.open(File.join(dir,".conignore")) do |f|
+ f.readlines
+ end
+ end
+
end
CONSTANTINOPLE = Constantinople.reload!
@@ -0,0 +1 @@
+error.yml
View
@@ -0,0 +1,4 @@
+<%
+error = ".ymlignore my butt."
+%>
+error: <%= error %>
@@ -18,4 +18,16 @@
CONFIG.spec.animal.should == 'turtle' # from test environment
CONFIG.empty.should be_empty
end
+
+ describe "ignore files" do
+ it "should read .ymlignore if it exists" do
+ Constantinople.send(:files_to_ignore, "spec/config").should == ['error.yml']
+ end
+
+ it "should not bother reading error.yml" do
+ lambda {
+ CONFIG.error
+ }.should raise_exception
+ end
+ end
end

0 comments on commit 4c60aaa

Please sign in to comment.