matterful_attributes 0.0.6 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/matterful_attributes.rb +20 -0
- data/lib/matterful_attributes/version.rb +1 -1
- data/matterful_attributes.gemspec +13 -8
- metadata +67 -3
data/lib/matterful_attributes.rb
CHANGED
@@ -87,6 +87,26 @@ module MatterfulAttributes
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
+
class Hash
|
91
|
+
# Extracted from : http://api.rubyonrails.org/v4.0.2/classes/Hash.html#method-i-diff
|
92
|
+
# ActiveSupport::Deprecation.warn "Hash#diff is no longer used inside of
|
93
|
+
# Rails, and is being deprecated with no replacement. If you're using
|
94
|
+
# it to compare hashes for the purpose of testing, please use MiniTest's assert_equal instead."
|
95
|
+
# Returns a hash that represents the difference between two hashes.
|
96
|
+
#
|
97
|
+
# {1 => 2}.diff(1 => 2) # => {}
|
98
|
+
# {1 => 2}.diff(1 => 3) # => {1 => 2}
|
99
|
+
# {}.diff(1 => 2) # => {1 => 2}
|
100
|
+
# {1 => 2, 3 => 4}.diff(1 => 2) # => {3 => 4}
|
101
|
+
def diff(other)
|
102
|
+
ActiveSupport::Deprecation.warn "Hash.diff Pulled back into Hash from Rails 4.0.2 ."
|
103
|
+
dup.
|
104
|
+
delete_if { |k, v| other[k] == v }.
|
105
|
+
merge!(other.dup.delete_if { |k, v| has_key?(k) })
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
|
90
110
|
# include the extension
|
91
111
|
ActiveRecord::Base.send(:include, MatterfulAttributes)
|
92
112
|
|
@@ -4,20 +4,25 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'matterful_attributes/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'matterful_attributes'
|
8
8
|
spec.version = MatterfulAttributes::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ['Nick Gorbikoff']
|
10
|
+
spec.email = ['nick.gorbikoff@gmail.com']
|
11
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
12
|
spec.summary = %q{See Readme.md}
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
13
|
+
spec.homepage = 'https://github.com/konung/matterful_attributes'
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_development_dependency
|
22
|
-
spec.add_development_dependency
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
22
|
+
spec.add_development_dependency 'rake'
|
23
|
+
spec.add_development_dependency 'pry'
|
24
|
+
spec.add_development_dependency 'debugger'
|
25
|
+
spec.add_development_dependency 'rake'
|
26
|
+
|
27
|
+
spec.add_runtime_dependency 'activesupport'
|
23
28
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-07-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -43,6 +43,70 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: pry
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: debugger
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rake
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: activesupport
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
46
110
|
description: ! 'Ruby / Rails gem that shims ActiveRecord::Base to provide some helpful
|
47
111
|
methods for parsing out attributes that matter to humans, i.e. Address.first.matterful_attributes
|
48
112
|
will return a hash of attributes minus id, type, polymorphic_id, polymorphic_type,
|
@@ -83,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
147
|
version: '0'
|
84
148
|
requirements: []
|
85
149
|
rubyforge_project:
|
86
|
-
rubygems_version: 1.8.
|
150
|
+
rubygems_version: 1.8.25
|
87
151
|
signing_key:
|
88
152
|
specification_version: 3
|
89
153
|
summary: See Readme.md
|