Sha256: 93e614949086b4d4ed084e7a46d49d3c27694ee2f1cd2d2b678fa0239d04b186

Contents?: true

Size: 957 Bytes

Versions: 3

Compression:

Stored size: 957 Bytes

Contents

module OldSql
  module ReportDesign
    class ChartParser
      def self.read_file file_to_read
        raise ArgumentError, 'Argument file is null.' unless !file_to_read.nil?
        full_path = "#{report_design_path}/#{file_to_read}"
        raise ArgumentError, "File #{full_path} not found." unless File.exists?(full_path)
        
        @chart = Chart.new
        
        template = File.read("#{report_design_path}/#{file_to_read}")
        design_template = YAML.load(Erubis::Eruby.new(template).result)
        
        design_template.each do |type, i|
          @chart.type = type
          i.each do |key, value|
            @chart.add(key, value)
          end
        end
      
        @chart
      end
      
      def self.report_design_path
        app_path = Rails.public_path.split("/")
        app_path.delete_at(-1)
        app_path = app_path.join("/")
        app_path << "/config/old_sql/report_design"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
old_sql-1.16.0 lib/old_sql/report_design/chart_parser.rb
old_sql-1.15.0 lib/old_sql/report_design/chart_parser.rb
old_sql-1.14.0 lib/old_sql/report_design/chart_parser.rb