Commit 9bfca4a2 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Use cursing to expected types when loading config.json.

A better style than checking for types of values.  More Rubyish too.
parent f0d4dd8f
Loading
Loading
Loading
Loading
+7 −11
Original line number Diff line number Diff line
@@ -405,20 +405,16 @@ module JsDuck
      json.each_pair do |key, value|
        if key == "--"
          # filenames
          config += value.is_a?(Array) ? value : [value]
          config += Array(value).map(&:to_s)
        elsif value == true
          # simple switch
          config += [key]
        elsif value.is_a?(String)
          # option with parameter
          config += [key, value]
        elsif value.is_a?(Array)
          # one option multiple times
          value.each do |v|
            config += [key, v]
          end
          config += [key.to_s]
        else
          # ignore anything else
          # An option with value or with multiple values.
          # In the latter case, add the option multiple times.
          Array(value).each do |v|
            config += [key.to_s, v.to_s]
          end
        end
      end
      config