utility_palettes 1.0.0 → 1.0.1

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: f92d00ec4bd6d39c2ff8c063ee872df11c97e4cd6f35bcef13f3e2384bd5b4e0
4
- data.tar.gz: bd9a68478305db2c062a1eaa55241ac07f580531199a2f8a2225a6e6c65b68ae
3
+ metadata.gz: 7db3ff622d508b9b3ec237a56f185e7e530c0e71fe01bdb35ce44ba909914876
4
+ data.tar.gz: d2a05bcb1c34d3ae1a98e16cbacabc7e354441608f7bc03a452c07239b15b6d5
5
5
  SHA512:
6
- metadata.gz: b78ff43e849a7bb275d46ee96bbf26462ca6a1ef62739482168cfb162bca577a4f5a937f3b120d7abaaba1ba7f94a4535f58bb4782c7a9a67d9c59aa5a2b33d0
7
- data.tar.gz: 94a65dbd6eea0880b16ff285168046a602a1612a1ceb18133098708809cec13d094f0c4f525ed52e54c3545d0cb92a939c566bd203eb887b117bd7ccf754e539
6
+ metadata.gz: 00e88a3d02edd7aba94e4a4c1bce0f7a926e0bc47c3f95bcd7c29d62dd7c878b5cf74c3a8de65a0b5da75c526620b8012371486937b220600363a705d07ec2f0
7
+ data.tar.gz: acaa16e80c37e7895a67e7314038fd86218dcf12290ae3bfa55144fee7fbff412624e8ac86f8199a7dfd8c245d51aa46c493b17ea9c77f939d08677ac7dcefaf
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # UtilityPalettes
2
2
 
3
+ ![Static Badge](https://img.shields.io/badge/Gem_Version-1.0.0-blue)
4
+ [![Static Badge](https://img.shields.io/badge/RubyGems-red)](https://rubygems.org/gems/utility_palettes)
5
+
3
6
  > Generate your own colour palettes in an instance.
4
7
 
5
8
  Utility Palettes is an ruby gem package for use in ruby or other projects that generates palettes and shades based on supplied colours.
@@ -22,13 +25,13 @@ gem install utility_palettes
22
25
 
23
26
  ## Usage
24
27
 
25
- To get the config full of
28
+ To get the config file:
26
29
 
27
30
  ```bash
28
31
  rails generate utility_palettes:config
29
32
  ```
30
33
 
31
- to generate the palettes
34
+ To generate the palettes:
32
35
 
33
36
  ```bash
34
37
  rails generate utility_palettes:generate
@@ -63,15 +66,14 @@ Should the default colours be included for the palette generator. Even if they a
63
66
 
64
67
  How the output file and values should be written:
65
68
 
66
- | Option | Description | Default | Value Type | Possible Values |
67
- | :------------ | :-------------------------------------------------------------------------------------- | :-----: | :--------: | :-----------------------------------------------------: |
68
- | ouput_dated | Should a timestamp be included in the filenames | false | Boolean | true / false |
69
- | ouput_files | The types of files the palette should be output in | ['json'] | Array | json, scss, css |
70
- | ouput_format | The colour syntax the output colours should be written in | hex | String | rgb, hsl, hsv, hsb, cmyk, cielab, lab, cielch, lch, hex |
71
- | ouput_prefix | A string that is appended to the start of all colour names, i.e. 'tw-' | nil | String | <any string> |
72
- | ouput_suffix | A string that is appended to the end of all colour names, i.e. '-col' | nil | String | <any string> |
73
-
74
- The JSON output file will appear at the top-level of your project, while SCSS and CSS are defined to go to `app/assets/stylesheets`.
69
+ | Option | Description | Default | Value Type | Possible Values |
70
+ | :------------ | :-------------------------------------------------------------------------------- | :----------------: | :--------: | :-----------------------------------------------------: |
71
+ | ouput_filename | Where the file should be output to including filename, without the file extension | 'utility_palettes' | String | <any filepath string> |
72
+ | ouput_dated | Should a timestamp be included in the filenames | false | Boolean | true / false |
73
+ | ouput_files | The types of files the palette should be output in | ['scss'] | Array | json, scss, css |
74
+ | ouput_format | The colour syntax the output colours should be written in | hex | String | rgb, hsl, hsv, hsb, cmyk, cielab, lab, cielch, lch, hex |
75
+ | ouput_prefix | A string that is appended to the start of all colour names, i.e. 'up-' | nil | String | <any string> |
76
+ | ouput_suffix | A string that is appended to the end of all colour names, i.e. '-col' | nil | String | <any string> |
75
77
 
76
78
  ### Method (WIP)
77
79
 
@@ -10,8 +10,9 @@ UtilityPalettes.configure do |config|
10
10
  # config.default_singles = true
11
11
 
12
12
  # Output
13
+ # config.output_filename = 'utility_palettes'
13
14
  # config.output_dated = false
14
- # config.output_files = ['json']
15
+ # config.output_files = ['scss']
15
16
  # config.output_format = 'hex'
16
17
  # config.output_prefix = nil
17
18
  # config.output_suffix = nil
@@ -4,7 +4,7 @@ module UtilityPalettes
4
4
  class Configuration
5
5
  attr_accessor :enable_environments,
6
6
  :use_default_absolutes, :use_default_relatives, :use_default_singles,
7
- :output_dated, :output_files, :output_format, :output_prefix, :output_suffix,
7
+ :output_filename, :output_dated, :output_files, :output_format, :output_prefix, :output_suffix,
8
8
  :method, :steps_h, :steps_s, :steps_l, :steps_r, :steps_g, :steps_b,
9
9
  :absolutes, :relatives, :singles
10
10
 
@@ -18,8 +18,9 @@ module UtilityPalettes
18
18
  @use_default_singles = true
19
19
 
20
20
  # Output
21
+ @output_filename = 'utility_palettes'
21
22
  @output_dated = false
22
- @output_files = ['json']
23
+ @output_files = ['scss']
23
24
  @output_format = 'hex'
24
25
  @output_prefix = ''
25
26
  @output_suffix = ''
@@ -53,40 +53,44 @@ module UtilityPalettes
53
53
  end
54
54
  end
55
55
 
56
- output_palettes
56
+ # TODO: sort by non-ASCII so that -50 is before -100 -> `naturally` gem
57
+ output_palettes.sort.to_h
57
58
  end
58
59
 
59
60
  def self.json(filename, output_palettes)
60
- file = Tempfile.new([filename, '.json'])
61
+ content = JSON.pretty_generate(output_palettes)
62
+ filepath = "#{filename}.json"
61
63
 
62
- File.open(file, 'w') do |f|
63
- f.write(JSON.pretty_generate(output_palettes))
64
- end
64
+ # Create directory if it doesn't exist
65
+ FileUtils.mkdir_p(File.dirname(filepath))
66
+ File.write(filepath, content)
65
67
 
66
68
  puts 'Exporting utility palettes JSON...'
67
- file
69
+ true
68
70
  end
69
71
 
70
72
  def self.scss(filename, output_palettes)
71
- file = Tempfile.new([filename, '.scss'])
73
+ content = output_palettes.collect { |label, hex| "$#{label}: #{hex};" }.join("\n")
74
+ filepath = "#{filename}.scss"
72
75
 
73
- File.open(file, 'w') do |f|
74
- f.write(output_palettes.collect { |label, hex| "$#{label}: #{hex};" }.join("\n"))
75
- end
76
+ # Create directory if it doesn't exist
77
+ FileUtils.mkdir_p(File.dirname(filepath))
78
+ File.write(filepath, content)
76
79
 
77
80
  puts 'Exporting utility palettes SCSS...'
78
- file
81
+ true
79
82
  end
80
83
 
81
84
  def self.css(filename, output_palettes)
82
- file = Tempfile.new([filename, '.css'])
85
+ content = ":root {\n\t#{output_palettes.collect { |label, hex| "--#{label}: #{hex};" }.join("\n\t")}\n}"
86
+ filepath = "#{filename}.css"
83
87
 
84
- File.open(file, 'w') do |f|
85
- f.write(":root {\n\t#{output_palettes.collect { |label, hex| "--#{label}: #{hex};" }.join("\n\t")}\n}")
86
- end
88
+ # Create directory if it doesn't exist
89
+ FileUtils.mkdir_p(File.dirname(filepath))
90
+ File.write(filepath, content)
87
91
 
88
92
  puts 'Exporting utility palettes CSS...'
89
- file
93
+ true
90
94
  end
91
95
 
92
96
  def bespoke_property_variables
@@ -44,22 +44,14 @@ module UtilityPalettes
44
44
  generated_palettes = self.format_palette(generated_palettes)
45
45
  output_palettes = UtilityPalettes::Outputs.generate(generated_palettes)
46
46
 
47
- filename = 'utility_palettes'
47
+ filename = configuration.output_filename
48
48
  filename += "-#{Time.zone.now.strftime('%Y%m%d-%H%M%S')}" if configuration.output_dated == true
49
49
 
50
50
  output_files = configuration.output_files.map(&:strip)
51
51
 
52
- file = nil
53
- file = UtilityPalettes::Outputs.json(filename, output_palettes) if output_files.include?('json')
54
- File.rename(file.path, "#{filename}.json") if file.present?
55
-
56
- file = nil
57
- file = UtilityPalettes::Outputs.scss(filename, output_palettes) if output_files.include?('scss')
58
- File.rename(file.path, "app/assets/stylesheets/#{filename}.scss") if file.present?
59
-
60
- file = nil
61
- file = UtilityPalettes::Outputs.css(filename, output_palettes) if output_files.include?('css')
62
- File.rename(file.path, "app/assets/stylesheets/#{filename}.css") if file.present?
52
+ UtilityPalettes::Outputs.json(filename, output_palettes) if output_files.include?('json')
53
+ UtilityPalettes::Outputs.scss(filename, output_palettes) if output_files.include?('scss')
54
+ UtilityPalettes::Outputs.css(filename, output_palettes) if output_files.include?('css')
63
55
 
64
56
  true
65
57
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UtilityPalettes
4
- VERSION = '1.0.0'
4
+ VERSION = '1.0.1'
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: utility_palettes
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Louis Davis
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-09-02 00:00:00.000000000 Z
10
+ date: 2025-09-04 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: color_converters