comment_attribute 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 83b5efdfae87002c0ac2771d81fa50ffa6c861598ff08ef5a5d2e5ead3776bd8
4
+ data.tar.gz: bd3d980a8bf21f4b5ea46506c4419556d75e4da656f037695066e0f1638c5f2b
5
+ SHA512:
6
+ metadata.gz: 2bbe0f33a6ff867872f79b2610a669376ebb9980cdcfd87d2663099ae623625f220736e4d5afd775ba31c0759df4d24a95aa2cd1a9e08ac65554237204d551d3
7
+ data.tar.gz: 7f7013630a13b6ee3ecee88d158073b20ac1768c17ffc81342792a0bdba8f71ba4785fb2bb3a4ada73ffbd4bc8d82fb308835e285a41c69910f60b1e9fd330dd
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2018 nizoraul
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,63 @@
1
+ comment_attribute
2
+ ====
3
+
4
+ This plug in can access attribute by the comment of the database
5
+
6
+ ## Description
7
+
8
+ It becomes available, and access is enabled to the column of the database using comment setting after Rails5.
9
+ Access to attribute using a multi-byte language is in this way enabled.
10
+
11
+ ## Example
12
+
13
+ migration
14
+ ```ruby
15
+ class CreateUsers < ActiveRecord::Migration[5.0]
16
+ def change
17
+ create_table :users, comment: "ユーザ" do |t|
18
+ t.string :first_name, comment: '姓'
19
+ t.string :last_name, comment: '名'
20
+ end
21
+ end
22
+ end
23
+ ```
24
+ example
25
+ ```ruby
26
+ user = User.new(first_name: "野比", last_name: "のび太")
27
+
28
+ #read
29
+ puts user["姓"] #=> 野比
30
+
31
+ #write
32
+ user['名'] = "しずか"
33
+ ```
34
+
35
+ ## Requirement
36
+
37
+ Rails > 5.0 and MySQL or PosgreSQL
38
+
39
+ ## Installation
40
+ Add this line to your application's Gemfile:
41
+
42
+ ```ruby
43
+ gem 'comment_attribute'
44
+ ```
45
+
46
+ And then execute:
47
+ ```bash
48
+ $ bundle
49
+ ```
50
+
51
+ Or install it yourself as:
52
+ ```bash
53
+ $ gem install comment_attribute
54
+ ```
55
+ When it is applied to all models
56
+
57
+ app/models/application_record.rb
58
+ ```ruby
59
+ include CommentAttribute
60
+ ```
61
+ ## Licence
62
+
63
+ [MIT](https://github.com/tcnksm/tool/blob/master/LICENCE)
data/Rakefile ADDED
@@ -0,0 +1,28 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'CommentAttribute'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+
21
+
22
+ require 'bundler/gem_tasks'
23
+
24
+ require 'rspec/core/rake_task'
25
+
26
+ RSpec::Core::RakeTask.new(:spec)
27
+ task default: :spec
28
+
@@ -0,0 +1,18 @@
1
+ module CommentAttribute
2
+ extend ActiveSupport::Concern
3
+
4
+ def [](comment)
5
+ attr_name = comment_to_attr_name(comment) || comment
6
+ super(attr_name)
7
+ end
8
+
9
+ def []=(comment, value)
10
+ attr_name = comment_to_attr_name(comment) || comment
11
+ super(attr_name, value)
12
+ end
13
+
14
+ def comment_to_attr_name(comment)
15
+ self.class.columns.find{|r| r.comment == comment }&.name
16
+ end
17
+ end
18
+
@@ -0,0 +1,3 @@
1
+ module CommentAttribute
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :comment_attribute do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: comment_attribute
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - nizoraul
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-05-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 5.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 5.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: mysql2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "<"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Activerecordを拡張してDBのコメントを利用してAttributeへのアクセスを可能とするgem
56
+ email:
57
+ - nizoraul@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - MIT-LICENSE
63
+ - README.md
64
+ - Rakefile
65
+ - lib/comment_attribute/comment_attribute.rb
66
+ - lib/comment_attribute/version.rb
67
+ - lib/tasks/comment_attribute_tasks.rake
68
+ homepage: https://github.com/nizoraul/comment_attribute
69
+ licenses:
70
+ - MIT
71
+ metadata: {}
72
+ post_install_message:
73
+ rdoc_options: []
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubyforge_project:
88
+ rubygems_version: 2.7.3
89
+ signing_key:
90
+ specification_version: 4
91
+ summary: DBのコメントでActiverecordの要素にアクセス
92
+ test_files: []