Permalink
Browse files

Fixed style

  • Loading branch information...
1 parent ae75629 commit 63cebd9333bfe732abaab7d0d8a362946f8f43ee @ankane committed May 12, 2015
View
@@ -1,4 +1,4 @@
-source 'https://rubygems.org'
+source "https://rubygems.org"
# Specify your gem's dependencies in blazer.gemspec
gemspec
View
@@ -1,2 +1 @@
require "bundler/gem_tasks"
-
@@ -45,7 +45,7 @@ def show
query = smart_variables[var]
if query
rows, 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 error
end
end
@@ -88,15 +88,15 @@ def run
@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.uniq
rows, 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)]
end
end
@@ -108,7 +108,7 @@ def run
render layout: false
end
format.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\""
end
end
end
@@ -174,12 +174,12 @@ def run_statement(statement)
end
def extract_vars(statement)
- statement.scan(/\{.*?\}/).map{|v| v[1...-1] }.uniq
+ statement.scan(/\{.*?\}/).map { |v| v[1...-1] }.uniq
end
def 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 @@ def tables
default_schema = postgresql? ? "public" : Blazer::Connection.connection_config[:database]
schema = Blazer::Connection.connection_config[:schema] || default_schema
rows, 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 }]
end
helper_method :tables
def postgresql?
Blazer::Connection.connection.adapter_name == "PostgreSQL"
end
-
end
end
@@ -1,6 +1,5 @@
module Blazer
module QueriesHelper
-
def title(title = nil)
if title
content_for(:title) { title }
@@ -10,12 +9,11 @@ def title(title = nil)
end
def 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)
else
value
end
end
-
end
end
@@ -8,6 +8,5 @@ class Query < ActiveRecord::Base
def to_param
[id, name.gsub("'", "").parameterize].join("-")
end
-
end
end
View
@@ -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::VERSION
spec.authors = ["Andrew Kane"]
spec.email = ["andrew@chartkick.com"]
- 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"
View
@@ -14,7 +14,7 @@ class << self
self.audit = true
self.user_name = :name
self.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]
@@ -4,8 +4,7 @@ class Engine < ::Rails::Engine
initializer "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
-
end
end

0 comments on commit 63cebd9

Please sign in to comment.