Module: Rapport

Defined in:
lib/helpers.rb,
lib/rapport/report.rb,
lib/rapport/report_generator.rb,
lib/rapport/report_generators/report_generator_fake.rb,
lib/rapport/report_generators/report_generator_simple_csv.rb

Defined Under Namespace

Modules: Report, ReportGenerator Classes: CellFormatter, ReportGeneratorFake, ReportGeneratorSimpleCsv

Class Method Summary collapse

Class Method Details

.format_camel_case(value) ⇒ Object



24
25
26
# File 'lib/helpers.rb', line 24

def format_camel_case(value)
  value.to_s.capitalize.gsub(/_(.)/){ $1.upcase }
end

.format_underscore(value) ⇒ Object



20
21
22
# File 'lib/helpers.rb', line 20

def format_underscore(value)
  value.to_s.gsub(/\W/,'_').gsub(/(.)([A-Z])/,'\1_\2').gsub(/_+/,'_').downcase
end

.loggerObject



28
29
30
31
32
33
34
# File 'lib/helpers.rb', line 28

def logger
  if Module.const_defined?("Rails")
    @_logger ||= Rails.logger
  else
    @_logger ||= Logger.new(STDERR)
  end
end

.logger=(logger) ⇒ Object



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

def logger=(logger)
  @_logger = logger
end

.safe_proc(proc) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/helpers.rb', line 6

def safe_proc(proc)
  lambda do |m|
    begin
      proc.call(m) 
    rescue NameError => ne
      nil
    end
  end
end

.safe_send(key) ⇒ Object



16
17
18
# File 'lib/helpers.rb', line 16

def safe_send(key)
  lambda{|m| !m.nil? and m.respond_to?(key) ? m.send(key) : nil }
end