Skip to content

Commit 3e65376

Browse files
committed
Replace File.exists? with File.exist?
Fixes Compass#2169 Closes Compass#2167 Signed-off-by: Jeff Byrnes <[email protected]>
1 parent 4de0147 commit 3e65376

File tree

21 files changed

+42
-42
lines changed

21 files changed

+42
-42
lines changed

cli/features/step_definitions/command_line_steps.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@
114114
end
115115

116116
Then /an? \w+ file ([^ ]+) is (not )?removed/ do |filename, negated|
117-
File.exists?(filename).should == !!negated
117+
File.exist?(filename).should == !!negated
118118
end
119119

120120
Then /an? \w+ file ([^ ]+) is (not )?created/ do |filename, negated|
121-
File.exists?(filename).should == !negated
121+
File.exist?(filename).should == !negated
122122
end
123123

124124
Then "the following files are reported removed:" do |table|

cli/lib/compass/actions.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ def copy(from, to, options = nil, binary = false)
2222
def directory(dir, options = nil)
2323
options ||= self.options if self.respond_to?(:options)
2424
options ||= {}
25-
if File.exists?(dir) && File.directory?(dir)
25+
if File.exist?(dir) && File.directory?(dir)
2626
# do nothing
27-
elsif File.exists?(dir)
27+
elsif File.exist?(dir)
2828
msg = "#{basename(dir)} already exists and is not a directory."
2929
raise Compass::FilesystemConflict.new(msg)
3030
else
@@ -38,7 +38,7 @@ def write_file(file_name, contents, options = nil, binary = false)
3838
options ||= self.options if self.respond_to?(:options)
3939
skip_write = false
4040
contents = process_erb(contents, options[:erb]) if options[:erb]
41-
if File.exists?(file_name)
41+
if File.exist?(file_name)
4242
existing_contents = IO.read(file_name)
4343
if existing_contents == contents
4444
log_action :identical, basename(file_name), options
@@ -73,7 +73,7 @@ def remove(file_name)
7373
if File.directory?(file_name)
7474
FileUtils.rm_rf file_name
7575
log_action :remove, basename(file_name)+"/", options
76-
elsif File.exists?(file_name)
76+
elsif File.exist?(file_name)
7777
File.unlink file_name
7878
log_action :remove, basename(file_name), options
7979
end

cli/lib/compass/app_integration/stand_alone/installer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def write_configuration_files(config_file = nil)
2121
end
2222

2323
def config_files_exist?
24-
File.exists? targetize('config.rb')
24+
File.exist? targetize('config.rb')
2525
end
2626

2727
def config_contents

cli/lib/compass/commands/project_base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def project_images_subdirectory
6060
end
6161

6262
def assert_project_directory_exists!
63-
if File.exists?(project_directory) && !File.directory?(project_directory)
63+
if File.exist?(project_directory) && !File.directory?(project_directory)
6464
raise Compass::FilesystemConflict.new("#{project_directory} is not a directory.")
6565
elsif !File.directory?(project_directory)
6666
raise Compass::Error.new("#{project_directory} does not exist.")

cli/lib/compass/commands/project_stats.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def sass_columns(sass_file)
121121
end
122122

123123
def css_columns(css_file)
124-
if File.exists?(css_file)
124+
if File.exist?(css_file)
125125
cf = Compass::Stats::CssFile.new(css_file)
126126
cf.analyze!
127127
%w(selector_count prop_count file_size).map do |t|

cli/lib/compass/commands/update_project.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def new_config?(compiler)
7373
return false unless config_file
7474
config_mtime = File.mtime(config_file)
7575
compiler.file_list.each do |(_, css_filename, _)|
76-
return config_file if File.exists?(css_filename) && config_mtime > File.mtime(css_filename)
76+
return config_file if File.exist?(css_filename) && config_mtime > File.mtime(css_filename)
7777
end
7878
nil
7979
end

cli/lib/compass/compiler.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def new_config?
9393
return false unless config_file
9494
config_mtime = File.mtime(config_file)
9595
css_files.each do |css_filename|
96-
return config_file if File.exists?(css_filename) && config_mtime > File.mtime(css_filename)
96+
return config_file if File.exist?(css_filename) && config_mtime > File.mtime(css_filename)
9797
end
9898
nil
9999
end

cli/lib/compass/configuration/helpers.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def add_project_configuration(*args)
8686
# Finds the configuration file, if it exists in a known location.
8787
def detect_configuration_file(project_path = nil)
8888
possible_files = KNOWN_CONFIG_LOCATIONS.map{|f| projectize(f, project_path) }
89-
possible_files.detect{|f| File.exists?(f)}
89+
possible_files.detect{|f| File.exist?(f)}
9090
end
9191

9292
def handle_configuration_change!

cli/lib/compass/installers/manifest.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ def with_manifest(manifest_file)
141141
# evaluated in a Manifest instance context
142142
def parse(manifest_file)
143143
with_manifest(manifest_file) do
144-
if File.exists?(manifest_file)
145-
open(manifest_file) do |f|
144+
if File.exist?(manifest_file)
145+
open(manifest_file) do |f|
146146
eval(f.read, instance_binding, manifest_file)
147147
end
148148
else

cli/lib/compass/sass_extensions/sprites/image.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def file
3232
def find_file
3333
Compass.configuration.sprite_load_path.compact.each do |path|
3434
f = File.join(path, relative_file)
35-
if File.exists?(f)
35+
if File.exist?(f)
3636
return f
3737
end
3838
end

cli/lib/compass/sass_extensions/sprites/sprite_methods.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def cleanup_old_sprites
7272

7373
# Does this sprite need to be generated
7474
def generation_required?
75-
!File.exists?(filename) || outdated? || options[:force]
75+
!File.exist?(filename) || outdated? || options[:force]
7676
end
7777

7878
# Returns the uniqueness hash for this sprite object
@@ -109,7 +109,7 @@ def image_filenames
109109

110110
# Checks whether this sprite is outdated
111111
def outdated?
112-
if File.exists?(filename)
112+
if File.exist?(filename)
113113
return @images.any? {|image| image.mtime.to_i > self.mtime.to_i }
114114
end
115115
true

cli/test/integrations/compass_test.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def test_on_stylesheet_error_callback
4646
def test_empty_project
4747
# With no sass files, we should have no css files.
4848
within_project(:empty) do |proj|
49-
return unless proj.css_path && File.exists?(proj.css_path)
49+
return unless proj.css_path && File.exist?(proj.css_path)
5050
Dir.new(proj.css_path).each do |f|
5151
fail "This file should not have been generated: #{f}" unless f == "." || f == ".."
5252
end
@@ -186,7 +186,7 @@ def assert_renders_correctly(*arguments)
186186

187187
def within_project(project_name, config_block = nil)
188188
@current_project = project_name
189-
Compass.add_configuration(configuration_file(project_name)) if File.exists?(configuration_file(project_name))
189+
Compass.add_configuration(configuration_file(project_name)) if File.exist?(configuration_file(project_name))
190190
Compass.configuration.project_path = project_path(project_name)
191191
Compass.configuration.environment = :production
192192
Compass.configuration.sourcemap = false unless Compass.configuration.sourcemap_set?
@@ -195,7 +195,7 @@ def within_project(project_name, config_block = nil)
195195
config_block.call(Compass.configuration)
196196
end
197197

198-
if Compass.configuration.sass_path && File.exists?(Compass.configuration.sass_path)
198+
if Compass.configuration.sass_path && File.exist?(Compass.configuration.sass_path)
199199
compiler = Compass.sass_compiler
200200
compiler.logger = Compass::NullLogger.new
201201
compiler.clean!
@@ -221,7 +221,7 @@ def each_sass_file(sass_dir = nil)
221221

222222
def save_output(dir)
223223
FileUtils.rm_rf(save_path(dir))
224-
FileUtils.cp_r(tempfile_path(dir), save_path(dir)) if File.exists?(tempfile_path(dir))
224+
FileUtils.cp_r(tempfile_path(dir), save_path(dir)) if File.exist?(tempfile_path(dir))
225225
end
226226

227227
def project_path(project_name)

cli/test/units/command_line_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def test_print_version
2121
def test_basic_install
2222
within_tmp_directory do
2323
compass(*%w(create --boring basic))
24-
assert File.exists?("basic/sass/screen.scss")
24+
assert File.exist?("basic/sass/screen.scss")
2525
assert_action_performed :directory, "basic/"
2626
assert_action_performed :create, "basic/sass/screen.scss"
2727
end
@@ -34,8 +34,8 @@ def test_basic_install
3434
define_method "test_#{framework.name}_installation" do
3535
within_tmp_directory do
3636
compass(*%W(create --boring --using #{framework.name} #{framework.name}_project))
37-
assert File.exists?("#{framework.name}_project/sass/screen.scss"), "sass/screen.scss is missing. Found: #{Dir.glob("#{framework.name}_project/**/*").join(", ")}"
38-
assert File.exists?("#{framework.name}_project/stylesheets/screen.css")
37+
assert File.exist?("#{framework.name}_project/sass/screen.scss"), "sass/screen.scss is missing. Found: #{Dir.glob("#{framework.name}_project/**/*").join(", ")}"
38+
assert File.exist?("#{framework.name}_project/stylesheets/screen.css")
3939
assert_action_performed :directory, "#{framework.name}_project/"
4040
assert_action_performed :create, "#{framework.name}_project/sass/screen.scss"
4141
assert_action_performed :write, "#{framework.name}_project/stylesheets/screen.css"

cli/test/units/sprites/layout_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def horizontal(options= {}, uri=URI)
117117
assert_equal 400, base.width
118118
assert_equal 60, base.height
119119
assert_equal [[0, 0], [20, 120], [20, 0], [20, 100], [20, 160]], base.images.map {|i| [i.top, i.left]}
120-
assert File.exists?(base.filename)
120+
assert File.exist?(base.filename)
121121
FileUtils.rm base.filename
122122
end
123123

@@ -130,7 +130,7 @@ def horizontal(options= {}, uri=URI)
130130
assert_equal 40, base.width
131131
assert_equal 40, base.height
132132
assert_equal [[30, 0], [20, 10], [10, 20], [0, 30]], base.images.map {|i| [i.top, i.left]}
133-
assert File.exists?(base.filename)
133+
assert File.exist?(base.filename)
134134
FileUtils.rm base.filename
135135
end
136136

@@ -173,7 +173,7 @@ def horizontal(options= {}, uri=URI)
173173
it "should generate a horrizontal sprite" do
174174
base = horizontal
175175
base.generate
176-
assert File.exists?(base.filename)
176+
assert File.exist?(base.filename)
177177
FileUtils.rm base.filename
178178
end
179179

cli/test/units/sprites/sprite_command_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ def options_to_cli(options)
4242
def teardown
4343
::Dir.chdir @before_dir
4444
clean_up_sprites
45-
if File.exists?(@test_dir)
45+
if File.exist?(@test_dir)
4646
::FileUtils.rm_r @test_dir
4747
end
4848
end
4949

5050
it "should create sprite file" do
5151
assert_equal 0, run_compass_with_options(['sprite', "-f", 'stylesheet.scss', "squares/*.png"]).to_i
52-
assert File.exists?(File.join(test_dir, 'stylesheet.scss'))
52+
assert File.exist?(File.join(test_dir, 'stylesheet.scss'))
5353
end
5454

5555
end

cli/test/units/sprites/sprite_map_test.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,21 @@ def teardown
7878

7979
it "should generate sprite" do
8080
@base.generate
81-
assert File.exists?(@base.filename)
81+
assert File.exist?(@base.filename)
8282
assert !@base.generation_required?
8383
assert !@base.outdated?
8484
end
8585

8686
it "should remove old sprite when generating new" do
8787
@base.generate
8888
file = @base.filename
89-
assert File.exists?(file), "Original file does not exist"
89+
assert File.exist?(file), "Original file does not exist"
9090
file_to_remove = File.join(@images_tmp_path, 'selectors', 'ten-by-ten.png')
9191
FileUtils.rm file_to_remove
92-
assert !File.exists?(file_to_remove), "Failed to remove sprite file"
92+
assert !File.exist?(file_to_remove), "Failed to remove sprite file"
9393
@base = sprite_map_test(@options)
9494
@base.generate
95-
assert !File.exists?(file), "Sprite file did not get removed"
95+
assert !File.exist?(file), "Sprite file did not get removed"
9696
end
9797

9898
test "should get correct relative_name" do

compass-style.org/content/help/documentation/configuration-reference.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ To disable the asset cache buster:
393393
more than once. Example:
394394

395395
watch "images/**/*" do |project_dir, relative_path|
396-
if File.exists?(File.join(project_dir, relative_path))
396+
if File.exist?(File.join(project_dir, relative_path))
397397
puts "File size of #{relative_path} is: #{File.size(File.join(project_dir, relative_path))}"
398398
end
399399
end
@@ -406,7 +406,7 @@ to avoid crashing the watcher in the case where the file has been removed.
406406
**`on_sprite_saved`** -- Pass this function a block of code that gets executed after a sprite is saved to disk. The block will be passed the filename. Can be invoked more then once. Example:
407407

408408
on_sprite_saved do |filename|
409-
post_process(filename) if File.exists?(filename)
409+
post_process(filename) if File.exist?(filename)
410410
end
411411

412412
**`on_sprite_generated`** -- Pass this function a block of code that gets executed after a sprite is generated but before its saved to disk. The block will be passed an instance of `ChunkyPNG::Image`. Can be invoked more then once. Example:

core/lib/compass/core/sass_extensions/functions/files.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module Compass::Core::SassExtensions::Functions::Files
77
def md5sum(file, format = nil)
88
assert_type file, :String
99
filename = nil
10-
if options[:css_filename] && File.exists?(options[:css_filename])
10+
if options[:css_filename] && File.exist?(options[:css_filename])
1111
filename = File.expand_path(file.value, File.dirname(options[:css_filename]))
1212
elsif Pathname.new(file.value).absolute?
1313
filename = file.value

core/lib/compass/core/sass_extensions/functions/image_size.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ def image_dimensions(image_file)
5555
end
5656

5757
def image_path_for_size(image_file)
58-
if File.exists?(image_file)
59-
return image_file
58+
if File.exist?(image_file)
59+
return image_file
6060
end
6161
real_path(image_file)
6262
end

core/lib/compass/frameworks.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def register_directory(directory)
9494
File.join(directory, 'lib', File.basename(directory)+".rb"),
9595
File.join(directory, File.basename(directory)+".rb")
9696
]
97-
loader = loaders.detect{|l| File.exists?(l)}
97+
loader = loaders.detect{|l| File.exist?(l)}
9898
registered_framework = detect_registration do
9999
require loader if loader
100100
end
@@ -117,7 +117,7 @@ def template_usage(template)
117117
framework = self[framework_name]
118118
template ||= "project"
119119
usage_file = File.join(framework.templates_directory, template, "USAGE.markdown")
120-
if File.exists?(usage_file)
120+
if File.exist?(usage_file)
121121
File.read(usage_file)
122122
elsif help = framework.manifest(template).help
123123
help

core/test/integrations/projects_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def assert_renders_correctly(*arguments)
7575
for name in arguments
7676
actual_result_file = "#{tempfile_path(@current_project)}/#{name}".gsub(/s[ac]ss/, "css")
7777
expected_result_file = "#{result_path(@current_project)}/#{name}.#{Sass.version[:major]}.#{Sass.version[:minor]}".gsub(/s[ac]ss/, "css")
78-
expected_result_file = "#{result_path(@current_project)}/#{name}".gsub(/s[ac]ss/, "css") unless File.exists?(expected_result_file)
78+
expected_result_file = "#{result_path(@current_project)}/#{name}".gsub(/s[ac]ss/, "css") unless File.exist?(expected_result_file)
7979
actual_lines = File.read(actual_result_file)
8080
actual_lines.gsub!(/^@charset[^;]+;/,'') if options[:ignore_charset]
8181
actual_lines = actual_lines.split("\n").reject{|l| l=~/\A\Z/}
@@ -140,7 +140,7 @@ def each_sass_file(sass_dir = nil)
140140

141141
def save_output(dir)
142142
FileUtils.rm_rf(save_path(dir))
143-
FileUtils.cp_r(tempfile_path(dir), save_path(dir)) if File.exists?(tempfile_path(dir))
143+
FileUtils.cp_r(tempfile_path(dir), save_path(dir)) if File.exist?(tempfile_path(dir))
144144
end
145145

146146
def projects

0 commit comments

Comments
 (0)