caesars 0.6.1 → 0.6.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.
Files changed (4) hide show
  1. data/CHANGES.txt +10 -2
  2. data/caesars.gemspec +1 -1
  3. data/lib/caesars.rb +40 -11
  4. metadata +2 -2
data/CHANGES.txt CHANGED
@@ -1,10 +1,18 @@
1
1
  CAESARS -- CHANGES
2
2
 
3
3
 
4
- #### 0.6.1 (2009-05-02) ###############################
4
+ #### 0.6.2 (2009-05-03) ###############################
5
+
6
+ * FIXED: When setting Caesars::Config.verbose it would get reset after a refresh.
7
+ * FIXED: Handling a keyword that's passed to both forced_hash and chill
8
+ * ADDED: Print message to STDERR when force refreshing in debug or verbose mode
9
+ * ADDED: Caesars::SyntaxError
5
10
 
6
- * ADDED: known_symbol? and known_symbol_by_glass?
7
11
 
12
+ #### 0.6.1 (2009-05-02) ###############################
13
+
14
+ * ADDED: known_symbol? and known_symbol_by_glass?
15
+
8
16
  #### 0.6.0 (2009-04-30) ###############################
9
17
 
10
18
  * ADDED: Forced reloading for Caesars::Config.refresh. This allows
data/caesars.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  @spec = Gem::Specification.new do |s|
2
2
  s.name = "caesars"
3
3
  s.rubyforge_project = "caesars"
4
- s.version = "0.6.1"
4
+ s.version = "0.6.2"
5
5
  s.specification_version = 1 if s.respond_to? :specification_version=
6
6
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
7
7
 
data/lib/caesars.rb CHANGED
@@ -88,9 +88,18 @@ class Caesars
88
88
  attr_accessor :caesars_properties
89
89
 
90
90
  class Error < RuntimeError
91
+ attr_accessor :backtrace
91
92
  def initialize(obj=nil); @obj = obj; end
92
93
  def message; "#{self.class}: #{@obj}"; end
93
94
  end
95
+ class SyntaxError < Caesars::Error
96
+ def message
97
+ msg = "Syntax error in #{@obj}"
98
+ bt = @backtrace
99
+ msg << " in " << bt.first.scan(/\`(.+?)'/).flatten.first if bt
100
+ msg
101
+ end
102
+ end
94
103
 
95
104
  def initialize(name=nil)
96
105
  @caesars_name = name if name
@@ -376,7 +385,8 @@ class Caesars
376
385
 
377
386
  return nil if caesars_names.empty? && b.nil?
378
387
  return method_missing(this_meth, *caesars_names, &b) if caesars_names.empty?
379
-
388
+
389
+ # TODO: This should be a loop
380
390
  caesars_name = caesars_names.shift
381
391
 
382
392
  prev = @caesars_pointer
@@ -387,17 +397,30 @@ class Caesars
387
397
  return
388
398
  end
389
399
 
390
- @caesars_pointer = hash # This is needed but I don't know why
400
+ # The pointer is pointing to the hash that contains "this_meth".
401
+ # We wan't to make it point to the this_meth hash so when we call
402
+ # the block, we'll create new entries in there.
403
+ @caesars_pointer = hash
404
+
391
405
  if b
392
406
  if Caesars.chilled?(this_meth)
407
+ # We're done processing this_meth so we want to return the pointer
408
+ # to the level above.
409
+ @caesars_pointer = prev
393
410
  @caesars_pointer[this_meth][caesars_name] = b
394
411
  else
412
+ # Since the pointer is pointing to the this_meth hash, all keys
413
+ # created in the block we be placed inside.
395
414
  b.call
415
+ # We're done processing this_meth so we want to return the pointer
416
+ # to the level above.
417
+ @caesars_pointer = prev
418
+ @caesars_pointer[this_meth][caesars_name] = hash
396
419
  end
397
420
  end
398
- @caesars_pointer = prev
399
- @caesars_pointer[this_meth][caesars_name] = hash
400
- @caesars_pointer = prev
421
+
422
+ @caesars_pointer = prev
423
+
401
424
  end
402
425
  }
403
426
  nil
@@ -526,8 +549,8 @@ end
526
549
  #
527
550
  class Caesars::Config
528
551
  attr_accessor :paths
529
- attr_accessor :options
530
- attr_accessor :verbose
552
+ attr_reader :options
553
+ attr_reader :verbose
531
554
 
532
555
  @@glasses = []
533
556
 
@@ -556,6 +579,11 @@ class Caesars::Config
556
579
  refresh
557
580
  end
558
581
 
582
+ def verbose=(enable)
583
+ @verbose = enable == true
584
+ @options[:verbose] = @verbose
585
+ end
586
+
559
587
  # Reset all config instance variables to nil.
560
588
  def caesars_init
561
589
  # Remove instance variables used to populate DSL data
@@ -593,7 +621,7 @@ class Caesars::Config
593
621
  def refresh
594
622
  caesars_init # Delete all current configuration
595
623
  @@glasses.each { |glass| extend glass }
596
-
624
+
597
625
  begin
598
626
  current_path = nil # used in error messages
599
627
  @paths.each do |path|
@@ -612,15 +640,16 @@ class Caesars::Config
612
640
  STDERR.puts "Too many forced refreshed (#{@forced_refreshes})"
613
641
  exit 9
614
642
  end
615
- STDERR.puts ex.message if Caesars.debug?
643
+ STDERR.puts ex.message if @verbose || Caesars.debug?
616
644
  refresh
617
645
 
618
646
  #rescue Caesars::Error => ex
619
647
  # STDERR.puts ex.message
620
648
  # STDERR.puts ex.backtrace if Caesars.debug?
621
649
  rescue ArgumentError, SyntaxError => ex
622
- STDERR.puts "Syntax error in #{current_path}."
623
- raise ex
650
+ newex = Caesars::SyntaxError.new(current_path)
651
+ newex.backtrace = ex.backtrace
652
+ raise newex
624
653
  end
625
654
  end
626
655
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caesars
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delano Mandelbaum
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-02 00:00:00 -04:00
12
+ date: 2009-05-03 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies: []
15
15