Module: OldSql

Defined in:
lib/old_sql.rb,
lib/old_sql/engine.rb,
lib/old_sql/report_design/row.rb,
lib/old_sql/report_design/cell.rb,
lib/old_sql/report_design/chart.rb,
lib/old_sql/report_design/model.rb,
lib/old_sql/shell_report_facade.rb,
lib/old_sql/report_design/parser.rb,
lib/old_sql/report_processor/base.rb,
lib/old_sql/report_design/cell_data.rb,
lib/old_sql/report_design/chart_data.rb,
lib/old_sql/report_design/chart_item.rb,
lib/old_sql/report_design/chart_parser.rb,
lib/generators/old_sql/install_generator.rb,
lib/generators/old_sql/old_sql_generator.rb,
lib/generators/old_sql/templates/test_db.rb,
app/controllers/old_sql/report_controller.rb,
lib/generators/old_sql/copy_assets_generator.rb,
lib/generators/old_sql/install_migrations_generator.rb,
lib/generators/old_sql/install_devise_migrations_generator.rb

Defined Under Namespace

Modules: Db, ReportDesign, ReportProcessor Classes: CopyAssetsGenerator, Engine, InstallDeviseMigrationsGenerator, InstallGenerator, InstallMigrationsGenerator, OldSqlGenerator, ReportController, ShellReportFacade

Constant Summary collapse

@@devise_model =
'user'
@@report_select_page_title =
'Old SQL Reports'
@@default_report_view =
'jqgrid'
@@round_report_values =
true
@@rounding_precision =
2
@@report_width =
630
@@jqgrid_row_num =
25
@@google_chart_colors =
['#E35F18','#307CC7','#D95117','#0A4592','#B33A13','#073D8D','#902811','#052D79','#7A1904','#061E59','#6E0E02','#071253','#530005','#1F3058','#2A437F','#3657A8','#5675BB','#7A94CC','#F38200','#C4794B','#BF5D29','#B8410B','#AD3300','#802205','#36170F']

Class Method Summary collapse

Class Method Details

.setup {|_self| ... } ⇒ Object

Default way to setup Old SQL. Run rails generate old_sql:install to create a fresh initializer with all configuration values.

Yields:

  • (_self)

Yield Parameters:

  • _self (OldSql)

    the object that the method was called on



43
44
45
# File 'lib/old_sql.rb', line 43

def self.setup
  yield self
end

.strip_html(html) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/old_sql.rb', line 47

def self.strip_html html
  text = html.
  gsub(/( |\n|\s)+/im, ' ').squeeze(' ').strip.
  gsub(/<([^\s]+)[^>]*(src|href)=\s*(.?)([^>\s]*)\3[^>]*>\4<\/\1>/i, '\4')

  links = []
  linkregex = /<[^>]*(src|href)=\s*(.?)([^>\s]*)\2[^>]*>\s*/i
  while linkregex.match(text)
    links << $~[3]
    text.sub!(linkregex, "[#{links.size}]")
  end

  text = CGI.unescapeHTML(
    text.
      gsub(/<(script|style)[^>]*>.*<\/\1>/im, '').
      gsub(/<!--.*-->/m, '').
      gsub(/<hr(| [^>]*)>/i, "___\n").
      gsub(/<li(| [^>]*)>/i, "\n* ").
      gsub(/<blockquote(| [^>]*)>/i, '> ').
      gsub(/<(br)(| [^>]*)>/i, "\n").
      gsub(/<(\/h[\d]+|p)(| [^>]*)>/i, "\n\n").
      gsub(/<[^>]*>/, '')
  ).lstrip.gsub(/\n[ ]+/, "\n") + "\n"

  for i in (0...links.size).to_a
    text = text + "\n  [#{i+1}] <#{CGI.unescapeHTML(links[i])}>" unless links[i].nil?
  end
  links = nil
  text
end