rails_dictionary 0.0.9.1 → 0.0.9.2
Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
+
0.0.9.1
|
2
|
+
fix a cache bug in 0.0.9
|
1
3
|
0.0.9
|
2
4
|
add Rails Engine to redesign the gem
|
3
5
|
use Rspec instead of Test::Unit to write test code
|
4
6
|
remove many nonsence code
|
7
|
+
DictType.tab_and_column returns an array of symbols instead of strings
|
5
8
|
if update from lower version,should run "rails runner "DictType.new.delete_all_caches" on app root.
|
6
9
|
0.0.1-0.0.8
|
7
10
|
old mixin coding style
|
data/README.rdoc
CHANGED
@@ -10,8 +10,10 @@ Rail3
|
|
10
10
|
or
|
11
11
|
gem "rails_dictionary",:git => 'git://github.com/raykin/rails_dictionary'
|
12
12
|
|
13
|
-
!!For user who update from old version to 0.0.9 or higher,Please run following command on app root
|
13
|
+
!!For user who update from old version to 0.0.9.1 or higher,Please run following command on app root after updates.
|
14
14
|
rails runner "DictType.new.delete_all_caches"
|
15
|
+
and in production
|
16
|
+
rails runner "DictType.new.delete_all_caches" -e production
|
15
17
|
See change log for brief info.
|
16
18
|
|
17
19
|
== Sample
|
@@ -73,7 +75,7 @@ Here is what should be like.Student model can be other models.
|
|
73
75
|
|
74
76
|
== Features (relies on the above data) :
|
75
77
|
DictType.all_cached #=> return cache of DictType.all
|
76
|
-
DictType.all_types =
|
78
|
+
DictType.all_types = [:student_city,:student_school] # also cached
|
77
79
|
Dictionary.student_city #=> [Dictionary.find(5),Dictionary.find(6)]
|
78
80
|
student_city is a dynamic method which returns a list of dictionary object which dict_type is "student_city".
|
79
81
|
Actually Dictionary will have as many dynamic methods as DictType.count and each dynamic method name is DictType.name.
|
@@ -112,4 +114,4 @@ There are no convention and implemention to map Class like Ckeditor::Asset to a
|
|
112
114
|
|
113
115
|
Rebuild core code.Using Rails engine.
|
114
116
|
|
115
|
-
|
117
|
+
Add test code for cache DictType.tab_and_column,then uncomment the cache code.
|
@@ -36,6 +36,7 @@ module RailsDictionary
|
|
36
36
|
# TODO:
|
37
37
|
# To cache this method output need more skills on how to caculate ActiveRecord::Base.descendants
|
38
38
|
# Temply remove the cache
|
39
|
+
# And add test for this situation
|
39
40
|
def tab_and_column
|
40
41
|
#Rails.cache.fetch("DictType.tab_and_column") do
|
41
42
|
all_model_class=ActiveRecord::Base.descendants.map(&:name).map(&:underscore)
|
@@ -25,7 +25,10 @@ module RailsDictionary
|
|
25
25
|
# rethink about the cache.
|
26
26
|
# cache methods like Dictionary.student_city(:locale => :zh,:sort => :name_fr)
|
27
27
|
# but not cache Dictionary.student_city,return it as relation
|
28
|
-
|
28
|
+
#
|
29
|
+
# Remove nil noise,if listed_attr =[[nil, 201], [nil, 203], [nil, 202], ["Sciences", 200]]
|
30
|
+
# the sort would be failed of ArgumentError: comparison of Array with Array failed
|
31
|
+
def method_missing(method_id,options={})
|
29
32
|
method_name=method_id.to_s.downcase
|
30
33
|
if DictType.all_types.include? method_id
|
31
34
|
Rails.cache.fetch("Dictionary.#{method_name}") { dict_type_name_eq(method_name) }
|
@@ -33,7 +36,7 @@ module RailsDictionary
|
|
33
36
|
# Instance of activerelation can not be dup?
|
34
37
|
if options.keys.include? :locale or options.keys.include? "locale"
|
35
38
|
locale="name_#{ options[:locale] }"
|
36
|
-
listed_attr.map! { |a| [a.send(locale),a.id] }
|
39
|
+
listed_attr.map! { |a| [a.send(locale),a.id] }.reject! {|ele| ele.first.nil?}
|
37
40
|
listed_attr.sort { |a,b| a.first <=> b.first }
|
38
41
|
# maybe remove the above line,or change some sorting and caching design
|
39
42
|
else
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rails_dictionary
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.9.
|
5
|
+
version: 0.0.9.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Raykin Lee
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-04-
|
13
|
+
date: 2011-04-15 00:00:00 Z
|
14
14
|
dependencies: []
|
15
15
|
|
16
16
|
description: Rails plugin for mapping static data of web application to Dictionary class
|