colorly 0.0.1 → 0.1.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/README.md +122 -2
- data/lib/colorly.rb +9 -0
- data/lib/colorly/command.rb +21 -11
- data/lib/colorly/data/color-names.yml +1640 -0
- data/lib/colorly/exceptions.rb +19 -0
- data/lib/colorly/extensions/chroma_color.rb +25 -1662
- data/lib/colorly/refinements/string.rb +38 -0
- data/lib/colorly/script.rb +26 -4
- data/lib/colorly/templates/html.erb +17 -10
- data/lib/colorly/version.rb +1 -1
- metadata +4 -3
- data/lib/colorly/extensions/string.rb +0 -27
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'chroma'
|
2
|
+
|
3
|
+
module StringRefinements
|
4
|
+
refine String do
|
5
|
+
def spin(*args)
|
6
|
+
paint.spin *args
|
7
|
+
end
|
8
|
+
|
9
|
+
def brighten(*args)
|
10
|
+
paint.brighten *args
|
11
|
+
end
|
12
|
+
|
13
|
+
def lighten(*args)
|
14
|
+
paint.lighten *args
|
15
|
+
end
|
16
|
+
|
17
|
+
def darken(*args)
|
18
|
+
paint.darken *args
|
19
|
+
end
|
20
|
+
|
21
|
+
def saturate(*args)
|
22
|
+
paint.saturate *args
|
23
|
+
end
|
24
|
+
|
25
|
+
def desaturate(*args)
|
26
|
+
paint.desaturate *args
|
27
|
+
end
|
28
|
+
|
29
|
+
def greyscale
|
30
|
+
paint.greyscale
|
31
|
+
end
|
32
|
+
alias grayscale greyscale
|
33
|
+
|
34
|
+
def palette(*args)
|
35
|
+
paint.palette *args
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/colorly/script.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module Colorly
|
2
2
|
class Script
|
3
|
+
using StringRefinements
|
3
4
|
attr_reader :script, :filename
|
4
5
|
|
5
6
|
def self.load(script_file)
|
@@ -12,20 +13,29 @@ module Colorly
|
|
12
13
|
end
|
13
14
|
|
14
15
|
def run
|
15
|
-
|
16
|
+
run!
|
17
|
+
rescue SyntaxError => e
|
18
|
+
raise ScriptSyntaxError.new e
|
19
|
+
rescue => e
|
20
|
+
raise ScriptError.new e
|
16
21
|
end
|
17
22
|
|
18
23
|
def output
|
19
24
|
@output ||= {}
|
20
25
|
end
|
21
26
|
|
22
|
-
def
|
27
|
+
def simple_output(names: false)
|
23
28
|
output.transform_values do |chroma_array|
|
24
29
|
chroma_array.map do |chroma|
|
25
|
-
|
30
|
+
if names
|
31
|
+
{ hex: chroma.to_hex, name: [chroma.name, chroma.shade] }
|
32
|
+
else
|
33
|
+
chroma.to_hex
|
34
|
+
end
|
26
35
|
end
|
27
36
|
end
|
28
37
|
end
|
38
|
+
alias to_h simple_output
|
29
39
|
|
30
40
|
# DSL Methods
|
31
41
|
|
@@ -38,11 +48,15 @@ module Colorly
|
|
38
48
|
color.each { |c| add c }
|
39
49
|
else
|
40
50
|
output[current_title] ||= []
|
41
|
-
|
51
|
+
register color
|
42
52
|
output[current_title] << last
|
43
53
|
end
|
44
54
|
end
|
45
55
|
|
56
|
+
def register(color)
|
57
|
+
@last = color.is_a?(String) ? color.paint : color
|
58
|
+
end
|
59
|
+
|
46
60
|
def last
|
47
61
|
@last ||= 'red'.paint
|
48
62
|
end
|
@@ -53,6 +67,14 @@ module Colorly
|
|
53
67
|
|
54
68
|
private
|
55
69
|
|
70
|
+
def run!
|
71
|
+
if filename
|
72
|
+
instance_eval script, filename
|
73
|
+
else
|
74
|
+
instance_eval script
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
56
78
|
def current_title
|
57
79
|
@current_title ||= "Untitled"
|
58
80
|
end
|
@@ -29,16 +29,23 @@
|
|
29
29
|
}
|
30
30
|
</style>
|
31
31
|
|
32
|
-
|
32
|
+
<%- output.each do |name, colors| -%>
|
33
|
+
<div class='colorset'>
|
33
34
|
<h2><%= name %></h2>
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
35
|
+
|
36
|
+
<%- colors.each do |color| -%>
|
37
|
+
<%- css_class = color.dark? ? 'dark color' : 'light color' -%>
|
38
|
+
<div class='<%= css_class %>' style='background-color:<%= color.to_hex %>'>
|
39
|
+
<%= color.to_hex.upcase %>
|
40
|
+
<%- if use_names -%>
|
41
|
+
<br><%= color.shade %><br><%= color.name %>
|
42
|
+
<%- end -%>
|
43
|
+
</div>
|
44
|
+
|
45
|
+
<%- end -%>
|
46
|
+
</div>
|
47
|
+
|
48
|
+
<%- end -%>
|
49
|
+
|
43
50
|
</body>
|
44
51
|
</html>
|
data/lib/colorly/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: colorly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-06-
|
11
|
+
date: 2021-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chroma
|
@@ -92,9 +92,10 @@ files:
|
|
92
92
|
- lib/colorly.rb
|
93
93
|
- lib/colorly/cli.rb
|
94
94
|
- lib/colorly/command.rb
|
95
|
+
- lib/colorly/data/color-names.yml
|
95
96
|
- lib/colorly/exceptions.rb
|
96
97
|
- lib/colorly/extensions/chroma_color.rb
|
97
|
-
- lib/colorly/
|
98
|
+
- lib/colorly/refinements/string.rb
|
98
99
|
- lib/colorly/script.rb
|
99
100
|
- lib/colorly/templates/html.erb
|
100
101
|
- lib/colorly/version.rb
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'chroma'
|
2
|
-
|
3
|
-
class String
|
4
|
-
def spin(*args)
|
5
|
-
paint.spin *args
|
6
|
-
end
|
7
|
-
|
8
|
-
def darken(*args)
|
9
|
-
paint.darken *args
|
10
|
-
end
|
11
|
-
|
12
|
-
def lighten(*args)
|
13
|
-
paint.lighten *args
|
14
|
-
end
|
15
|
-
|
16
|
-
def saturate(*args)
|
17
|
-
paint.saturate *args
|
18
|
-
end
|
19
|
-
|
20
|
-
def desaturate(*args)
|
21
|
-
paint.desaturate *args
|
22
|
-
end
|
23
|
-
|
24
|
-
def palette(*args)
|
25
|
-
paint.palette *args
|
26
|
-
end
|
27
|
-
end
|