rails_dictionary 0.2.2 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 622dff0abbc1c9f416b4f86b7b962c2b7a394db0c801a836573fefbe537cf2f0
4
- data.tar.gz: 24b8e3e1a53a4419a6a84555590b14ea7081d4d208b2033e63c2c11b0fbdf5dc
3
+ metadata.gz: aa45031164009565fcb220ccce7c96a6482cfb81d8b41225b4008e06d5ea95c9
4
+ data.tar.gz: 912b98be0d156d8253aa46fad087c387d648afb81e83eb08bf959d007cb96dfc
5
5
  SHA512:
6
- metadata.gz: f7978afeaa816170a80105168a25990a1a7ebdb1f2aa88e4204097a1afc1e79c3aa591ffc78e73964a2893257b233946706e71dad804c23462cd9608af8c948f
7
- data.tar.gz: 46a06cf437d586bf133ee8c9ff8c33d3787317678f7f2a384543f66a9297e70cc88e55e887d97a04fee99ac4599ce90bebf50326079024e909e90e7ed5d080f7
6
+ metadata.gz: ac1649c7b55cdc093791d6160210e1d09a4d78a5a1a6c44c75722ae4023e42f2c63363233eaf9c9485a358c7ff1671a570e764f1745944dc4c8a3c1e603b76e8
7
+ data.tar.gz: cb3b2def00bb03ee636eb718699a3586f2b52cd37743e0b45614012af5798bb2e2b5b5a5aa398fdde48e952d5067023630c8239042615fc405e2e0da0ac471be
data/.gitignore CHANGED
@@ -1,6 +1,6 @@
1
1
  pkg/
2
2
  .git/
3
- .gitignore
4
- Gemfile.lock
5
3
  tmp/*
6
- .idea/
4
+ .idea/
5
+ .byebug_history
6
+ log/
data/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ 0.2.4
2
+ Support Rails7
1
3
  0.2
2
4
  Add Support For Rails4
3
5
 
data/Gemfile CHANGED
@@ -4,8 +4,8 @@ source "http://rubygems.org"
4
4
  gemspec
5
5
 
6
6
  group :development,:test do
7
- gem 'rspec', '~> 2.14.0'
8
- gem 'byebug'
9
- gem "rspec-rails", '2.14.2'
7
+ gem 'rails', '~> 7.0'
8
+ gem 'pry-byebug'
9
+ gem "rspec-rails", '5.1.0'
10
10
  gem 'sqlite3'
11
11
  end
data/Gemfile.lock ADDED
@@ -0,0 +1,193 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rails_dictionary (0.2.5)
5
+ rails (> 6.0, < 7.1)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ actioncable (7.0.2.2)
11
+ actionpack (= 7.0.2.2)
12
+ activesupport (= 7.0.2.2)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ actionmailbox (7.0.2.2)
16
+ actionpack (= 7.0.2.2)
17
+ activejob (= 7.0.2.2)
18
+ activerecord (= 7.0.2.2)
19
+ activestorage (= 7.0.2.2)
20
+ activesupport (= 7.0.2.2)
21
+ mail (>= 2.7.1)
22
+ net-imap
23
+ net-pop
24
+ net-smtp
25
+ actionmailer (7.0.2.2)
26
+ actionpack (= 7.0.2.2)
27
+ actionview (= 7.0.2.2)
28
+ activejob (= 7.0.2.2)
29
+ activesupport (= 7.0.2.2)
30
+ mail (~> 2.5, >= 2.5.4)
31
+ net-imap
32
+ net-pop
33
+ net-smtp
34
+ rails-dom-testing (~> 2.0)
35
+ actionpack (7.0.2.2)
36
+ actionview (= 7.0.2.2)
37
+ activesupport (= 7.0.2.2)
38
+ rack (~> 2.0, >= 2.2.0)
39
+ rack-test (>= 0.6.3)
40
+ rails-dom-testing (~> 2.0)
41
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
42
+ actiontext (7.0.2.2)
43
+ actionpack (= 7.0.2.2)
44
+ activerecord (= 7.0.2.2)
45
+ activestorage (= 7.0.2.2)
46
+ activesupport (= 7.0.2.2)
47
+ globalid (>= 0.6.0)
48
+ nokogiri (>= 1.8.5)
49
+ actionview (7.0.2.2)
50
+ activesupport (= 7.0.2.2)
51
+ builder (~> 3.1)
52
+ erubi (~> 1.4)
53
+ rails-dom-testing (~> 2.0)
54
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
55
+ activejob (7.0.2.2)
56
+ activesupport (= 7.0.2.2)
57
+ globalid (>= 0.3.6)
58
+ activemodel (7.0.2.2)
59
+ activesupport (= 7.0.2.2)
60
+ activerecord (7.0.2.2)
61
+ activemodel (= 7.0.2.2)
62
+ activesupport (= 7.0.2.2)
63
+ activestorage (7.0.2.2)
64
+ actionpack (= 7.0.2.2)
65
+ activejob (= 7.0.2.2)
66
+ activerecord (= 7.0.2.2)
67
+ activesupport (= 7.0.2.2)
68
+ marcel (~> 1.0)
69
+ mini_mime (>= 1.1.0)
70
+ activesupport (7.0.2.2)
71
+ concurrent-ruby (~> 1.0, >= 1.0.2)
72
+ i18n (>= 1.6, < 2)
73
+ minitest (>= 5.1)
74
+ tzinfo (~> 2.0)
75
+ builder (3.2.4)
76
+ byebug (11.0.1)
77
+ coderay (1.1.2)
78
+ concurrent-ruby (1.1.9)
79
+ crass (1.0.6)
80
+ diff-lcs (1.5.0)
81
+ digest (3.1.0)
82
+ erubi (1.10.0)
83
+ globalid (1.0.0)
84
+ activesupport (>= 5.0)
85
+ i18n (1.10.0)
86
+ concurrent-ruby (~> 1.0)
87
+ io-wait (0.2.1)
88
+ loofah (2.14.0)
89
+ crass (~> 1.0.2)
90
+ nokogiri (>= 1.5.9)
91
+ mail (2.7.1)
92
+ mini_mime (>= 0.1.1)
93
+ marcel (1.0.2)
94
+ method_source (0.9.2)
95
+ mini_mime (1.1.2)
96
+ mini_portile2 (2.8.0)
97
+ minitest (5.15.0)
98
+ net-imap (0.2.3)
99
+ digest
100
+ net-protocol
101
+ strscan
102
+ net-pop (0.1.1)
103
+ digest
104
+ net-protocol
105
+ timeout
106
+ net-protocol (0.1.2)
107
+ io-wait
108
+ timeout
109
+ net-smtp (0.3.1)
110
+ digest
111
+ net-protocol
112
+ timeout
113
+ nio4r (2.5.8)
114
+ nokogiri (1.13.4)
115
+ mini_portile2 (~> 2.8.0)
116
+ racc (~> 1.4)
117
+ pry (0.12.2)
118
+ coderay (~> 1.1.0)
119
+ method_source (~> 0.9.0)
120
+ pry-byebug (3.7.0)
121
+ byebug (~> 11.0)
122
+ pry (~> 0.10)
123
+ racc (1.6.0)
124
+ rack (2.2.3)
125
+ rack-test (1.1.0)
126
+ rack (>= 1.0, < 3)
127
+ rails (7.0.2.2)
128
+ actioncable (= 7.0.2.2)
129
+ actionmailbox (= 7.0.2.2)
130
+ actionmailer (= 7.0.2.2)
131
+ actionpack (= 7.0.2.2)
132
+ actiontext (= 7.0.2.2)
133
+ actionview (= 7.0.2.2)
134
+ activejob (= 7.0.2.2)
135
+ activemodel (= 7.0.2.2)
136
+ activerecord (= 7.0.2.2)
137
+ activestorage (= 7.0.2.2)
138
+ activesupport (= 7.0.2.2)
139
+ bundler (>= 1.15.0)
140
+ railties (= 7.0.2.2)
141
+ rails-dom-testing (2.0.3)
142
+ activesupport (>= 4.2.0)
143
+ nokogiri (>= 1.6)
144
+ rails-html-sanitizer (1.4.2)
145
+ loofah (~> 2.3)
146
+ railties (7.0.2.2)
147
+ actionpack (= 7.0.2.2)
148
+ activesupport (= 7.0.2.2)
149
+ method_source
150
+ rake (>= 12.2)
151
+ thor (~> 1.0)
152
+ zeitwerk (~> 2.5)
153
+ rake (13.0.6)
154
+ rspec-core (3.11.0)
155
+ rspec-support (~> 3.11.0)
156
+ rspec-expectations (3.11.0)
157
+ diff-lcs (>= 1.2.0, < 2.0)
158
+ rspec-support (~> 3.11.0)
159
+ rspec-mocks (3.11.0)
160
+ diff-lcs (>= 1.2.0, < 2.0)
161
+ rspec-support (~> 3.11.0)
162
+ rspec-rails (5.1.0)
163
+ actionpack (>= 5.2)
164
+ activesupport (>= 5.2)
165
+ railties (>= 5.2)
166
+ rspec-core (~> 3.10)
167
+ rspec-expectations (~> 3.10)
168
+ rspec-mocks (~> 3.10)
169
+ rspec-support (~> 3.10)
170
+ rspec-support (3.11.0)
171
+ sqlite3 (1.4.2)
172
+ strscan (3.0.1)
173
+ thor (1.2.1)
174
+ timeout (0.2.0)
175
+ tzinfo (2.0.4)
176
+ concurrent-ruby (~> 1.0)
177
+ websocket-driver (0.7.5)
178
+ websocket-extensions (>= 0.1.0)
179
+ websocket-extensions (0.1.5)
180
+ zeitwerk (2.5.4)
181
+
182
+ PLATFORMS
183
+ ruby
184
+
185
+ DEPENDENCIES
186
+ pry-byebug
187
+ rails (~> 7.0)
188
+ rails_dictionary!
189
+ rspec-rails (= 5.1.0)
190
+ sqlite3
191
+
192
+ BUNDLED WITH
193
+ 2.2.32
@@ -22,7 +22,7 @@ module RailsDictionary
22
22
  belongs_to :dict_type
23
23
  after_save :delete_dicts_cache
24
24
  after_destroy :delete_dicts_cache
25
- scope :dict_type_name_eq, lambda { |name| joins(:dict_type).where("dict_types.name" => name) }
25
+ scope :dict_type_name_eq, ->(name) { joins(:dict_type).where({ "dict_types.name" => name }) }
26
26
 
27
27
  include RailsDictionary::ActsAsDictionary
28
28
  end
@@ -34,7 +34,7 @@ module RailsDictionary
34
34
  def acts_as_dict_slave(ops={})
35
35
  include RailsDictionary::ActsAsDictSlave
36
36
  class_attribute :default_dict_locale, :instance_writer => false
37
- cattr_accessor :dict_mapping_columns, :instance_writes => false
37
+ cattr_accessor :dict_mapping_columns, :instance_writer => false
38
38
  self.default_dict_locale = ops[:locale] if ops[:locale]
39
39
  self.dict_mapping_columns = dict_columns(ops)
40
40
  unless dict_mapping_columns.nil?
@@ -23,7 +23,7 @@ module RailsDictionary
23
23
  # the sort would be failed of ArgumentError: comparison of Array with Array failed
24
24
  # split this method ,make it more short and maintainance
25
25
  def method_missing(method_id,options={})
26
- if DictType.all_types.include? method_id
26
+ if ::DictType.all_types.include? method_id
27
27
  method_name=method_id.to_s.downcase
28
28
  # TODO: If cache engine is failed, then the code will failed with null cant dup
29
29
  Rails.cache.fetch("Dictionary.#{method_name}") { dict_type_name_eq(method_name).to_a }
@@ -56,7 +56,7 @@ module RailsDictionary
56
56
  end
57
57
 
58
58
  def respond_to?(name, include_private=false)
59
- DictType.all_types.include?(name) || super
59
+ ::DictType.all_types.include?(name) || super
60
60
  end
61
61
 
62
62
  private
@@ -76,7 +76,7 @@ module RailsDictionary
76
76
 
77
77
  module InstanceMethods
78
78
  def delete_dicts_cache
79
- method_name=DictType.revert(self.dict_type_id)
79
+ method_name = ::DictType.revert(self.dict_type_id)
80
80
  Rails.cache.delete("Dictionary.#{method_name}")
81
81
  return true
82
82
  end
@@ -1,3 +1,3 @@
1
1
  module RailsDictionary
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.5"
3
3
  end
@@ -1,8 +1,8 @@
1
1
  require File.join(File.dirname(__FILE__), "rails_dictionary/array_core_ext")
2
- require File.join(File.dirname(__FILE__), "rails_dictionary/models/active_record_extension")
3
- require File.join(File.dirname(__FILE__), "rails_dictionary/models/acts_as_dict_type")
4
- require File.join(File.dirname(__FILE__), "rails_dictionary/models/acts_as_dictionary")
5
- require File.join(File.dirname(__FILE__), "rails_dictionary/models/acts_as_dict_slave")
2
+ require File.join(File.dirname(__FILE__), "rails_dictionary/active_record_extension")
3
+ require File.join(File.dirname(__FILE__), "rails_dictionary/acts_as_dict_type")
4
+ require File.join(File.dirname(__FILE__), "rails_dictionary/acts_as_dictionary")
5
+ require File.join(File.dirname(__FILE__), "rails_dictionary/acts_as_dict_slave")
6
6
 
7
7
  # rake tasks not autoload in Rails4
8
8
  Dir[File.expand_path('../tasks/**/*.rake',__FILE__)].each { |ext| load ext } if defined?(Rake)
Binary file
Binary file
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  $:.push File.expand_path("../lib", __FILE__)
3
2
  require "rails_dictionary/version"
4
3
 
@@ -8,13 +7,12 @@ Gem::Specification.new do |s|
8
7
  s.platform = Gem::Platform::RUBY
9
8
  s.authors = ["Raykin Lee"]
10
9
  s.email = ["raykincoldxiao@campus.com"]
10
+ s.licenses = ['MIT']
11
11
  s.homepage = "https://github.com/raykin/rails_dictionary"
12
12
  s.summary = %q{dictionary data for web application}
13
13
  s.description = %q{Rails plugin for mapping static data of web application to Dictionary class}
14
14
 
15
- s.rubyforge_project = "rails_dictionary"
16
-
17
- s.add_runtime_dependency 'rails', '> 3.0'
15
+ s.add_runtime_dependency 'rails', '> 6.0', '< 7.1'
18
16
 
19
17
  s.files = `git ls-files`.split("\n")
20
18
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
data/spec/fake_app.rb CHANGED
@@ -1,7 +1,11 @@
1
-
2
1
  # database
3
2
  ActiveRecord::Base.configurations = {'test' => {:adapter => 'sqlite3', :database => ':memory:'}}
4
- ActiveRecord::Base.establish_connection(:test)
3
+
4
+ if ActiveRecord::VERSION::MAJOR >= 5
5
+ ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
6
+ else
7
+ ActiveRecord::Base.establish_connection(:test)
8
+ end
5
9
 
6
10
  # config
7
11
  app = Class.new(Rails::Application)
@@ -22,7 +26,7 @@ class Student < ActiveRecord::Base
22
26
  end
23
27
 
24
28
  #migrations
25
- class CreateAllTables < ActiveRecord::Migration
29
+ class CreateAllTables < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Migration[5.0] : ActiveRecord::Migration
26
30
  def self.up
27
31
  create_table(:dict_types) {|t| t.string :name}
28
32
  create_table(:dictionaries) {|t| t.string :name_en; t.string :name_zh ; t.string :name_fr ; t.integer :dict_type_id}
@@ -1,10 +1,10 @@
1
- # -*- coding: utf-8 -*-
1
+ # coding: utf-8
2
2
  require File.expand_path('spec_helper', File.dirname(__FILE__))
3
3
 
4
4
  describe RailsDictionary::ActiveRecordExtension do
5
5
  %w[acts_as_dict_type acts_as_dictionary acts_as_dict_slave].each do |method_name|
6
6
  it "contains #{method_name}" do
7
- ActiveRecord::Base.methods.include?(method_name.to_sym).should be_true
7
+ expect(ActiveRecord::Base.methods).to include(method_name.to_sym)
8
8
  end
9
9
  end
10
10
  end
@@ -86,14 +86,14 @@ describe RailsDictionary do
86
86
  end
87
87
 
88
88
  it "update city by set city_name to a value" do
89
- stu_shanghai.update_attributes city_name: "wuhan"
89
+ stu_shanghai.update city_name: "wuhan"
90
90
  stu_shanghai.reload.city_name.should == "wuhan"
91
- Dictionary.student_city.map(&:name_en).include?("wuhan").should be_true
91
+ Dictionary.student_city.map(&:name_en).include?("wuhan").should be_truthy
92
92
  end
93
93
 
94
94
  it "update city by set city_name to an exist dictionary name" do
95
95
  Dictionary.where(name_en: "beijing").count.should eq(1)
96
- stu_shanghai.update_attributes city_name: "beijing"
96
+ stu_shanghai.update city_name: "beijing"
97
97
  stu_shanghai.reload.city_name.should eq('beijing')
98
98
  Dictionary.where(name_en: "beijing").count.should eq(1)
99
99
  end
@@ -108,6 +108,14 @@ describe RailsDictionary do
108
108
  Student.acts_as_dict_slave :locale => :fr
109
109
  stu_beijing.named_city.should == "Pékin"
110
110
  end
111
+
112
+ it "create a student with new city(reproduce conflict error with Rails5.2.0)" do
113
+ s = Student.new
114
+ s.city_name = 'Sedan'
115
+ s.save
116
+ s.reload
117
+ s.city_name.should == 'Sedan'
118
+ end
111
119
  end
112
120
  end
113
121
 
data/spec/spec_helper.rb CHANGED
@@ -12,11 +12,12 @@ require File.join(File.dirname(__FILE__), 'fake_app')
12
12
 
13
13
  require 'rspec/rails'
14
14
 
15
- $stdout = StringIO.new # remove the noise output
15
+ require 'pry-byebug'
16
+
17
+ # $stdout = StringIO.new # remove the noise output. It can also disable pry debugger. Weird
16
18
 
17
19
  RSpec.configure do |config|
18
20
  config.use_transactional_fixtures = true
21
+ config.expect_with(:rspec) { |c| c.syntax = [:should, :expect] }
19
22
  CreateAllTables.up unless ActiveRecord::Base.connection.table_exists? 'dict_types'
20
23
  end
21
-
22
- require 'byebug'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_dictionary
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raykin Lee
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-06 00:00:00.000000000 Z
11
+ date: 2022-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,14 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - ">"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.0'
19
+ version: '6.0'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '7.1'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - ">"
25
28
  - !ruby/object:Gem::Version
26
- version: '3.0'
29
+ version: '6.0'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '7.1'
27
33
  description: Rails plugin for mapping static data of web application to Dictionary
28
34
  class
29
35
  email:
@@ -35,24 +41,28 @@ files:
35
41
  - ".gitignore"
36
42
  - CHANGELOG
37
43
  - Gemfile
44
+ - Gemfile.lock
38
45
  - README.rdoc
39
46
  - Rakefile
40
47
  - lib/rails_dictionary.rb
48
+ - lib/rails_dictionary/active_record_extension.rb
49
+ - lib/rails_dictionary/acts_as_dict_slave.rb
50
+ - lib/rails_dictionary/acts_as_dict_type.rb
51
+ - lib/rails_dictionary/acts_as_dictionary.rb
41
52
  - lib/rails_dictionary/array_core_ext.rb
42
- - lib/rails_dictionary/models/active_record_extension.rb
43
- - lib/rails_dictionary/models/acts_as_dict_slave.rb
44
- - lib/rails_dictionary/models/acts_as_dict_type.rb
45
- - lib/rails_dictionary/models/acts_as_dictionary.rb
46
53
  - lib/rails_dictionary/version.rb
47
54
  - lib/tasks/dicts.rake
55
+ - pkg/rails_dictionary-0.2.2.gem
56
+ - pkg/rails_dictionary-0.2.3.gem
48
57
  - rails_dictionary.gemspec
49
58
  - spec/fake_app.rb
50
59
  - spec/rails_dictionary_spec.rb
51
60
  - spec/spec_helper.rb
52
61
  homepage: https://github.com/raykin/rails_dictionary
53
- licenses: []
62
+ licenses:
63
+ - MIT
54
64
  metadata: {}
55
- post_install_message:
65
+ post_install_message:
56
66
  rdoc_options: []
57
67
  require_paths:
58
68
  - lib
@@ -67,9 +77,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
77
  - !ruby/object:Gem::Version
68
78
  version: '0'
69
79
  requirements: []
70
- rubyforge_project: rails_dictionary
71
- rubygems_version: 2.7.7
72
- signing_key:
80
+ rubygems_version: 3.2.32
81
+ signing_key:
73
82
  specification_version: 4
74
83
  summary: dictionary data for web application
75
84
  test_files: