rails_dictionary 0.1.2 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,3 +1,6 @@
1
1
  pkg/
2
2
  .git/
3
3
  .gitignore
4
+ Gemfile.lock
5
+ tmp/*
6
+ .idea/
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ 0.2
2
+ Add Support For Rails4
3
+
1
4
  0.1.2
2
5
  Remove Engine cause it's never used.
3
6
 
data/Gemfile CHANGED
@@ -5,6 +5,7 @@ gemspec
5
5
 
6
6
  group :development,:test do
7
7
  gem 'rspec', '>= 2.5.0'
8
- gem 'rails', '>= 3.0.0'
8
+ gem 'debugger'
9
+ gem "rspec-rails"
9
10
  gem 'sqlite3'
10
- end
11
+ end
data/README.rdoc CHANGED
@@ -5,9 +5,10 @@ This gem can map these static data to a Dictionary#method like Dictionary#studen
5
5
 
6
6
  = Usage
7
7
  == Installation
8
- Version 1.0 support Rails3.1
8
+ Version 0.2 support Rails4
9
+
10
+ Version 0.1 support Rails3.1
9
11
 
10
- Rail3
11
12
  gem 'rails_dictionary'
12
13
  or
13
14
  gem "rails_dictionary", :git => 'git://github.com/raykin/rails_dictionary'
@@ -74,7 +75,8 @@ Here is what should be like.Student model can be other models.
74
75
  end
75
76
 
76
77
  class Student < ActiveRecord::Base
77
- acts_as_dict_slave
78
+ # use acts_as_dict_slave when your rails_dictionary version < 0.2
79
+ acts_as_dict_consumer
78
80
  end
79
81
 
80
82
  == Features (relies on the above data) :
@@ -126,6 +128,5 @@ In short,when you confused with the debug data,try running "rails tmp:clear" fir
126
128
  Remove engine. Becase for the view layer we can use gem rails_admin. so this gem did not need rails engine.
127
129
  Is there any exist low level method to monitor the change of descendents?
128
130
  Add test code for cache DictType.tab_and_column,then uncomment the cache code.
129
- Remove gems/rails_dictionary-0.0.9.4/app/views from rails view path
130
131
 
131
132
  There are no conventions and implemention to map Class like Ckeditor::Asset to a legal method name.
data/Rakefile CHANGED
@@ -1,9 +1,10 @@
1
1
  require 'bundler'
2
2
  Bundler::GemHelper.install_tasks
3
3
 
4
+ task :default => [:test]
5
+
4
6
  desc "Running Test"
5
7
  task :test do
6
8
  # system "ruby -I . test/rails_dictionary_test.rb " # used with version 0.0.8 or before it
7
9
  system "rspec spec/rails_dictionary_spec.rb"
8
10
  end
9
-
@@ -42,6 +42,7 @@ module RailsDictionary
42
42
  end
43
43
  end
44
44
 
45
+ alias_method :acts_as_dict_consumer, :acts_as_dict_slave
45
46
  end
46
47
  end
47
48
  end
@@ -25,7 +25,7 @@ module RailsDictionary
25
25
  def method_missing(method_id,options={})
26
26
  if DictType.all_types.include? method_id
27
27
  method_name=method_id.to_s.downcase
28
- Rails.cache.fetch("Dictionary.#{method_name}") { dict_type_name_eq(method_name).all }
28
+ Rails.cache.fetch("Dictionary.#{method_name}") { dict_type_name_eq(method_name).to_a }
29
29
  listed_attr=Rails.cache.read("Dictionary.#{method_name}").dup # Instance of ActiveRecord::Relation can not be dup?
30
30
  build_scope_method(method_id)
31
31
  if options.keys.include? :locale or options.keys.include? "locale"
@@ -45,8 +45,7 @@ module RailsDictionary
45
45
  if options.keys.include? :locale or options.keys.include? "locale"
46
46
  locale="name_#{ options[:locale] }"
47
47
  if options[:locale].to_sym == :zh
48
- conv = Iconv.new("GBK", "utf-8")
49
- Proc.new { |a,b| conv.iconv(a.send(locale)) <=> conv.iconv(b.send(locale)) }
48
+ Proc.new { |a,b| a.send(locale).encode('GBK') <=> b.send(locale).encode('GBK') }
50
49
  else
51
50
  Proc.new { |a,b| a.send(locale).downcase <=> b.send(locale).downcase }
52
51
  end
@@ -55,6 +54,10 @@ module RailsDictionary
55
54
  end
56
55
  end
57
56
 
57
+ def respond_to?(name, include_private=false)
58
+ DictType.all_types.include?(name) || super
59
+ end
60
+
58
61
  private
59
62
 
60
63
  def build_scope_method(name)
@@ -1,3 +1,3 @@
1
1
  module RailsDictionary
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2"
3
3
  end
@@ -1,9 +1,10 @@
1
- require 'iconv'
2
-
3
1
  require File.join(File.dirname(__FILE__), "rails_dictionary/array_core_ext")
4
2
  require File.join(File.dirname(__FILE__), "rails_dictionary/models/active_record_extension")
5
3
  require File.join(File.dirname(__FILE__), "rails_dictionary/models/acts_as_dict_type")
6
4
  require File.join(File.dirname(__FILE__), "rails_dictionary/models/acts_as_dictionary")
7
5
  require File.join(File.dirname(__FILE__), "rails_dictionary/models/acts_as_dict_slave")
8
6
 
7
+ # rake tasks not autoload in Rails4
8
+ Dir[File.expand_path('../tasks/**/*.rake',__FILE__)].each { |ext| load ext } if defined?(Rake)
9
+
9
10
  ::ActiveRecord::Base.send :include, RailsDictionary::ActiveRecordExtension
@@ -1,4 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
+ require 'debugger'
2
3
  require File.expand_path('spec_helper', File.dirname(__FILE__))
3
4
 
4
5
  describe RailsDictionary::ActiveRecordExtension do
@@ -40,6 +41,10 @@ describe RailsDictionary do
40
41
  end
41
42
 
42
43
  describe Dictionary do
44
+ it "should respond to student_city" do
45
+ Dictionary.should respond_to(:student_city)
46
+ end
47
+
43
48
  it "generate student_city method" do
44
49
  Dictionary.student_city.should == [dy_shanghai,dy_beijing]
45
50
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_dictionary
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: '0.2'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-05 00:00:00.000000000Z
12
+ date: 2013-07-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &24997520 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>'
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '3.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *24997520
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>'
28
+ - !ruby/object:Gem::Version
29
+ version: '3.0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rails
27
- requirement: &24997020 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>'
@@ -32,7 +37,12 @@ dependencies:
32
37
  version: '3.0'
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *24997020
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>'
44
+ - !ruby/object:Gem::Version
45
+ version: '3.0'
36
46
  description: Rails plugin for mapping static data of web application to Dictionary
37
47
  class
38
48
  email:
@@ -54,7 +64,6 @@ files:
54
64
  - lib/rails_dictionary/models/acts_as_dictionary.rb
55
65
  - lib/rails_dictionary/version.rb
56
66
  - lib/tasks/dicts.rake
57
- - log/development.log
58
67
  - rails_dictionary.gemspec
59
68
  - spec/fake_app.rb
60
69
  - spec/rails_dictionary_spec.rb
@@ -79,9 +88,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
88
  version: '0'
80
89
  requirements: []
81
90
  rubyforge_project: rails_dictionary
82
- rubygems_version: 1.8.11
91
+ rubygems_version: 1.8.23
83
92
  signing_key:
84
93
  specification_version: 3
85
94
  summary: dictionary data for web application
86
95
  test_files: []
87
- has_rdoc:
data/log/development.log DELETED
@@ -1,2 +0,0 @@
1
-
2
- ***** Debugger requested, but was not available (ensure ruby-debug is listed in Gemfile/installed as gem): Start server with --debugger to enable *****