summaryrefslogtreecommitdiff
diff options
authorFrederik Deweerdt <[email protected]>2016-03-15 20:10:11 -0700
committerFrederik Deweerdt <[email protected]>2016-03-15 20:11:01 -0700
commite78d9b7cddee66b51e5d4f831c5ddb3058486fcd (patch)
tree3ec23bd983a8c0812bcf8007040c1ee013507658
parent6311483fe4d36f2c2f33e4bbb4b18b84aae35c09 (diff)
downloaddadi-master.tar.gz
Patch from Alex Boussinet:HEADmaster
- Use a more concise API to find out if a given class supports a method - Remove superfluous 'then'
-rwxr-xr-xdadi.rb16
1 files changed, 4 insertions, 12 deletions
diff --git a/dadi.rb b/dadi.rb
index 2d0bc84..ae39568 100755
--- a/dadi.rb
+++ b/dadi.rb
@@ -67,7 +67,6 @@ begin
# them
end
if options[:xml_file].size < 1
- then
raise "Parsing error: Missing required arguments"
end#if
# Reset the xml_file array for the second parsing
@@ -86,7 +85,7 @@ begin
# Second pass on the options understood by the dumper
begin
# Support additional options if needed
- if dumper_class.methods.include?(:add_options) || dumper_class.methods.include?("add_options") then
+ if dumper_class.respond_to?(:add_options)
dumper_class.add_options(op, options)
end#if
op.parse!
@@ -117,7 +116,6 @@ def build_dest_folders (dest_dirs, force)
dest_dirs.each { |d| Dir.mkdir(d) }
rescue
if force != nil
- then
dest_dirs.each do |d|
dirs = []
Dir.glob("#{d}/**/{.[^.],..?,}*") do |f|
@@ -136,14 +134,10 @@ def build_dest_folders (dest_dirs, force)
end#build_dest_folders
-if dumper.methods.include?(:dest_folders) || dumper.methods.include?("dest_folders")
- build_dest_folders(dumper.dest_folders, options[:force])
-end#if
-if dumper.methods.include?(:prolog) || dumper.methods.include?("prolog")
- dumper.prolog
-end#if
+build_dest_folders(dumper.dest_folders, options[:force]) if dumper.respond_to?(:dest_folders)
+dumper.prolog if dumper.respond_to?(:prolog)
types = {}
options[:xml_file].each {
@@ -160,6 +154,4 @@ options[:xml_file].each {
dumper.dump_datatree(datatree, name)
}
-if dumper.methods.include?(:epilog) || dumper.methods.include?("epilog")
- dumper.epilog
-end#if
+dumper.epilog if dumper.respond_to?(:epilog)