datamappify 0.2.2 → 0.9.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 +7 -0
- data/.gitignore +2 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +4 -0
- data/README.md +69 -78
- data/Rakefile +20 -13
- data/datamappify.gemspec +29 -57
- data/lib/datamappify.rb +7 -16
- data/lib/datamappify/data.rb +6 -0
- data/lib/datamappify/data/association_methods.rb +29 -0
- data/lib/datamappify/data/base.rb +11 -0
- data/lib/datamappify/entity.rb +44 -0
- data/lib/datamappify/entity/associated_collection.rb +28 -0
- data/lib/datamappify/entity/associated_entity.rb +28 -0
- data/lib/datamappify/entity/association_methods.rb +20 -0
- data/lib/datamappify/repository.rb +65 -0
- data/lib/datamappify/repository/persistence.rb +38 -0
- data/lib/datamappify/version.rb +3 -0
- data/spec/entity_spec.rb +83 -0
- data/spec/repository/finders_and_persistence_spec.rb +71 -0
- data/spec/repository_spec.rb +60 -0
- data/spec/spec_helper.rb +24 -0
- data/spec/support/active_record_tables.rb +34 -0
- data/spec/support/comment.rb +9 -0
- data/spec/support/role.rb +9 -0
- data/spec/support/user.rb +21 -0
- metadata +244 -79
- data/MIT-LICENSE +0 -20
- data/VERSION +0 -1
- data/lib/datamappify/associations.rb +0 -21
- data/lib/datamappify/collection.rb +0 -46
- data/lib/datamappify/fake/column.rb +0 -17
- data/lib/datamappify/fake/connection.rb +0 -77
- data/lib/datamappify/fake/index.rb +0 -34
- data/lib/datamappify/railtie.rb +0 -10
- data/lib/datamappify/resource.rb +0 -35
- data/lib/datamappify/schema_dumper.rb +0 -21
- data/lib/tasks/datamappify.rake +0 -15
- data/vendor/auto_migrations/MIT-LICENSE +0 -20
- data/vendor/auto_migrations/README +0 -46
- data/vendor/auto_migrations/Rakefile +0 -24
- data/vendor/auto_migrations/init.rb +0 -2
- data/vendor/auto_migrations/lib/auto_migrations.rb +0 -178
- data/vendor/auto_migrations/lib/tasks/auto_migrations_tasks.rake +0 -20
- data/vendor/auto_migrations/test/auto_migrations_test.rb +0 -8
@@ -0,0 +1,21 @@
|
|
1
|
+
class User
|
2
|
+
include Datamappify::Entity
|
3
|
+
|
4
|
+
attribute :first_name, String
|
5
|
+
attribute :last_name, String
|
6
|
+
attribute :age, Integer
|
7
|
+
|
8
|
+
validations do
|
9
|
+
validates :first_name, :presence => true,
|
10
|
+
:length => { :minimum => 2 }
|
11
|
+
end
|
12
|
+
|
13
|
+
relationships do
|
14
|
+
has_one :role
|
15
|
+
has_many :comments
|
16
|
+
end
|
17
|
+
|
18
|
+
def full_name
|
19
|
+
"#{first_name} #{last_name}"
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,99 +1,264 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: datamappify
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
segments:
|
6
|
-
- 0
|
7
|
-
- 2
|
8
|
-
- 2
|
9
|
-
version: 0.2.2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.0
|
10
5
|
platform: ruby
|
11
|
-
authors:
|
6
|
+
authors:
|
12
7
|
- Fred Wu
|
13
8
|
autorequire:
|
14
9
|
bindir: bin
|
15
10
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
11
|
+
date: 2013-03-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: virtus
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.5'
|
20
|
+
type: :runtime
|
22
21
|
prerelease: false
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 4.0.0.beta1
|
34
|
+
- - <
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '5'
|
31
37
|
type: :runtime
|
32
|
-
|
33
|
-
|
34
|
-
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 4.0.0.beta1
|
44
|
+
- - <
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '5'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: activerecord
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 4.0.0.beta1
|
54
|
+
- - <
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '5'
|
57
|
+
type: :runtime
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 4.0.0.beta1
|
64
|
+
- - <
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '5'
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: bundler
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ~>
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '1.3'
|
74
|
+
type: :development
|
75
|
+
prerelease: false
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ~>
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '1.3'
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: rake
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: minitest
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - '>='
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
- !ruby/object:Gem::Dependency
|
110
|
+
name: minitest-colorize
|
111
|
+
requirement: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - '>='
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
type: :development
|
117
|
+
prerelease: false
|
118
|
+
version_requirements: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - '>='
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
- !ruby/object:Gem::Dependency
|
124
|
+
name: pry
|
125
|
+
requirement: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - '>='
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
type: :development
|
131
|
+
prerelease: false
|
132
|
+
version_requirements: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - '>='
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
- !ruby/object:Gem::Dependency
|
138
|
+
name: simplecov
|
139
|
+
requirement: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - '>='
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
type: :development
|
145
|
+
prerelease: false
|
146
|
+
version_requirements: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - '>='
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
- !ruby/object:Gem::Dependency
|
152
|
+
name: cane
|
153
|
+
requirement: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
type: :development
|
159
|
+
prerelease: false
|
160
|
+
version_requirements: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - '>='
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '0'
|
165
|
+
- !ruby/object:Gem::Dependency
|
166
|
+
name: sqlite3
|
167
|
+
requirement: !ruby/object:Gem::Requirement
|
168
|
+
requirements:
|
169
|
+
- - '>='
|
170
|
+
- !ruby/object:Gem::Version
|
171
|
+
version: '0'
|
172
|
+
type: :development
|
173
|
+
prerelease: false
|
174
|
+
version_requirements: !ruby/object:Gem::Requirement
|
175
|
+
requirements:
|
176
|
+
- - '>='
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '0'
|
179
|
+
- !ruby/object:Gem::Dependency
|
180
|
+
name: database_cleaner
|
181
|
+
requirement: !ruby/object:Gem::Requirement
|
182
|
+
requirements:
|
183
|
+
- - '>='
|
184
|
+
- !ruby/object:Gem::Version
|
185
|
+
version: 1.0.0.RC1
|
186
|
+
- - <
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: '2'
|
189
|
+
type: :development
|
190
|
+
prerelease: false
|
191
|
+
version_requirements: !ruby/object:Gem::Requirement
|
192
|
+
requirements:
|
193
|
+
- - '>='
|
194
|
+
- !ruby/object:Gem::Version
|
195
|
+
version: 1.0.0.RC1
|
196
|
+
- - <
|
197
|
+
- !ruby/object:Gem::Version
|
198
|
+
version: '2'
|
199
|
+
description: Separate domain logic from data persistence.
|
200
|
+
email:
|
201
|
+
- ifredwu@gmail.com
|
35
202
|
executables: []
|
36
|
-
|
37
203
|
extensions: []
|
38
|
-
|
39
|
-
|
40
|
-
- README.md
|
41
|
-
files:
|
204
|
+
extra_rdoc_files: []
|
205
|
+
files:
|
42
206
|
- .gitignore
|
43
|
-
-
|
207
|
+
- .travis.yml
|
208
|
+
- CHANGELOG.md
|
209
|
+
- Gemfile
|
44
210
|
- README.md
|
45
211
|
- Rakefile
|
46
|
-
- VERSION
|
47
212
|
- datamappify.gemspec
|
48
213
|
- lib/datamappify.rb
|
49
|
-
- lib/datamappify/
|
50
|
-
- lib/datamappify/
|
51
|
-
- lib/datamappify/
|
52
|
-
- lib/datamappify/
|
53
|
-
- lib/datamappify/
|
54
|
-
- lib/datamappify/
|
55
|
-
- lib/datamappify/
|
56
|
-
- lib/datamappify/
|
57
|
-
- lib/
|
58
|
-
-
|
59
|
-
-
|
60
|
-
-
|
61
|
-
-
|
62
|
-
-
|
63
|
-
-
|
64
|
-
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
214
|
+
- lib/datamappify/data.rb
|
215
|
+
- lib/datamappify/data/association_methods.rb
|
216
|
+
- lib/datamappify/data/base.rb
|
217
|
+
- lib/datamappify/entity.rb
|
218
|
+
- lib/datamappify/entity/associated_collection.rb
|
219
|
+
- lib/datamappify/entity/associated_entity.rb
|
220
|
+
- lib/datamappify/entity/association_methods.rb
|
221
|
+
- lib/datamappify/repository.rb
|
222
|
+
- lib/datamappify/repository/persistence.rb
|
223
|
+
- lib/datamappify/version.rb
|
224
|
+
- spec/entity_spec.rb
|
225
|
+
- spec/repository/finders_and_persistence_spec.rb
|
226
|
+
- spec/repository_spec.rb
|
227
|
+
- spec/spec_helper.rb
|
228
|
+
- spec/support/active_record_tables.rb
|
229
|
+
- spec/support/comment.rb
|
230
|
+
- spec/support/role.rb
|
231
|
+
- spec/support/user.rb
|
232
|
+
homepage: https://github.com/fredwu/datamappify
|
233
|
+
licenses:
|
234
|
+
- MIT
|
235
|
+
metadata: {}
|
69
236
|
post_install_message:
|
70
|
-
rdoc_options:
|
71
|
-
|
72
|
-
require_paths:
|
237
|
+
rdoc_options: []
|
238
|
+
require_paths:
|
73
239
|
- lib
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
none: false
|
85
|
-
requirements:
|
86
|
-
- - ">="
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
segments:
|
89
|
-
- 0
|
90
|
-
version: "0"
|
240
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
241
|
+
requirements:
|
242
|
+
- - '>='
|
243
|
+
- !ruby/object:Gem::Version
|
244
|
+
version: '0'
|
245
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
246
|
+
requirements:
|
247
|
+
- - '>='
|
248
|
+
- !ruby/object:Gem::Version
|
249
|
+
version: '0'
|
91
250
|
requirements: []
|
92
|
-
|
93
251
|
rubyforge_project:
|
94
|
-
rubygems_version:
|
252
|
+
rubygems_version: 2.0.0
|
95
253
|
signing_key:
|
96
|
-
specification_version:
|
97
|
-
summary:
|
98
|
-
test_files:
|
99
|
-
|
254
|
+
specification_version: 4
|
255
|
+
summary: Separate domain logic from data persistence.
|
256
|
+
test_files:
|
257
|
+
- spec/entity_spec.rb
|
258
|
+
- spec/repository/finders_and_persistence_spec.rb
|
259
|
+
- spec/repository_spec.rb
|
260
|
+
- spec/spec_helper.rb
|
261
|
+
- spec/support/active_record_tables.rb
|
262
|
+
- spec/support/comment.rb
|
263
|
+
- spec/support/role.rb
|
264
|
+
- spec/support/user.rb
|
data/MIT-LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2010 [name of plugin creator]
|
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/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.2.2
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module Datamappify
|
2
|
-
module Associations
|
3
|
-
mattr_accessor :join_tables
|
4
|
-
|
5
|
-
@@join_tables = {}
|
6
|
-
|
7
|
-
module ClassMethods
|
8
|
-
def belongs_to(association_id, options = {})
|
9
|
-
super
|
10
|
-
foreign_key = options.include?(:foreign_key) ? options[:foreign_key] : association_id.to_s.foreign_key
|
11
|
-
property(foreign_key.to_sym, :integer)
|
12
|
-
end
|
13
|
-
|
14
|
-
def has_and_belongs_to_many(association_id, options = {}, &extension)
|
15
|
-
super
|
16
|
-
reflection = self.send :create_has_and_belongs_to_many_reflection, association_id, options
|
17
|
-
Associations.join_tables[reflection.options[:join_table]] = [reflection.association_foreign_key, reflection.primary_key_name]
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
module Datamappify
|
2
|
-
class Collection
|
3
|
-
def self.get
|
4
|
-
collection = []
|
5
|
-
|
6
|
-
Dir.glob(Rails.root.join('app', 'models', '**', '*.rb')).each do |file|
|
7
|
-
name = file[/.*\/(.*)\.rb/, 1]
|
8
|
-
klass = name.camelize.constantize
|
9
|
-
|
10
|
-
next unless klass.included_modules.include?(Datamappify::Resource) and klass.respond_to?(:properties)
|
11
|
-
|
12
|
-
collection << {
|
13
|
-
:name => name,
|
14
|
-
:table_name => klass.table_name,
|
15
|
-
:properties => klass.properties,
|
16
|
-
:indexes => klass.indexes,
|
17
|
-
}
|
18
|
-
end
|
19
|
-
|
20
|
-
Associations.join_tables.each do |table_name, ids|
|
21
|
-
collection << {
|
22
|
-
:name => table_name,
|
23
|
-
:table_name => table_name,
|
24
|
-
:properties => [{
|
25
|
-
:name => ids[0],
|
26
|
-
:sql_type => :integer,
|
27
|
-
:options => {},
|
28
|
-
}, {
|
29
|
-
:name => ids[1],
|
30
|
-
:sql_type => :integer,
|
31
|
-
:options => {},
|
32
|
-
}],
|
33
|
-
:indexes => [{
|
34
|
-
:columns => ids[0],
|
35
|
-
:options => {},
|
36
|
-
}, {
|
37
|
-
:columns => ids[1],
|
38
|
-
:options => {},
|
39
|
-
}],
|
40
|
-
}
|
41
|
-
end
|
42
|
-
|
43
|
-
collection
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|