record_mold 0.1.0 → 0.1.1

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: 2e33b3dc7e7534ff38f53af6f66d4a27896a8582c64614e38372cf34c86eb3e7
4
- data.tar.gz: 1068849b2453055583392fce2f28ce12da8830e3bce153a4777cd1ba9a7a3f93
3
+ metadata.gz: 65baec051c7589a39656c0a519e20ffee0abf6f4b85198d599c859d45a9a975f
4
+ data.tar.gz: 2127e0455d4ecbed1650848e0c3c174a93f89bb5f0bedd2dd59ee13cee419a34
5
5
  SHA512:
6
- metadata.gz: 6068bac170f860b37b8274c1d957b6ebe5ba5c1287a4debd36c3148739d17e6d764df5d997adf2277843ad25cd57594962b1d2ab9a8ebb2d5f219bc41971500c
7
- data.tar.gz: 38d5fb8be90935146b8a6c8dbfdb335678f5994c9e39412b469925acc7686b94fe002f45176c909bc6140f81dcb681d51d99dadcbd08928b077f297a5ada22fd
6
+ metadata.gz: a8941e58f5f4462d7ee30ae44484dcb81808636d0e1cc6bf9e549a6b31a65583e52622335e0ab7c27e150bcae9af6f9f301be0097cee476121c66b195f2fb2f8
7
+ data.tar.gz: 4975ed364a073a20e15ad5f54bcc5c5ac9882e41989996ae5a8396cfb16beabed9c5f7dff105a031c9bf57fe877af22ddcf4ae3e28926b9ab00e9d6cd986a2fc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- record_mold (0.1.0)
4
+ record_mold (0.1.1)
5
5
  activerecord
6
6
 
7
7
  GEM
data/LICENSE ADDED
@@ -0,0 +1,14 @@
1
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2
+ Version 2, December 2004
3
+
4
+ Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
5
+
6
+ Everyone is permitted to copy and distribute verbatim or modified
7
+ copies of this license document, and changing it is allowed as long
8
+ as the name is changed.
9
+
10
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12
+
13
+ 0. You just DO WHAT THE FUCK YOU WANT TO.
14
+
data/lib/record_mold.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  module RecordMold
2
2
  def self.included(model)
3
- exception_columns = model.send(:timestamp_attributes_for_create) + model.send(:timestamp_attributes_for_update)
3
+ exception_columns = model.send(:timestamp_attributes_for_create) + model.send(:timestamp_attributes_for_update) + model.defined_enums.keys
4
+ exception_columns = (exception_columns + exception_columns.map { |column| model.attribute_aliases[column] }.compact).uniq
4
5
  model.columns.each do |field|
5
6
  next if field.name == model.primary_key
6
7
  next if exception_columns.include?(field.name)
data/record_mold.gemspec CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "record_mold"
8
- spec.version = '0.1.0'
8
+ spec.version = '0.1.1'
9
9
  spec.authors = ["Kenji Gonnokami"]
10
10
  spec.email = ["amatsukikuu@gmail.com"]
11
11
  spec.description = 'Provide validations from ActiveRecord schema information.'
@@ -75,7 +75,7 @@ RSpec.describe RecordMold do
75
75
  end
76
76
 
77
77
  describe 'Instance of class included this module' do
78
- let(:user) { User.new(name: 'Bob', age: 18, left: false, my_number: '00000001') }
78
+ let(:user) { User.new(name: 'Bob', age: 18, left: false, my_number: '00000001', register_method: :email) }
79
79
 
80
80
  context 'user\'s data is valid' do
81
81
  it 'is valid' do
data/spec/fake_app.rb CHANGED
@@ -16,6 +16,9 @@ end
16
16
 
17
17
  # models
18
18
  class User < ActiveRecord::Base
19
+ enum register_method: {email: 1, twitter: 2, facebook: 3, google: 4}
20
+ alias_attribute :gender, :sex
21
+ enum gender: {male: 1, female: 2}
19
22
  end
20
23
 
21
24
  # migrations
@@ -27,6 +30,8 @@ class CreateAllTables < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Migrat
27
30
  t.integer :age, null: false
28
31
  t.integer :height
29
32
  t.boolean :left, null: false
33
+ t.integer :register_method, null: false
34
+ t.integer :sex, null: false
30
35
  t.string :my_number, null: false
31
36
  t.index :my_number, unique: true
32
37
  t.datetime "created_at", null: false
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: record_mold
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenji Gonnokami
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-11 00:00:00.000000000 Z
11
+ date: 2019-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -118,6 +118,7 @@ files:
118
118
  - ".gitignore"
119
119
  - Gemfile
120
120
  - Gemfile.lock
121
+ - LICENSE
121
122
  - README.md
122
123
  - Rakefile
123
124
  - lib/record_mold.rb