lib/ruboclean/runner.rb in ruboclean-0.5.0 vs lib/ruboclean/runner.rb in ruboclean-0.6.0
- old
+ new
@@ -15,16 +15,25 @@
load_file.then(&method(:order))
.then(&method(:cleanup_paths))
.then(&method(:convert_to_yaml))
.then(&method(:write_file!))
+ .then(&method(:changed?))
end
+ def changed?(target_yaml)
+ target_yaml != source_yaml
+ end
+
def verbose?
cli_arguments.verbose?
end
+ def verify?
+ cli_arguments.verify?
+ end
+
def path
cli_arguments.path
end
private
@@ -52,10 +61,12 @@
def convert_to_yaml(configuration_hash)
ToYamlConverter.new(configuration_hash, cli_arguments.preserve_comments?, source_yaml).to_yaml
end
def write_file!(target_yaml)
- source_file_pathname.write(target_yaml)
+ target_yaml.tap do |content|
+ source_file_pathname.write(content) unless verify?
+ end
end
def source_file_pathname
@source_file_pathname ||= find_source_file_pathname
end