Browse Source

Fixed style

Andrew Kane 9 years ago
parent
commit
63cebd9333

+ 1 - 1
Gemfile

@@ -1,4 +1,4 @@
-source 'https://rubygems.org'
+source "https://rubygems.org"
 
 # Specify your gem's dependencies in blazer.gemspec
 gemspec

+ 0 - 1
Rakefile

@@ -1,2 +1 @@
 require "bundler/gem_tasks"
-

+ 8 - 9
app/controllers/blazer/queries_controller.rb

@@ -45,7 +45,7 @@ module Blazer
         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 @@ 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.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 @@ module Blazer
           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 @@ module Blazer
     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 @@ module Blazer
       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 - 3
app/helpers/blazer/queries_helper.rb

@@ -1,6 +1,5 @@
 module Blazer
   module QueriesHelper
-
     def title(title = nil)
       if title
         content_for(:title) { title }
@@ -10,12 +9,11 @@ module Blazer
     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

+ 0 - 1
app/models/blazer/query.rb

@@ -8,6 +8,5 @@ module Blazer
     def to_param
       [id, name.gsub("'", "").parameterize].join("-")
     end
-
   end
 end

+ 4 - 4
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::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"
 

+ 1 - 1
lib/blazer.rb

@@ -14,7 +14,7 @@ module Blazer
   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]

+ 1 - 2
lib/blazer/engine.rb

@@ -4,8 +4,7 @@ module Blazer
 
     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