Class: UtilityColors::Imports
- Inherits:
-
Object
- Object
- UtilityColors::Imports
- Defined in:
- lib/utility_colors/imports.rb
Class Method Summary collapse
Class Method Details
.css(import_path) ⇒ Object
37 38 39 40 |
# File 'lib/utility_colors/imports.rb', line 37 def self.css(import_path) # expecting a normal css file of variables File.read(import_path).scan(/--([^:]+):\s*([^;]+);/).to_h end |
.import ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/utility_colors/imports.rb', line 5 def self.import import_path = UtilityColors.configuration.import_palettes_filepath if import_path.present? && File.file?(import_path) case File.extname(import_path) when '.json' UtilityColors::Imports.json(import_path) when '.scss' UtilityColors::Imports.scss(import_path) when '.css' UtilityColors::Imports.css(import_path) else warn 'WARNING: Palette file could not be imported as it is not JSON, SCSS, or CSS.' {} end else {} end end |
.json(import_path) ⇒ Object
27 28 29 30 |
# File 'lib/utility_colors/imports.rb', line 27 def self.json(import_path) # expecting a normal json hash of name and value JSON.parse(File.read(import_path)) end |
.scss(import_path) ⇒ Object
32 33 34 35 |
# File 'lib/utility_colors/imports.rb', line 32 def self.scss(import_path) # expecting a normal scss file of variables File.read(import_path).scan(/\$([^:]+):\s*([^;]+);/).to_h end |