Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding ability to ignore files so they dont' throw warnings

  • Loading branch information...
commit 4c60aaaf8f74277ec1842fde920f41d476771f25 1 parent d89bcf2
@marksim marksim authored
View
8 lib/constantinople.rb
@@ -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!
View
1  spec/config/.constantinopleignore
@@ -0,0 +1 @@
+error.yml
View
4 spec/config/error.yml
@@ -0,0 +1,4 @@
+<%
+error = ".ymlignore my butt."
+%>
+error: <%= error %>
View
12 spec/lib/constantinople_spec.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.