Class: OldSql::ReportDesign::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/old_sql/report_design/parser.rb

Class Method Summary collapse

Class Method Details

.read_file(file_to_read) ⇒ Object

Raises:

  • (ArgumentError)


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/old_sql/report_design/parser.rb', line 4

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)
  
  @model = Model.new
  
  file = File.new(full_path, "r")
  while (line = file.gets)
    @model.add line
  end
  file.close

  @model
end

.report_design_pathObject



20
21
22
23
24
25
# File 'lib/old_sql/report_design/parser.rb', line 20

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