utility_palettes 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4dd0760b2f72cc78a687afcbf878d4e88a936cc4503bba60d46c73e1df21467c
4
- data.tar.gz: a85e503c4b282647c6001446950e58ebcf32bef6549e0f68a8e226264fb8e14f
3
+ metadata.gz: 23332faf82c72ba20e4cf27ddfd3d9f1518b78b2f94ebc561fe69a5e881f2743
4
+ data.tar.gz: 2f636967a325e694deb98ec7960dff63d62bfce4c25dd966452ccb288cca9f4d
5
5
  SHA512:
6
- metadata.gz: 4c5569c8bc1bc5eb3eb2916dd45b29fc211eb4bae211c10d7aeae20c933e79b7efc4dc9e0af27a6654ecc256890645758949c66424f46573df18f1e4f3003aff
7
- data.tar.gz: ff3a66f8ed5839f3b25608ecf6836aaeae7ba99ae02bd67dccfb3b2f2797a5f5d3f98456d557ac22efbe521fb4769e67fdd59cebaf2c5a09a51913629ad96ff8
6
+ metadata.gz: 71f73653beeb5ccb1566dd1561510de4f53cb91c35271a2a7c80658783c0e20f0f9cb93facf97c16bf15e7a7e7ab48db80084d0e5e030be01584c303328f9d6b
7
+ data.tar.gz: 34499831e9976f15d273c626506adfc3083ad563553b4639f1376967565fefdd6e31f6dd4ba692b4515a0006c8d38433be59bd15eabbeb6893a93d16345850da
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # UtilityPalettes
2
2
 
3
- ![Static Badge](https://img.shields.io/badge/Gem_Version-1.0.1-blue)
3
+ ![Static Badge](https://img.shields.io/badge/Gem_Version-1.0.5-blue)
4
4
  [![Static Badge](https://img.shields.io/badge/RubyGems-red)](https://rubygems.org/gems/utility_palettes)
5
5
 
6
6
  > Generate your own colour palettes in an instance.
@@ -110,7 +110,8 @@ The value can be;
110
110
 
111
111
  - a string such as '#ff0000' or 'rgb(51, 102, 204)',
112
112
  - a hash of colour space keys and values such as { r: 51, g: 102, b: 204 } or { h: 30, s: 50, l: 75 },
113
- - a 'reference' to a colour the is previously defined be using that colour name as the value but prepended with '$', such as '$red' (this felt useful if there are colours if you re-use the same colours under different use names)
113
+ - a 'reference' to a colour the is also defined in one of your config be using that colour name as the value but prepended with '$', such as '$red' (this felt useful if there are colours if you re-use the same colours under different use names)
114
+ - currently you can only reference colours defined in the config, not colours that would be generated as part of the palette generator process
114
115
 
115
116
  | Option | Default | Possible Values |
116
117
  | :-------- | :-----: | :-----------------------------------: |
@@ -1,13 +1,20 @@
1
- # frozen_string_literal: true
2
-
3
- module UtilityPalettes
4
- module Generators
5
- class ConfigGenerator < Rails::Generators::Base
6
- source_root File.expand_path('../../..', __dir__)
7
-
8
- def copy_config
9
- copy_file 'lib/generators/templates/config/utility_palettes.rb', 'config/initializers/utility_palettes.rb'
10
- end
11
- end
12
- end
13
- end
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require 'rails/generators'
5
+ require 'rails/generators/base'
6
+ rescue LoadError => e
7
+ raise LoadError, "railties gem is required for generators. Add 'railties' to your Gemfile: #{e.message}"
8
+ end
9
+
10
+ module UtilityPalettes
11
+ module Generators
12
+ class ConfigGenerator < Rails::Generators::Base
13
+ source_root File.expand_path('../../..', __dir__)
14
+
15
+ def copy_config
16
+ copy_file 'lib/generators/templates/config/utility_palettes.rb', 'config/initializers/utility_palettes.rb'
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,29 +1,36 @@
1
- # frozen_string_literal: true
2
-
3
- module UtilityPalettes
4
- module Generators
5
- class GenerateGenerator < Rails::Generators::Base
6
- def generate_utility_palettes
7
- self.class.config_format_warn if File.exist?('config/utility_palettes.yml') || File.exist?('config/utility_palettes.json')
8
-
9
- if UtilityPalettes.configuration.enable_environments.include?(Rails.env.to_sym)
10
- UtilityPalettes::Palettes.generate
11
- else
12
- self.class.disabled_warn
13
- end
14
- end
15
-
16
- private
17
-
18
- # TODO: add links to README for migration
19
- def self.config_format_warn
20
- warn 'WARNING: Utility Palettes now uses an initializer to set config. You need to migrate and remove your YML/JSON file.'
21
- end
22
-
23
- # TODO: add links to README for environment setting
24
- def self.disabled_warn
25
- warn 'ERROR: Utility Palettes is disabled for this environment. Palettes will not be generated.'
26
- end
27
- end
28
- end
29
- end
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require 'rails/generators'
5
+ require 'rails/generators/base'
6
+ rescue LoadError => e
7
+ raise LoadError, "railties gem is required for generators. Add 'railties' to your Gemfile: #{e.message}"
8
+ end
9
+
10
+ module UtilityPalettes
11
+ module Generators
12
+ class GenerateGenerator < Rails::Generators::Base
13
+ def generate_utility_palettes
14
+ self.class.config_format_warn if File.exist?('config/utility_palettes.yml') || File.exist?('config/utility_palettes.json')
15
+
16
+ if UtilityPalettes.configuration.enable_environments.include?(Rails.env.to_sym)
17
+ UtilityPalettes::Palettes.generate
18
+ else
19
+ self.class.disabled_warn
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ # TODO: add links to README for migration
26
+ def self.config_format_warn
27
+ warn 'WARNING: Utility Palettes now uses an initializer to set config. You need to migrate and remove your YML/JSON file.'
28
+ end
29
+
30
+ # TODO: add links to README for environment setting
31
+ def self.disabled_warn
32
+ warn 'ERROR: Utility Palettes is disabled for this environment. Palettes will not be generated.'
33
+ end
34
+ end
35
+ end
36
+ end
@@ -65,7 +65,7 @@ module UtilityPalettes
65
65
  FileUtils.mkdir_p(File.dirname(filepath))
66
66
  File.write(filepath, content)
67
67
 
68
- puts 'Exporting utility palettes JSON...'
68
+ puts "Exporting utility palettes JSON to #{filepath}..."
69
69
  true
70
70
  end
71
71
 
@@ -77,7 +77,7 @@ module UtilityPalettes
77
77
  FileUtils.mkdir_p(File.dirname(filepath))
78
78
  File.write(filepath, content)
79
79
 
80
- puts 'Exporting utility palettes SCSS...'
80
+ puts "Exporting utility palettes SCSS to #{filepath}..."
81
81
  true
82
82
  end
83
83
 
@@ -89,7 +89,7 @@ module UtilityPalettes
89
89
  FileUtils.mkdir_p(File.dirname(filepath))
90
90
  File.write(filepath, content)
91
91
 
92
- puts 'Exporting utility palettes CSS...'
92
+ puts "Exporting utility palettes CSS to #{filepath}..."
93
93
  true
94
94
  end
95
95
 
@@ -64,8 +64,17 @@ module UtilityPalettes
64
64
  basic_hash.each do |label, colour|
65
65
  begin
66
66
  if colour.is_a?(String) && colour.start_with?('$')
67
- # if the colour label begins with $ then it is a reference to a different defined colour, so must be looked up in the main
68
- colourized_hash[label] = ColorConverters::Color.new(@combined_samples.dig(colour.slice(1..-1).to_sym))
67
+ colour_ref_array = [colour]
68
+
69
+ # if the colour label begins with $ then it is a reference to a different defined colour, so must be looked up in the main hash
70
+ while colour_ref_array.last.is_a?(String) && colour_ref_array.last.start_with?('$')
71
+ colour_ref = @combined_samples.dig(colour_ref_array.last.slice(1..-1))
72
+ raise UtilityPalettes::Error, "Circular reference detected for colour '#{label}': #{colour_ref_array.join(' -> ')}" if colour_ref_array.include?(colour_ref)
73
+
74
+ colour_ref_array << colour_ref
75
+ end
76
+
77
+ colourized_hash[label] = ColorConverters::Color.new(colour_ref)
69
78
  else
70
79
  colourized_hash[label] = ColorConverters::Color.new(colour)
71
80
  end
@@ -76,6 +85,8 @@ module UtilityPalettes
76
85
  # hash[colourized_hash[label].name] = hash.delete(label)
77
86
  # puts "Blank colour #{colour} has been given the name: #{colourized_hash[label].name}"
78
87
  # end
88
+ rescue UtilityPalettes::Error => e
89
+ warn "Error processing colour #{label}: #{e.message}"
79
90
  rescue ColorConverters::InvalidColorError => e
80
91
  warn "Error processing colour #{label} with value #{colour}: #{e.message}"
81
92
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UtilityPalettes
4
- VERSION = '1.0.3'
4
+ VERSION = '1.0.5'
5
5
  end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: utility_palettes
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Louis Davis
8
+ autorequire:
8
9
  bindir: bin
9
10
  cert_chain: []
10
- date: 2025-09-05 00:00:00.000000000 Z
11
+ date: 2026-01-27 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: color_converters
@@ -66,6 +67,7 @@ metadata:
66
67
  homepage_uri: https://github.com/louiswdavis/utility_palettes
67
68
  source_code_uri: https://github.com/louiswdavis/utility_palettes
68
69
  changelog_uri: https://github.com/louiswdavis/utility_palettes/blob/master/CHANGELOG.md
70
+ post_install_message:
69
71
  rdoc_options: []
70
72
  require_paths:
71
73
  - lib
@@ -80,7 +82,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
82
  - !ruby/object:Gem::Version
81
83
  version: '0'
82
84
  requirements: []
83
- rubygems_version: 3.6.3
85
+ rubygems_version: 3.5.22
86
+ signing_key:
84
87
  specification_version: 4
85
88
  summary: Quickly build colour palettes based on default or supplied colour swatches,
86
89
  and export them for use in stylesheets.