Skip to content

Commit

Permalink
chore: Removed Object#blank? monkey patch
Browse files Browse the repository at this point in the history
  • Loading branch information
jylamont committed Jan 7, 2025
1 parent 72d2e5a commit 7434687
Show file tree
Hide file tree
Showing 12 changed files with 14 additions and 43 deletions.
26 changes: 2 additions & 24 deletions lib/generators/vero_generator.rb
Original file line number Diff line number Diff line change
@@ -1,34 +1,12 @@
# frozen_string_literal: true

class VeroGenerator < Rails::Generators::Base
class_option :heroku
class_option :api_key
class_option :api_secret

def create_initializer_file
type = options[:heroku] || "standard"

abort("You must provide an API KEY and API SECRET to proceed.") if options[:heroku].blank? && (options[:api_key].blank? || options[:api_secret].blank?)
create_file "config/initializers/vero.rb", send(:"#{type}_initializer_content")
end

private

def standard_initializer_content
<<~END_TEXT
Vero::App.init do |config|
config.api_key = '#{options[:api_key]}'
config.secret = '#{options[:api_secret]}'
end
END_TEXT
end

def heroku_initializer_content
<<~END_TEXT
create_file("config/initializers/vero.rb", <<~INITIALIZER)
Vero::App.init do |config|
config.api_key = ENV['VERO_API_KEY']
config.secret = ENV['VERO_API_SECRET']
end
END_TEXT
INITIALIZER
end
end
1 change: 0 additions & 1 deletion lib/vero.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

require "rest-client"
require "vero/utility/ext"

module Vero
autoload :Config, "vero/config"
Expand Down
2 changes: 1 addition & 1 deletion lib/vero/api/events/track_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def request
end

def validate!
raise ArgumentError, "Missing :event_name" if options[:event_name].to_s.blank?
raise ArgumentError, "Missing :event_name" if options[:event_name].to_s.empty?
raise ArgumentError, ":data must be either nil or a Hash" unless options[:data].nil? || options[:data].is_a?(Hash)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/vero/api/users/delete_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def request
end

def validate!
raise ArgumentError, "Missing :id" if options[:id].to_s.blank?
raise ArgumentError, "Missing :id" if options[:id].to_s.empty?
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/vero/api/users/edit_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def request
end

def validate!
raise ArgumentError, "Missing :id or :email" if options[:id].to_s.blank? && options[:email].to_s.blank?
raise ArgumentError, "Missing :id or :email" if options[:id].to_s.empty? && options[:email].to_s.empty?
raise ArgumentError, ":changes must be a Hash" unless options[:changes].is_a?(Hash)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/vero/api/users/edit_tags_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def request
end

def validate!
raise ArgumentError, "Missing :id or :email" if options[:id].to_s.blank? && options[:email].to_s.blank?
raise ArgumentError, "Missing :id or :email" if options[:id].to_s.empty? && options[:email].to_s.empty?
raise ArgumentError, ":add must an Array if present" unless options[:add].nil? || options[:add].is_a?(Array)
raise ArgumentError, ":remove must an Array if present" unless options[:remove].nil? || options[:remove].is_a?(Array)
raise ArgumentError, "Either :add or :remove must be present" if options[:remove].nil? && options[:add].nil?
Expand Down
4 changes: 2 additions & 2 deletions lib/vero/api/users/reidentify_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def request
end

def validate!
raise ArgumentError, "Missing :id" if options[:id].to_s.blank?
raise ArgumentError, "Missing :new_id" if options[:new_id].to_s.blank?
raise ArgumentError, "Missing :id" if options[:id].to_s.empty?
raise ArgumentError, "Missing :new_id" if options[:new_id].to_s.empty?
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/vero/api/users/resubscribe_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def request
end

def validate!
raise ArgumentError, "Missing :id or :email" if options[:id].to_s.blank? && options[:email].to_s.blank?
raise ArgumentError, "Missing :id or :email" if options[:id].to_s.empty? && options[:email].to_s.empty?
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/vero/api/users/track_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def request
end

def validate!
raise ArgumentError, "Missing :id or :email" if options[:id].to_s.blank? && options[:email].to_s.blank?
raise ArgumentError, "Missing :id or :email" if options[:id].to_s.empty? && options[:email].to_s.empty?
raise ArgumentError, ":data must be either nil or a Hash" unless options[:data].nil? || options[:data].is_a?(Hash)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/vero/api/users/unsubscribe_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def request
end

def validate!
raise ArgumentError, "Missing :id or :email" if options[:id].to_s.blank? && options[:email].to_s.blank?
raise ArgumentError, "Missing :id or :email" if options[:id].to_s.empty? && options[:email].to_s.empty?
end
end
end
Expand Down
5 changes: 3 additions & 2 deletions lib/vero/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ def request_params
end

def domain
if @domain.blank?
if @domain.nil? || @domain.empty?
"https://api.getvero.com"
else
%r{https?://.+}.match?(@domain) ? @domain : "http://#{@domain}"
a_domain = @domain.to_s
%r{https?://.+}.match?(a_domain) ? a_domain : "http://#{a_domain}"
end
end

Expand Down
7 changes: 0 additions & 7 deletions lib/vero/utility/ext.rb

This file was deleted.

0 comments on commit 7434687

Please sign in to comment.