smart_attr 0.1.1
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 +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +18 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +154 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/smart_attr/base.rb +113 -0
- data/lib/smart_attr/config_hash.rb +34 -0
- data/lib/smart_attr/version.rb +3 -0
- data/lib/smart_attr.rb +6 -0
- data/smart_attr.gemspec +32 -0
- metadata +175 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3cf5b0d2587c7b36d9804217e246217bb9b2da21
|
4
|
+
data.tar.gz: 4d76c6482d0ca12b216ca4d5161b54763d0436f8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7255744ece8b2cca8c2468f03e3fb0d3e8d6a1025b0ebaf32739ac576b7d69532411e5d3432c4b9de103c9860674218606f707cf0e21ce6e645bb4cca96b7c2c
|
7
|
+
data.tar.gz: fb3b58541df5bb16772ac0f9526f39dface701dbde7c00ef993394cbbd3eedd708090d93bd40d1d04b86cc90e04bc03c29c50e0f93c6781ca4fbe674acbc7504
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
sudo: true
|
2
|
+
language: ruby
|
3
|
+
rvm:
|
4
|
+
- 2.2.2
|
5
|
+
- 2.3.0
|
6
|
+
- 2.3.1
|
7
|
+
- 2.3.2
|
8
|
+
- 2.3.3
|
9
|
+
|
10
|
+
# Because ActiveSupport-4.2 requires json-1.8.3, but json-1.8.3 is not compatible with ruby 2.4
|
11
|
+
# https://github.com/flori/json/issues/303
|
12
|
+
#- 2.4.0
|
13
|
+
|
14
|
+
before_script:
|
15
|
+
- yes | sudo apt-get -y install mongodb
|
16
|
+
- sudo mongod --dbpath=/var/lib/mongodb &
|
17
|
+
|
18
|
+
script: bundle exec rspec spec
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at kun.liu@dji.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 kunliu
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
# SmartAttr
|
2
|
+
|
3
|
+
This gem helps you make your model's attribute smart.You can get many useful methods with only a little code.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'smart_attr'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install smart_attr
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
### Basic Usage(Without database)
|
24
|
+
|
25
|
+
'Without database' means that your model does not inherit from something like ActiveRecord::Base, and does not include something like Mongoid::Document.
|
26
|
+
|
27
|
+
You can see more details in the example below:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
class Movie
|
31
|
+
|
32
|
+
include SmartAttr::Base
|
33
|
+
|
34
|
+
smart_attr :star, config: {
|
35
|
+
one: { value: 1, desc: 'one star' },
|
36
|
+
two: { value: 2, desc: 'two star' },
|
37
|
+
three: { value: 3, desc: 'three star' },
|
38
|
+
four: { value: 4, desc: 'four star' },
|
39
|
+
five: { value: 5, desc: 'five star' }
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
Movie.star_config_hash
|
44
|
+
# => { :one=>{:value=>1, :desc=>"one star"},
|
45
|
+
# :two=>{:value=>2, :desc=>"two star"},
|
46
|
+
# :three=>{:value=>3, :desc=>"three star"},
|
47
|
+
# :four=>{:value=>4, :desc=>"four star"},
|
48
|
+
# :five=>{:value=>5, :desc=>"five star"}
|
49
|
+
# }
|
50
|
+
|
51
|
+
movie = Movie.new # => #<Movie:0x007fcc041b0490>
|
52
|
+
|
53
|
+
movie.star = 1 # => 1
|
54
|
+
movie.star_name # => :one
|
55
|
+
movie.star_desc # => "one star"
|
56
|
+
movie.star_one? # => true
|
57
|
+
movie.star_two? # => false
|
58
|
+
|
59
|
+
movie.star_two! # => 2
|
60
|
+
movie.star # => 2
|
61
|
+
movie.star_two? # => true
|
62
|
+
|
63
|
+
movie.star_config # => {:value=>2, :desc=>"two star", :key=>:two}
|
64
|
+
```
|
65
|
+
|
66
|
+
In this situation, an instance_variable is created to store the value when you set value for the attribute.
|
67
|
+
|
68
|
+
For example:
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
movie = Movie.new # => #<Movie:0x007fcc041b0490>
|
72
|
+
movie.star = 3 # =>3
|
73
|
+
|
74
|
+
# By run 'movie.inspect', you can see that there is an instance_variable named '@star'.
|
75
|
+
movie.inspect # => "#<Movie:0x007fcc041b0490 @star=3>"
|
76
|
+
```
|
77
|
+
|
78
|
+
### Used With ActiveRecord
|
79
|
+
|
80
|
+
It is almost the same like the basic usage when used with ActiveRecord.
|
81
|
+
|
82
|
+
The only difference is that it will not create an instance_variable to store the value when you set value for the attribute.
|
83
|
+
This is because it will store the value in the database.
|
84
|
+
|
85
|
+
For example, suppose you have a class named "Movie" with database table 'movies', then you should ensure that 'movies' have column 'star' before you use 'smart_attr :star, config: { # something }'
|
86
|
+
|
87
|
+
```ruby
|
88
|
+
class Movie
|
89
|
+
|
90
|
+
include SmartAttr::Base
|
91
|
+
|
92
|
+
smart_attr :star, config: {
|
93
|
+
one: { value: 1, desc: 'one star' },
|
94
|
+
two: { value: 2, desc: 'two star' },
|
95
|
+
three: { value: 3, desc: 'three star' },
|
96
|
+
four: { value: 4, desc: 'four star' },
|
97
|
+
five: { value: 5, desc: 'five star' }
|
98
|
+
}
|
99
|
+
end
|
100
|
+
|
101
|
+
Movie.star_config_hash
|
102
|
+
# => { :one=>{:value=>1, :desc=>"one star"},
|
103
|
+
# :two=>{:value=>2, :desc=>"two star"},
|
104
|
+
# :three=>{:value=>3, :desc=>"three star"},
|
105
|
+
# :four=>{:value=>4, :desc=>"four star"},
|
106
|
+
# :five=>{:value=>5, :desc=>"five star"}
|
107
|
+
# }
|
108
|
+
|
109
|
+
movie = Movie.new # => #<Movie:0x007fcc041b0490>
|
110
|
+
|
111
|
+
movie.star = 1 # => 1
|
112
|
+
movie.star_name # => :one
|
113
|
+
movie.star_desc # => "one star"
|
114
|
+
movie.star_one? # => true
|
115
|
+
movie.star_two? # => false
|
116
|
+
|
117
|
+
movie.star_two! # => 2
|
118
|
+
movie.star # => 2
|
119
|
+
movie.star_two? # => true
|
120
|
+
|
121
|
+
movie.star_config # => {:value=>2, :desc=>"two star", :key=>:two}
|
122
|
+
```
|
123
|
+
|
124
|
+
### Used With Mongoid
|
125
|
+
|
126
|
+
Same like used with ActiveRecord.
|
127
|
+
|
128
|
+
|
129
|
+
## Supported Ruby Version
|
130
|
+
From 2.0.0 To 2.3.3
|
131
|
+
|
132
|
+
NOTE: 2.4.0 is not supported yet!
|
133
|
+
|
134
|
+
## Status
|
135
|
+
[](https://travis-ci.org/liukgg/smart_attr)
|
136
|
+
|
137
|
+
## TODO
|
138
|
+
- Introduce SimpleCov
|
139
|
+
|
140
|
+
## Development
|
141
|
+
|
142
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
143
|
+
|
144
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
145
|
+
|
146
|
+
## Contributing
|
147
|
+
|
148
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/liukgg/smart_attr. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
149
|
+
|
150
|
+
|
151
|
+
## License
|
152
|
+
|
153
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
154
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "smart_attr"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'active_support/all'
|
2
|
+
require 'smart_attr/config_hash'
|
3
|
+
|
4
|
+
module SmartAttr
|
5
|
+
module Base
|
6
|
+
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
|
11
|
+
def smart_attr *args
|
12
|
+
column_name, options = args[0], args.extract_options!
|
13
|
+
|
14
|
+
config = ConfigHash.new(options[:config])
|
15
|
+
|
16
|
+
# result:
|
17
|
+
# {
|
18
|
+
# one: { value: 1, desc: 'one star' },
|
19
|
+
# two: { value: 2, desc: 'two star' },
|
20
|
+
# three: { value: 3, desc: 'three star' },
|
21
|
+
# four: { value: 4, desc: 'four star' },
|
22
|
+
# five: { value: 5, desc: 'five star' }
|
23
|
+
# }
|
24
|
+
define_singleton_method "#{column_name}_config".to_sym do |*_args|
|
25
|
+
config
|
26
|
+
end
|
27
|
+
|
28
|
+
define_singleton_method "#{column_name}_config_hash".to_sym do |*_args|
|
29
|
+
config.instance_variable_get :@config_hash
|
30
|
+
end
|
31
|
+
|
32
|
+
# result:
|
33
|
+
# [
|
34
|
+
# ['one star', 1],
|
35
|
+
# ['two star', 2],
|
36
|
+
# ['three star', 3],
|
37
|
+
# ['four star', 4],
|
38
|
+
# ['five star', 5]
|
39
|
+
# ]
|
40
|
+
define_singleton_method "#{column_name}_array".to_sym do |*_args|
|
41
|
+
_selector = self.send("#{column_name}_config").dup
|
42
|
+
|
43
|
+
_selector.inject([]) do |_result, _pair|
|
44
|
+
_key, _config = _pair
|
45
|
+
|
46
|
+
_result << [_config[:value], _config[:desc]]
|
47
|
+
_result
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# result:
|
52
|
+
#
|
53
|
+
# { value: 1, desc: 'one star' }
|
54
|
+
#
|
55
|
+
define_method "#{column_name}_config".to_sym do
|
56
|
+
return {} unless self.class.respond_to?("#{column_name}_config".to_sym)
|
57
|
+
|
58
|
+
result = self.class.send("#{column_name}_config").item(self.send(column_name.to_s))
|
59
|
+
result || {}
|
60
|
+
end
|
61
|
+
|
62
|
+
define_method "#{column_name}_desc".to_sym do
|
63
|
+
self.send("#{column_name}_config")[:desc]
|
64
|
+
end
|
65
|
+
|
66
|
+
define_method "#{column_name}_name".to_sym do
|
67
|
+
self.send("#{column_name}_config")[:key]
|
68
|
+
end
|
69
|
+
|
70
|
+
all_instance_methods = self.private_instance_methods + self.instance_methods
|
71
|
+
if all_instance_methods.include?(:write_attribute) && all_instance_methods.include?(:read_attribute)
|
72
|
+
define_method "#{column_name}_name=".to_sym do |name|
|
73
|
+
write_attribute(column_name, self.class.send("#{column_name}_config")[name].try(:[], :value))
|
74
|
+
end
|
75
|
+
|
76
|
+
config.keys.each do |_key|
|
77
|
+
|
78
|
+
define_method "#{column_name}_#{_key}!".to_sym do
|
79
|
+
write_attribute(column_name, self.class.send("#{column_name}_config")[_key.to_sym].try(:[], :value))
|
80
|
+
end
|
81
|
+
|
82
|
+
define_method "#{column_name}_#{_key}?".to_sym do
|
83
|
+
read_attribute(column_name) == self.class.send("#{column_name}_config")[_key.to_sym][:value]
|
84
|
+
end
|
85
|
+
end
|
86
|
+
else
|
87
|
+
attr_accessor column_name
|
88
|
+
|
89
|
+
define_method "#{column_name}_name=".to_sym do |name|
|
90
|
+
send("#{column_name}=", self.class.send("#{column_name}_config")[name].try(:[], :value))
|
91
|
+
end
|
92
|
+
|
93
|
+
config.keys.each do |_key|
|
94
|
+
|
95
|
+
define_method "#{column_name}_#{_key}!".to_sym do
|
96
|
+
send("#{column_name}=", self.class.send("#{column_name}_config")[_key.to_sym][:value])
|
97
|
+
end
|
98
|
+
|
99
|
+
define_method "#{column_name}_#{_key}?".to_sym do
|
100
|
+
send(column_name) == self.class.send("#{column_name}_config")[_key.to_sym][:value]
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
# TODO
|
111
|
+
# Object.send :include, SmartAttr::Base
|
112
|
+
# ActiveRecord::Base.send :include, SmartAttr::Base if Module.constants.include? :ActiveRecord
|
113
|
+
# Mongoid::Document.send :include, SmartAttr::Base if Module.constants.include? :Mongoid
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module SmartAttr
|
2
|
+
class ConfigHash
|
3
|
+
|
4
|
+
attr_reader :config_values_map
|
5
|
+
|
6
|
+
def initialize(*args)
|
7
|
+
@config_hash = args.extract_options!
|
8
|
+
|
9
|
+
@config_values_map = {}
|
10
|
+
|
11
|
+
@config_hash.each do |_key, _config|
|
12
|
+
@config_values_map[_config[:value]] = _config.merge(key: _key)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def item(value)
|
17
|
+
@config_values_map[value]
|
18
|
+
end
|
19
|
+
|
20
|
+
def keys
|
21
|
+
@config_hash.keys
|
22
|
+
end
|
23
|
+
|
24
|
+
def [](key)
|
25
|
+
@config_hash[key]
|
26
|
+
end
|
27
|
+
|
28
|
+
# TODO
|
29
|
+
# Add spec
|
30
|
+
# def method_missing
|
31
|
+
# # delegate to Hash
|
32
|
+
# end
|
33
|
+
end
|
34
|
+
end
|
data/lib/smart_attr.rb
ADDED
data/smart_attr.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'smart_attr/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "smart_attr"
|
8
|
+
spec.version = SmartAttr::VERSION
|
9
|
+
spec.authors = ["kunliu"]
|
10
|
+
spec.email = ["kun.liu@dji.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{SmartAttr helps you make your model's attribute smart.}
|
13
|
+
spec.description = %q{This gem helps you make your model's attribute smart.You can get many useful methods with only a little code.
|
14
|
+
}
|
15
|
+
spec.homepage = "https://github.com/liukgg/smart_attr"
|
16
|
+
spec.license = "MIT"
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
26
|
+
spec.add_development_dependency "pry", "~> 0.10"
|
27
|
+
spec.add_development_dependency "activerecord", "~> 4.2"
|
28
|
+
spec.add_development_dependency "sqlite3", "~> 1.3"
|
29
|
+
spec.add_development_dependency "mongoid", "~> 5.1"
|
30
|
+
|
31
|
+
spec.add_dependency "activesupport", "~> 4.2"
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,175 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: smart_attr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- kunliu
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-12-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.10'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.10'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: activerecord
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '4.2'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '4.2'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: sqlite3
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.3'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.3'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: mongoid
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '5.1'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '5.1'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: activesupport
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '4.2'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '4.2'
|
125
|
+
description: 'This gem helps you make your model''s attribute smart.You can get many
|
126
|
+
useful methods with only a little code.
|
127
|
+
|
128
|
+
'
|
129
|
+
email:
|
130
|
+
- kun.liu@dji.com
|
131
|
+
executables: []
|
132
|
+
extensions: []
|
133
|
+
extra_rdoc_files: []
|
134
|
+
files:
|
135
|
+
- ".gitignore"
|
136
|
+
- ".rspec"
|
137
|
+
- ".travis.yml"
|
138
|
+
- CODE_OF_CONDUCT.md
|
139
|
+
- Gemfile
|
140
|
+
- LICENSE.txt
|
141
|
+
- README.md
|
142
|
+
- Rakefile
|
143
|
+
- bin/console
|
144
|
+
- bin/setup
|
145
|
+
- lib/smart_attr.rb
|
146
|
+
- lib/smart_attr/base.rb
|
147
|
+
- lib/smart_attr/config_hash.rb
|
148
|
+
- lib/smart_attr/version.rb
|
149
|
+
- smart_attr.gemspec
|
150
|
+
homepage: https://github.com/liukgg/smart_attr
|
151
|
+
licenses:
|
152
|
+
- MIT
|
153
|
+
metadata: {}
|
154
|
+
post_install_message:
|
155
|
+
rdoc_options: []
|
156
|
+
require_paths:
|
157
|
+
- lib
|
158
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
159
|
+
requirements:
|
160
|
+
- - ">="
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: '0'
|
163
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
requirements: []
|
169
|
+
rubyforge_project:
|
170
|
+
rubygems_version: 2.6.6
|
171
|
+
signing_key:
|
172
|
+
specification_version: 4
|
173
|
+
summary: SmartAttr helps you make your model's attribute smart.
|
174
|
+
test_files: []
|
175
|
+
has_rdoc:
|