colorly 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -2
- data/lib/colorly/command.rb +4 -3
- data/lib/colorly/dsl.rb +25 -0
- data/lib/colorly/script.rb +11 -29
- data/lib/colorly/templates/html.erb +1 -1
- data/lib/colorly/version.rb +1 -1
- data/lib/colorly.rb +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 572649998dd2a43148239699a5c95c418d38860f7a89bc15ccba507b1414acab
|
4
|
+
data.tar.gz: 062e72d51fe3fc1c61a1f4e3a8e2da95c5f4da8883a7ddd80c4a79639cb93ef0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e911bd401cf6459e7e24ed6396b2e4b0c0c6bad1e31e66e7204edbb568dcc2963f155f509c6638959f4f91dc2bbce5c4d7f2cd434e74609278f265a601e317c
|
7
|
+
data.tar.gz: f4755d5079887a84bf97acb6624a1917648c98ea35e00e05f0128a32f15556c7d0d25e9eb793c70d9dae7e11f1e25da2c65d5e84aa738137b12726158a6d0c00
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
---
|
8
8
|
|
9
|
-
Colorly is a command line
|
9
|
+
Colorly is a command line utility and a Ruby library for generating color
|
10
10
|
palettes using a simple DSL.
|
11
11
|
|
12
12
|
It is a thin wrapper around the [chroma] gem.
|
@@ -107,9 +107,15 @@ require 'colorly'
|
|
107
107
|
script = Colorly::Script.load 'script_file.rb'
|
108
108
|
|
109
109
|
# ... or from a string
|
110
|
-
script_string = "title 'Hello'; add
|
110
|
+
script_string = "title 'Hello'; add params[:base_color] ; add last.spin 90"
|
111
111
|
script = Colorly::Script.new script_string
|
112
112
|
|
113
|
+
# Optionally, pass parameters to the script, which you can use in the script
|
114
|
+
# by accessing the `params` hash.
|
115
|
+
script.params = { base_color: '#cdc' }
|
116
|
+
# or
|
117
|
+
script.params[:base_color] = '#cdc'
|
118
|
+
|
113
119
|
# Run it
|
114
120
|
script.run
|
115
121
|
|
data/lib/colorly/command.rb
CHANGED
@@ -10,14 +10,15 @@ module Colorly
|
|
10
10
|
class Command < MisterBin::Command
|
11
11
|
include Colsole
|
12
12
|
summary "Run a colorly script"
|
13
|
+
version Colorly::VERSION
|
13
14
|
|
14
15
|
help "Execute a colorly script and save or print its output"
|
15
16
|
|
16
17
|
usage "colorly SCRIPT [OUTPUT_PATH] [--watch --names]"
|
17
|
-
usage "colorly --help"
|
18
|
+
usage "colorly --help | --version"
|
18
19
|
|
19
|
-
option "-w
|
20
|
-
option "-n
|
20
|
+
option "-w --watch", "Watch the script file and regenerate on change"
|
21
|
+
option "-n --names", "Also show color names and shades (slower)"
|
21
22
|
|
22
23
|
param "SCRIPT", "Path to script file"
|
23
24
|
param "OUTPUT_PATH", "Path to output file. The output format is determined by the file extension. Supported formats:\n- YAML (.yaml or .yml)\n- JSON (.json)\n- HTML (.html)\nIf left empty, YAML format will be sent to STDOUT."
|
data/lib/colorly/dsl.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Colorly
|
2
|
+
module DSL
|
3
|
+
def title(title)
|
4
|
+
@current_title = title
|
5
|
+
end
|
6
|
+
|
7
|
+
def add(color)
|
8
|
+
if color.is_a? Array
|
9
|
+
color.each { |c| add c }
|
10
|
+
else
|
11
|
+
output[current_title] ||= []
|
12
|
+
register color
|
13
|
+
output[current_title] << last
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def last
|
18
|
+
@last ||= 'red'.paint
|
19
|
+
end
|
20
|
+
|
21
|
+
def random
|
22
|
+
"#%06x" % (rand * 0xffffff)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/colorly/script.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
module Colorly
|
2
2
|
class Script
|
3
|
+
include DSL
|
3
4
|
using StringRefinements
|
4
5
|
attr_reader :script, :filename
|
6
|
+
attr_writer :params
|
5
7
|
|
6
8
|
def self.load(script_file)
|
7
9
|
raise ScriptNotFound, "Unable to load #{script_file}" unless File.exist? script_file
|
@@ -24,6 +26,10 @@ module Colorly
|
|
24
26
|
@output ||= {}
|
25
27
|
end
|
26
28
|
|
29
|
+
def params
|
30
|
+
@params ||= {}
|
31
|
+
end
|
32
|
+
|
27
33
|
def simple_output(names: false)
|
28
34
|
output.transform_values do |chroma_array|
|
29
35
|
chroma_array.map do |chroma|
|
@@ -37,34 +43,6 @@ module Colorly
|
|
37
43
|
end
|
38
44
|
alias to_h simple_output
|
39
45
|
|
40
|
-
# DSL Methods
|
41
|
-
|
42
|
-
def title(title)
|
43
|
-
@current_title = title
|
44
|
-
end
|
45
|
-
|
46
|
-
def add(color)
|
47
|
-
if color.is_a? Array
|
48
|
-
color.each { |c| add c }
|
49
|
-
else
|
50
|
-
output[current_title] ||= []
|
51
|
-
register color
|
52
|
-
output[current_title] << last
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def register(color)
|
57
|
-
@last = color.is_a?(String) ? color.paint : color
|
58
|
-
end
|
59
|
-
|
60
|
-
def last
|
61
|
-
@last ||= 'red'.paint
|
62
|
-
end
|
63
|
-
|
64
|
-
def random
|
65
|
-
"#%06x" % (rand * 0xffffff)
|
66
|
-
end
|
67
|
-
|
68
46
|
private
|
69
47
|
|
70
48
|
def run!
|
@@ -75,8 +53,12 @@ module Colorly
|
|
75
53
|
end
|
76
54
|
end
|
77
55
|
|
56
|
+
def register(color)
|
57
|
+
@last = color.is_a?(String) ? color.paint : color
|
58
|
+
end
|
59
|
+
|
78
60
|
def current_title
|
79
|
-
@current_title ||= "
|
61
|
+
@current_title ||= "Colors"
|
80
62
|
end
|
81
63
|
|
82
64
|
end
|
data/lib/colorly/version.rb
CHANGED
data/lib/colorly.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.1.
|
4
|
+
version: 0.1.1
|
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-
|
11
|
+
date: 2021-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chroma
|
@@ -93,6 +93,7 @@ files:
|
|
93
93
|
- lib/colorly/cli.rb
|
94
94
|
- lib/colorly/command.rb
|
95
95
|
- lib/colorly/data/color-names.yml
|
96
|
+
- lib/colorly/dsl.rb
|
96
97
|
- lib/colorly/exceptions.rb
|
97
98
|
- lib/colorly/extensions/chroma_color.rb
|
98
99
|
- lib/colorly/refinements/string.rb
|
@@ -120,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
121
|
- !ruby/object:Gem::Version
|
121
122
|
version: '0'
|
122
123
|
requirements: []
|
123
|
-
rubygems_version: 3.2.
|
124
|
+
rubygems_version: 3.2.25
|
124
125
|
signing_key:
|
125
126
|
specification_version: 4
|
126
127
|
summary: Colorly color palette CLI
|