Business intelligence made simple
Fixed style
Andrew Kane63cebd9333bf
diff --git a/Gemfile b/Gemfileindex 23ebcf43..e21e4961 100644--- a/Gemfile+++ b/Gemfile@@ -1,4 +1,4 @@-source 'https://rubygems.org'+source "https://rubygems.org"# Specify your gem's dependencies in blazer.gemspecgemspecdiff --git a/Rakefile b/Rakefileindex 809eb561..29955274 100644--- a/Rakefile+++ b/Rakefile@@ -1,2 +1 @@require "bundler/gem_tasks"-diff --git a/app/controllers/blazer/queries_controller.rb b/app/controllers/blazer/queries_controller.rbindex 8d4a228b..cd023dfd 100644--- a/app/controllers/blazer/queries_controller.rb+++ b/app/controllers/blazer/queries_controller.rb@@ -45,7 +45,7 @@ module Blazerquery = smart_variables[var]if queryrows, error = run_statement(query)- @smart_vars[var] = rows.map{|v| v.values.reverse }+ @smart_vars[var] = rows.map { |v| v.values.reverse }@sql_errors << error if errorendend@@ -88,15 +88,15 @@ module Blazer@filename = @query.name.parameterize if @query- @min_width_types = (@rows.first || {}).select{|k, v| v.is_a?(Time) or v.is_a?(String) or smart_columns[k] }.keys+ @min_width_types = (@rows.first || {}).select { |k, v| v.is_a?(Time) || v.is_a?(String) || smart_columns[k] }.keys@boom = {}@columns.keys.each do |key|query = smart_columns[key]if query- values = @rows.map{|r| r[key] }.compact.uniq+ values = @rows.map { |r| r[key] }.compact.uniqrows, error = run_statement(ActiveRecord::Base.send(:sanitize_sql_array, [query.sub("{value}", "(?)"), values]))- @boom[key] = Hash[ rows.map(&:values) ]+ @boom[key] = Hash[rows.map(&:values)]endend@@ -108,7 +108,7 @@ module Blazerrender layout: falseendformat.csv do- send_data csv_data(@rows), type: 'text/csv; charset=utf-8; header=present', disposition: "attachment; filename=\"#{@query ? @query.name.parameterize : "query"}.csv\""+ send_data csv_data(@rows), type: "text/csv; charset=utf-8; header=present", disposition: "attachment; filename=\"#{@query ? @query.name.parameterize : 'query'}.csv\""endendend@@ -174,12 +174,12 @@ module Blazerenddef extract_vars(statement)- statement.scan(/\{.*?\}/).map{|v| v[1...-1] }.uniq+ statement.scan(/\{.*?\}/).map { |v| v[1...-1] }.uniqenddef process_vars(statement)@bind_vars = extract_vars(statement)- @success = @bind_vars.all?{|v| params[v] }+ @success = @bind_vars.all? { |v| params[v] }if @success@bind_vars.each do |var|@@ -213,13 +213,12 @@ module Blazerdefault_schema = postgresql? ? "public" : Blazer::Connection.connection_config[:database]schema = Blazer::Connection.connection_config[:schema] || default_schemarows, error = run_statement(Blazer::Connection.send(:sanitize_sql_array, ["SELECT table_name, column_name, ordinal_position, data_type FROM information_schema.columns WHERE table_schema = ?", schema]))- Hash[ rows.group_by{|r| r["table_name"] }.map{|t, f| [t, f.sort_by{|f| f["ordinal_position"] }.map{|f| f.slice("column_name", "data_type") }] }.sort_by{|t, f| t } ]+ Hash[rows.group_by { |r| r["table_name"] }.map { |t, f| [t, f.sort_by { |f| f["ordinal_position"] }.map { |f| f.slice("column_name", "data_type") }] }.sort_by { |t, _f| t }]endhelper_method :tablesdef postgresql?Blazer::Connection.connection.adapter_name == "PostgreSQL"end-endenddiff --git a/app/helpers/blazer/queries_helper.rb b/app/helpers/blazer/queries_helper.rbindex 101cc5cd..b681f7a6 100644--- a/app/helpers/blazer/queries_helper.rb+++ b/app/helpers/blazer/queries_helper.rb@@ -1,6 +1,5 @@module Blazermodule QueriesHelper-def title(title = nil)if titlecontent_for(:title) { title }@@ -10,12 +9,11 @@ module Blazerenddef format_value(key, value)- if value.is_a?(Integer) and !key.to_s.end_with?("id")+ if value.is_a?(Integer) && !key.to_s.end_with?("id")number_with_delimiter(value)elsevalueendend-endenddiff --git a/app/models/blazer/query.rb b/app/models/blazer/query.rbindex ccff03b2..d455df1e 100644--- a/app/models/blazer/query.rb+++ b/app/models/blazer/query.rb@@ -8,6 +8,5 @@ module Blazerdef to_param[id, name.gsub("'", "").parameterize].join("-")end-endenddiff --git a/blazer.gemspec b/blazer.gemspecindex efb9579b..1d19c680 100644--- a/blazer.gemspec+++ b/blazer.gemspec@@ -1,15 +1,15 @@# coding: utf-8-lib = File.expand_path('../lib', __FILE__)+lib = File.expand_path("../lib", __FILE__)$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)-require 'blazer/version'+require "blazer/version"Gem::Specification.new do |spec|spec.name = "blazer"spec.version = Blazer::VERSIONspec.authors = ["Andrew Kane"]spec.email = ["[email protected]"]- spec.summary = %q{Share data effortlessly with your team}- spec.description = %q{Share data effortlessly with your team}+ spec.summary = "Share data effortlessly with your team"+ spec.description = "Share data effortlessly with your team"spec.homepage = "https://github.com/ankane/blazer"spec.license = "MIT"diff --git a/lib/blazer.rb b/lib/blazer.rbindex 60c09180..a3f8ccfb 100644--- a/lib/blazer.rb+++ b/lib/blazer.rb@@ -14,7 +14,7 @@ module Blazerself.audit = trueself.user_name = :nameself.timeout = 15- self.user_class = 'User'+ self.user_class = "User"def self.time_zone=(time_zone)@time_zone = time_zone.is_a?(ActiveSupport::TimeZone) ? time_zone : ActiveSupport::TimeZone[time_zone.to_s]diff --git a/lib/blazer/engine.rb b/lib/blazer/engine.rbindex 81f2249f..4422c600 100644--- a/lib/blazer/engine.rb+++ b/lib/blazer/engine.rb@@ -4,8 +4,7 @@ module Blazerinitializer "precompile" do |app|# use a proc instead of a string- app.config.assets.precompile << Proc.new{|path| path =~ /\Ablazer\/application\.(js|css)\z/ }+ app.config.assets.precompile << proc { |path| path =~ /\Ablazer\/application\.(js|css)\z/ }end-endend