Sha256: f236a10cd86833f0d1345b6a37da4e6aae7711c4d921e638f03c3c4389fbd9f3

Contents?: true

Size: 1020 Bytes

Versions: 1

Compression:

Stored size: 1020 Bytes

Contents

module EditorConfigGenerator
  # Transforms options given to an EditorConfig object
  class OptionTransformer
    def self.transform_options(options)
      transform_root_option(options)
      transform_whitespace_option(options)
      transform_final_newline_option(options)
    end

    def self.transform_final_newline_option(options)
      if options[:insert_final_newline] == 'y'
        options[:insert_final_newline] = true
      elsif options[:insert_final_newline] == 'n'
        options[:insert_final_newline] = false
      end
    end

    def self.transform_whitespace_option(options)
      if options[:trim_trailing_whitespace] == 'y'
        options[:trim_trailing_whitespace] = true
      elsif options[:trim_trailing_whitespace] == 'n'
        options[:trim_trailing_whitespace] = false
      end
    end

    def self.transform_root_option(options)
      if options[:root] == 'y'
        options[:root] = true
      elsif options[:root] == 'n'
        options[:root] = false
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
editorconfig_generator-0.2.3 lib/editorconfig/option_transformer.rb