module Purpur
Constants
- ICON_EXTENTION
- ICON_SIZES
- ICON_SYNONIMS_HASH
- VERSION
Public Class Methods
assets_dir()
click to toggle source
# File lib/purpur.rb, line 76 def assets_dir File.join(root_dir, 'app', 'assets') end
icon_key(n)
click to toggle source
# File lib/purpur.rb, line 43 def icon_key(n) case n when Symbol, String n.downcase when Class n.name.to_s.downcase when Object n.class.name.to_s.downcase end end
icon_name(key)
click to toggle source
# File lib/purpur.rb, line 54 def icon_name(key) icon_names[icon_synonim(icon_key(key))] end
icon_names()
click to toggle source
# File lib/purpur.rb, line 88 def icon_names Hash[ self.icons.map {|i| [File.basename(i, ICON_EXTENTION), File.basename(i, ICON_EXTENTION)] } ].tap do |h| h.default_proc = ->(_, i) { Rails.logger.warn("'#{i}' is wrong icon name. Use one of #{h.keys.join(', ')}"); i.to_s } end end
icon_size(size)
click to toggle source
# File lib/purpur.rb, line 33 def icon_size(size) ICON_SIZES[size] end
icon_synonim(key)
click to toggle source
# File lib/purpur.rb, line 37 def icon_synonim(key) (ICON_SYNONIMS_HASH.with_indifferent_access.tap do |h| h.default_proc = ->(_, i) { i.to_s } end)[key] end
icons()
click to toggle source
# File lib/purpur.rb, line 84 def icons Dir[File.join(self.images_dir, "*#{ICON_EXTENTION}")] end
images_dir()
click to toggle source
# File lib/purpur.rb, line 80 def images_dir File.join(assets_dir, 'icons') end
rails?()
click to toggle source
# File lib/purpur.rb, line 64 def rails? defined?(::Rails::Engine) end
register!()
click to toggle source
# File lib/purpur.rb, line 58 def register! register_helpers register_engine if rails? register_sprockets if sprockets? end
root_dir()
click to toggle source
# File lib/purpur.rb, line 72 def root_dir File.expand_path "." end
sprite_file()
click to toggle source
# File lib/purpur.rb, line 98 def sprite_file File.join(assets_dir, 'images', 'purpur.svg') end
sprockets?()
click to toggle source
# File lib/purpur.rb, line 68 def sprockets? defined?(::Sprockets) end
Private Class Methods
register_engine()
click to toggle source
# File lib/purpur.rb, line 104 def register_engine require_relative 'purpur/engine' end
register_helpers()
click to toggle source
# File lib/purpur.rb, line 112 def register_helpers require_relative 'purpur/helpers' end
register_sprockets()
click to toggle source
# File lib/purpur.rb, line 108 def register_sprockets Sprockets.append_path(File.join(File.expand_path('../../', __FILE__), 'assets')) end