stylegen 0.3.0 → 0.3.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: 5c648fda564306d4dc88dab32098c2d6fb0a355e16adb0c352eec6b5ca7cea23
4
- data.tar.gz: 0517ac0a864f9663f508376d3ab71859a248f82c028fbb14bd2eb33ac8ce6658
3
+ metadata.gz: e4808a4d66b66694ce4df774bc4fc3cc4048e5eb28849bc9d6e89c191a2c9f32
4
+ data.tar.gz: 639451c4ee1913d543c1b10cd3ed6dc7bf8f70b5711ac490ca1644d28b88bd88
5
5
  SHA512:
6
- metadata.gz: 81a4d52f8b5c45938296c7b934069ff6b0906e167d554798da00e893fe38838623ca206d576222dbededddefa6885e2a25e04e29fe56fe93ff2892bda62e0cce
7
- data.tar.gz: ce866c1b9c3de44234b290d964baa02c819ac814e74541e59f54fa112c0913752ba83281303ab82c5f182ce6f8301a8bf209c1861737ab3e967ad4fe7d2e7cb8
6
+ metadata.gz: 3ac5a414042b33bef240224d8390d79e92466b777a98bd9ffa0dcd20fe63b4b3353823d26dcc129655bd3d534b1eca2b7c9950b2b6e1764b5d7e30e8e1381ac2
7
+ data.tar.gz: 8d2e762fef43e854ca222e9fba107fb8df885d2ae4b2d0ab44eed03c6f7e0c5f61138df701954fd479b4dcbe2f1698b18ae4a140423a625bab83ccff95b0eec5
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## v0.3.1
5
+ ### Changed
6
+ - Increased precision of HEX color conversion to avoid truncation.
7
+
4
8
  ## v0.3.0
5
9
  ### Added
6
10
  - SwiftUI support.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stylegen (0.3.0)
4
+ stylegen (0.3.1)
5
5
  dry-inflector (~> 0.2.0)
6
6
  gli (~> 2.1)
7
7
  json_schemer (~> 0.2.0)
@@ -13,7 +13,7 @@ GEM
13
13
  dry-inflector (0.2.0)
14
14
  ecma-re-validator (0.3.0)
15
15
  regexp_parser (~> 2.0)
16
- gli (2.20.0)
16
+ gli (2.20.1)
17
17
  hana (1.3.7)
18
18
  json_schemer (0.2.18)
19
19
  ecma-re-validator (~> 0.3)
@@ -21,20 +21,30 @@ module Stylegen
21
21
  raise ArgumentError, "Invalid color syntax: #{hex}"
22
22
  end
23
23
 
24
- max_digits = 2
24
+ max_precision = 16
25
25
 
26
- Color.new(r.round(max_digits), g.round(max_digits), b.round(max_digits), alpha || 1.0)
26
+ Color.new(r.round(max_precision), g.round(max_precision), b.round(max_precision), alpha || 1.0)
27
27
  end
28
28
 
29
29
  def grayscale?
30
30
  @red == @green && @green == @blue
31
31
  end
32
32
 
33
- def to_s(struct_name, _indent = 0)
33
+ def to_s(struct_name, indent = 0)
34
34
  if grayscale?
35
35
  "#{struct_name}(white: #{@red}, alpha: #{@alpha})"
36
36
  else
37
- "#{struct_name}(red: #{@red}, green: #{@green}, blue: #{@blue}, alpha: #{@alpha})"
37
+ indent_prefix = " " * indent
38
+
39
+ result = []
40
+ result << "#{struct_name}("
41
+ result << "#{indent_prefix} red: #{@red},"
42
+ result << "#{indent_prefix} green: #{@green},"
43
+ result << "#{indent_prefix} blue: #{@blue},"
44
+ result << "#{indent_prefix} alpha: #{@alpha}"
45
+ result << "#{indent_prefix})"
46
+
47
+ result.join("\n")
38
48
  end
39
49
  end
40
50
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Stylegen
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.1"
5
5
  end
data/test/test_color.rb CHANGED
@@ -6,14 +6,14 @@ class TestColor < MiniTest::Test
6
6
  def test_parsing
7
7
  color = Stylegen::Color.from_hex("#FF8000")
8
8
  assert_equal 1.0, color.red
9
- assert_equal 0.5, color.green
9
+ assert_equal 0.5019607843137255, color.green
10
10
  assert_equal 0.0, color.blue
11
11
  assert_equal 1.0, color.alpha
12
12
 
13
13
  # Optional pound sign
14
14
  color = Stylegen::Color.from_hex("FF8000")
15
15
  assert_equal 1.0, color.red
16
- assert_equal 0.5, color.green
16
+ assert_equal 0.5019607843137255, color.green
17
17
  assert_equal 0.0, color.blue
18
18
  assert_equal 1.0, color.alpha
19
19
 
@@ -25,14 +25,14 @@ class TestColor < MiniTest::Test
25
25
  def test_parsing_shorthand_syntax
26
26
  color = Stylegen::Color.from_hex("#FC0")
27
27
  assert_equal 1.0, color.red
28
- assert_equal 0.8, color.green
28
+ assert_equal 0.8000000000000002, color.green
29
29
  assert_equal 0.0, color.blue
30
30
  assert_equal 1.0, color.alpha
31
31
 
32
32
  # Optional pound sign
33
33
  color = Stylegen::Color.from_hex("FC0")
34
34
  assert_equal 1.0, color.red
35
- assert_equal 0.8, color.green
35
+ assert_equal 0.8000000000000002, color.green
36
36
  assert_equal 0.0, color.blue
37
37
  assert_equal 1.0, color.alpha
38
38
  end
@@ -47,7 +47,16 @@ class TestColor < MiniTest::Test
47
47
 
48
48
  def test_to_string
49
49
  color = Stylegen::Color.from_hex("#00FF00")
50
- expected = "ThemeColor(red: 0.0, green: 1.0, blue: 0.0, alpha: 1.0)"
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
+
51
60
  assert_equal expected, color.to_s("ThemeColor")
52
61
 
53
62
  # Grayscale
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stylegen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ramon Torres
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-06 00:00:00.000000000 Z
11
+ date: 2021-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-inflector
@@ -193,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
195
  requirements: []
196
- rubygems_version: 3.0.1
196
+ rubygems_version: 3.0.3
197
197
  signing_key:
198
198
  specification_version: 4
199
199
  summary: Tool for generating styling code for iOS apps