rails_dictionary 0.2.1 → 0.2.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 29704f4fcfc7b1a4a58b808a271d6121d790ed0c
4
- data.tar.gz: 9f58740b71f9b150134c87b44e3d112c62b83c5d
2
+ SHA256:
3
+ metadata.gz: dcf4185af21ff1e6ebe6ed0e6073f2ac8fb8a9caa884c988ef1910a53a30cdbe
4
+ data.tar.gz: 23bb42965b174ca7320f789e681ec33007cbd4e2091d6db4275cbf6a8b6fdff8
5
5
  SHA512:
6
- metadata.gz: 2c1fd60db8d10a661fe7ab9f0925e51c874685816af149a57e9a914778ee88ea55c6f9137cf0929d924c6921cdb932398116f70752f1a22ee385641e6722af45
7
- data.tar.gz: 4cf139cf52ad990394c9686365e639a1f81803f6503460cf3fac17f716a9ad903c7243ab1facd0a5b6fbe159f3190cffa636bb6c8b29144fc22a0876789cf207
6
+ metadata.gz: ce8dbd37b0f3b2316bba612c9a9a5decc627a1038e08c2d03237713c277135c2c5221a56b3e0e0f286310a4891521d7f3667c6f2b1450f8e36b9061b349ad226
7
+ data.tar.gz: a283f4abc71b97719b3d5bb5549f2956e6d1f6dad774d220501d1e60162edb46881c0dbd254bcf8e549114f4fd5f13229ee0ef106a770ef7f57cc097221f05d2
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.3)
5
+ rails (> 4.0)
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.3)
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
data/README.rdoc CHANGED
@@ -1,5 +1,5 @@
1
1
  = Plan
2
- I plan wrote a new gem to replace it. The new gem will use rails STI. so we dont need maintenance dict_types table. It should be a better solution.
2
+ Working on sti branch will target to 0.3 version which will not compatible with 0.1 and 0.2
3
3
 
4
4
  = Intro
5
5
  There are always some static data(not static page) in application.For example product type or student diploma type.
@@ -8,6 +8,8 @@ This gem can map these static data to a Dictionary#method like Dictionary#studen
8
8
 
9
9
  = Usage
10
10
  == Installation
11
+ Branch sti is used to target version 0.3 which will totall rewrite. The main change is use STI to replace dict_types.
12
+
11
13
  Version 0.2 support Rails4
12
14
 
13
15
  Version 0.1 support Rails3.1
@@ -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?
@@ -18,7 +18,7 @@ module RailsDictionary
18
18
  def revert(arg)
19
19
  if arg.is_a?(String)
20
20
  DictType.where(name: arg).first.try(:id)
21
- elsif arg.is_a?(Fixnum)
21
+ elsif arg.is_a?(Integer)
22
22
  DictType.where(id: arg).first.try(:name)
23
23
  end
24
24
  end
@@ -1,3 +1,3 @@
1
1
  module RailsDictionary
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.4"
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.1
4
+ version: 0.2.4
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: 2015-03-11 00:00:00.000000000 Z
11
+ date: 2022-03-08 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,10 +77,11 @@ 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.2.2
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
- test_files: []
76
- has_rdoc:
84
+ test_files:
85
+ - spec/fake_app.rb
86
+ - spec/rails_dictionary_spec.rb
87
+ - spec/spec_helper.rb