Skip to content
This repository has been archived by the owner on Jul 9, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1 from daedalus96/master
Browse files Browse the repository at this point in the history
Mainly Cosmetic, but adds some readability.
-------------------------------------------
Works for me. Accepted. Thanks, Isaac! - Leon
  • Loading branch information
leongersing committed Jul 7, 2011
2 parents 70234f3 + c9c5659 commit eb37e12
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
8 changes: 4 additions & 4 deletions lib/configulations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ def self.configure(&blk)
end

def find_properties
@properties = {}
@properties.extend(MagicHash)
@properties = MagicHash.new

Dir[@include_pattern].each do |file|
ext = File.extname(file)
Expand All @@ -33,9 +32,10 @@ def find_properties
end

def parser_for_extname(extname)
if(extname =~ /\.js(?:on)?/i)
case extname
when /\.js(?:on)?/i
return JSON
elsif(extname =~ /\.ya?ml/i)
when /\.ya?ml/i
return YAML
else
raise "Only files ending in .js, .json, .yml, .yaml have parsers at the moment."
Expand Down
12 changes: 7 additions & 5 deletions lib/magic_hash.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
module MagicHash

def self.new
Hash.new.extend(MagicHash)
end

def objectify
self.make_keys_valid_message_aliases
self.hash_all_keys
self
end

def make_keys_valid_message_aliases
tmp={}
tmp.extend(MagicHash)
tmp = MagicHash.new
self.each_pair do |key, value|
new_key = key.is_a?(Symbol) ? key : key.gsub(/\s|-/,"_").strip.to_sym
if(value.is_a? Hash)
Expand All @@ -30,9 +33,8 @@ def make_keys_valid_message_aliases
self.replace(tmp)
end

def hash_all_keys()
tmp = {}
tmp.extend(MagicHash)
def hash_all_keys
tmp = MagicHash.new
self.each_pair do |k, v|
if v.is_a? Hash
v.extend(MagicHash) unless v.respond_to? :objectify
Expand Down

0 comments on commit eb37e12

Please sign in to comment.