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.
@@ -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
@@ -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
+