dm-is-reflective 1.0.1.rc → 1.0.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.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/task/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.rbc
|
data/task/gemgem.rb
CHANGED
@@ -12,23 +12,88 @@ module Gemgem
|
|
12
12
|
s.authors = ['Lin Jen-Shin (godfat)']
|
13
13
|
s.email = ['godfat (XD) godfat.org']
|
14
14
|
|
15
|
-
s.
|
16
|
-
|
17
|
-
s.description = s.summary
|
15
|
+
s.description = description.join
|
16
|
+
s.summary = description.first
|
18
17
|
|
19
|
-
s.extra_rdoc_files = %w[CHANGES CONTRIBUTORS LICENSE TODO]
|
20
|
-
s.rdoc_options = %w[--main README]
|
21
18
|
s.rubygems_version = Gem::VERSION
|
22
19
|
s.date = Time.now.strftime('%Y-%m-%d')
|
23
20
|
s.files = gem_files
|
24
21
|
s.test_files = gem_files.grep(%r{^test/(.+?/)*test_.+?\.rb$})
|
22
|
+
s.executables = Dir['bin/*'].map{ |f| File.basename(f) }
|
25
23
|
s.require_paths = %w[lib]
|
26
24
|
})
|
27
|
-
spec.homepage
|
28
|
-
spec.homepage
|
25
|
+
spec.homepage ||= "https://github.com/godfat/#{spec.name}"
|
29
26
|
spec
|
30
27
|
end
|
31
28
|
|
29
|
+
def readme
|
30
|
+
path = %w[README.md README].find{ |name|
|
31
|
+
File.exist?("#{Gemgem.dir}/#{name}")
|
32
|
+
}
|
33
|
+
@readme ||=
|
34
|
+
if path
|
35
|
+
ps = "##{File.read(path)}".
|
36
|
+
scan(/((#+)[^\n]+\n\n.+?(?=\n\n\2[^#\n]+\n))/m).map(&:first)
|
37
|
+
ps.inject({'HEADER' => ps.first}){ |r, s, i|
|
38
|
+
r[s[/\w+/]] = s
|
39
|
+
r
|
40
|
+
}
|
41
|
+
else
|
42
|
+
{}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def description
|
47
|
+
@description ||= (readme['DESCRIPTION']||'').sub(/.+\n\n/, '').lines.to_a
|
48
|
+
end
|
49
|
+
|
50
|
+
def changes
|
51
|
+
path = %w[CHANGES.md CHANGES].find{ |name|
|
52
|
+
File.exist?("#{Gemgem.dir}/#{name}")
|
53
|
+
}
|
54
|
+
@changes ||=
|
55
|
+
if path
|
56
|
+
date = '\d+{4}\-\d+{2}\-\d{2}'
|
57
|
+
File.read(path).match(
|
58
|
+
/([^\n]+#{date}\n\n(.+?))(?=\n\n[^\n]+#{date}\n|\Z)/m)[1]
|
59
|
+
else
|
60
|
+
''
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def ann_md
|
65
|
+
"#{readme['HEADER'].sub(/([\w\-]+)/, "[\\1](#{spec.homepage})")}\n\n" \
|
66
|
+
"##{readme['DESCRIPTION'][/[^\n]+\n\n[^\n]+/]}\n\n" \
|
67
|
+
"### CHANGES:\n\n" \
|
68
|
+
"###{changes}\n\n" \
|
69
|
+
"##{readme['INSTALLATION']}\n\n" +
|
70
|
+
if readme['SYNOPSIS'] then "##{readme['SYNOPSIS'][/[^\n]+\n\n[^\n]+/]}"
|
71
|
+
else '' end
|
72
|
+
end
|
73
|
+
|
74
|
+
def ann_html
|
75
|
+
gem 'nokogiri'
|
76
|
+
gem 'kramdown'
|
77
|
+
|
78
|
+
IO.popen('kramdown', 'r+') do |md|
|
79
|
+
md.puts Gemgem.ann_md
|
80
|
+
md.close_write
|
81
|
+
require 'nokogiri'
|
82
|
+
html = Nokogiri::XML.parse("<gemgem>#{md.read}</gemgem>")
|
83
|
+
html.css('*').each{ |n| n.delete('id') }
|
84
|
+
html.root.children.to_html
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def ann_email
|
89
|
+
"#{readme['HEADER'].sub(/([\w\-]+)/, "\\1 <#{spec.homepage}>")}\n\n" \
|
90
|
+
"#{readme['DESCRIPTION']}\n\n" \
|
91
|
+
"#{readme['INSTALLATION']}\n\n" +
|
92
|
+
if readme['SYNOPSIS'] then "##{readme['SYNOPSIS']}\n\n" else '' end +
|
93
|
+
"## CHANGES:\n\n" \
|
94
|
+
"##{changes}\n\n"
|
95
|
+
end
|
96
|
+
|
32
97
|
def gem_tag
|
33
98
|
"#{spec.name}-#{spec.version}"
|
34
99
|
end
|
@@ -50,7 +115,7 @@ module Gemgem
|
|
50
115
|
|
51
116
|
def all_files
|
52
117
|
@all_files ||= find_files(Pathname.new(dir)).map{ |file|
|
53
|
-
if file.to_s =~ %r{\.git
|
118
|
+
if file.to_s =~ %r{\.git/|\.git$}
|
54
119
|
nil
|
55
120
|
else
|
56
121
|
file.to_s
|
@@ -83,7 +148,7 @@ module Gemgem
|
|
83
148
|
|
84
149
|
def ignore_patterns
|
85
150
|
@ignore_files ||= expand_patterns(
|
86
|
-
|
151
|
+
gitignore.split("\n").reject{ |pattern|
|
87
152
|
pattern.strip == ''
|
88
153
|
}).map{ |pattern| %r{^([^/]+/)*?#{Regexp.escape(pattern)}(/[^/]+)*?$} }
|
89
154
|
end
|
@@ -100,6 +165,14 @@ module Gemgem
|
|
100
165
|
end
|
101
166
|
}.flatten
|
102
167
|
end
|
168
|
+
|
169
|
+
def gitignore
|
170
|
+
if File.exist?(path = "#{dir}/.gitignore")
|
171
|
+
File.read(path)
|
172
|
+
else
|
173
|
+
''
|
174
|
+
end
|
175
|
+
end
|
103
176
|
end
|
104
177
|
|
105
178
|
namespace :gem do
|
@@ -128,23 +201,52 @@ task :check do
|
|
128
201
|
ver = Gemgem.spec.version.to_s
|
129
202
|
|
130
203
|
if ENV['VERSION'].nil?
|
131
|
-
puts("\
|
132
|
-
"\
|
204
|
+
puts("\e[35mExpected " \
|
205
|
+
"\e[33mVERSION\e[35m=\e[33m#{ver}\e[0m")
|
133
206
|
exit(1)
|
134
207
|
|
135
208
|
elsif ENV['VERSION'] != ver
|
136
|
-
puts("\
|
137
|
-
"\
|
138
|
-
"\
|
209
|
+
puts("\e[35mExpected \e[33mVERSION\e[35m=\e[33m#{ver} " \
|
210
|
+
"\e[35mbut got\n " \
|
211
|
+
"\e[33mVERSION\e[35m=\e[33m#{ENV['VERSION']}\e[0m")
|
139
212
|
exit(2)
|
140
213
|
end
|
141
214
|
end
|
142
215
|
|
143
216
|
end # of gem namespace
|
144
217
|
|
145
|
-
desc 'Run tests'
|
218
|
+
desc 'Run tests in memory'
|
146
219
|
task :test do
|
147
|
-
|
220
|
+
require 'bacon'
|
221
|
+
Bacon.extend(Bacon::TestUnitOutput)
|
222
|
+
Bacon.summary_on_exit
|
223
|
+
$LOAD_PATH.unshift('lib')
|
224
|
+
Dir['./test/**/test_*.rb'].each{ |file| require file[0..-4] }
|
225
|
+
end
|
226
|
+
|
227
|
+
desc 'Run tests with shell'
|
228
|
+
task 'test:shell', :RUBY_OPTS do |t, args|
|
229
|
+
files = Dir['test/**/test_*.rb'].join(' ')
|
230
|
+
|
231
|
+
cmd = [Gem.ruby, args[:RUBY_OPTS],
|
232
|
+
'-I', 'lib', '-S', 'bacon', '--quiet', files]
|
233
|
+
|
234
|
+
sh(cmd.compact.join(' '))
|
235
|
+
end
|
236
|
+
|
237
|
+
desc 'Generate ann markdown'
|
238
|
+
task 'ann:md' => ['gem:spec'] do
|
239
|
+
puts Gemgem.ann_md
|
240
|
+
end
|
241
|
+
|
242
|
+
desc 'Generate ann html'
|
243
|
+
task 'ann:html' => ['gem:spec'] do
|
244
|
+
puts Gemgem.ann_html
|
245
|
+
end
|
246
|
+
|
247
|
+
desc 'Generate ann email'
|
248
|
+
task 'ann:email' => ['gem:spec'] do
|
249
|
+
puts Gemgem.ann_email
|
148
250
|
end
|
149
251
|
|
150
252
|
desc 'Generate rdoc'
|
@@ -153,7 +255,7 @@ task :doc => ['gem:spec'] do
|
|
153
255
|
" --files #{Gemgem.spec.extra_rdoc_files.join(',')}")
|
154
256
|
end
|
155
257
|
|
156
|
-
desc '
|
258
|
+
desc 'Remove ignored files'
|
157
259
|
task :clean => ['gem:spec'] do
|
158
260
|
trash = "~/.Trash/#{Gemgem.spec.name}/"
|
159
261
|
sh "mkdir -p #{trash}" unless File.exist?(File.expand_path(trash))
|
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dm-is-reflective
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.1
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.1
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Lin Jen-Shin (godfat)
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-05-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: dm-core
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: dm-do-adapter
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: dm-migrations
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: '0'
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: dm-sqlite-adapter
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ! '>='
|
@@ -54,10 +69,15 @@ dependencies:
|
|
54
69
|
version: '0'
|
55
70
|
type: :development
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
58
78
|
- !ruby/object:Gem::Dependency
|
59
79
|
name: dm-mysql-adapter
|
60
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
61
81
|
none: false
|
62
82
|
requirements:
|
63
83
|
- - ! '>='
|
@@ -65,10 +85,15 @@ dependencies:
|
|
65
85
|
version: '0'
|
66
86
|
type: :development
|
67
87
|
prerelease: false
|
68
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
69
94
|
- !ruby/object:Gem::Dependency
|
70
95
|
name: dm-postgres-adapter
|
71
|
-
requirement:
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
72
97
|
none: false
|
73
98
|
requirements:
|
74
99
|
- - ! '>='
|
@@ -76,30 +101,29 @@ dependencies:
|
|
76
101
|
version: '0'
|
77
102
|
type: :development
|
78
103
|
prerelease: false
|
79
|
-
version_requirements:
|
80
|
-
|
81
|
-
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
description: ! 'DataMapper plugin that helps you manipulate an existing database.
|
111
|
+
|
112
|
+
It creates mappings between existing columns and model''s properties.'
|
82
113
|
email:
|
83
114
|
- godfat (XD) godfat.org
|
84
115
|
executables: []
|
85
116
|
extensions: []
|
86
|
-
extra_rdoc_files:
|
87
|
-
- CHANGES
|
88
|
-
- CONTRIBUTORS
|
89
|
-
- LICENSE
|
90
|
-
- TODO
|
117
|
+
extra_rdoc_files: []
|
91
118
|
files:
|
92
119
|
- .gitignore
|
93
120
|
- .gitmodules
|
94
|
-
- CHANGES
|
95
|
-
- CONTRIBUTORS
|
121
|
+
- CHANGES.md
|
96
122
|
- Gemfile
|
97
123
|
- LICENSE
|
98
|
-
-
|
99
|
-
- README
|
100
|
-
- README.rdoc
|
124
|
+
- README.md
|
101
125
|
- Rakefile
|
102
|
-
- TODO
|
126
|
+
- TODO.md
|
103
127
|
- dm-is-reflective.gemspec
|
104
128
|
- lib/dm-is-reflective.rb
|
105
129
|
- lib/dm-is-reflective/is/adapters/data_objects_adapter.rb
|
@@ -107,8 +131,8 @@ files:
|
|
107
131
|
- lib/dm-is-reflective/is/adapters/postgres_adapter.rb
|
108
132
|
- lib/dm-is-reflective/is/adapters/sqlite_adapter.rb
|
109
133
|
- lib/dm-is-reflective/is/reflective.rb
|
110
|
-
- lib/dm-is-reflective/is/version.rb
|
111
134
|
- lib/dm-is-reflective/version.rb
|
135
|
+
- task/.gitignore
|
112
136
|
- task/gemgem.rb
|
113
137
|
- test/abstract.rb
|
114
138
|
- test/setup_db.sh
|
@@ -116,9 +140,7 @@ files:
|
|
116
140
|
homepage: https://github.com/godfat/dm-is-reflective
|
117
141
|
licenses: []
|
118
142
|
post_install_message:
|
119
|
-
rdoc_options:
|
120
|
-
- --main
|
121
|
-
- README
|
143
|
+
rdoc_options: []
|
122
144
|
require_paths:
|
123
145
|
- lib
|
124
146
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -130,15 +152,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
130
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
153
|
none: false
|
132
154
|
requirements:
|
133
|
-
- - ! '
|
155
|
+
- - ! '>='
|
134
156
|
- !ruby/object:Gem::Version
|
135
|
-
version:
|
157
|
+
version: '0'
|
136
158
|
requirements: []
|
137
159
|
rubyforge_project:
|
138
|
-
rubygems_version: 1.8.
|
160
|
+
rubygems_version: 1.8.24
|
139
161
|
signing_key:
|
140
162
|
specification_version: 3
|
141
|
-
summary: DataMapper plugin that helps you manipulate an existing database.
|
142
|
-
mappings between existing columns and model's properties.
|
163
|
+
summary: DataMapper plugin that helps you manipulate an existing database.
|
143
164
|
test_files:
|
144
165
|
- test/test_dm-is-reflective.rb
|
166
|
+
has_rdoc:
|
data/CHANGES
DELETED
@@ -1,201 +0,0 @@
|
|
1
|
-
= dm-is-reflective changes history
|
2
|
-
|
3
|
-
=== dm-is-reflective 1.0.1, ?
|
4
|
-
* allow_nil is more close to db's semantics, not required. Thanks miaout17.
|
5
|
-
`:allow_nil` allows empty value, but `:required` does not. So here we
|
6
|
-
always use `:allow_nil` to match db's semantics.
|
7
|
-
|
8
|
-
=== dm-is-reflective 1.0.0, 2011-06-16
|
9
|
-
* updated against dm-core 1.1.0
|
10
|
-
|
11
|
-
=== dm-is-reflective 0.9.0, 2010-07-05
|
12
|
-
* adapted to dm-core 1.0.0
|
13
|
-
* reanmed AbstractAdapter to DataObjectsAdapter
|
14
|
-
|
15
|
-
=== dm-is-reflective 0.8.0, 2009-09-16
|
16
|
-
* require dm-core 0.10.0 and above now
|
17
|
-
* Serial would map to Serial not Integer now
|
18
|
-
* no more type_map now
|
19
|
-
* no more Extlib::Hook to load adapter
|
20
|
-
|
21
|
-
=== dm-mapping 0.7.1, never released as a gem
|
22
|
-
don't open module Migration and edit it, instead, use include, more see:
|
23
|
-
* added DataMapper::Mapping::AbstractAdapter
|
24
|
-
* added DataMapper::Mapping::Sqlite3Adapter
|
25
|
-
* added DataMapper::Mapping::MysqlAdapter
|
26
|
-
* added DataMapper::Mapping::PostgresAdapter
|
27
|
-
* each adapter was included in related adapter in DataMapper.
|
28
|
-
* Model#fields now accept repository name as argument
|
29
|
-
|
30
|
-
there's differences between adapters,
|
31
|
-
Sqlite3 added default => 'UL' in Boolean type,
|
32
|
-
Mysql can't tell whether it's a Boolean or Tinyint,
|
33
|
-
and Postgres is fine. see test/abstract.rb: super_user_fields for detail.
|
34
|
-
|
35
|
-
=== dm-mapping 0.7.0, 2008-09-01
|
36
|
-
* feature added
|
37
|
-
- added postgres support.
|
38
|
-
* bug fixed
|
39
|
-
- fixed key mapping in mysql adapter. PRI and MUL are all keys.
|
40
|
-
- use DM::Text.size as default text size in sqlite3.
|
41
|
-
|
42
|
-
=== dm-mapping 0.6.2, 2008-08-30
|
43
|
-
* mapping more data types for mysql.
|
44
|
-
* don't map TINYINT to TrueClass with mysql, skip it in type_map.
|
45
|
-
|
46
|
-
=== dm-mapping 0.6.1, 2008-08-22
|
47
|
-
* gem 'dm-core', '>=0.9.3' instead of '=0.9.3'
|
48
|
-
|
49
|
-
=== dm-mapping 0.6.0, 2008-08-16
|
50
|
-
* mapping returns an array of properties indicating fields it mapped.
|
51
|
-
* performance boosted by refactored mapping implementation.
|
52
|
-
* changed the way using auto_genclass!, now accepts args like mapping!
|
53
|
-
* changed fields to return field name with Symbol instead of String.
|
54
|
-
this would make it be more consistent with DataMapper.
|
55
|
-
* storage names remain String.
|
56
|
-
* added more mysql data type to map
|
57
|
-
* use Extlib::Hook to setup dm-mapping instead of stupid alias_method.
|
58
|
-
* removed ensure_require in model. always setup DataMapper before define model.
|
59
|
-
|
60
|
-
=== dm-mapping 0.5.0, 2008-08-14
|
61
|
-
* feature added
|
62
|
-
- added mysql support.
|
63
|
-
- reflect size 65535 in TEXT for sqlite3.
|
64
|
-
* bug fixed
|
65
|
-
- reflect VARCHAR(size) instead of default size in sqlite3.
|
66
|
-
* misc
|
67
|
-
- renamed sqlite3adapter to sqlite3_adapter.
|
68
|
-
|
69
|
-
=== dm-mapping 0.4.1, 2008-08-14
|
70
|
-
* removed type hack, replaced with rejecting special type to lookup.
|
71
|
-
|
72
|
-
=== dm-mapping 0.4.0, 2008-08-04
|
73
|
-
* added Migration#auto_genclass!.
|
74
|
-
* updated README.
|
75
|
-
* added more rdoc.
|
76
|
-
|
77
|
-
=== dm-mapping 0.3.0, 2008-08-04
|
78
|
-
* added support of mapping Integer, DateTime, etc.
|
79
|
-
* renamed some internals.
|
80
|
-
* changed the way requiring adapter. no more setup first.
|
81
|
-
* added Migration#storages_and_fields
|
82
|
-
* added mapping :serial => true for primary key.
|
83
|
-
* added mapping :default, and :nullable.
|
84
|
-
* added support of mapping name. (through passing symbol or string)
|
85
|
-
* added support of multiple arguments.
|
86
|
-
* removed Mapping::All, use /.*/ instead.
|
87
|
-
|
88
|
-
=== dm-mapping 0.2.1, 2008-08-03
|
89
|
-
* fixed a bug that type map should lookup for parent.
|
90
|
-
* fixed a bug that sql type could be lower case.
|
91
|
-
fixed by calling upcase.
|
92
|
-
|
93
|
-
=== dm-mapping 0.2.0, 2008-08-02
|
94
|
-
* added Sqlite3Adapter::Migration#fields
|
95
|
-
* added DataMapper::Model#mapping
|
96
|
-
* added DataMapper::Model#fields
|
97
|
-
* added DataMapper::TypeMap#find_primitive for reversed lookup.
|
98
|
-
mapping SQL type back to Ruby type.
|
99
|
-
* added corresponded test.
|
100
|
-
|
101
|
-
=== dm-mapping 0.1.0, 2008-07-27
|
102
|
-
* birthday!
|
103
|
-
* added DataMapper.repository.storages for sqlite3.
|
104
|
-
* please refer:
|
105
|
-
http://groups.google.com/group/datamapper/browse_thread/thread/b9ca41120c5c9389
|
106
|
-
|
107
|
-
original message:
|
108
|
-
|
109
|
-
from Lin Jen-Shin
|
110
|
-
to DataMapper
|
111
|
-
cc godfat
|
112
|
-
date Sun, Jul 27, 2008 at 5:40 PM
|
113
|
-
subject Manipulate an existing database.
|
114
|
-
mailed-by gmail.com
|
115
|
-
|
116
|
-
Greetings,
|
117
|
-
|
118
|
-
DataMapper looks very promising for me, so I am thinking of
|
119
|
-
using it in the near future. I hate separate my domain objects into
|
120
|
-
two parts in Rails, writing migration and switching to ActiveRecord,
|
121
|
-
vice versa, is very annoying to me.
|
122
|
-
|
123
|
-
But there's a very convenient feature to me in ActiveRecord,
|
124
|
-
that is ActiveRecord automatically mapping all fields in a table.
|
125
|
-
It makes me easily control an existing database without any domain object.
|
126
|
-
|
127
|
-
For example,
|
128
|
-
|
129
|
-
require 'active_record'
|
130
|
-
|
131
|
-
ActiveRecord::Base.establish_connection(
|
132
|
-
:adapter => 'sqlite3',
|
133
|
-
:database => 'db/development.sqlite3'
|
134
|
-
)
|
135
|
-
|
136
|
-
clsas User < ActiveRecord::Base
|
137
|
-
end
|
138
|
-
|
139
|
-
User.find 1
|
140
|
-
=> #<User id: 1, account: "admin", created_at: "2008-05-18 20:08:37", etc.>
|
141
|
-
|
142
|
-
Some people would use database admin such as phpMyAdmin to
|
143
|
-
accomplish this kind of task, but I prefer anything in Ruby,
|
144
|
-
calling Ruby function, manipulating data without SQL and
|
145
|
-
any domain object. (i.e. I didn't have to load up entire environment.)
|
146
|
-
|
147
|
-
In DataMapper, I didn't find an easy way to accomplish this.
|
148
|
-
I am sorry if there's one but I didn't find it, please point out,
|
149
|
-
many thanks. In short, I would like to do this in DataMapper:
|
150
|
-
|
151
|
-
class User
|
152
|
-
include DataMapper::Resource
|
153
|
-
mapping :account, :created_at
|
154
|
-
end
|
155
|
-
|
156
|
-
or
|
157
|
-
|
158
|
-
class User
|
159
|
-
include DataMapper::Resource
|
160
|
-
mapping All
|
161
|
-
end
|
162
|
-
|
163
|
-
class User
|
164
|
-
include DataMapper::ResourceAll
|
165
|
-
end
|
166
|
-
|
167
|
-
or
|
168
|
-
|
169
|
-
class User
|
170
|
-
include DataMapper::Resource
|
171
|
-
mapping *storage_fields
|
172
|
-
end
|
173
|
-
|
174
|
-
The above User.storage_fields should return an Array,
|
175
|
-
telling all the fields in the table, e.g. [:account, :created_at, :etc]
|
176
|
-
or a Hash includes data type, e.g. {:account => String,
|
177
|
-
:created_at => DateTime}
|
178
|
-
then mapping *storage_fields should change to:
|
179
|
-
|
180
|
-
mapping *storage_fields.each_key.to_a
|
181
|
-
|
182
|
-
If it's possible, a feature returning the database schema as well:
|
183
|
-
|
184
|
-
DataMapper.repository.storages
|
185
|
-
# => [:users, :posts, :etc]
|
186
|
-
|
187
|
-
DataMapper.repository.storages_and_fields
|
188
|
-
# => {:users => {:account => String},
|
189
|
-
:posts => {:title => String, :content => Text}}
|
190
|
-
|
191
|
-
or returning DataObject::Field, DataObject::Storage, etc.
|
192
|
-
|
193
|
-
DataMapper.repository.storage
|
194
|
-
# => [#<DataObject::Storage @name='users' @fields=
|
195
|
-
[#<DataObject::Field @name='account' @type=String>]>]
|
196
|
-
|
197
|
-
If you feel this kind of feature is indeed needed or not bad for
|
198
|
-
adding it, I could try to provide a patch for it. Though I didn't
|
199
|
-
read the source code deeply, not knowning it's easy or not.
|
200
|
-
|
201
|
-
sincerely,
|