module SvgHeartsYou

Constants

VERSION

Attributes

configuration[RW]

Public Class Methods

configure() { |configuration| ... } click to toggle source

Allow a persistent configuration object to be set on the module

# File lib/svg_hearts_you/module.rb, line 7
def self.configure
  yield(configuration)
end
find_svg_file(filename) click to toggle source
# File lib/svg_hearts_you/helpers.rb, line 5
def self.find_svg_file(filename)
  configuration.all_svg_paths.each do |path|
    file_path = File.join path, filename
    if File.exists?(file_path)
      return File.read file_path
    end
  end

  # if not found, raise error
  raise "File #{filename} not found"
end
svgs_for_folder(folder_name) click to toggle source
# File lib/svg_hearts_you/helpers.rb, line 17
def self.svgs_for_folder(folder_name)
  configuration.all_svg_paths.each do |path|
    folder_path = File.join path, folder_name
    if File.exists?(folder_path) && File.directory?(folder_path)
      Dir.chdir(folder_path)
      return Dir.glob("*.svg*").map do |filename|
        file_path = File.join folder_path, filename
        { file: File.read(file_path), filename: filename }
        # File.join(folder_name, filename)
      end
    end
  end

  # if not found, raise error
  raise "Folder #{folder_name} not found"
end

Private Class Methods

reset() click to toggle source
# File lib/svg_hearts_you/module.rb, line 16
def self.reset
  @configuration = Configuration.new
end