rails_dictionary 0.0.5 → 0.0.6
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.
@@ -5,7 +5,7 @@ class Array
|
|
5
5
|
keys_array.each {|ky| ret_hash[ky.to_sym]=[]}
|
6
6
|
self.each do |sf|
|
7
7
|
keys_array.each do |ky|
|
8
|
-
ret_hash[ky.to_sym] << sf.sub("#{ky}_","") if sf =~ Regexp.new("^#{ky}")
|
8
|
+
ret_hash[ky.to_sym] << sf.sub("#{ky}_","") if sf =~ Regexp.new("^#{ky}_")
|
9
9
|
end
|
10
10
|
end
|
11
11
|
ret_hash.reject { |k,v| v.blank? }
|
@@ -58,8 +58,10 @@ end
|
|
58
58
|
class CoreExtTest < Test::Unit::TestCase
|
59
59
|
def test_array
|
60
60
|
expected_hash={:student => %w[school city],:admin => %w[role]}
|
61
|
+
blank_hash={}
|
61
62
|
assert_equal expected_hash, %w[student_school student_city admin_role].extract_to_hash(%w[student admin])
|
62
63
|
assert_equal expected_hash, %w[root student_school student_city admin_role].extract_to_hash(%w[student admin])
|
64
|
+
assert_equal blank_hash, %w[root students_school students_city].extract_to_hash(%w[student])
|
63
65
|
end
|
64
66
|
end
|
65
67
|
|