matterful_attributes 0.0.3 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +31 -31
- data/Gemfile +4 -4
- data/LICENSE.txt +22 -22
- data/README.md +137 -27
- data/Rakefile +1 -1
- data/lib/matterful_attributes.rb +92 -74
- data/lib/matterful_attributes/version.rb +3 -3
- data/matterful_attributes.gemspec +23 -23
- metadata +16 -10
- checksums.yaml +0 -7
data/.gitignore
CHANGED
@@ -1,32 +1,32 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
.bundle
|
4
|
-
.config
|
5
|
-
.yardoc
|
6
|
-
Gemfile.lock
|
7
|
-
InstalledFiles
|
8
|
-
_yardoc
|
9
|
-
coverage
|
10
|
-
doc/
|
11
|
-
lib/bundler/man
|
12
|
-
pkg
|
13
|
-
rdoc
|
14
|
-
spec/reports
|
15
|
-
test/tmp
|
16
|
-
test/version_tmp
|
17
|
-
tmp
|
18
|
-
*.sassc
|
19
|
-
.sass-cache
|
20
|
-
capybara-*.html
|
21
|
-
.rspec
|
22
|
-
/.bundle
|
23
|
-
/vendor/bundle
|
24
|
-
/log/*
|
25
|
-
/tmp/*
|
26
|
-
/db/*.sqlite3
|
27
|
-
/public/system/*
|
28
|
-
/coverage/
|
29
|
-
/spec/tmp/*
|
30
|
-
**.orig
|
31
|
-
rerun.txt
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.sassc
|
19
|
+
.sass-cache
|
20
|
+
capybara-*.html
|
21
|
+
.rspec
|
22
|
+
/.bundle
|
23
|
+
/vendor/bundle
|
24
|
+
/log/*
|
25
|
+
/tmp/*
|
26
|
+
/db/*.sqlite3
|
27
|
+
/public/system/*
|
28
|
+
/coverage/
|
29
|
+
/spec/tmp/*
|
30
|
+
**.orig
|
31
|
+
rerun.txt
|
32
32
|
pickle-email-*.html
|
data/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in matterful_attributes.gemspec
|
4
|
-
gemspec
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in matterful_attributes.gemspec
|
4
|
+
gemspec
|
data/LICENSE.txt
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
Copyright (c) 2013 Nick Gorbikoff
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1
|
+
Copyright (c) 2013 Nick Gorbikoff
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,27 +1,137 @@
|
|
1
|
-
matterful_attributes
|
2
|
-
====================
|
3
|
-
|
4
|
-
Ruby / Rails gem that shims ActiveRecord::Base to provide some helpful methods for parsing out attributes that matter to humans, i.e.
|
5
|
-
``` Address.first.matterful_attributes ```
|
6
|
-
will return a hash of attributes minus
|
7
|
-
<b> id, type, polymorphic_id, polymorphic_type, cretated_at, updated_at</b> and can also skip all foreign_keys, like <b>category_id or status_id </b>.
|
8
|
-
|
9
|
-
This is really useful when you need to be able to import, compare and update information on a record from an external source like a CSV file or a legacy DB. In that context only attributes specific to the model matter. In the world outside of rails, such as some old legacy DB these Rails specific attributes don't mean much. And I got tired of writing things like
|
10
|
-
```ruby
|
11
|
-
Address.first.attributes.except('id','created_at','updated_at').diff(OldStyleAddress.first.attributes)
|
12
|
-
```
|
13
|
-
It's much cleaner to right it this way:
|
14
|
-
```ruby
|
15
|
-
Address.first.matterful_diff(OldStyleAddress.first)
|
16
|
-
```
|
17
|
-
don't you think?
|
18
|
-
|
19
|
-
|
20
|
-
Production
|
21
|
-
==========
|
22
|
-
This was extracted from production code that's tested. However use at your own risk. NO warranties or guarantees provided!
|
23
|
-
|
24
|
-
|
25
|
-
Tests
|
26
|
-
=====
|
27
|
-
This gem needs tests! It's tested in the context of my production code, but no gem specific tests. I'll add them later if time allows. Really bad practice, I know, but I'm really short on time.
|
1
|
+
matterful_attributes
|
2
|
+
====================
|
3
|
+
|
4
|
+
Ruby / Rails gem that shims ActiveRecord::Base to provide some helpful methods for parsing out attributes that matter to humans, i.e.
|
5
|
+
``` Address.first.matterful_attributes ```
|
6
|
+
will return a hash of attributes minus
|
7
|
+
<b> id, type, polymorphic_id, polymorphic_type, cretated_at, updated_at</b> and can also skip all foreign_keys, like <b>category_id or status_id </b>.
|
8
|
+
|
9
|
+
This is really useful when you need to be able to import, compare and update information on a record from an external source like a CSV file or a legacy DB. In that context only attributes specific to the model matter. In the world outside of rails, such as some old legacy DB these Rails specific attributes don't mean much. And I got tired of writing things like
|
10
|
+
```ruby
|
11
|
+
Address.first.attributes.except('id','created_at','updated_at').diff(OldStyleAddress.first.attributes)
|
12
|
+
```
|
13
|
+
It's much cleaner to right it this way:
|
14
|
+
```ruby
|
15
|
+
Address.first.matterful_diff(OldStyleAddress.first)
|
16
|
+
```
|
17
|
+
don't you think?
|
18
|
+
|
19
|
+
|
20
|
+
Production
|
21
|
+
==========
|
22
|
+
This was extracted from production code that's tested. However use at your own risk. NO warranties or guarantees provided!
|
23
|
+
|
24
|
+
|
25
|
+
Tests
|
26
|
+
=====
|
27
|
+
This gem needs tests! It's tested in the context of my production code, but no gem specific tests. I'll add them later if time allows. Really bad practice, I know, but I'm really short on time.
|
28
|
+
I suggest you check out this answer on stackoverflow: http://stackoverflow.com/a/13156750/198424
|
29
|
+
|
30
|
+
Usage
|
31
|
+
=====
|
32
|
+
Using Gemfile:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
gem 'matterful_attributes', require: 'matterful_attributes'
|
36
|
+
```
|
37
|
+
|
38
|
+
Available methods
|
39
|
+
```ruby
|
40
|
+
# List attributes that matter to humans
|
41
|
+
matterful_attributes( source,
|
42
|
+
optons={ default:true,
|
43
|
+
sti: true,
|
44
|
+
polymorphic: true,
|
45
|
+
foreign_key: true,
|
46
|
+
extra: ['Array', 'of extra', 'attributes', 'to ignore as strings']
|
47
|
+
})
|
48
|
+
|
49
|
+
# Do comparison of two similar Records for attributes that matter. Returns a
|
50
|
+
# hash of attributes that will be updated with the information that will update it
|
51
|
+
matterful_diff(source ,
|
52
|
+
optons={ default:true,
|
53
|
+
sti: true,
|
54
|
+
polymorphic: true,
|
55
|
+
foreign_key: true,
|
56
|
+
extra: ['Array', 'of extra', 'attributes', 'to ignore as strings']
|
57
|
+
})
|
58
|
+
|
59
|
+
# Diff and update target from source. Returns self. with updated attributes, but doesn't save!!!
|
60
|
+
matterful_update(source, options={ default:true,
|
61
|
+
sti: true,
|
62
|
+
polymorphic: true,
|
63
|
+
foreign_key: true,
|
64
|
+
extra: ['Array', 'of extra', 'attributes', 'to ignore as strings']
|
65
|
+
})
|
66
|
+
|
67
|
+
# Same as matterful_update but also saves self. right away if valid. Returns true / false.
|
68
|
+
matterful_update!(source, options={ default:true,
|
69
|
+
sti: true,
|
70
|
+
polymorphic: true,
|
71
|
+
foreign_key: true,
|
72
|
+
extra: ['Array', 'of extra', 'attributes', 'to ignore as strings']
|
73
|
+
})
|
74
|
+
|
75
|
+
# I decided not to overload standard comparison operators to avoid confusion. hence this. Returns true or false
|
76
|
+
same_as?(source, options={ default:true,
|
77
|
+
sti: true,
|
78
|
+
polymorphic: true,
|
79
|
+
foreign_key: true,
|
80
|
+
extra: ['Array', 'of extra', 'attributes', 'to ignore as strings']
|
81
|
+
})
|
82
|
+
```
|
83
|
+
|
84
|
+
!!! Attention
|
85
|
+
Foreign_keys such as category_id are by default not ignored pass foreign_key: false to ignore them. See example below.
|
86
|
+
|
87
|
+
|
88
|
+
Now all your models have matterful INSTANCE methods. These methods only make sence to use in an instance of Address.first, no in Address as class by itself doesn't hod any information that matters to humans: sucha s when you import CSV data you are going to update a very specific record, not some abstract Address.
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
# Assuming you have an Address model like so
|
92
|
+
class Address < ActiveRecord::Base {
|
93
|
+
:id => :integer,
|
94
|
+
:address_line_1 => :string,
|
95
|
+
:address_line_2 => :string,
|
96
|
+
:address_line_3 => :string,
|
97
|
+
:city => :string,
|
98
|
+
:state => :string,
|
99
|
+
:zip => :string,
|
100
|
+
:country => :string,
|
101
|
+
:attn => :string,
|
102
|
+
:category_id => :integer,
|
103
|
+
:addressable_id => :integer,
|
104
|
+
:addressable_type => :string,
|
105
|
+
:created_at => :datetime,
|
106
|
+
:updated_at => :datetime
|
107
|
+
}
|
108
|
+
```
|
109
|
+
|
110
|
+
```ruby
|
111
|
+
# List matterful attributes, without foreign_keys like category_id
|
112
|
+
Address.first.matterful_attributes(foreign_keys: false)
|
113
|
+
|
114
|
+
# Returns hash like so
|
115
|
+
# {"address_line_1"=>"300 Sample Drive",
|
116
|
+
# "address_line_2"=>nil,
|
117
|
+
# "address_line_3"=>nil,
|
118
|
+
# "city"=>"Buffalo Grove",
|
119
|
+
# "state"=>"IL",
|
120
|
+
# "zip"=>"60089",
|
121
|
+
# "country"=>"USA",
|
122
|
+
# "attn"=>nil}
|
123
|
+
|
124
|
+
# List matterful attributes, without foreign_keys like category_id
|
125
|
+
Address.first.matterful_diff(Address.last)
|
126
|
+
|
127
|
+
# Returns hash like so
|
128
|
+
# {"address_line_1"=>"300 Sample Drive",
|
129
|
+
# "address_line_2"=>nil,
|
130
|
+
# "address_line_3"=>nil,
|
131
|
+
# "city"=>"Buffalo Grove",
|
132
|
+
# "state"=>"IL",
|
133
|
+
# "zip"=>"60089",
|
134
|
+
# "country"=>"USA",
|
135
|
+
# "attn"=>nil}
|
136
|
+
|
137
|
+
```
|
data/Rakefile
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/matterful_attributes.rb
CHANGED
@@ -1,74 +1,92 @@
|
|
1
|
-
require "matterful_attributes/version"
|
2
|
-
|
3
|
-
module MatterfulAttributes
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
# These only make sense as instance methods
|
6
|
-
def matterful_attributes(options={})
|
7
|
-
options = options.dup
|
8
|
-
default = options[:default].nil? ? true : options[:default]
|
9
|
-
foreign_key = options[:foreign_key].nil? ? true : options[:foreign_key]
|
10
|
-
sti = options[:sti].nil? ? true : options[:sti]
|
11
|
-
polymorphic = options[:polymorphic].nil? ? true : options[:polymorphic]
|
12
|
-
#
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
#
|
18
|
-
|
19
|
-
|
20
|
-
#
|
21
|
-
#
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
#
|
26
|
-
#
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
1
|
+
require "matterful_attributes/version"
|
2
|
+
|
3
|
+
module MatterfulAttributes
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
# These only make sense as instance methods
|
6
|
+
def matterful_attributes(options={})
|
7
|
+
options = options.dup
|
8
|
+
default = options[:default].nil? ? true : options[:default]
|
9
|
+
foreign_key = options[:foreign_key].nil? ? true : options[:foreign_key]
|
10
|
+
sti = options[:sti].nil? ? true : options[:sti]
|
11
|
+
polymorphic = options[:polymorphic].nil? ? true : options[:polymorphic]
|
12
|
+
# Set compare_blank_values to false only if you, DO NOT want to update existing information with nil information from the new object
|
13
|
+
# For example, sometimes your table has historical data, while source, may only have current. You may want to keep historical data
|
14
|
+
# for reference, or if some process relies on it. It's generally not a good idea to delete good data, unless you have to.
|
15
|
+
compare_blank_values = options[:compare_blank_values].nil? ? true : options[:compare_blank_values]
|
16
|
+
|
17
|
+
# extra keys supplied as array of strings to ignore in comparison
|
18
|
+
attributes_to_ignore = options[:extra].nil? ? [] : options[:extra]
|
19
|
+
|
20
|
+
# Let's check for and add typical attributes that sti & polymorphic models have, override
|
21
|
+
# this by sti: false, polymorphic: false, foreign_key: false
|
22
|
+
# by default when looking to compare two objects
|
23
|
+
# Customer.find(1).shipping_address.same_as? Address.new(city: 'Chicago')
|
24
|
+
# we really only want to see if any of the 'matterfule information changed', like address_line_1 or city.
|
25
|
+
# TODO: I guess I could do some smart checking on the model to see what kind of attributes it has.
|
26
|
+
# For now we'll just check for all that we want to remove
|
27
|
+
if default
|
28
|
+
attributes_to_ignore += ['id', 'created_at', 'updated_at']
|
29
|
+
end
|
30
|
+
# By default we want foreign keys like caegory_id as they provide useful information about current record.
|
31
|
+
# Let's say you import a bunch of addresses
|
32
|
+
# and they ony matterful change was from shipping to billing category.
|
33
|
+
unless foreign_key
|
34
|
+
# This will skip polymorphic style foreign keys and only deal with belongs_to style keys
|
35
|
+
attributes_to_ignore += attributes.keys.keep_if{|k| k.match(/_id\z/) && !k.match(/able_id\z/) }
|
36
|
+
end
|
37
|
+
if sti
|
38
|
+
attributes_to_ignore += ['type']
|
39
|
+
end
|
40
|
+
# If you are looking at a model that is polymorphic than most like you want to update something
|
41
|
+
# like city for an Address , not addressable_id or addresable_type
|
42
|
+
# That is more likely type of information to be updated on external import.
|
43
|
+
if polymorphic
|
44
|
+
attributes_to_ignore += attributes.keys.keep_if{|k| k.match(/able_id\z/) }
|
45
|
+
attributes_to_ignore += attributes.keys.keep_if{|k| k.match(/able_type\z/) }
|
46
|
+
end
|
47
|
+
|
48
|
+
# This will only be invoked on blank values
|
49
|
+
# Since this gem is used only in the context of ActiveRecord, safe to use blank?, from ActionPack
|
50
|
+
# KEEP IN MIND THIS THI WILL NOT CHECK for blanks in sti, foreign, and default attributes
|
51
|
+
# it will only check for blank values in keys not in attributes_to_ignore already!!!!
|
52
|
+
unless compare_blank_values
|
53
|
+
attributes.except(*attributes_to_ignore).keys.each do |key|
|
54
|
+
if self.send(key).blank?
|
55
|
+
attributes_to_ignore += [key]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
attributes.except(*attributes_to_ignore)
|
60
|
+
end
|
61
|
+
|
62
|
+
def same_as?(source,options={})
|
63
|
+
matterful_attributes(options) == source.matterful_attributes(options)
|
64
|
+
end
|
65
|
+
|
66
|
+
def matterful_diff(source,options={})
|
67
|
+
matterful_attributes(options).diff(source.matterful_attributes(options))
|
68
|
+
end
|
69
|
+
|
70
|
+
# Update self if source object has new data but DO NOT save. Let's say you want to do
|
71
|
+
# futer processing on the new data. Validation, upcasing, concatination
|
72
|
+
def matterful_update(source,options={})
|
73
|
+
options = options.dup
|
74
|
+
# Pay attention to this! Reversing comparison to get expected results
|
75
|
+
if !(target_attributes = source.matterful_diff(self, options)).empty?
|
76
|
+
target_attributes.each_pair do |k,v|
|
77
|
+
self[k] = v
|
78
|
+
end
|
79
|
+
end
|
80
|
+
self
|
81
|
+
end
|
82
|
+
|
83
|
+
def matterful_update!(source,options={})
|
84
|
+
# This will update self and save self if valid. Will return true or false.
|
85
|
+
self.matterful_update(source,options)
|
86
|
+
save
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# include the extension
|
91
|
+
ActiveRecord::Base.send(:include, MatterfulAttributes)
|
92
|
+
|
@@ -1,3 +1,3 @@
|
|
1
|
-
module MatterfulAttributes
|
2
|
-
VERSION = "0.0.
|
3
|
-
end
|
1
|
+
module MatterfulAttributes
|
2
|
+
VERSION = "0.0.6"
|
3
|
+
end
|
@@ -1,23 +1,23 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'matterful_attributes/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "matterful_attributes"
|
8
|
-
spec.version = MatterfulAttributes::VERSION
|
9
|
-
spec.authors = ["Nick Gorbikoff"]
|
10
|
-
spec.email = ["nick.gorbikoff@gmail.com"]
|
11
|
-
spec.description = %q{Ruby / Rails gem that shims ActiveRecord::Base to provide some helpful methods for parsing out attributes that matter to humans, i.e. Address.first.matterful_attributes will return a hash of attributes minus id, type, polymorphic_id, polymorphic_type, cretated_at, updated_at and can also skip all foreign_keys, like category_id or status_id. }
|
12
|
-
spec.summary = %q{See Readme.md}
|
13
|
-
spec.homepage = "https://github.com/konung/matterful_attributes"
|
14
|
-
spec.license = "MIT"
|
15
|
-
|
16
|
-
spec.files = `git ls-files`.split($/)
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = ["lib"]
|
20
|
-
|
21
|
-
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
-
spec.add_development_dependency "rake"
|
23
|
-
end
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'matterful_attributes/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "matterful_attributes"
|
8
|
+
spec.version = MatterfulAttributes::VERSION
|
9
|
+
spec.authors = ["Nick Gorbikoff"]
|
10
|
+
spec.email = ["nick.gorbikoff@gmail.com"]
|
11
|
+
spec.description = %q{Ruby / Rails gem that shims ActiveRecord::Base to provide some helpful methods for parsing out attributes that matter to humans, i.e. Address.first.matterful_attributes will return a hash of attributes minus id, type, polymorphic_id, polymorphic_type, cretated_at, updated_at and can also skip all foreign_keys, like category_id or status_id. }
|
12
|
+
spec.summary = %q{See Readme.md}
|
13
|
+
spec.homepage = "https://github.com/konung/matterful_attributes"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
metadata
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: matterful_attributes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Nick Gorbikoff
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2013-
|
12
|
+
date: 2013-11-15 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: bundler
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
19
|
- - ~>
|
18
20
|
- !ruby/object:Gem::Version
|
@@ -20,6 +22,7 @@ dependencies:
|
|
20
22
|
type: :development
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
27
|
- - ~>
|
25
28
|
- !ruby/object:Gem::Version
|
@@ -27,18 +30,20 @@ dependencies:
|
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: rake
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
|
-
- - '>='
|
35
|
+
- - ! '>='
|
32
36
|
- !ruby/object:Gem::Version
|
33
37
|
version: '0'
|
34
38
|
type: :development
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
|
-
- - '>='
|
43
|
+
- - ! '>='
|
39
44
|
- !ruby/object:Gem::Version
|
40
45
|
version: '0'
|
41
|
-
description: 'Ruby / Rails gem that shims ActiveRecord::Base to provide some helpful
|
46
|
+
description: ! 'Ruby / Rails gem that shims ActiveRecord::Base to provide some helpful
|
42
47
|
methods for parsing out attributes that matter to humans, i.e. Address.first.matterful_attributes
|
43
48
|
will return a hash of attributes minus id, type, polymorphic_id, polymorphic_type,
|
44
49
|
cretated_at, updated_at and can also skip all foreign_keys, like category_id or
|
@@ -60,26 +65,27 @@ files:
|
|
60
65
|
homepage: https://github.com/konung/matterful_attributes
|
61
66
|
licenses:
|
62
67
|
- MIT
|
63
|
-
metadata: {}
|
64
68
|
post_install_message:
|
65
69
|
rdoc_options: []
|
66
70
|
require_paths:
|
67
71
|
- lib
|
68
72
|
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
69
74
|
requirements:
|
70
|
-
- - '>='
|
75
|
+
- - ! '>='
|
71
76
|
- !ruby/object:Gem::Version
|
72
77
|
version: '0'
|
73
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
74
80
|
requirements:
|
75
|
-
- - '>='
|
81
|
+
- - ! '>='
|
76
82
|
- !ruby/object:Gem::Version
|
77
83
|
version: '0'
|
78
84
|
requirements: []
|
79
85
|
rubyforge_project:
|
80
|
-
rubygems_version:
|
86
|
+
rubygems_version: 1.8.24
|
81
87
|
signing_key:
|
82
|
-
specification_version:
|
88
|
+
specification_version: 3
|
83
89
|
summary: See Readme.md
|
84
90
|
test_files: []
|
85
91
|
has_rdoc:
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 71b08449dae61ecb94fb522f7fa6704a1752ee7c
|
4
|
-
data.tar.gz: 35f693c553e2fda54742fb1dd1d405b02becf49e
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: dcae85a5ebe606d6da72088eca64e2f128ce4da5d6b17d80fe2838d83e50ea42746b16bde47eb93c31417b44a219950c6a302480b9c4bce1ea5aecac5329cc74
|
7
|
-
data.tar.gz: 352775d60b8f4629d3d0f7ff3bba2bb04c9437acc35ec6c972bf0dd45de01803a4f5734bf9820435d462c3dbb2844c9fc420593fc58b7e0348c46df5f23e1e93
|