Module: Reportinator

Defined in:
lib/reportinator.rb,
lib/reportinator/base.rb,
lib/reportinator/config.rb,
lib/reportinator/parser.rb,
lib/reportinator/helpers.rb,
lib/reportinator/version.rb,
lib/reportinator/function.rb,
lib/reportinator/report/row.rb,
lib/reportinator/report_type.rb,
lib/reportinator/types/model.rb,
lib/reportinator/types/preset.rb,
lib/reportinator/parsers/value.rb,
lib/reportinator/report/column.rb,
lib/reportinator/report/loader.rb,
lib/reportinator/report/report.rb,
lib/reportinator/parsers/method.rb,
lib/reportinator/parsers/report.rb,
lib/reportinator/functions/array.rb,
lib/reportinator/report/template.rb,
lib/reportinator/functions/string.rb,
lib/reportinator/functions/array/join.rb,
lib/reportinator/functions/array/range.rb,
lib/reportinator/functions/string/date.rb,
lib/reportinator/functions/string/join.rb,
lib/reportinator/functions/array/helper.rb,
lib/reportinator/functions/array/method.rb,
lib/reportinator/functions/array/string.rb,
lib/reportinator/functions/string/range.rb,
lib/reportinator/functions/array/flatten.rb,
lib/reportinator/functions/array/snippet.rb,
lib/reportinator/functions/string/number.rb,
lib/reportinator/functions/string/symbol.rb,
lib/reportinator/functions/string/logical.rb,
lib/reportinator/functions/string/addition.rb,
lib/reportinator/functions/string/constant.rb,
lib/reportinator/functions/string/variable.rb

Defined Under Namespace

Modules: Helpers Classes: AdditionStringFunction, ArrayFunction, Base, Column, Config, ConstantStringFunction, DateStringFunction, Error, FlattenArrayFunction, Function, HelperArrayFunction, JoinArrayFunction, JoinStringFunction, LogicalStringFunction, MethodArrayFunction, MethodParser, ModelReport, NumberStringFunction, Parser, PresetReport, RangeArrayFunction, RangeStringFunction, Report, ReportLoader, ReportParser, ReportType, Row, SnippetArrayFunction, StringArrayFunction, StringFunction, SymbolStringFunction, Template, ValueParser, VariableStringFunction

Constant Summary collapse

SCHEMA =
"#{__dir__}/../data/schema/report_schema.json"
VERSION =
"0.3.4"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configObject



22
23
24
# File 'lib/reportinator.rb', line 22

def self.config
  @config ||= Config.new
end

.loggerObject



36
37
38
# File 'lib/reportinator.rb', line 36

def self.logger
  @logger || ActiveSupport::Logger.new($stdout)
end

.schemaObject



30
31
32
33
34
# File 'lib/reportinator.rb', line 30

def self.schema
  return @schema if @schema.instance_of? JSONSchemer
  schema = JSON.parse(File.read(SCHEMA))
  @schema = JSONSchemer.schema(schema)
end

Class Method Details

.configure {|config| ... } ⇒ Object

Yields:



26
27
28
# File 'lib/reportinator.rb', line 26

def self.configure
  yield(config)
end

.output(template, metadata = {}, filename = "") ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/reportinator.rb', line 49

def self.output(template,  = {}, filename = "")
  filename = (filename.present? ? filename : "#{template}.csv")
  path = "#{config.output_directory}/#{filename}"
  FileUtils.mkdir_p(File.dirname(path))
  report = ReportLoader.load(template, ).report
  data = report.to_csv
  if File.write(path, data)
    path
  else
    raise "Error writing to: #{path}"
  end
end

.parse(input, metadata = {}) ⇒ Object



40
41
42
# File 'lib/reportinator.rb', line 40

def self.parse(input,  = {})
  ValueParser.parse(input, )
end

.report(template, metadata = {}) ⇒ Object



44
45
46
47
# File 'lib/reportinator.rb', line 44

def self.report(template,  = {})
  report = ReportLoader.load(template, ).report
  report.output
end