Skip to content

Commit

Permalink
chore: Replaced rubocop w/ StandardRb
Browse files Browse the repository at this point in the history
  • Loading branch information
jylamont committed Jan 7, 2025
1 parent d3bf358 commit f5172ed
Show file tree
Hide file tree
Showing 54 changed files with 470 additions and 523 deletions.
42 changes: 0 additions & 42 deletions .rubocop.yml

This file was deleted.

25 changes: 0 additions & 25 deletions .rubocop_todo.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .standard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# For available configuration options, see:
# https://github.com/standardrb/standard
ruby_version: 2.7
20 changes: 10 additions & 10 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# frozen_string_literal: true

source 'http://rubygems.org'
source "http://rubygems.org"

gemspec

group :development do
gem 'rubocop'

gem 'delayed_job'
gem 'delayed_job_active_record'
gem 'rails'
gem 'resque'
gem 'sidekiq'
gem 'sucker_punch'
gem "delayed_job"
gem "delayed_job_active_record"
gem "rails"
gem "resque"
gem "rubocop"
gem "sidekiq"
gem "sucker_punch"
gem "standard"
end

group :test do
gem 'rspec'
gem "rspec"
end
6 changes: 6 additions & 0 deletions bin/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
set -vx

bundle install
6 changes: 3 additions & 3 deletions lib/generators/vero_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ class VeroGenerator < Rails::Generators::Base
class_option :api_secret

def create_initializer_file
type = options[:heroku] || 'standard'
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".to_sym)
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".to_sym)
end

private
Expand Down
62 changes: 31 additions & 31 deletions lib/vero.rb
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
# frozen_string_literal: true

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

module Vero
autoload :Config, 'vero/config'
autoload :App, 'vero/app'
autoload :Context, 'vero/context'
autoload :APIContext, 'vero/context/api'
autoload :Trackable, 'vero/trackable'
autoload :DSL, 'vero/dsl'
autoload :Sender, 'vero/sender'
autoload :SuckerPunchWorker, 'vero/senders/sucker_punch'
autoload :ResqueWorker, 'vero/senders/resque'
autoload :SidekiqWorker, 'vero/senders/sidekiq'
autoload :Config, "vero/config"
autoload :App, "vero/app"
autoload :Context, "vero/context"
autoload :APIContext, "vero/context/api"
autoload :Trackable, "vero/trackable"
autoload :DSL, "vero/dsl"
autoload :Sender, "vero/sender"
autoload :SuckerPunchWorker, "vero/senders/sucker_punch"
autoload :ResqueWorker, "vero/senders/resque"
autoload :SidekiqWorker, "vero/senders/sidekiq"

module Api
module Workers
autoload :BaseAPI, 'vero/api/base_api'
autoload :BaseAPI, "vero/api/base_api"

module Events
autoload :TrackAPI, 'vero/api/events/track_api'
autoload :TrackAPI, "vero/api/events/track_api"
end

module Users
autoload :TrackAPI, 'vero/api/users/track_api'
autoload :EditAPI, 'vero/api/users/edit_api'
autoload :EditTagsAPI, 'vero/api/users/edit_tags_api'
autoload :UnsubscribeAPI, 'vero/api/users/unsubscribe_api'
autoload :ResubscribeAPI, 'vero/api/users/resubscribe_api'
autoload :ReidentifyAPI, 'vero/api/users/reidentify_api'
autoload :DeleteAPI, 'vero/api/users/delete_api'
autoload :TrackAPI, "vero/api/users/track_api"
autoload :EditAPI, "vero/api/users/edit_api"
autoload :EditTagsAPI, "vero/api/users/edit_tags_api"
autoload :UnsubscribeAPI, "vero/api/users/unsubscribe_api"
autoload :ResubscribeAPI, "vero/api/users/resubscribe_api"
autoload :ReidentifyAPI, "vero/api/users/reidentify_api"
autoload :DeleteAPI, "vero/api/users/delete_api"
end
end

autoload :Events, 'vero/api'
autoload :Users, 'vero/api'
autoload :Events, "vero/api"
autoload :Users, "vero/api"
end

module Senders
autoload :Base, 'vero/senders/base'
autoload :DelayedJob, 'vero/senders/delayed_job'
autoload :Resque, 'vero/senders/resque'
autoload :Sidekiq, 'vero/senders/sidekiq'
autoload :Invalid, 'vero/senders/invalid'
autoload :SuckerPunch, 'vero/senders/sucker_punch'
autoload :Base, "vero/senders/base"
autoload :DelayedJob, "vero/senders/delayed_job"
autoload :Resque, "vero/senders/resque"
autoload :Sidekiq, "vero/senders/sidekiq"
autoload :Invalid, "vero/senders/invalid"
autoload :SuckerPunch, "vero/senders/sucker_punch"
end

module Utility
autoload :Logger, 'vero/utility/logger'
autoload :Logger, "vero/utility/logger"
end
end

require 'vero/railtie' if defined?(Rails)
require "vero/railtie" if defined?(Rails)
12 changes: 7 additions & 5 deletions lib/vero/api/base_api.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require 'json'
require 'rest-client'
require "json"
require "rest-client"

module Vero
module Api
Expand Down Expand Up @@ -42,16 +42,18 @@ def proxy.<<(message)
end
end

def url; end
def url
end

def validate!
raise "#{self.class.name}#validate! should be overridden"
end

def request; end
def request
end

def request_content_type
{ content_type: :json, accept: :json }
{content_type: :json, accept: :json}
end

def request_params_as_json
Expand Down
4 changes: 2 additions & 2 deletions lib/vero/api/events/track_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 :event_name' if options[:event_name].to_s.blank?
raise ArgumentError, ':data must be either nil or a Hash' unless options[:data].nil? || options[:data].is_a?(Hash)
raise ArgumentError, "Missing :event_name" if options[:event_name].to_s.blank?
raise ArgumentError, ":data must be either nil or a Hash" unless options[:data].nil? || options[:data].is_a?(Hash)
end
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.blank?
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/vero/api/users/edit_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 or :email' if options[:id].to_s.blank? && options[:email].to_s.blank?
raise ArgumentError, ':changes must be a Hash' unless options[:changes].is_a?(Hash)
raise ArgumentError, "Missing :id or :email" if options[:id].to_s.blank? && options[:email].to_s.blank?
raise ArgumentError, ":changes must be a Hash" unless options[:changes].is_a?(Hash)
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/vero/api/users/edit_tags_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ def request
end

def validate!
raise ArgumentError, 'Missing :id or :email' if options[:id].to_s.blank? && options[:email].to_s.blank?
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?
raise ArgumentError, "Missing :id or :email" if options[:id].to_s.blank? && options[:email].to_s.blank?
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?
end
end
end
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.blank?
raise ArgumentError, "Missing :new_id" if options[:new_id].to_s.blank?
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.blank? && options[:email].to_s.blank?
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/vero/api/users/track_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 or :email' if options[:id].to_s.blank? && options[:email].to_s.blank?
raise ArgumentError, ':data must be either nil or a Hash' unless options[:data].nil? || options[:data].is_a?(Hash)
raise ArgumentError, "Missing :id or :email" if options[:id].to_s.blank? && options[:email].to_s.blank?
raise ArgumentError, ":data must be either nil or a Hash" unless options[:data].nil? || options[:data].is_a?(Hash)
end
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.blank? && options[:email].to_s.blank?
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/vero/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def self.default_context
end

def self.init(&block)
default_context.configure(&block) if block_given?
default_context.configure(&block) if block
end

def self.reset!
Expand Down
14 changes: 7 additions & 7 deletions lib/vero/config.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require 'base64'
require "base64"

module Vero
class Config
Expand All @@ -16,7 +16,7 @@ def initialize
end

def config_params
{ tracking_api_key: tracking_api_key }
{tracking_api_key: tracking_api_key}
end

def request_params
Expand All @@ -28,9 +28,9 @@ def request_params

def domain
if @domain.blank?
'https://api.getvero.com'
"https://api.getvero.com"
else
@domain =~ %r{https?://.+} ? @domain : "http://#{@domain}"
%r{https?://.+}.match?(@domain) ? @domain : "http://#{@domain}"
end
end

Expand All @@ -43,10 +43,10 @@ def disable_requests!
end

def reset!
self.disabled = false
self.disabled = false
self.development_mode = false
self.async = true
self.logging = false
self.async = true
self.logging = false
self.tracking_api_key = nil
end

Expand Down
2 changes: 1 addition & 1 deletion lib/vero/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def initialize(object = {})
def configure(hash = {}, &block)
@config.update_attributes(hash) if hash.is_a?(Hash) && hash.any?

block.call(@config) if block_given?
block&.call(@config)
end

def reset!
Expand Down
Loading

0 comments on commit f5172ed

Please sign in to comment.