delano-caesars 0.7.1 → 0.7.3
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/CHANGES.txt +14 -0
- data/caesars.gemspec +1 -1
- data/lib/caesars/config.rb +1 -1
- data/lib/caesars/hash.rb +24 -6
- data/lib/caesars/orderedhash.rb +0 -3
- data/lib/caesars.rb +16 -5
- metadata +1 -1
data/CHANGES.txt
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
CAESARS -- CHANGES
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
#### 0.7.3 (2009-06-23) ###############################
|
|
5
|
+
|
|
6
|
+
* FIXED: Caesars::Config now correctly reports the config file in exceptions
|
|
7
|
+
|
|
8
|
+
#### 0.7.2 (2009-06-13) ###############################
|
|
9
|
+
|
|
10
|
+
* FIXED: Caesars::Hash method missing now correctly returns
|
|
11
|
+
hash values for element keys which are Strings.
|
|
12
|
+
* ADDED: Caesars::Hash.__class__ method which returns
|
|
13
|
+
one of: Hash (Ruby 1.9) or Caesars::OrderedHash (Ruby 1.8)
|
|
14
|
+
* CHANGE: All arguments to forced_hash methods now reference
|
|
15
|
+
the value of the first argument. They were previously
|
|
16
|
+
ignored but now mimic the default behavior.
|
|
17
|
+
|
|
4
18
|
#### 0.7.1 (2009-06-08) ###############################
|
|
5
19
|
|
|
6
20
|
* FIXED: Updated file manifest in gemspec
|
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.7.
|
|
4
|
+
s.version = "0.7.3"
|
|
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/config.rb
CHANGED
|
@@ -93,7 +93,7 @@ class Caesars
|
|
|
93
93
|
puts "Loading config from #{path}" if @verbose || Caesars.debug?
|
|
94
94
|
dsl = File.read path
|
|
95
95
|
# eval so the DSL code can be executed in this namespace.
|
|
96
|
-
eval dsl, binding,
|
|
96
|
+
eval dsl, binding, path
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
# Execute Caesars::Config.postprocesses after all files are loaded.
|
data/lib/caesars/hash.rb
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
|
|
2
|
-
# A subclass of ::Hash that provides method names for hash parameters.
|
|
3
|
-
# It's like a lightweight OpenStruct.
|
|
4
|
-
# ch = Caesars::Hash[:tabasco => :lots!]
|
|
5
|
-
# puts ch.tabasco # => lots!
|
|
6
|
-
#
|
|
7
2
|
class Caesars
|
|
3
|
+
# = Caesars::Hash
|
|
4
|
+
#
|
|
5
|
+
# A subclass of ::Hash (1.9) or Caesars::OrderedHash (1.8) that provides
|
|
6
|
+
# method names for hash parameters. It's like a lightweight OpenStruct.
|
|
7
|
+
#
|
|
8
|
+
# ch = Caesars::Hash[:tabasco => :lots!]
|
|
9
|
+
# puts ch.tabasco # => lots!
|
|
10
|
+
#
|
|
8
11
|
class Hash < HASH_TYPE
|
|
12
|
+
|
|
9
13
|
def method_missing(meth)
|
|
10
|
-
|
|
14
|
+
STDERR.puts "Caesars::Hash.method_missing: #{meth}" if Caesars.debug?
|
|
15
|
+
self[meth] || self[meth.to_s]
|
|
11
16
|
end
|
|
12
17
|
|
|
13
18
|
# Returns a clone of itself and all children cast as ::Hash objects
|
|
@@ -26,6 +31,19 @@ class Caesars
|
|
|
26
31
|
end
|
|
27
32
|
target
|
|
28
33
|
end
|
|
34
|
+
|
|
35
|
+
def __class__
|
|
36
|
+
HASH_TYPE
|
|
37
|
+
end
|
|
38
|
+
|
|
29
39
|
|
|
40
|
+
##def githash(s)
|
|
41
|
+
## # http://stackoverflow.com/questions/552659/assigning-git-sha1s-without-git
|
|
42
|
+
## # http://github.com/mojombo/grit/blob/master/lib/grit/git-ruby/git_object.rb#L81
|
|
43
|
+
## # http://github.com/mojombo/grit/blob/master/lib/grit/git-ruby/git_object.rb#L225
|
|
44
|
+
## # http://www.kernel.org/pub/software/scm/git-core/docs/git-hash-object.html
|
|
45
|
+
## # $ git hash-object file
|
|
46
|
+
## DIGEST_TYPE.hexdigest(("%s %d\0" % ['blob', s.length]) << s)
|
|
47
|
+
##end
|
|
30
48
|
end
|
|
31
49
|
end
|
data/lib/caesars/orderedhash.rb
CHANGED
data/lib/caesars.rb
CHANGED
|
@@ -13,15 +13,17 @@ class Caesars
|
|
|
13
13
|
require 'caesars/exceptions'
|
|
14
14
|
require 'caesars/config'
|
|
15
15
|
|
|
16
|
-
VERSION = "0.7.
|
|
16
|
+
VERSION = "0.7.3"
|
|
17
17
|
@@debug = false
|
|
18
18
|
@@chilled = {}
|
|
19
19
|
@@forced_array = {}
|
|
20
20
|
@@forced_ignore = {}
|
|
21
21
|
@@known_symbols = []
|
|
22
22
|
@@known_symbols_by_glass = {}
|
|
23
|
+
|
|
23
24
|
HASH_TYPE = (RUBY_VERSION =~ /1.9/) ? ::Hash : Caesars::OrderedHash
|
|
24
|
-
|
|
25
|
+
DIGEST_TYPE = Digest::SHA1
|
|
26
|
+
|
|
25
27
|
require 'caesars/hash'
|
|
26
28
|
|
|
27
29
|
def Caesars.enable_debug; @@debug = true; end
|
|
@@ -249,6 +251,7 @@ class Caesars
|
|
|
249
251
|
# previously) and also in subclasses of Caesars for returning the appropriate
|
|
250
252
|
# attribute values.
|
|
251
253
|
def method_missing(meth, *args, &b)
|
|
254
|
+
STDERR.puts "Caesars.method_missing: #{meth}" if Caesars.debug?
|
|
252
255
|
add_known_symbol(meth)
|
|
253
256
|
if Caesars.forced_ignore?(meth)
|
|
254
257
|
STDERR.puts "Forced ignore: #{meth}" if Caesars.debug?
|
|
@@ -355,6 +358,7 @@ class Caesars
|
|
|
355
358
|
module_eval %Q{
|
|
356
359
|
def #{caesars_meth}(*caesars_names,&b)
|
|
357
360
|
this_meth = :'#{caesars_meth}'
|
|
361
|
+
|
|
358
362
|
add_known_symbol(this_meth)
|
|
359
363
|
if Caesars.forced_ignore?(this_meth)
|
|
360
364
|
STDERR.puts "Forced ignore: \#{this_meth}" if Caesars.debug?
|
|
@@ -368,11 +372,12 @@ class Caesars
|
|
|
368
372
|
return nil if caesars_names.empty? && b.nil?
|
|
369
373
|
return method_missing(this_meth, *caesars_names, &b) if caesars_names.empty?
|
|
370
374
|
|
|
371
|
-
#
|
|
375
|
+
# Take the first argument in the list provided to "caesars_meth"
|
|
372
376
|
caesars_name = caesars_names.shift
|
|
373
377
|
|
|
374
378
|
prev = @caesars_pointer
|
|
375
379
|
@caesars_pointer[this_meth] ||= Caesars::Hash.new
|
|
380
|
+
|
|
376
381
|
hash = Caesars::Hash.new
|
|
377
382
|
if @caesars_pointer[this_meth].has_key?(caesars_name)
|
|
378
383
|
STDERR.puts "duplicate key ignored: \#{caesars_name}"
|
|
@@ -400,8 +405,14 @@ class Caesars
|
|
|
400
405
|
@caesars_pointer = prev
|
|
401
406
|
@caesars_pointer[this_meth][caesars_name] = hash
|
|
402
407
|
end
|
|
403
|
-
|
|
404
|
-
|
|
408
|
+
|
|
409
|
+
# All other arguments provided to "caesars_meth"
|
|
410
|
+
# will reference the value for the first argument.
|
|
411
|
+
caesars_names.each do |name|
|
|
412
|
+
@caesars_pointer[this_meth][name] = @caesars_pointer[this_meth][caesars_name]
|
|
413
|
+
end
|
|
414
|
+
|
|
415
|
+
@caesars_pointer = prev # Make sure we're back up one level
|
|
405
416
|
end
|
|
406
417
|
}
|
|
407
418
|
nil
|