godfat-dm-mapping 0.4.0 → 0.4.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.
- data/CHANGES +3 -0
- data/README +8 -7
- data/Rakefile +4 -3
- data/TODO +3 -2
- data/dm-mapping.gemspec +4 -4
- data/lib/dm-mapping/adapters/sqlite3adapter.rb +0 -3
- data/lib/dm-mapping/type_map.rb +5 -1
- data/lib/dm-mapping/version.rb +1 -1
- data/tasks/manifest.rake +3 -3
- data/test/test_sqlite3.rb +8 -8
- metadata +2 -4
- data/.gitignore +0 -3
data/CHANGES
CHANGED
data/README
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
= dm-mapping 0.4.
|
1
|
+
= dm-mapping 0.4.1
|
2
2
|
by Lin Jen-Shin (a.k.a. godfat-真常[http://godfat.org])
|
3
3
|
godfat (XD) godfat.org
|
4
4
|
|
@@ -23,7 +23,7 @@ by Lin Jen-Shin (a.k.a. godfat-真常[http://godfat.org])
|
|
23
23
|
|
24
24
|
class User
|
25
25
|
include DataMapper::Resource
|
26
|
-
#
|
26
|
+
# mapping all
|
27
27
|
mapping /.*/
|
28
28
|
|
29
29
|
# mapping for ended with _at, and started with salt_
|
@@ -46,10 +46,10 @@ by Lin Jen-Shin (a.k.a. godfat-真常[http://godfat.org])
|
|
46
46
|
# there's no guarantee of the order in fields array
|
47
47
|
User.fields.sort
|
48
48
|
# => [['created_at', DateTime, {}],
|
49
|
-
['email', String, {:default => 'nospam@nospam.tw'}],
|
49
|
+
['email', String, {:size => 255, :default => 'nospam@nospam.tw'}],
|
50
50
|
['id', Integer, {:serial => true}],
|
51
|
-
['salt_first', String, {}],
|
52
|
-
['salt_second', String, {}]]
|
51
|
+
['salt_first', String, {:size => 50}],
|
52
|
+
['salt_second', String, {:size => 50}]]
|
53
53
|
|
54
54
|
dm.fields('users').sort == User.fields.sort
|
55
55
|
# => true
|
@@ -58,8 +58,8 @@ by Lin Jen-Shin (a.k.a. godfat-真常[http://godfat.org])
|
|
58
58
|
# => {'users' => [['id', Integer, {:serial => true}],
|
59
59
|
['email', String, {:default => 'nospam@nospam.tw'}],
|
60
60
|
['created_at', DateTime, {}],
|
61
|
-
['salt_first', String, {}],
|
62
|
-
['salt_second', String, {}]]}
|
61
|
+
['salt_first', String, {:size => 50}],
|
62
|
+
['salt_second', String, {:size => 50}]]}
|
63
63
|
|
64
64
|
# there's no guarantee of the order in returned array
|
65
65
|
dm.auto_genclass!
|
@@ -74,6 +74,7 @@ by Lin Jen-Shin (a.k.a. godfat-真常[http://godfat.org])
|
|
74
74
|
== REQUIREMENTS:
|
75
75
|
|
76
76
|
* dm-core 0.9.3
|
77
|
+
* at least one do_* adapter (currently only sqlite3 is supported)
|
77
78
|
|
78
79
|
== INSTALL:
|
79
80
|
|
data/Rakefile
CHANGED
@@ -45,15 +45,16 @@ PROJ.gem.dependencies << ['dm-core', '>=0.9.3'] << ['extlib', '>=0.9.3']
|
|
45
45
|
# PROJ.gem.files = []
|
46
46
|
|
47
47
|
PROJ.manifest_file = 'Manifest'
|
48
|
-
PROJ.exclude
|
48
|
+
PROJ.exclude += ['Manifest', '^tmp', 'tmp$', '^pkg', '.gitignore', '^ann-']
|
49
49
|
|
50
50
|
PROJ.readme_file = 'README'
|
51
51
|
PROJ.rdoc.main = 'README'
|
52
52
|
PROJ.rdoc.remote_dir = 'dm-mapping'
|
53
|
-
PROJ.rdoc.exclude
|
53
|
+
PROJ.rdoc.exclude += ['Rakefile', '^tasks', '^test']
|
54
54
|
PROJ.rdoc.include << '\w+'
|
55
55
|
PROJ.rdoc.opts << '--diagram' if !WIN32 and `which dot` =~ %r/\/dot/
|
56
|
-
PROJ.rdoc.opts
|
56
|
+
PROJ.rdoc.opts += ['--charset=utf-8', '--inline-source',
|
57
|
+
'--line-numbers', '--promiscuous']
|
57
58
|
|
58
59
|
PROJ.spec.opts << '--color'
|
59
60
|
|
data/TODO
CHANGED
data/dm-mapping.gemspec
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
s.name = %q{dm-mapping}
|
4
|
-
s.version = "0.4.
|
4
|
+
s.version = "0.4.1"
|
5
5
|
|
6
6
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
7
7
|
s.authors = ["Lin Jen-Shin (a.k.a. godfat \347\234\237\345\270\270)"]
|
8
|
-
s.date = %q{2008-08-
|
8
|
+
s.date = %q{2008-08-14}
|
9
9
|
s.description = %q{DataMapper plugin that helps you manipulate an existing database. It creates mappings between existing columns and model's properties.}
|
10
10
|
s.email = %q{godfat (XD) godfat.org}
|
11
|
-
s.extra_rdoc_files = ["
|
12
|
-
s.files = ["
|
11
|
+
s.extra_rdoc_files = ["CHANGES", "LICENSE", "NOTICE", "README", "TODO", "dm-mapping.gemspec"]
|
12
|
+
s.files = ["CHANGES", "LICENSE", "NOTICE", "README", "Rakefile", "TODO", "dm-mapping.gemspec", "lib/dm-mapping.rb", "lib/dm-mapping/adapters/abstract_adapter.rb", "lib/dm-mapping/adapters/sqlite3adapter.rb", "lib/dm-mapping/model.rb", "lib/dm-mapping/type_map.rb", "lib/dm-mapping/version.rb", "tasks/ann.rake", "tasks/bones.rake", "tasks/gem.rake", "tasks/git.rake", "tasks/manifest.rake", "tasks/notes.rake", "tasks/post_load.rake", "tasks/rdoc.rake", "tasks/rubyforge.rake", "tasks/setup.rb", "tasks/spec.rake", "tasks/svn.rake", "tasks/test.rake", "test/test_sqlite3.rb"]
|
13
13
|
s.has_rdoc = true
|
14
14
|
s.homepage = %q{http://github.com/godfat/dm-mapping}
|
15
15
|
s.rdoc_options = ["--diagram", "--charset=utf-8", "--inline-source", "--line-numbers", "--promiscuous", "--main", "README"]
|
@@ -23,9 +23,6 @@ module DataMapper
|
|
23
23
|
type, chain = self.class.type_map.
|
24
24
|
lookup_primitive(field.type.gsub(/\(\d+\)/, '').upcase)
|
25
25
|
|
26
|
-
# stupid hack
|
27
|
-
type = String if type == Class
|
28
|
-
|
29
26
|
attrs = {}
|
30
27
|
attrs[:serial] = true if field.pk != 0
|
31
28
|
attrs[:nullable] = true if field.notnull != 0 && !attrs[:serial]
|
data/lib/dm-mapping/type_map.rb
CHANGED
@@ -7,7 +7,11 @@ module DataMapper
|
|
7
7
|
# # => { DateTime => {:auto_validation => true} }
|
8
8
|
def lookup_primitive primitive, type_map = self
|
9
9
|
type_map.chains.find{ |type, chain|
|
10
|
-
primitive == chain.primitive
|
10
|
+
primitive == chain.primitive &&
|
11
|
+
[Integer, Float, BigDecimal,
|
12
|
+
String, TrueClass, FalseClass,
|
13
|
+
DateTime, Date, Time,
|
14
|
+
DM::Text, DM::Boolean].member?(type)
|
11
15
|
} or lookup_primitive(primitive, type_map.parent)
|
12
16
|
end
|
13
17
|
end
|
data/lib/dm-mapping/version.rb
CHANGED
data/tasks/manifest.rake
CHANGED
@@ -15,9 +15,9 @@ namespace :manifest do
|
|
15
15
|
lines.map! do |line|
|
16
16
|
case line
|
17
17
|
when %r/^(-{3}|\+{3})/; nil
|
18
|
-
when %r/^@/;
|
19
|
-
when %r/^\+/;
|
20
|
-
when %r/^\-/;
|
18
|
+
when %r/^@/; ANSICode.blue line
|
19
|
+
when %r/^\+/; ANSICode.green line
|
20
|
+
when %r/^\-/; ANSICode.red line
|
21
21
|
else line end
|
22
22
|
end
|
23
23
|
end
|
data/test/test_sqlite3.rb
CHANGED
@@ -50,17 +50,17 @@ class DMMTest < Test::Unit::TestCase
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def user_fields
|
53
|
-
[['created_at', DateTime,
|
54
|
-
['id', Integer,
|
55
|
-
['login', String,
|
56
|
-
['sig',
|
53
|
+
[['created_at', DateTime, {}],
|
54
|
+
['id', Integer, {:serial => true}],
|
55
|
+
['login', String, {:size => 50}],
|
56
|
+
['sig', DM::Text, {}]]
|
57
57
|
end
|
58
58
|
|
59
59
|
def comment_fields
|
60
|
-
[['body',
|
61
|
-
['id', Integer
|
62
|
-
['title', String
|
63
|
-
['user_id', Integer
|
60
|
+
[['body', DM::Text, {}],
|
61
|
+
['id', Integer, {:serial => true}],
|
62
|
+
['title', String, {:size => 50, :default => 'default title'}],
|
63
|
+
['user_id', Integer, {}]]
|
64
64
|
end
|
65
65
|
|
66
66
|
def test_storages
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: godfat-dm-mapping
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Lin Jen-Shin (a.k.a. godfat \xE7\x9C\x9F\xE5\xB8\xB8)"
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-08-
|
12
|
+
date: 2008-08-14 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -37,7 +37,6 @@ executables: []
|
|
37
37
|
extensions: []
|
38
38
|
|
39
39
|
extra_rdoc_files:
|
40
|
-
- .gitignore
|
41
40
|
- CHANGES
|
42
41
|
- LICENSE
|
43
42
|
- NOTICE
|
@@ -45,7 +44,6 @@ extra_rdoc_files:
|
|
45
44
|
- TODO
|
46
45
|
- dm-mapping.gemspec
|
47
46
|
files:
|
48
|
-
- .gitignore
|
49
47
|
- CHANGES
|
50
48
|
- LICENSE
|
51
49
|
- NOTICE
|
data/.gitignore
DELETED