Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Removed Object#blank? monkey patch #83

Draft
wants to merge 1 commit into
base: 01-06-chore_replaced_rubocop_w__standardrb
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading