stylegen 0.5.0 → 0.6.0
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 +4 -4
- data/CHANGELOG.md +7 -0
- data/bin/stylegen +9 -2
- data/lib/stylegen/cli/commands.rb +76 -0
- data/lib/stylegen/cli/error.rb +8 -0
- data/lib/stylegen/cli.rb +1 -1
- data/lib/stylegen/version.rb +1 -1
- data/lib/stylegen.rb +1 -0
- metadata +14 -28
- data/.deepsource.toml +0 -5
- data/.github/workflows/ci.yml +0 -32
- data/.gitignore +0 -6
- data/.rubocop.yml +0 -16
- data/Gemfile +0 -5
- data/Gemfile.lock +0 -63
- data/Rakefile +0 -10
- data/lib/stylegen/cli/app.rb +0 -62
- data/stylegen.gemspec +0 -31
- data/test/helper.rb +0 -8
- data/test/test_base_elevated_color.rb +0 -34
- data/test/test_color.rb +0 -67
- data/test/test_light_dark_color.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 615869614190f084f865e58f8f64e7b2769498c6d582c0746239fff8a8f58260
|
4
|
+
data.tar.gz: 529834fed7438410cb530801016277bd1a9206e4b018fdb9e68c80ec32ca8b7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d6b421af6b58144a307056ff0a6ee5325db69651589f6a93ca8b216ac2dda98cb403b1943dd555bed4abae7f08d6946d4ad59a76933bbf014da19e5153d0cb5
|
7
|
+
data.tar.gz: 280d122e2fdd15771ff59cff799c660afcd1fd2b63cda567e8d1c58bb0fc1f5993604e4e505366ff5911b4bd84a49cb42cc1591db023db22a7173eadda1f4e00
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
# Changelog
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
+
## v0.6.0
|
5
|
+
### Changed
|
6
|
+
- Switched from GLI to dry-cli for CLI. Some may produce slightly different STDOUT and STDERR output.
|
7
|
+
### Added
|
8
|
+
- Added `--output` flag to `stylegen init` command. This allows you to specify a different output file than the default `theme.yaml`.
|
9
|
+
- Added `--input` flag to `stylegen build` command. This allows you to specify a different input file than the default `theme.yaml`.
|
10
|
+
|
4
11
|
## v0.5.0
|
5
12
|
### Changed
|
6
13
|
- Switched generated code from `struct` to `class`.
|
data/bin/stylegen
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require 'stylegen
|
4
|
+
require 'stylegen'
|
5
5
|
|
6
|
-
|
6
|
+
begin
|
7
|
+
arguments = ARGV.empty? ? ['build'] : ARGV
|
8
|
+
cli = Dry::CLI.new(Stylegen::CLI::Commands)
|
9
|
+
cli.call(arguments: arguments)
|
10
|
+
rescue Stylegen::CLI::Commands::Error => e
|
11
|
+
warn e.message
|
12
|
+
exit 1
|
13
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
require 'dry/cli'
|
5
|
+
|
6
|
+
require 'stylegen/validator'
|
7
|
+
require 'stylegen/generator'
|
8
|
+
require 'stylegen/version'
|
9
|
+
require 'stylegen/cli/error'
|
10
|
+
|
11
|
+
module Stylegen
|
12
|
+
module CLI
|
13
|
+
module Commands
|
14
|
+
extend Dry::CLI::Registry
|
15
|
+
|
16
|
+
class Error < StandardError
|
17
|
+
end
|
18
|
+
|
19
|
+
class Version < Dry::CLI::Command
|
20
|
+
desc 'Prints stylegen version'
|
21
|
+
|
22
|
+
def call(*)
|
23
|
+
puts "stylegen version #{Stylegen::VERSION}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class Init < Dry::CLI::Command
|
28
|
+
desc 'Generates a sample theme.yaml file in the current directory'
|
29
|
+
|
30
|
+
option :output, aliases: ['-o'], type: :string, default: 'theme.yaml', desc: 'Path to the output file'
|
31
|
+
|
32
|
+
def call(output: 'theme.yaml', **)
|
33
|
+
raise Error, "'#{output}' already exists." if File.exist?(output)
|
34
|
+
|
35
|
+
template = File.read(File.join(__dir__, 'template.yaml'))
|
36
|
+
File.write(output, template)
|
37
|
+
|
38
|
+
puts "Generated '#{output}'."
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
class Build < Dry::CLI::Command
|
43
|
+
desc 'Generates the Swift colors file'
|
44
|
+
|
45
|
+
option :input, aliases: ['-i'], type: :string, default: 'theme.yaml', desc: 'Path to the theme.yaml file'
|
46
|
+
|
47
|
+
def call(input: 'theme.yaml', **)
|
48
|
+
raise Error, "'#{input}' not found. Create one with 'stylegen init'." unless File.exist?(input)
|
49
|
+
|
50
|
+
data = File.open(input) { |file| YAML.safe_load(file) }
|
51
|
+
|
52
|
+
validator = Validator.new
|
53
|
+
unless validator.valid?(data)
|
54
|
+
message = []
|
55
|
+
message << "#{input} contains one or more errors:"
|
56
|
+
|
57
|
+
validator.validate(data).each do |e|
|
58
|
+
message << " #{e}"
|
59
|
+
end
|
60
|
+
|
61
|
+
raise Error, message.join("\n")
|
62
|
+
end
|
63
|
+
|
64
|
+
generator = Generator.new(data)
|
65
|
+
generator.generate
|
66
|
+
|
67
|
+
puts "Generated '#{generator.stats[:output_path]}' with #{generator.stats[:color_count]} colors."
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
register 'init', Init
|
72
|
+
register 'build', Build
|
73
|
+
register 'version', Version, aliases: ['-v', '--version']
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
data/lib/stylegen/cli.rb
CHANGED
data/lib/stylegen/version.rb
CHANGED
data/lib/stylegen.rb
CHANGED
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stylegen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ramon Torres
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: dry-
|
14
|
+
name: dry-cli
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.7.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.7.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: dry-inflector
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 0.2.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 0.2.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: json_schemer
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -144,20 +144,14 @@ executables:
|
|
144
144
|
extensions: []
|
145
145
|
extra_rdoc_files: []
|
146
146
|
files:
|
147
|
-
- ".deepsource.toml"
|
148
|
-
- ".github/workflows/ci.yml"
|
149
|
-
- ".gitignore"
|
150
|
-
- ".rubocop.yml"
|
151
147
|
- CHANGELOG.md
|
152
|
-
- Gemfile
|
153
|
-
- Gemfile.lock
|
154
148
|
- LICENSE
|
155
149
|
- README.md
|
156
|
-
- Rakefile
|
157
150
|
- bin/stylegen
|
158
151
|
- lib/stylegen.rb
|
159
152
|
- lib/stylegen/cli.rb
|
160
|
-
- lib/stylegen/cli/
|
153
|
+
- lib/stylegen/cli/commands.rb
|
154
|
+
- lib/stylegen/cli/error.rb
|
161
155
|
- lib/stylegen/cli/template.yaml
|
162
156
|
- lib/stylegen/colors.rb
|
163
157
|
- lib/stylegen/colors/base_elevated_color.rb
|
@@ -169,15 +163,11 @@ files:
|
|
169
163
|
- lib/stylegen/template.rb
|
170
164
|
- lib/stylegen/validator.rb
|
171
165
|
- lib/stylegen/version.rb
|
172
|
-
- stylegen.gemspec
|
173
|
-
- test/helper.rb
|
174
|
-
- test/test_base_elevated_color.rb
|
175
|
-
- test/test_color.rb
|
176
|
-
- test/test_light_dark_color.rb
|
177
166
|
homepage: https://github.com/raymondjavaxx/stylegen
|
178
167
|
licenses:
|
179
168
|
- MIT
|
180
|
-
metadata:
|
169
|
+
metadata:
|
170
|
+
rubygems_mfa_required: 'true'
|
181
171
|
post_install_message:
|
182
172
|
rdoc_options: []
|
183
173
|
require_paths:
|
@@ -193,12 +183,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
193
183
|
- !ruby/object:Gem::Version
|
194
184
|
version: '0'
|
195
185
|
requirements: []
|
196
|
-
rubygems_version: 3.1.
|
186
|
+
rubygems_version: 3.1.4
|
197
187
|
signing_key:
|
198
188
|
specification_version: 4
|
199
189
|
summary: Tool for generating styling code for iOS apps
|
200
|
-
test_files:
|
201
|
-
- test/helper.rb
|
202
|
-
- test/test_base_elevated_color.rb
|
203
|
-
- test/test_color.rb
|
204
|
-
- test/test_light_dark_color.rb
|
190
|
+
test_files: []
|
data/.deepsource.toml
DELETED
data/.github/workflows/ci.yml
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
name: CI
|
2
|
-
on:
|
3
|
-
push:
|
4
|
-
branches:
|
5
|
-
- master
|
6
|
-
pull_request:
|
7
|
-
branches:
|
8
|
-
- master
|
9
|
-
|
10
|
-
jobs:
|
11
|
-
test:
|
12
|
-
runs-on: ubuntu-latest
|
13
|
-
strategy:
|
14
|
-
matrix:
|
15
|
-
ruby-version:
|
16
|
-
- "2.5"
|
17
|
-
- "2.6"
|
18
|
-
- "2.7"
|
19
|
-
- "3.0"
|
20
|
-
- "3.1"
|
21
|
-
|
22
|
-
steps:
|
23
|
-
- uses: actions/checkout@v3
|
24
|
-
- name: Set up Ruby
|
25
|
-
uses: ruby/setup-ruby@v1
|
26
|
-
with:
|
27
|
-
ruby-version: ${{ matrix.ruby-version }}
|
28
|
-
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
29
|
-
- name: Lint
|
30
|
-
run: bundle exec rake rubocop
|
31
|
-
- name: Run tests
|
32
|
-
run: bundle exec rake
|
data/.gitignore
DELETED
data/.rubocop.yml
DELETED
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
stylegen (0.5.0)
|
5
|
-
dry-inflector (~> 0.2.0)
|
6
|
-
gli (~> 2.1)
|
7
|
-
json_schemer (~> 0.2.0)
|
8
|
-
|
9
|
-
GEM
|
10
|
-
remote: https://rubygems.org/
|
11
|
-
specs:
|
12
|
-
ast (2.4.2)
|
13
|
-
dry-inflector (0.2.0)
|
14
|
-
ecma-re-validator (0.3.0)
|
15
|
-
regexp_parser (~> 2.0)
|
16
|
-
gli (2.21.0)
|
17
|
-
hana (1.3.7)
|
18
|
-
json_schemer (0.2.24)
|
19
|
-
ecma-re-validator (~> 0.3)
|
20
|
-
hana (~> 1.3)
|
21
|
-
regexp_parser (~> 2.0)
|
22
|
-
uri_template (~> 0.7)
|
23
|
-
minitest (5.14.4)
|
24
|
-
parallel (1.20.1)
|
25
|
-
parser (3.0.1.1)
|
26
|
-
ast (~> 2.4.1)
|
27
|
-
rainbow (3.0.0)
|
28
|
-
rake (13.0.3)
|
29
|
-
regexp_parser (2.1.1)
|
30
|
-
rexml (3.2.5)
|
31
|
-
rubocop (1.14.0)
|
32
|
-
parallel (~> 1.10)
|
33
|
-
parser (>= 3.0.0.0)
|
34
|
-
rainbow (>= 2.2.2, < 4.0)
|
35
|
-
regexp_parser (>= 1.8, < 3.0)
|
36
|
-
rexml
|
37
|
-
rubocop-ast (>= 1.5.0, < 2.0)
|
38
|
-
ruby-progressbar (~> 1.7)
|
39
|
-
unicode-display_width (>= 1.4.0, < 3.0)
|
40
|
-
rubocop-ast (1.5.0)
|
41
|
-
parser (>= 3.0.1.1)
|
42
|
-
rubocop-minitest (0.12.1)
|
43
|
-
rubocop (>= 0.90, < 2.0)
|
44
|
-
rubocop-rake (0.5.1)
|
45
|
-
rubocop
|
46
|
-
ruby-progressbar (1.11.0)
|
47
|
-
unicode-display_width (2.0.0)
|
48
|
-
uri_template (0.7.0)
|
49
|
-
|
50
|
-
PLATFORMS
|
51
|
-
ruby
|
52
|
-
|
53
|
-
DEPENDENCIES
|
54
|
-
bundler
|
55
|
-
minitest (~> 5.14)
|
56
|
-
rake
|
57
|
-
rubocop
|
58
|
-
rubocop-minitest
|
59
|
-
rubocop-rake
|
60
|
-
stylegen!
|
61
|
-
|
62
|
-
BUNDLED WITH
|
63
|
-
2.1.4
|
data/Rakefile
DELETED
data/lib/stylegen/cli/app.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'yaml'
|
4
|
-
require 'gli'
|
5
|
-
|
6
|
-
require 'stylegen/validator'
|
7
|
-
require 'stylegen/generator'
|
8
|
-
|
9
|
-
module Stylegen
|
10
|
-
module CLI
|
11
|
-
class App
|
12
|
-
extend GLI::App
|
13
|
-
|
14
|
-
program_desc 'CLI tool for managing colors in iOS apps'
|
15
|
-
|
16
|
-
version Stylegen::VERSION
|
17
|
-
|
18
|
-
default_command :build
|
19
|
-
|
20
|
-
# Commands
|
21
|
-
|
22
|
-
desc 'Generates a sample theme.yaml file in the current directory'
|
23
|
-
command :init do |c|
|
24
|
-
c.action do
|
25
|
-
exit_now!("'theme.yaml' already exists!") if File.exist?('theme.yaml')
|
26
|
-
|
27
|
-
template = File.read(File.join(__dir__, 'template.yaml'))
|
28
|
-
File.write('theme.yaml', template)
|
29
|
-
|
30
|
-
puts "Generated 'theme.yaml'."
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
desc 'Generates the Swift colors file'
|
35
|
-
command :build do |c|
|
36
|
-
c.action do
|
37
|
-
exit_now!("'theme.yaml' not found. Create one with 'stylegen init'.") unless File.exist?('theme.yaml')
|
38
|
-
|
39
|
-
data = File.open('theme.yaml') { |file| YAML.safe_load(file) }
|
40
|
-
|
41
|
-
validator = Validator.new
|
42
|
-
|
43
|
-
unless validator.valid?(data)
|
44
|
-
message = []
|
45
|
-
message << 'theme.yaml contains one or more errors:'
|
46
|
-
|
47
|
-
validator.validate(data).each do |e|
|
48
|
-
message << " #{e}"
|
49
|
-
end
|
50
|
-
|
51
|
-
exit_now!(message.join("\n"))
|
52
|
-
end
|
53
|
-
|
54
|
-
generator = Generator.new(data)
|
55
|
-
generator.generate
|
56
|
-
|
57
|
-
puts "Generated '#{generator.stats[:output_path]}' with #{generator.stats[:color_count]} colors."
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
data/stylegen.gemspec
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require './lib/stylegen/version'
|
4
|
-
|
5
|
-
Gem::Specification.new do |s|
|
6
|
-
s.name = 'stylegen'
|
7
|
-
s.version = Stylegen::VERSION
|
8
|
-
s.platform = Gem::Platform::RUBY
|
9
|
-
s.authors = ['Ramon Torres']
|
10
|
-
s.email = ['raymondjavaxx@gmail.com']
|
11
|
-
s.homepage = 'https://github.com/raymondjavaxx/stylegen'
|
12
|
-
s.description = s.summary = 'Tool for generating styling code for iOS apps'
|
13
|
-
s.files = `git ls-files`.split("\n")
|
14
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
16
|
-
s.require_paths = ['lib']
|
17
|
-
s.license = 'MIT'
|
18
|
-
|
19
|
-
s.add_runtime_dependency 'dry-inflector', '~> 0.2.0'
|
20
|
-
s.add_runtime_dependency 'gli', '~> 2.1'
|
21
|
-
s.add_runtime_dependency 'json_schemer', '~> 0.2.0'
|
22
|
-
|
23
|
-
s.add_development_dependency 'bundler'
|
24
|
-
s.add_development_dependency 'minitest', '~> 5.14'
|
25
|
-
s.add_development_dependency 'rake'
|
26
|
-
s.add_development_dependency 'rubocop'
|
27
|
-
s.add_development_dependency 'rubocop-minitest'
|
28
|
-
s.add_development_dependency 'rubocop-rake'
|
29
|
-
|
30
|
-
s.required_ruby_version = '>= 2.5.0'
|
31
|
-
end
|
data/test/helper.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'helper'
|
4
|
-
|
5
|
-
class TestBaseElevatedColor < MiniTest::Test
|
6
|
-
def test_to_string
|
7
|
-
color = Stylegen::BaseElevatedColor.new(
|
8
|
-
Stylegen::Color.from_hex('#000000'),
|
9
|
-
Stylegen::Color.from_hex('#333333')
|
10
|
-
)
|
11
|
-
|
12
|
-
# Default indentation
|
13
|
-
|
14
|
-
expected = <<~CODE.chomp
|
15
|
-
ThemeColor(
|
16
|
-
base: ThemeColor(white: 0.0, alpha: 1.0),
|
17
|
-
elevated: ThemeColor(white: 0.2, alpha: 1.0)
|
18
|
-
)
|
19
|
-
CODE
|
20
|
-
|
21
|
-
assert_equal expected, color.to_s('ThemeColor')
|
22
|
-
|
23
|
-
# Additional indentation
|
24
|
-
|
25
|
-
expected = <<~CODE.chomp
|
26
|
-
ThemeColor(
|
27
|
-
base: ThemeColor(white: 0.0, alpha: 1.0),
|
28
|
-
elevated: ThemeColor(white: 0.2, alpha: 1.0)
|
29
|
-
)
|
30
|
-
CODE
|
31
|
-
|
32
|
-
assert_equal expected, color.to_s('ThemeColor', 4)
|
33
|
-
end
|
34
|
-
end
|
data/test/test_color.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'helper'
|
4
|
-
|
5
|
-
class TestColor < MiniTest::Test
|
6
|
-
def test_parsing
|
7
|
-
color = Stylegen::Color.from_hex('#FF8000')
|
8
|
-
assert_in_delta(1.0, color.red)
|
9
|
-
assert_in_delta(0.5019607843137255, color.green)
|
10
|
-
assert_in_delta(0.0, color.blue)
|
11
|
-
assert_in_delta(1.0, color.alpha)
|
12
|
-
|
13
|
-
# Optional pound sign
|
14
|
-
color = Stylegen::Color.from_hex('FF8000')
|
15
|
-
assert_in_delta(1.0, color.red)
|
16
|
-
assert_in_delta(0.5019607843137255, color.green)
|
17
|
-
assert_in_delta(0.0, color.blue)
|
18
|
-
assert_in_delta(1.0, color.alpha)
|
19
|
-
|
20
|
-
# Specify alpha
|
21
|
-
color = Stylegen::Color.from_hex('#FF8000', 0.5)
|
22
|
-
assert_in_delta(0.5, color.alpha)
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_parsing_shorthand_syntax
|
26
|
-
color = Stylegen::Color.from_hex('#FC0')
|
27
|
-
assert_in_delta(1.0, color.red)
|
28
|
-
assert_in_delta(0.8000000000000002, color.green)
|
29
|
-
assert_in_delta(0.0, color.blue)
|
30
|
-
assert_in_delta(1.0, color.alpha)
|
31
|
-
|
32
|
-
# Optional pound sign
|
33
|
-
color = Stylegen::Color.from_hex('FC0')
|
34
|
-
assert_in_delta(1.0, color.red)
|
35
|
-
assert_in_delta(0.8000000000000002, color.green)
|
36
|
-
assert_in_delta(0.0, color.blue)
|
37
|
-
assert_in_delta(1.0, color.alpha)
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_grayscale
|
41
|
-
color = Stylegen::Color.new(1, 1, 1, 1)
|
42
|
-
assert color.grayscale?
|
43
|
-
|
44
|
-
color = Stylegen::Color.new(1, 1, 0.9, 1)
|
45
|
-
refute color.grayscale?
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_to_string
|
49
|
-
color = Stylegen::Color.from_hex('#00FF00')
|
50
|
-
|
51
|
-
expected = <<~CODE.strip
|
52
|
-
ThemeColor(
|
53
|
-
red: 0.0,
|
54
|
-
green: 1.0,
|
55
|
-
blue: 0.0,
|
56
|
-
alpha: 1.0
|
57
|
-
)
|
58
|
-
CODE
|
59
|
-
|
60
|
-
assert_equal expected, color.to_s('ThemeColor')
|
61
|
-
|
62
|
-
# Grayscale
|
63
|
-
color = Stylegen::Color.from_hex('#FFFFFF')
|
64
|
-
expected = 'ThemeColor(white: 1.0, alpha: 1.0)'
|
65
|
-
assert_equal expected, color.to_s('ThemeColor')
|
66
|
-
end
|
67
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'helper'
|
4
|
-
|
5
|
-
class TestLightDarkColor < MiniTest::Test
|
6
|
-
def test_to_string
|
7
|
-
color = Stylegen::LightDarkColor.new(
|
8
|
-
Stylegen::Color.from_hex('#FFFFFF'),
|
9
|
-
Stylegen::Color.from_hex('#333333')
|
10
|
-
)
|
11
|
-
|
12
|
-
# Default indentation
|
13
|
-
|
14
|
-
expected = <<~CODE.chomp
|
15
|
-
ThemeColor(
|
16
|
-
light: ThemeColor(white: 1.0, alpha: 1.0),
|
17
|
-
dark: ThemeColor(white: 0.2, alpha: 1.0)
|
18
|
-
)
|
19
|
-
CODE
|
20
|
-
|
21
|
-
assert_equal expected, color.to_s('ThemeColor')
|
22
|
-
|
23
|
-
# Additional indentation
|
24
|
-
|
25
|
-
expected = <<~CODE.chomp
|
26
|
-
ThemeColor(
|
27
|
-
light: ThemeColor(white: 1.0, alpha: 1.0),
|
28
|
-
dark: ThemeColor(white: 0.2, alpha: 1.0)
|
29
|
-
)
|
30
|
-
CODE
|
31
|
-
|
32
|
-
assert_equal expected, color.to_s('ThemeColor', 4)
|
33
|
-
end
|
34
|
-
end
|