bud 0.0.6 → 0.0.7

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.
data/lib/bud/bud_meta.rb CHANGED
@@ -57,7 +57,7 @@ class BudMeta #:nodoc: all
57
57
  def binaryrel2map(rel)
58
58
  map = {}
59
59
  rel.each do |s|
60
- raise Bud::BudError unless s.length == 2
60
+ raise Bud::Error unless s.length == 2
61
61
  map[s[0]] = s[1]
62
62
  end
63
63
  return map
@@ -43,7 +43,7 @@ module Bud
43
43
  # user-specified schema.
44
44
  given_schema.each do |s|
45
45
  if s.to_s.start_with? "@"
46
- raise BudError, "illegal use of location specifier (@) in column #{s} of non-channel collection #{tabname}"
46
+ raise Bud::Error, "illegal use of location specifier (@) in column #{s} of non-channel collection #{tabname}"
47
47
  end
48
48
  end
49
49
 
@@ -60,7 +60,7 @@ module Bud
60
60
  private
61
61
  def parse_schema(given_schema)
62
62
  if given_schema.respond_to? :keys
63
- raise BudError, "invalid schema for #{tabname}" if given_schema.length != 1
63
+ raise Bud::Error, "invalid schema for #{tabname}" if given_schema.length != 1
64
64
  key_cols = given_schema.keys.first
65
65
  val_cols = given_schema.values.first
66
66
  else
@@ -71,11 +71,11 @@ module Bud
71
71
  cols = key_cols + val_cols
72
72
  cols.each do |c|
73
73
  if c.class != Symbol
74
- raise BudError, "invalid schema element \"#{c}\", type \"#{c.class}\""
74
+ raise Bud::Error, "invalid schema element \"#{c}\", type \"#{c.class}\""
75
75
  end
76
76
  end
77
77
  if cols.uniq.length < cols.length
78
- raise BudError, "schema for #{tabname} contains duplicate names"
78
+ raise Bud::Error, "schema for #{tabname} contains duplicate names"
79
79
  end
80
80
 
81
81
  return [cols, key_cols]
@@ -110,7 +110,7 @@ module Bud
110
110
  reserved = eval "defined?(#{colname})"
111
111
  unless (reserved.nil? or
112
112
  (reserved == "method" and method(colname).arity == -1 and (eval(colname))[0] == self.tabname))
113
- raise BudError, "symbol :#{colname} reserved, cannot be used as column name for #{tabname}"
113
+ raise Bud::Error, "symbol :#{colname} reserved, cannot be used as column name for #{tabname}"
114
114
  end
115
115
  end
116
116
 
@@ -216,7 +216,7 @@ module Bud
216
216
  when :storage then @storage
217
217
  when :delta then @delta
218
218
  when :new_delta then @new_delta
219
- else raise BudError, "bad symbol passed into each_from_sym"
219
+ else raise Bud::Error, "bad symbol passed into each_from_sym"
220
220
  end
221
221
  end
222
222
  each_from(bufs, &block)
@@ -289,10 +289,10 @@ module Bud
289
289
  private
290
290
  def prep_tuple(o)
291
291
  unless o.respond_to?(:length) and o.respond_to?(:[])
292
- raise BudTypeError, "non-indexable type inserted into \"#{tabname}\": #{o.inspect}"
292
+ raise Bud::TypeError, "non-indexable type inserted into \"#{tabname}\": #{o.inspect}"
293
293
  end
294
294
  if o.class <= String
295
- raise BudTypeError, "String value used as a fact inserted into \"#{tabname}\": #{o.inspect}"
295
+ raise Bud::TypeError, "String value used as a fact inserted into \"#{tabname}\": #{o.inspect}"
296
296
  end
297
297
 
298
298
  if o.length < cols.length then
@@ -336,7 +336,7 @@ module Bud
336
336
  private
337
337
  def check_enumerable(o)
338
338
  unless o.nil? or o.class < Enumerable
339
- raise BudTypeError, "collection #{tabname} expected Enumerable value, not #{o.inspect} (class = #{o.class})"
339
+ raise Bud::TypeError, "collection #{tabname} expected Enumerable value, not #{o.inspect} (class = #{o.class})"
340
340
  end
341
341
  end
342
342
 
@@ -448,8 +448,8 @@ module Bud
448
448
  def tick # :nodoc: all
449
449
  @storage = @pending
450
450
  @pending = {}
451
- raise BudError, "orphaned tuples in @delta for #{@tabname}" unless @delta.empty?
452
- raise BudError, "orphaned tuples in @new_delta for #{@tabname}" unless @new_delta.empty?
451
+ raise Bud::Error, "orphaned tuples in @delta for #{@tabname}" unless @delta.empty?
452
+ raise Bud::Error, "orphaned tuples in @new_delta for #{@tabname}" unless @new_delta.empty?
453
453
  end
454
454
 
455
455
  # move deltas to storage, and new_deltas to deltas.
@@ -487,7 +487,7 @@ module Bud
487
487
  public
488
488
  def argagg(aggname, gbkey_cols, collection)
489
489
  agg = bud_instance.send(aggname, nil)[0]
490
- raise BudError, "#{aggname} not declared exemplary" unless agg.class <= Bud::ArgExemplary
490
+ raise Bud::Error, "#{aggname} not declared exemplary" unless agg.class <= Bud::ArgExemplary
491
491
  keynames = gbkey_cols.map do |k|
492
492
  if k.class == Symbol
493
493
  k.to_s
@@ -686,10 +686,10 @@ module Bud
686
686
  the_cols, the_key_cols = parse_schema(given_schema)
687
687
  spec_count = the_cols.count {|c| c.to_s.start_with? "@"}
688
688
  if spec_count == 0
689
- raise BudError, "missing location specifier for channel '#{name}'"
689
+ raise Bud::Error, "missing location specifier for channel '#{name}'"
690
690
  end
691
691
  if spec_count > 1
692
- raise BudError, "multiple location specifiers for channel '#{name}'"
692
+ raise Bud::Error, "multiple location specifiers for channel '#{name}'"
693
693
  end
694
694
 
695
695
  the_val_cols = the_cols - the_key_cols
@@ -725,7 +725,7 @@ module Bud
725
725
  lsplit[1] = lsplit[1].to_i
726
726
  return lsplit
727
727
  rescue Exception => e
728
- raise BudError, "illegal location specifier in tuple #{t.inspect} for channel \"#{tabname}\": #{e.to_s}"
728
+ raise Bud::Error, "illegal location specifier in tuple #{t.inspect} for channel \"#{tabname}\": #{e.to_s}"
729
729
  end
730
730
  end
731
731
 
@@ -751,7 +751,7 @@ module Bud
751
751
  the_locspec = [ip, port]
752
752
  else
753
753
  the_locspec = split_locspec(t, @locspec_idx)
754
- raise BudError, "'#{t[@locspec_idx]}', channel '#{@tabname}'" if the_locspec[0].nil? or the_locspec[1].nil? or the_locspec[0] == '' or the_locspec[1] == ''
754
+ raise Bud::Error, "'#{t[@locspec_idx]}', channel '#{@tabname}'" if the_locspec[0].nil? or the_locspec[1].nil? or the_locspec[0] == '' or the_locspec[1] == ''
755
755
  end
756
756
  @bud_instance.dsock.send_datagram([@tabname, t].to_msgpack, the_locspec[0], the_locspec[1])
757
757
  end
@@ -782,13 +782,13 @@ module Bud
782
782
  end
783
783
 
784
784
  superator "<+" do |o|
785
- raise BudError, "illegal use of <+ with channel '#{@tabname}' on left"
785
+ raise Bud::Error, "illegal use of <+ with channel '#{@tabname}' on left"
786
786
  end
787
787
 
788
788
  undef merge
789
789
 
790
790
  def <=(o)
791
- raise BudError, "illegal use of <= with channel '#{@tabname}' on left"
791
+ raise Bud::Error, "illegal use of <= with channel '#{@tabname}' on left"
792
792
  end
793
793
  end
794
794
 
@@ -842,14 +842,14 @@ module Bud
842
842
  public
843
843
  def tick #:nodoc: all
844
844
  @storage = {}
845
- raise BudError, "orphaned pending tuples in terminal" unless @pending.empty?
845
+ raise Bud::Error, "orphaned pending tuples in terminal" unless @pending.empty?
846
846
  end
847
847
 
848
848
  undef merge
849
849
 
850
850
  public
851
851
  def <=(o) #:nodoc: all
852
- raise BudError, "illegal use of <= with terminal '#{@tabname}' on left"
852
+ raise Bud::Error, "illegal use of <= with terminal '#{@tabname}' on left"
853
853
  end
854
854
 
855
855
  superator "<~" do |o|
@@ -860,26 +860,26 @@ module Bud
860
860
  def get_out_io
861
861
  rv = @bud_instance.options[:stdout]
862
862
  rv ||= $stdout
863
- raise BudError, "attempting to write to terminal #{tabname} that was already closed" if rv.closed?
863
+ raise Bud::Error, "attempting to write to terminal #{tabname} that was already closed" if rv.closed?
864
864
  rv
865
865
  end
866
866
  end
867
867
 
868
868
  class BudPeriodic < BudCollection # :nodoc: all
869
869
  def <=(o)
870
- raise BudError, "illegal use of <= with periodic '#{tabname}' on left"
870
+ raise Bud::Error, "illegal use of <= with periodic '#{tabname}' on left"
871
871
  end
872
872
 
873
873
  superator "<~" do |o|
874
- raise BudError, "illegal use of <~ with periodic '#{tabname}' on left"
874
+ raise Bud::Error, "illegal use of <~ with periodic '#{tabname}' on left"
875
875
  end
876
876
 
877
877
  superator "<-" do |o|
878
- raise BudError, "illegal use of <- with periodic '#{tabname}' on left"
878
+ raise Bud::Error, "illegal use of <- with periodic '#{tabname}' on left"
879
879
  end
880
880
 
881
881
  superator "<+" do |o|
882
- raise BudError, "illegal use of <+ with periodic '#{tabname}' on left"
882
+ raise Bud::Error, "illegal use of <+ with periodic '#{tabname}' on left"
883
883
  end
884
884
  end
885
885
 
data/lib/bud/errors.rb CHANGED
@@ -1,18 +1,18 @@
1
1
  module Bud
2
2
  # Root Bud exception type.
3
- class BudError < StandardError; end
3
+ class Error < StandardError; end
4
4
 
5
5
  # Raised (at runtime) when a type mismatch occurs (e.g., supplying a
6
6
  # non-Enumerable object to the RHS of a Bud statement).
7
- class BudTypeError < BudError; end
7
+ class TypeError < Error; end
8
8
 
9
9
  # Raised when a primary key constraint is violated.
10
- class KeyConstraintError < BudError; end
10
+ class KeyConstraintError < Error; end
11
11
 
12
12
  # Raised when the input program fails to compile (e.g., due to illegal
13
13
  # syntax).
14
- class CompileError < BudError; end
14
+ class CompileError < Error; end
15
15
 
16
16
  # Raised when evaluation halts with outstanding callbacks
17
- class BudShutdownWithCallbacksError < BudError; end
17
+ class ShutdownWithCallbacksError < Error; end
18
18
  end
data/lib/bud/joins.rb CHANGED
@@ -84,6 +84,19 @@ module Bud
84
84
  preds.uniq
85
85
  end
86
86
 
87
+ private_class_method
88
+ def self.positionwise_preds(bud_instance, rels)
89
+ preds = []
90
+ rels.each do |r|
91
+ rels.each do |s|
92
+ [r.cols.length, s.cols.length].min.times do |c|
93
+ preds << [bud_instance.send(r.tabname).send(r.cols[c]), bud_instance.send(s.tabname).send(s.cols[c])] unless r.tabname.to_s >= s.tabname.to_s
94
+ end
95
+ end
96
+ end
97
+ preds.uniq
98
+ end
99
+
87
100
  # flatten joined items into arrays, with attribute accessors inherited
88
101
  # from the input collections, disambiguated via suffix indexes as needed.
89
102
  # similar to <tt>SELECT * FROM ... WHERE...</tt> block in SQL.
@@ -120,7 +133,7 @@ module Bud
120
133
  public
121
134
  # map each (nested) item in the collection into a string, suitable for placement in stdio
122
135
  def inspected
123
- raise BudError, "join left unconverted to binary" if @rels.length > 2
136
+ raise Bud::Error, "join left unconverted to binary" if @rels.length > 2
124
137
  tabnames = @origrels.map {|r| r.tabname.to_s}.join " * "
125
138
  [["(#{tabnames}): [#{self.map{|r1, r2| "\n (#{r1.inspect}, #{r2.inspect})"}}]"]]
126
139
  end
@@ -221,15 +234,24 @@ module Bud
221
234
  @origpreds = preds
222
235
  # no projection involved here, so we can propagate the schema
223
236
  @cols = @rels[0].cols
237
+ if preds == [] and blk.nil? and @cols.length == @rels[1].cols.length
238
+ preds = BudJoin::positionwise_preds(@bud_instance, rels)
239
+ end
224
240
  setup_preds(preds)
225
241
  setup_state if self.class <= Bud::BudJoin
226
242
  if blk.nil?
227
- @matches = map { |r, s| r }
243
+ if preds == [] # mismatched schemas -- no matches to be excluded
244
+ @exclude = []
245
+ else
246
+ # exclude those tuples of r that have a match
247
+ @exclude = map { |r, s| r }
248
+ end
228
249
  else
229
- @matches = map { |r, s| r unless blk.call(r, s).nil? }.compact
250
+ # exclude tuples of r that pass the blk call
251
+ @exclude = map { |r, s| r unless blk.call(r, s).nil? }.compact
230
252
  end
231
- # XXX: @matches is an Array, which makes include? O(n)
232
- @rels[0].map {|r| (@matches.include? r) ? nil : r}
253
+ # XXX: @exclude is an Array, which makes include? O(n)
254
+ @rels[0].map {|r| (@exclude.include? r) ? nil : r}
233
255
  end
234
256
 
235
257
  private
data/lib/bud/metrics.rb CHANGED
@@ -1,4 +1,4 @@
1
- require "bud/errors"
1
+ require 'bud/errors'
2
2
  require 'faster_csv'
3
3
 
4
4
  # metrics are reported in a nested hash representing a collection of relational tables.
@@ -31,7 +31,7 @@ end
31
31
 
32
32
  # see http://en.wikipedia.org/wiki/Standard_deviation#Rapid_calculation_methods
33
33
  def running_stats(stats, elapsed)
34
- raise Bud::BudError, "running_stats called with negative elapsed time" if elapsed < 0
34
+ raise Bud::Error, "running_stats called with negative elapsed time" if elapsed < 0
35
35
  stats[{:name=>:count}] += 1
36
36
  oldmean = stats[{:name=>:mean}]
37
37
  stats[{:name=>:mean}] = stats[{:name=>:mean}] + \
data/lib/bud/server.rb CHANGED
@@ -1,47 +1,45 @@
1
1
  require 'socket'
2
2
 
3
- module Bud
4
- class BudServer < EM::Connection #:nodoc: all
5
- def initialize(bud)
6
- @bud = bud
7
- @pac = MessagePack::Unpacker.new
8
- super
9
- end
3
+ class Bud::BudServer < EM::Connection #:nodoc: all
4
+ def initialize(bud)
5
+ @bud = bud
6
+ @pac = MessagePack::Unpacker.new
7
+ super
8
+ end
10
9
 
11
- def receive_data(data)
12
- # Feed the received data to the deserializer
13
- @pac.feed data
10
+ def receive_data(data)
11
+ # Feed the received data to the deserializer
12
+ @pac.feed data
14
13
 
15
- # streaming deserialize
16
- @pac.each do |obj|
17
- message_received(obj)
18
- end
14
+ # streaming deserialize
15
+ @pac.each do |obj|
16
+ message_received(obj)
17
+ end
19
18
 
20
- begin
21
- @bud.tick_internal if @bud.running_async
22
- rescue Exception
23
- # If we raise an exception here, EM dies, which causes problems (e.g.,
24
- # other Bud instances in the same process will crash). Ignoring the
25
- # error isn't best though -- we should do better (#74).
26
- puts "Exception handling network messages: #{$!}"
27
- puts "Inbound messages:"
28
- @bud.inbound.each do |m|
29
- puts " #{m[1].inspect} (channel: #{m[0]})"
30
- end
31
- @bud.inbound.clear
19
+ begin
20
+ @bud.tick_internal if @bud.running_async
21
+ rescue Exception
22
+ # If we raise an exception here, EM dies, which causes problems (e.g.,
23
+ # other Bud instances in the same process will crash). Ignoring the
24
+ # error isn't best though -- we should do better (#74).
25
+ puts "Exception handling network messages: #{$!}"
26
+ puts "Inbound messages:"
27
+ @bud.inbound.each do |m|
28
+ puts " #{m[1].inspect} (channel: #{m[0]})"
32
29
  end
33
-
34
- @bud.rtracer.sleep if @bud.options[:rtrace]
30
+ @bud.inbound.clear
35
31
  end
36
32
 
37
- def message_received(obj)
38
- unless (obj.class <= Array and obj.length == 2 and
39
- @bud.tables.include?(obj[0].to_sym) and obj[1].class <= Array)
40
- raise BudError, "bad inbound message of class #{obj.class}: #{obj.inspect}"
41
- end
33
+ @bud.rtracer.sleep if @bud.options[:rtrace]
34
+ end
42
35
 
43
- @bud.rtracer.recv(obj) if @bud.options[:rtrace]
44
- @bud.inbound << obj
36
+ def message_received(obj)
37
+ unless (obj.class <= Array and obj.length == 2 and
38
+ @bud.tables.include?(obj[0].to_sym) and obj[1].class <= Array)
39
+ raise Bud::Error, "bad inbound message of class #{obj.class}: #{obj.inspect}"
45
40
  end
41
+
42
+ @bud.rtracer.recv(obj) if @bud.options[:rtrace]
43
+ @bud.inbound << obj
46
44
  end
47
45
  end
data/lib/bud/state.rb CHANGED
@@ -55,7 +55,7 @@ module Bud
55
55
  @tables[name] = Bud::BudTcTable.new(name, self, schema)
56
56
  @tc_tables[name] = @tables[name]
57
57
  else
58
- raise BudError, "unknown synchronous storage engine #{storage.to_s}"
58
+ raise Bud::Error, "unknown synchronous storage engine #{storage.to_s}"
59
59
  end
60
60
  end
61
61
 
@@ -65,12 +65,12 @@ module Bud
65
65
  when :zookeeper
66
66
  # treat "schema" as a hash of options
67
67
  options = schema
68
- raise BudError, "Zookeeper tables require a :path option" if options[:path].nil?
68
+ raise Bud::Error, "Zookeeper tables require a :path option" if options[:path].nil?
69
69
  options[:addr] ||= "localhost:2181"
70
70
  @tables[name] = Bud::BudZkTable.new(name, options[:path], options[:addr], self)
71
71
  @zk_tables[name] = @tables[name]
72
72
  else
73
- raise BudError, "unknown async storage engine #{storage.to_s}"
73
+ raise Bud::Error, "unknown async storage engine #{storage.to_s}"
74
74
  end
75
75
  end
76
76
 
@@ -118,14 +118,14 @@ module Bud
118
118
  # rhs of statements only.
119
119
  def periodic(name, period=1)
120
120
  define_collection(name)
121
- raise BudError if @periodics.has_key? [name]
121
+ raise Bud::Error if @periodics.has_key? [name]
122
122
  @periodics << [name, period]
123
123
  @tables[name] = Bud::BudPeriodic.new(name, self)
124
124
  end
125
125
 
126
126
  def terminal(name) # :nodoc: all
127
127
  if defined?(@terminal) && @terminal != name
128
- raise Bud::BudError, "can't register IO collection #{name} in addition to #{@terminal}"
128
+ raise Bud::Error, "can't register IO collection #{name} in addition to #{@terminal}"
129
129
  else
130
130
  @terminal = name
131
131
  end
@@ -5,9 +5,9 @@ module Bud
5
5
  class BudDbmTable < BudCollection # :nodoc: all
6
6
  def initialize(name, bud_instance, given_schema)
7
7
  dbm_dir = bud_instance.options[:dbm_dir]
8
- raise BudError, "dbm support must be enabled via 'dbm_dir'" unless dbm_dir
8
+ raise Bud::Error, "dbm support must be enabled via 'dbm_dir'" unless dbm_dir
9
9
  if bud_instance.port.nil?
10
- raise BudError, "use of dbm storage requires an explicit port to be specified in Bud initialization options"
10
+ raise Bud::Error, "use of dbm storage requires an explicit port to be specified in Bud initialization options"
11
11
  end
12
12
 
13
13
  unless File.exists?(dbm_dir)
@@ -30,7 +30,7 @@ module Bud
30
30
  end
31
31
  @dbm = DBM.open(db_fname, 0666, flags)
32
32
  if @dbm.nil?
33
- raise BudError, "failed to open dbm database '#{db_fname}': #{@dbm.errmsg}"
33
+ raise Bud::Error, "failed to open dbm database '#{db_fname}': #{@dbm.errmsg}"
34
34
  end
35
35
  end
36
36
 
@@ -9,9 +9,9 @@ module Bud
9
9
  class BudTcTable < BudCollection # :nodoc: all
10
10
  def initialize(name, bud_instance, given_schema)
11
11
  tc_dir = bud_instance.options[:tc_dir]
12
- raise BudError, "TC support must be enabled via 'tc_dir'" unless tc_dir
12
+ raise Bud::Error, "TC support must be enabled via 'tc_dir'" unless tc_dir
13
13
  if bud_instance.port.nil?
14
- raise BudError, "use of dbm storage requires an explicit port to be specified in Bud initialization options"
14
+ raise Bud::Error, "use of dbm storage requires an explicit port to be specified in Bud initialization options"
15
15
  end
16
16
 
17
17
  unless File.exists?(tc_dir)
@@ -35,7 +35,7 @@ module Bud
35
35
  flags |= TokyoCabinet::HDB::OTRUNC
36
36
  end
37
37
  if !@hdb.open(db_fname, flags)
38
- raise BudError, "failed to open TokyoCabinet DB '#{db_fname}': #{@hdb.errmsg}"
38
+ raise Bud::Error, "failed to open TokyoCabinet DB '#{db_fname}': #{@hdb.errmsg}"
39
39
  end
40
40
  @hdb.tranbegin
41
41
  end
@@ -9,7 +9,7 @@ module Bud
9
9
  class BudZkTable < BudCollection # :nodoc: all
10
10
  def initialize(name, zk_path, zk_addr, bud_instance)
11
11
  unless defined? HAVE_ZOOKEEPER
12
- raise BudError, "zookeeper gem is not installed: zookeeper-backed stores cannot be used"
12
+ raise Bud::Error, "zookeeper gem is not installed: zookeeper-backed stores cannot be used"
13
13
  end
14
14
 
15
15
  # schema = {[:key] => [:val]}
@@ -37,7 +37,7 @@ module Bud
37
37
  end
38
38
 
39
39
  def clone_empty
40
- raise BudError
40
+ raise Bud::Error
41
41
  end
42
42
 
43
43
  def stat_and_watch
@@ -164,15 +164,15 @@ module Bud
164
164
  end
165
165
 
166
166
  superator "<+" do |o|
167
- raise BudError, "illegal use of <+ with zookeeper store '#{@tabname}' on left"
167
+ raise Bud::Error, "illegal use of <+ with zookeeper store '#{@tabname}' on left"
168
168
  end
169
169
 
170
170
  def <=(o)
171
- raise BudError, "illegal use of <= with zookeeper store '#{@tabname}' on left"
171
+ raise Bud::Error, "illegal use of <= with zookeeper store '#{@tabname}' on left"
172
172
  end
173
173
 
174
174
  def <<(o)
175
- raise BudError, "illegal use of << with zookeeper store '#{@tabname}' on left"
175
+ raise Bud::Error, "illegal use of << with zookeeper store '#{@tabname}' on left"
176
176
  end
177
177
  end
178
178
  end
data/lib/bud.rb CHANGED
@@ -163,7 +163,7 @@ module Bud
163
163
  @rule_orig_src = []
164
164
  declaration
165
165
  @strata.each_with_index do |s,i|
166
- raise BudError if s.class <= Array
166
+ raise Bud::Error if s.class <= Array
167
167
  @strata[i] = [s]
168
168
  # Don't try to record source text for old-style rule blocks
169
169
  @rule_src[i] = [""]
@@ -306,7 +306,7 @@ module Bud
306
306
 
307
307
  schedule_and_wait do
308
308
  if @running_async
309
- raise BudError, "run_bg called on already-running Bud instance"
309
+ raise Bud::Error, "run_bg called on already-running Bud instance"
310
310
  end
311
311
  @running_async = true
312
312
 
@@ -331,8 +331,8 @@ module Bud
331
331
 
332
332
  private
333
333
  def do_startup
334
- raise BudError, "EventMachine not started" unless EventMachine::reactor_running?
335
- raise BudError unless EventMachine::reactor_thread?
334
+ raise Bud::Error, "EventMachine not started" unless EventMachine::reactor_running?
335
+ raise Bud::Error unless EventMachine::reactor_thread?
336
336
 
337
337
  @instance_id = Bud.init_signal_handlers(self)
338
338
  do_start_server
@@ -376,7 +376,7 @@ module Bud
376
376
  # If we're called from the EventMachine thread (and EM is running), blocking
377
377
  # the current thread would imply deadlocking ourselves.
378
378
  if Thread.current == EventMachine::reactor_thread and EventMachine::reactor_running?
379
- raise BudError, "cannot invoke run_fg from inside EventMachine"
379
+ raise Bud::Error, "cannot invoke run_fg from inside EventMachine"
380
380
  end
381
381
 
382
382
  q = Queue.new
@@ -430,7 +430,7 @@ module Bud
430
430
 
431
431
  def cancel_shutdown_cb(id)
432
432
  schedule_and_wait do
433
- raise Bud::BudError unless @shutdown_callbacks.has_key? id
433
+ raise Bud::Error unless @shutdown_callbacks.has_key? id
434
434
  @shutdown_callbacks.delete(id)
435
435
  end
436
436
  end
@@ -494,10 +494,10 @@ module Bud
494
494
  cb_id = nil
495
495
  schedule_and_wait do
496
496
  unless @tables.has_key? tbl_name
497
- raise Bud::BudError, "no such table: #{tbl_name}"
497
+ raise Bud::Error, "no such table: #{tbl_name}"
498
498
  end
499
499
 
500
- raise Bud::BudError if @callbacks.has_key? @callback_id
500
+ raise Bud::Error if @callbacks.has_key? @callback_id
501
501
  @callbacks[@callback_id] = [tbl_name, block]
502
502
  cb_id = @callback_id
503
503
  @callback_id += 1
@@ -508,7 +508,7 @@ module Bud
508
508
  # Unregister the callback that has the given ID.
509
509
  def unregister_callback(id)
510
510
  schedule_and_wait do
511
- raise Bud::BudError, "missing callback: #{id.inspect}" unless @callbacks.has_key? id
511
+ raise Bud::Error, "missing callback: #{id.inspect}" unless @callbacks.has_key? id
512
512
  @callbacks.delete(id)
513
513
  end
514
514
  end
@@ -543,7 +543,7 @@ module Bud
543
543
  result = q.pop
544
544
  if result == :callback
545
545
  # Don't try to unregister the callbacks first: runtime is already shutdown
546
- raise BudShutdownWithCallbacksError, "Bud instance shutdown before sync_callback completed"
546
+ raise Bud::ShutdownWithCallbacksError, "Bud instance shutdown before sync_callback completed"
547
547
  end
548
548
  unregister_callback(cb)
549
549
  cancel_shutdown_cb(shutdown_cb)
@@ -571,9 +571,9 @@ module Bud
571
571
  return if EventMachine::reactor_running?
572
572
 
573
573
  EventMachine::error_handler do |e|
574
- # Only print a backtrace if a non-BudError is raised (this presumably
574
+ # Only print a backtrace if a non-Bud::Error is raised (this presumably
575
575
  # indicates an unexpected failure).
576
- if e.class <= BudError
576
+ if e.class <= Bud::Error
577
577
  puts "#{e.class}: #{e}"
578
578
  else
579
579
  puts "Unexpected Bud error: #{e.inspect}"
@@ -664,7 +664,7 @@ module Bud
664
664
  # forwarding, and external_ip:local_port would be if you're in a DMZ, for
665
665
  # example.
666
666
  def ip_port
667
- raise BudError, "ip_port called before port defined" if port.nil?
667
+ raise Bud::Error, "ip_port called before port defined" if port.nil?
668
668
  ip.to_s + ":" + port.to_s
669
669
  end
670
670
 
@@ -680,7 +680,7 @@ module Bud
680
680
 
681
681
  # Returns the internal IP and port. See ip_port.
682
682
  def int_ip_port
683
- raise BudError, "ip_port called before port defined" if @port.nil? and @options[:port] == 0
683
+ raise Bud::Error, "ip_port called before port defined" if @port.nil? and @options[:port] == 0
684
684
  @port.nil? ? "#{@ip}:#{@options[:port]}" : "#{@ip}:#{@port}"
685
685
  end
686
686
 
@@ -730,7 +730,7 @@ module Bud
730
730
  # this value is guaranteed to remain the same for the duration of a single
731
731
  # tick, but will likely change between ticks.
732
732
  def bud_clock
733
- raise BudError, "bud_clock undefined outside tick" unless @inside_tick
733
+ raise Bud::Error, "bud_clock undefined outside tick" unless @inside_tick
734
734
  @tick_clock_time ||= Time.now
735
735
  @tick_clock_time
736
736
  end
@@ -742,7 +742,7 @@ module Bud
742
742
  # initialized before user-defined state.
743
743
  def builtin_state
744
744
  # We expect there to be no previously-defined tables
745
- raise BudError unless @tables.empty?
745
+ raise Bud::Error unless @tables.empty?
746
746
 
747
747
  loopback :localtick, [:col1]
748
748
  @stdio = terminal :stdio
@@ -837,8 +837,8 @@ module Bud
837
837
  end
838
838
 
839
839
  new_e = e
840
- unless new_e.class <= BudError
841
- new_e = BudError
840
+ unless new_e.class <= Bud::Error
841
+ new_e = Bud::Error
842
842
  end
843
843
  raise new_e, "exception during Bud evaluation.\nException: #{e.inspect}.#{src_msg}"
844
844
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bud
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 6
10
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Peter Alvaro
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2011-10-09 00:00:00 Z
21
+ date: 2011-10-10 00:00:00 Z
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
24
  name: backports