class Cranium::DSL::SourceDefinition

Attributes

fields[R]
files[R]
name[R]

Public Class Methods

new(name) click to toggle source
# File lib/cranium/dsl/source_definition.rb, line 19
def initialize(name)
  @name = name
  @file = default_file_name
  @fields = {}
  @delimiter = ","
  @escape = '"'
  @quote = '"'
  @encoding = "UTF-8"
end

Public Instance Methods

==(other) click to toggle source
# File lib/cranium/dsl/source_definition.rb, line 49
def ==(other)
  name == other.name and
    file == other.file and
    delimiter == other.delimiter and
    escape == other.escape and
    quote == other.quote and
    encoding == other.encoding and
    fields == other.fields
end
field(name, type) click to toggle source
# File lib/cranium/dsl/source_definition.rb, line 37
def field(name, type)
  @fields[name] = type
end
file_name_overriden?() click to toggle source
# File lib/cranium/dsl/source_definition.rb, line 43
def file_name_overriden?
  @file != default_file_name
end
resolve_files() click to toggle source
# File lib/cranium/dsl/source_definition.rb, line 31
def resolve_files
  @files = Dir[File.join Cranium.configuration.upload_path, @file].map { |file| File.basename file }.sort
end

Private Instance Methods

default_file_name() click to toggle source
# File lib/cranium/dsl/source_definition.rb, line 63
def default_file_name
  "#{@name}.csv"
end