From 2ffed364f8a9db879eb270abb39427ed9ed9a725 Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Sun, 5 Aug 2018 17:43:59 +0200 Subject: move exception classes to SSON module --- lib/sson.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/sson.rb b/lib/sson.rb index 684749a..dd4ea67 100644 --- a/lib/sson.rb +++ b/lib/sson.rb @@ -18,16 +18,16 @@ require 'json' require 'prettyprint' require 'strscan' -module SSON; end -class << SSON +module SSON VERSION = "0.1" - - SCANIDENT = /[^0-9#;()" \t\r\n+-][^#;()" \t\r\n]*/ - IDENT = /\A#{SCANIDENT}\z/ class SSONError < StandardError; end class GeneratorError < SSONError; end class ParserError < SSONError; end +end +class << SSON + SCANIDENT = /[^0-9#;()" \t\r\n+-][^#;()" \t\r\n]*/ + IDENT = /\A#{SCANIDENT}\z/ def generate(o) case o @@ -137,7 +137,7 @@ class << SSON rescue StopIteration r else - raise ParserError, "trailing garbage" + raise SSON::ParserError, "trailing garbage" end end @@ -161,7 +161,7 @@ class << SSON elsif s = ss.scan(/[-+]?(?:\d*\.?\d+|\d+\.?\d*)(?:[eE][-+]?\d+)?/) yield Float(s) else - raise ParserError, "invalid SSON: " + ss.peek(20).dump + raise SSON::ParserError, "invalid SSON: " + ss.peek(20).dump end end end @@ -185,7 +185,7 @@ class << SSON end e.next r - when :CLOSE; raise ParserError, "invalid SSON, toplevel )" + when :CLOSE; raise SSON::ParserError, "invalid SSON, toplevel )" when :NULL; nil when :TRUE; true when :FALSE; false -- cgit 1.4.1