Module: CsvExporter

Defined in:
lib/csv_exporter.rb,
lib/csv_exporter/base.rb,
lib/csv_exporter/version.rb

Defined Under Namespace

Classes: Base, NotFound, RuntimeError

Constant Summary collapse

VERSION =
"0.0.2"

Class Method Summary collapse

Class Method Details

.configurationObject



18
19
20
# File 'lib/csv_exporter.rb', line 18

def configuration
  @configuration
end

.file(filename = nil) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/csv_exporter.rb', line 22

def file(filename = nil)
  file_hash = if configuration
    { path: configuration['filepath'], name: filename || configuration['filename'] }
  else
    { path: 'tmp', name: filename || 'file.csv' }
  end

  File.join(root, file_hash[:path], file_hash[:name])
end

.load(file, env = nil) ⇒ Object



12
13
14
15
16
# File 'lib/csv_exporter.rb', line 12

def load(file, env = nil)
  @environment = env.to_s if env
  config = YAML.load_file(file)
  @configuration = defined?(@environment) ? config[@environment] : config
end

.rootObject



32
33
34
# File 'lib/csv_exporter.rb', line 32

def root
  defined?(Rails) ? Rails.root : File.expand_path("../.." , __FILE__)
end