stylegen 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +2 -2
- data/lib/stylegen/colors/color.rb +14 -4
- data/lib/stylegen/version.rb +1 -1
- data/test/test_color.rb +14 -5
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4808a4d66b66694ce4df774bc4fc3cc4048e5eb28849bc9d6e89c191a2c9f32
|
4
|
+
data.tar.gz: 639451c4ee1913d543c1b10cd3ed6dc7bf8f70b5711ac490ca1644d28b88bd88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ac5a414042b33bef240224d8390d79e92466b777a98bd9ffa0dcd20fe63b4b3353823d26dcc129655bd3d534b1eca2b7c9950b2b6e1764b5d7e30e8e1381ac2
|
7
|
+
data.tar.gz: 8d2e762fef43e854ca222e9fba107fb8df885d2ae4b2d0ab44eed03c6f7e0c5f61138df701954fd479b4dcbe2f1698b18ae4a140423a625bab83ccff95b0eec5
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
stylegen (0.3.
|
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.
|
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
|
-
|
24
|
+
max_precision = 16
|
25
25
|
|
26
|
-
Color.new(r.round(
|
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,
|
33
|
+
def to_s(struct_name, indent = 0)
|
34
34
|
if grayscale?
|
35
35
|
"#{struct_name}(white: #{@red}, alpha: #{@alpha})"
|
36
36
|
else
|
37
|
-
|
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
|
data/lib/stylegen/version.rb
CHANGED
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.
|
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.
|
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.
|
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.
|
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
|
-
|
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.
|
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-
|
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.
|
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
|