Skip to content

Business intelligence made simple

Improved code [skip ci]

Andrew Kane4e3c5b384d88
diff --git a/lib/blazer/adapters/hive_adapter.rb b/lib/blazer/adapters/hive_adapter.rb
index 4f2b4c81..3dba4398 100644
--- a/lib/blazer/adapters/hive_adapter.rb
+++ b/lib/blazer/adapters/hive_adapter.rb
@@ -45,7 +45,7 @@ module Blazer
port: uri.port,
username: uri.user,
password: uri.password,
- database: uri.path.sub(/\A\//, ""),
+ database: uri.path.delete_prefix("/"),
mode: uri.scheme.to_sym
)
end
diff --git a/lib/blazer/adapters/presto_adapter.rb b/lib/blazer/adapters/presto_adapter.rb
index 79895109..d94824f0 100644
--- a/lib/blazer/adapters/presto_adapter.rb
+++ b/lib/blazer/adapters/presto_adapter.rb
@@ -42,7 +42,7 @@ module Blazer
query = uri.query ? CGI.parse(uri.query) : {}
Presto::Client.new(
server: "#{uri.host}:#{uri.port}",
- catalog: uri.path.to_s.sub(/\A\//, ""),
+ catalog: uri.path.to_s.delete_prefix("/"),
schema: query["schema"] || "public",
user: uri.user,
http_debug: false
diff --git a/lib/blazer/adapters/sql_adapter.rb b/lib/blazer/adapters/sql_adapter.rb
index f35826c9..8958301e 100644
--- a/lib/blazer/adapters/sql_adapter.rb
+++ b/lib/blazer/adapters/sql_adapter.rb
@@ -150,7 +150,7 @@ module Blazer
def cohort_analysis_statement(statement, period:, days:)
raise "Cohort analysis not supported" unless supports_cohort_analysis?
- cohort_column = statement =~ /\bcohort_time\b/ ? "cohort_time" : "conversion_time"
+ cohort_column = statement.match?(/\bcohort_time\b/) ? "cohort_time" : "conversion_time"
tzname = Blazer.time_zone.tzinfo.name
if mysql?
diff --git a/lib/blazer/statement.rb b/lib/blazer/statement.rb
index af378331..d23a9c16 100644
--- a/lib/blazer/statement.rb
+++ b/lib/blazer/statement.rb
@@ -33,9 +33,9 @@ module Blazer
end
unless value.is_a?(ActiveSupport::TimeWithZone)
- if value =~ /\A\d+\z/
+ if value.match?(/\A\d+\z/)
value = value.to_i
- elsif value =~ /\A\d+\.\d+\z/
+ elsif value.match?(/\A\d+\.\d+\z/)
value = value.to_f
end
end