colorly 0.0.1 → 0.1.2
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 +129 -3
- data/lib/colorly/command.rb +21 -13
- data/lib/colorly/data/color-names.yml +1640 -0
- data/lib/colorly/dsl.rb +25 -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 +27 -23
- data/lib/colorly/templates/html.erb +18 -11
- data/lib/colorly/version.rb +1 -1
- data/lib/colorly.rb +10 -0
- metadata +9 -7
- data/lib/colorly/extensions/string.rb +0 -27
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/exceptions.rb
CHANGED
@@ -3,4 +3,23 @@ module Colorly
|
|
3
3
|
class Interrupt < Error; end
|
4
4
|
class ArgumentError < Error; end
|
5
5
|
class ScriptNotFound < Error; end
|
6
|
+
|
7
|
+
class ScriptError < Error
|
8
|
+
attr_reader :error
|
9
|
+
|
10
|
+
def initialize(error)
|
11
|
+
@error = error
|
12
|
+
trace = error.backtrace_locations.first
|
13
|
+
message = error.message.gsub(/ for #<Colorly::Script.*>/, '')
|
14
|
+
super "#{trace.path}:#{trace.lineno}: #{message}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class ScriptSyntaxError < Error
|
19
|
+
def initialize(error)
|
20
|
+
super error.message
|
21
|
+
end
|
22
|
+
end
|
6
23
|
end
|
24
|
+
|
25
|
+
|