dm-is-reflective 1.0.1.rc → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.md +226 -0
- data/README.md +132 -0
- data/Rakefile +0 -1
- data/{TODO → TODO.md} +1 -1
- data/dm-is-reflective.gemspec +33 -44
- data/lib/dm-is-reflective/version.rb +1 -1
- data/task/.gitignore +1 -0
- data/task/gemgem.rb +119 -17
- metadata +59 -37
- data/CHANGES +0 -201
- data/CONTRIBUTORS +0 -1
- data/NOTICE +0 -20
- data/README +0 -123
- data/README.rdoc +0 -123
- data/lib/dm-is-reflective/is/version.rb +0 -8
data/CONTRIBUTORS
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
Lin Jen-Shin (godfat)
|
data/NOTICE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
= notice and thanks
|
2
|
-
|
3
|
-
* dm-is-reflective is a plugin of DataMapper
|
4
|
-
> gem install dm-core
|
5
|
-
http://datamapper.org
|
6
|
-
|
7
|
-
* this project skeleton is built through Mr Bones
|
8
|
-
http://codeforpeople.rubyforge.org/bones/
|
9
|
-
|
10
|
-
* Ruby the great language
|
11
|
-
http://www.ruby-lang.org
|
12
|
-
|
13
|
-
* Rubygems the great package management
|
14
|
-
http://rubygems.org
|
15
|
-
|
16
|
-
* Rake the great task automation
|
17
|
-
http://rake.rubyforge.org
|
18
|
-
|
19
|
-
* Github for hosting git
|
20
|
-
http://github.com
|
data/README
DELETED
@@ -1,123 +0,0 @@
|
|
1
|
-
= dm-is-reflective
|
2
|
-
by Lin Jen-Shin (godfat[http://godfat.org])
|
3
|
-
godfat (XD) godfat.org
|
4
|
-
|
5
|
-
== LINKS:
|
6
|
-
|
7
|
-
* {github}[http://github.com/godfat/dm-is-reflective]
|
8
|
-
* {rubygems}[http://rubygems.org/gems/dm-is-reflective]
|
9
|
-
* {rdoc}[http://rdoc.info/projects/godfat/dm-is-reflective]
|
10
|
-
|
11
|
-
== DESCRIPTION:
|
12
|
-
|
13
|
-
DataMapper plugin that helps you manipulate an existing database.
|
14
|
-
It creates mappings between existing columns and model's properties.
|
15
|
-
|
16
|
-
== SYNOPSIS:
|
17
|
-
|
18
|
-
require 'dm-is-reflective' # this would require 'dm-core'
|
19
|
-
dm = DataMapper.setup :default, 'sqlite:db/dev.sqlite3'
|
20
|
-
|
21
|
-
class User
|
22
|
-
include DataMapper::Resource
|
23
|
-
is :reflective
|
24
|
-
|
25
|
-
# mapping all, returns an array of properties indicating fields it mapped
|
26
|
-
reflect /.*/ # e.g. => [#<Property:#<Class:0x18f89b8>:id>,
|
27
|
-
# #<Property:#<Class:0x18f89b8>:title>,
|
28
|
-
# #<Property:#<Class:0x18f89b8>:body>,
|
29
|
-
# #<Property:#<Class:0x18f89b8>:user_id>]
|
30
|
-
|
31
|
-
# mapping all (with no argument at all)
|
32
|
-
reflect
|
33
|
-
|
34
|
-
# mapping for field name ended with _at, and started with salt_
|
35
|
-
reflect /_at$/, /^salt_/
|
36
|
-
|
37
|
-
# mapping id and email
|
38
|
-
reflect :id, :email
|
39
|
-
|
40
|
-
# mapping all fields with type String, and id
|
41
|
-
reflect String, :id
|
42
|
-
|
43
|
-
# mapping login, and all fields with type Integer
|
44
|
-
reflect :login, Integer
|
45
|
-
end
|
46
|
-
|
47
|
-
# there's no guarantee of the order in storages array
|
48
|
-
dm.storages
|
49
|
-
# => ['users']
|
50
|
-
|
51
|
-
# there's no guarantee of the order in fields array
|
52
|
-
User.fields
|
53
|
-
# => [[:created_at, DateTime, {:required => false}],
|
54
|
-
[:email, String, {:required => false, :length => 255,
|
55
|
-
:default => 'nospam@nospam.tw'}],
|
56
|
-
[:id, Serial, {:required => true, :serial => true,
|
57
|
-
:key => true}],
|
58
|
-
[:salt_first, String, {:required => false, :length => 50}],
|
59
|
-
[:salt_second, String, {:required => false, :length => 50}]]
|
60
|
-
|
61
|
-
dm.fields('users').sort_by{ |field| field.first.to_s } ==
|
62
|
-
User.fields.sort_by{ |field| field.first.to_s }
|
63
|
-
# => true
|
64
|
-
|
65
|
-
dm.storages_and_fields
|
66
|
-
# => {'users' => [[:id, Serial, {:required => true,
|
67
|
-
:serial => true,
|
68
|
-
:key => true}],
|
69
|
-
[:email, String, {:required => false,
|
70
|
-
:default => 'nospam@nospam.tw'}],
|
71
|
-
[:created_at, DateTime, {:required => false}],
|
72
|
-
[:salt_first, String, {:required => false, :length => 50}],
|
73
|
-
[:salt_second, String, {:required => false, :length => 50}]]}
|
74
|
-
|
75
|
-
# there's no guarantee of the order in returned array
|
76
|
-
dm.auto_genclass!
|
77
|
-
# => [DataMapper::Is::Reflective::User,
|
78
|
-
DataMapper::Is::Reflective::SchemaInfo,
|
79
|
-
DataMapper::Is::Reflective::Session]
|
80
|
-
|
81
|
-
# you can change the scope of generated models:
|
82
|
-
dm.auto_genclass! :scope => Object
|
83
|
-
# => [User, SchemaInfo, Session]
|
84
|
-
|
85
|
-
# you can generate classes for tables you specified only:
|
86
|
-
dm.auto_genclass! :scope => Object, :storages => /^phpbb_/
|
87
|
-
# => [PhpbbUser, PhpbbPost, PhpbbConfig]
|
88
|
-
|
89
|
-
# you can generate classes with String too:
|
90
|
-
dm.auto_genclass! :storages => ['users', 'config'], :scope => Object
|
91
|
-
# => [User, Config]
|
92
|
-
|
93
|
-
# you can generate a class only:
|
94
|
-
dm.auto_genclass! :storages => 'users'
|
95
|
-
# => [DataMapper::Is::Reflective::User]
|
96
|
-
|
97
|
-
== REQUIREMENTS:
|
98
|
-
|
99
|
-
* dm-core 1.1.0 or later
|
100
|
-
* at least one dm-*-adapter which is using dm-do-adapter.
|
101
|
-
(relational database, namely sqlite, postgres, and mysql at the moment)
|
102
|
-
|
103
|
-
== INSTALL:
|
104
|
-
|
105
|
-
> gem install dm-is-reflective
|
106
|
-
|
107
|
-
== LICENSE:
|
108
|
-
|
109
|
-
Apache License 2.0
|
110
|
-
|
111
|
-
Copyright (c) 2008-2011, Lin Jen-Shin (godfat)
|
112
|
-
|
113
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
114
|
-
you may not use this file except in compliance with the License.
|
115
|
-
You may obtain a copy of the License at
|
116
|
-
|
117
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
118
|
-
|
119
|
-
Unless required by applicable law or agreed to in writing, software
|
120
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
121
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
122
|
-
See the License for the specific language governing permissions and
|
123
|
-
limitations under the License.
|
data/README.rdoc
DELETED
@@ -1,123 +0,0 @@
|
|
1
|
-
= dm-is-reflective
|
2
|
-
by Lin Jen-Shin (godfat[http://godfat.org])
|
3
|
-
godfat (XD) godfat.org
|
4
|
-
|
5
|
-
== LINKS:
|
6
|
-
|
7
|
-
* {github}[http://github.com/godfat/dm-is-reflective]
|
8
|
-
* {rubygems}[http://rubygems.org/gems/dm-is-reflective]
|
9
|
-
* {rdoc}[http://rdoc.info/projects/godfat/dm-is-reflective]
|
10
|
-
|
11
|
-
== DESCRIPTION:
|
12
|
-
|
13
|
-
DataMapper plugin that helps you manipulate an existing database.
|
14
|
-
It creates mappings between existing columns and model's properties.
|
15
|
-
|
16
|
-
== SYNOPSIS:
|
17
|
-
|
18
|
-
require 'dm-is-reflective' # this would require 'dm-core'
|
19
|
-
dm = DataMapper.setup :default, 'sqlite:db/dev.sqlite3'
|
20
|
-
|
21
|
-
class User
|
22
|
-
include DataMapper::Resource
|
23
|
-
is :reflective
|
24
|
-
|
25
|
-
# mapping all, returns an array of properties indicating fields it mapped
|
26
|
-
reflect /.*/ # e.g. => [#<Property:#<Class:0x18f89b8>:id>,
|
27
|
-
# #<Property:#<Class:0x18f89b8>:title>,
|
28
|
-
# #<Property:#<Class:0x18f89b8>:body>,
|
29
|
-
# #<Property:#<Class:0x18f89b8>:user_id>]
|
30
|
-
|
31
|
-
# mapping all (with no argument at all)
|
32
|
-
reflect
|
33
|
-
|
34
|
-
# mapping for field name ended with _at, and started with salt_
|
35
|
-
reflect /_at$/, /^salt_/
|
36
|
-
|
37
|
-
# mapping id and email
|
38
|
-
reflect :id, :email
|
39
|
-
|
40
|
-
# mapping all fields with type String, and id
|
41
|
-
reflect String, :id
|
42
|
-
|
43
|
-
# mapping login, and all fields with type Integer
|
44
|
-
reflect :login, Integer
|
45
|
-
end
|
46
|
-
|
47
|
-
# there's no guarantee of the order in storages array
|
48
|
-
dm.storages
|
49
|
-
# => ['users']
|
50
|
-
|
51
|
-
# there's no guarantee of the order in fields array
|
52
|
-
User.fields
|
53
|
-
# => [[:created_at, DateTime, {:required => false}],
|
54
|
-
[:email, String, {:required => false, :length => 255,
|
55
|
-
:default => 'nospam@nospam.tw'}],
|
56
|
-
[:id, Serial, {:required => true, :serial => true,
|
57
|
-
:key => true}],
|
58
|
-
[:salt_first, String, {:required => false, :length => 50}],
|
59
|
-
[:salt_second, String, {:required => false, :length => 50}]]
|
60
|
-
|
61
|
-
dm.fields('users').sort_by{ |field| field.first.to_s } ==
|
62
|
-
User.fields.sort_by{ |field| field.first.to_s }
|
63
|
-
# => true
|
64
|
-
|
65
|
-
dm.storages_and_fields
|
66
|
-
# => {'users' => [[:id, Serial, {:required => true,
|
67
|
-
:serial => true,
|
68
|
-
:key => true}],
|
69
|
-
[:email, String, {:required => false,
|
70
|
-
:default => 'nospam@nospam.tw'}],
|
71
|
-
[:created_at, DateTime, {:required => false}],
|
72
|
-
[:salt_first, String, {:required => false, :length => 50}],
|
73
|
-
[:salt_second, String, {:required => false, :length => 50}]]}
|
74
|
-
|
75
|
-
# there's no guarantee of the order in returned array
|
76
|
-
dm.auto_genclass!
|
77
|
-
# => [DataMapper::Is::Reflective::User,
|
78
|
-
DataMapper::Is::Reflective::SchemaInfo,
|
79
|
-
DataMapper::Is::Reflective::Session]
|
80
|
-
|
81
|
-
# you can change the scope of generated models:
|
82
|
-
dm.auto_genclass! :scope => Object
|
83
|
-
# => [User, SchemaInfo, Session]
|
84
|
-
|
85
|
-
# you can generate classes for tables you specified only:
|
86
|
-
dm.auto_genclass! :scope => Object, :storages => /^phpbb_/
|
87
|
-
# => [PhpbbUser, PhpbbPost, PhpbbConfig]
|
88
|
-
|
89
|
-
# you can generate classes with String too:
|
90
|
-
dm.auto_genclass! :storages => ['users', 'config'], :scope => Object
|
91
|
-
# => [User, Config]
|
92
|
-
|
93
|
-
# you can generate a class only:
|
94
|
-
dm.auto_genclass! :storages => 'users'
|
95
|
-
# => [DataMapper::Is::Reflective::User]
|
96
|
-
|
97
|
-
== REQUIREMENTS:
|
98
|
-
|
99
|
-
* dm-core 1.1.0 or later
|
100
|
-
* at least one dm-*-adapter which is using dm-do-adapter.
|
101
|
-
(relational database, namely sqlite, postgres, and mysql at the moment)
|
102
|
-
|
103
|
-
== INSTALL:
|
104
|
-
|
105
|
-
> gem install dm-is-reflective
|
106
|
-
|
107
|
-
== LICENSE:
|
108
|
-
|
109
|
-
Apache License 2.0
|
110
|
-
|
111
|
-
Copyright (c) 2008-2011, Lin Jen-Shin (godfat)
|
112
|
-
|
113
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
114
|
-
you may not use this file except in compliance with the License.
|
115
|
-
You may obtain a copy of the License at
|
116
|
-
|
117
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
118
|
-
|
119
|
-
Unless required by applicable law or agreed to in writing, software
|
120
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
121
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
122
|
-
See the License for the specific language governing permissions and
|
123
|
-
limitations under the License.
|