Module: DbAgile::IO

Extended by:
IO
Included in:
IO, Restful::Middleware::Utils
Defined in:
lib/dbagile/io.rb,
lib/dbagile/io/csv.rb,
lib/dbagile/io/xml.rb,
lib/dbagile/io/html.rb,
lib/dbagile/io/json.rb,
lib/dbagile/io/ruby.rb,
lib/dbagile/io/text.rb,
lib/dbagile/io/yaml.rb,
lib/dbagile/io/type_safe.rb,
lib/dbagile/io/pretty_table.rb

Defined Under Namespace

Modules: CSV, HTML, JSON, PrettyTable, Ruby, Text, TypeSafe, XML, YAML

Constant Summary collapse

ROUND_TRIP_OPTIONS =

Options to set to ensure roundtrip on each format

{
  :type_system => SByC::TypeSystem::Ruby
}
KNOWN_FORMATS =

Known IO formats

[:yaml, :csv, :json, :ruby, :text, :xml, :html]
KNOWN_TO_FORMATS =

Known to_xxx IO formats

[:yaml, :csv, :json, :ruby, :text, :xml, :html]
KNOWN_FROM_FORMATS =

Known from_xxx formats

[:yaml, :csv, :json, :ruby]
FORMAT_TO_MODULE =

Format to helper module

{
  :yaml => DbAgile::IO::YAML,
  :csv  => DbAgile::IO::CSV,
  :json => DbAgile::IO::JSON,
  :ruby => DbAgile::IO::Ruby,
  :text => DbAgile::IO::Text,
  :xml  => DbAgile::IO::XML,
  :html => DbAgile::IO::HTML
}
EXTENSION_TO_FORMAT =

Which format for what extension

{
  ".csv"   => :csv,
  ".txt"   => :text,
  ".json"  => :json,
  ".yaml"  => :yaml,
  ".yml"   => :yaml,
  ".xml"   => :xml,
  ".html"  => :html,
  ".ruby"  => :ruby,
  ".rb"    => :ruby
}
FORMAT_TO_CONTENT_TYPE =

Which content type for which format

{
  :csv  => "text/csv",
  :text => "text/plain",
  :json => "application/json",
  :yaml => "text/yaml",
  :xml  => "text/xml",
  :html => "text/html",
  :ruby => "text/plain"
}

Instance Method Summary collapse

Instance Method Details

#known_extension?(f) ⇒ Boolean

Checks if an extension is known. Returns the associated format.

Returns:

  • (Boolean)


63
64
65
66
# File 'lib/dbagile/io.rb', line 63

def known_extension?(f)
  f = ".#{f}" unless f[0,1] == '.'
  EXTENSION_TO_FORMAT[f]
end

#known_format?(f) ⇒ Boolean

Checks if a format is known. Returns the associated content type.

Returns:

  • (Boolean)


69
70
71
# File 'lib/dbagile/io.rb', line 69

def known_format?(f)
  FORMAT_TO_CONTENT_TYPE[f]
end

#roundtrip_options(format) ⇒ Object

Returns roundtrip options



74
75
76
# File 'lib/dbagile/io.rb', line 74

def roundtrip_options(format)
  ROUND_TRIP_OPTIONS
end