Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Rebuild gem #115

Merged
merged 9 commits into from
Jan 4, 2024
Merged
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
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ inherit_from:

require:
- rubocop-packaging

Style/Alias:
EnforcedStyle: prefer_alias_method
2 changes: 2 additions & 0 deletions .simplecov
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ if RSpec.configuration.files_to_run.length > 1
end

SimpleCov.start do
add_filter "lib/core_ext"

enable_coverage :branch

formatter SimpleCov::Formatter::MultiFormatter.new(formatters)
Expand Down
24 changes: 0 additions & 24 deletions exe/svgeez

This file was deleted.

153 changes: 153 additions & 0 deletions lib/core_ext/object/blank.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# frozen_string_literal: true

# Derived from Active Support's core extensions.
#
# Note that the dependency and code relying on the concurrent-ruby gem have
# been removed.
#
# @see https://github.com/rails/rails/blob/v7.1.2/activesupport/lib/active_support/core_ext/object/blank.rb
# @see https://github.com/rails/rails/pull/31049

class Object
# An object is blank if it's false, empty, or a whitespace string.
# For example, +nil+, '', ' ', [], {}, and +false+ are all blank.
#
# This simplifies
#
# !address || address.empty?
#
# to
#
# address.blank?
#
# @return [true, false]
def blank?
respond_to?(:empty?) ? !!empty? : !self
end

# An object is present if it's not blank.
#
# @return [true, false]
def present?
!blank?
end

# Returns the receiver if it's present otherwise returns +nil+.
# <tt>object.presence</tt> is equivalent to
#
# object.present? ? object : nil
#
# For example, something like
#
# state = params[:state] if params[:state].present?
# country = params[:country] if params[:country].present?
# region = state || country || 'US'
#
# becomes
#
# region = params[:state].presence || params[:country].presence || 'US'
#
# @return [Object]
def presence
self if present?
end
end

class NilClass
# +nil+ is blank:
#
# nil.blank? # => true
#
# @return [true]
def blank?
true
end
end

class FalseClass
# +false+ is blank:
#
# false.blank? # => true
#
# @return [true]
def blank?
true
end
end

class TrueClass
# +true+ is not blank:
#
# true.blank? # => false
#
# @return [false]
def blank?
false
end
end

class Array
# An array is blank if it's empty:
#
# [].blank? # => true
# [1,2,3].blank? # => false
#
# @return [true, false]
alias_method :blank?, :empty?
end

class Hash
# A hash is blank if it's empty:
#
# {}.blank? # => true
# { key: 'value' }.blank? # => false
#
# @return [true, false]
alias_method :blank?, :empty?
end

class String
BLANK_RE = /\A[[:space:]]*\z/

# A string is blank if it's empty or contains whitespaces only:
#
# ''.blank? # => true
# ' '.blank? # => true
# "\t\n\r".blank? # => true
# ' blah '.blank? # => false
#
# Unicode whitespace is supported:
#
# "\u00a0".blank? # => true
#
# @return [true, false]
def blank?
# The regexp that matches blank strings is expensive. For the case of empty
# strings we can speed up this method (~3.5x) with an empty? call. The
# penalty for the rest of strings is marginal.
empty? || BLANK_RE.match?(self)
end
end

class Numeric # :nodoc:
# No number is blank:
#
# 1.blank? # => false
# 0.blank? # => false
#
# @return [false]
def blank?
false
end
end

class Time # :nodoc:
# No Time is blank:
#
# Time.now.blank? # => false
#
# @return [false]
def blank?
false
end
end
28 changes: 8 additions & 20 deletions lib/svgeez.rb
Original file line number Diff line number Diff line change
@@ -1,31 +1,19 @@
# frozen_string_literal: true

require "fileutils"
require "logger"
require "mkmf"
require "securerandom"

require "listen"
require "mercenary"

require_relative "svgeez/version"

require_relative "svgeez/command"
require_relative "svgeez/commands/build"
require_relative "svgeez/commands/watch"

require_relative "svgeez/elements/svg_element"
require_relative "svgeez/elements/symbol_element"
require_relative "core_ext/object/blank"

require_relative "svgeez/builder"
require_relative "svgeez/destination"
require_relative "svgeez/optimizer"
require_relative "svgeez/source"
require_relative "svgeez/sprite"
require_relative "svgeez/sprite_sheet"
require_relative "svgeez/sprite_sheet_builder"

module Svgeez
def self.logger
@logger ||= Logger.new($stdout)
# @param (see Svgeez::SpriteSheetBuilder#initialize)
# @return (see Svgeez::SpriteSheetBuilder#initialize)
def self.build_sprite_sheet(...)
Svgeez::SpriteSheetBuilder.new(...).build_sprite_sheet
end

logger.formatter = proc { |_, _, _, msg| "#{msg}\n" }
end
73 changes: 0 additions & 73 deletions lib/svgeez/builder.rb

This file was deleted.

41 changes: 0 additions & 41 deletions lib/svgeez/command.rb

This file was deleted.

27 changes: 0 additions & 27 deletions lib/svgeez/commands/build.rb

This file was deleted.

Loading