dr_nic_magic_models 0.8.1 → 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.
- data/History.txt +10 -0
- data/Manifest.txt +55 -0
- data/README +268 -0
- data/Rakefile +82 -107
- data/lib/base.rb +1 -5
- data/lib/dr_nic_magic_models.rb +4 -1
- data/lib/dr_nic_magic_models/inflector.rb +14 -0
- data/lib/dr_nic_magic_models/magic_model.rb +125 -0
- data/lib/dr_nic_magic_models/schema.rb +224 -196
- data/lib/dr_nic_magic_models/validations.rb +6 -6
- data/lib/dr_nic_magic_models/version.rb +2 -2
- data/lib/module.rb +33 -0
- data/scripts/txt2html +3 -2
- data/scripts/txt2js +3 -2
- data/test.db +0 -0
- data/test/abstract_unit.rb +4 -0
- data/test/connections/native_postgresql/connection.rb +0 -2
- data/test/connections/native_sqlite/connection.rb +10 -0
- data/test/fixtures/.DS_Store +0 -0
- data/test/fixtures/db_definitions/mysql.sql +0 -2
- data/test/fixtures/db_definitions/postgresql.sql +0 -1
- data/test/fixtures/db_definitions/sqlite.sql +49 -0
- data/test/invisible_model_access_test.rb +8 -2
- data/test/invisible_model_assoc_test.rb +17 -13
- data/test/magic_module_test.rb +20 -0
- data/website/index.html +283 -297
- data/website/index.txt +4 -16
- data/website/version-raw.js +1 -1
- data/website/version.js +1 -1
- metadata +53 -56
- data/scripts/http-access2-2.0.6.gem +0 -0
- data/scripts/rubyforge-orig +0 -217
- data/test/fixtures/db_definitions/postgresql.drop.sql +0 -4
data/website/index.txt
CHANGED
@@ -1,17 +1,5 @@
|
|
1
1
|
h1. Dr Nic's Magic Models
|
2
2
|
|
3
|
-
h2. News alert
|
4
|
-
|
5
|
-
Assocations now generated using "Foreign Keys":foreignkeys.html too!
|
6
|
-
|
7
|
-
Now... on with the magic show!
|
8
|
-
<br />
|
9
|
-
<br />
|
10
|
-
|
11
|
-
<blockquote>
|
12
|
-
*conjure* 1. To create events that appear to be magical<br />
|
13
|
-
- "David Copperfield":http://www.dcopperfield.com/ website
|
14
|
-
</blockquote>
|
15
3
|
If you've used Ruby on Rails you'll have written at least one model class like this:
|
16
4
|
|
17
5
|
<pre syntax='ruby'>
|
@@ -46,15 +34,15 @@ class Person < ActiveRecord::Base; end
|
|
46
34
|
or, if you read right to the end of this page, this...
|
47
35
|
|
48
36
|
<pre syntax='ruby'>
|
49
|
-
|
37
|
+
# Go fish.
|
50
38
|
</pre>
|
51
39
|
|
52
40
|
Magic and mystery abound. All for you. Impress your friends, amaze your mother.
|
53
41
|
|
54
|
-
NOTE: The gratuitous use of *Dr Nic's* in the name should only enhance the mystical
|
42
|
+
NOTE: The gratuitous use of *Dr Nic's* in the name should only enhance the mystical magikery,
|
55
43
|
for magic needs a magician; and I love magic. I always wanted to create my own magic trick.
|
56
|
-
So I shall be the magician for the sake of magic itself. I look a bit like Harry Potter
|
57
|
-
if Harry were
|
44
|
+
So I shall be the magician for the sake of magic itself. I look a bit like Harry Potter too,
|
45
|
+
if Harry were 32 and better dressed.
|
58
46
|
|
59
47
|
h2. Installation
|
60
48
|
|
data/website/version-raw.js
CHANGED
data/website/version.js
CHANGED
metadata
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.
|
2
|
+
rubygems_version: 0.9.2
|
3
3
|
specification_version: 1
|
4
4
|
name: dr_nic_magic_models
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date:
|
8
|
-
summary: Invisible validations, assocations and Active Record models themselves!
|
6
|
+
version: 0.9.0
|
7
|
+
date: 2007-04-09 00:00:00 +02:00
|
8
|
+
summary: Dr Nic's Magic Models - Invisible validations, assocations and Active Record models themselves!
|
9
9
|
require_paths:
|
10
10
|
- lib
|
11
11
|
email: drnicwilliams@gmail.com
|
12
12
|
homepage: http://magicmodels.rubyforge.org
|
13
13
|
rubyforge_project: magicmodels
|
14
|
-
description:
|
15
|
-
autorequire:
|
14
|
+
description: Dr Nic's Magic Models - Invisible validations, assocations and Active Record models themselves!
|
15
|
+
autorequire:
|
16
16
|
default_executable:
|
17
17
|
bindir: bin
|
18
18
|
has_rdoc: true
|
@@ -25,74 +25,71 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
25
25
|
platform: ruby
|
26
26
|
signing_key:
|
27
27
|
cert_chain:
|
28
|
+
post_install_message:
|
28
29
|
authors:
|
29
|
-
-
|
30
|
+
- nicwilliams
|
30
31
|
files:
|
32
|
+
- CHANGELOG
|
33
|
+
- History.txt
|
34
|
+
- Manifest.txt
|
35
|
+
- README
|
31
36
|
- Rakefile
|
32
37
|
- install.rb
|
33
|
-
- README
|
34
|
-
- CHANGELOG
|
35
|
-
- lib/dr_nic_magic_models
|
36
|
-
- lib/connection_adapters
|
37
|
-
- lib/dr_nic_magic_models.rb
|
38
38
|
- lib/base.rb
|
39
|
-
- lib/
|
40
|
-
- lib/dr_nic_magic_models/validations.rb
|
41
|
-
- lib/dr_nic_magic_models/schema.rb
|
42
|
-
- lib/dr_nic_magic_models/version.rb
|
43
|
-
- lib/connection_adapters/abstract
|
39
|
+
- lib/connection_adapters/abstract/schema_statements.rb
|
44
40
|
- lib/connection_adapters/abstract_adapter.rb
|
45
|
-
- lib/connection_adapters/postgresql_adapter.rb
|
46
41
|
- lib/connection_adapters/mysql_adapter.rb
|
47
|
-
- lib/connection_adapters/
|
48
|
-
-
|
49
|
-
-
|
50
|
-
-
|
42
|
+
- lib/connection_adapters/postgresql_adapter.rb
|
43
|
+
- lib/dr_nic_magic_models.rb
|
44
|
+
- lib/dr_nic_magic_models/inflector.rb
|
45
|
+
- lib/dr_nic_magic_models/magic_model.rb
|
46
|
+
- lib/dr_nic_magic_models/schema.rb
|
47
|
+
- lib/dr_nic_magic_models/validations.rb
|
48
|
+
- lib/dr_nic_magic_models/version.rb
|
49
|
+
- lib/module.rb
|
50
|
+
- lib/rails.rb
|
51
|
+
- scripts/txt2html
|
52
|
+
- scripts/txt2js
|
53
|
+
- test.db
|
51
54
|
- test/abstract_unit.rb
|
52
|
-
- test/foreign_keys_test.rb
|
53
|
-
- test/invisible_model_access_test.rb
|
54
|
-
- test/env_test.rb
|
55
|
-
- test/fun_user_plus.rb
|
56
|
-
- test/dummy_test.rb
|
57
|
-
- test/invisible_model_assoc_test.rb
|
58
|
-
- test/connections/native_postgresql
|
59
|
-
- test/connections/native_mysql
|
60
|
-
- test/connections/native_postgresql/connection.rb
|
61
55
|
- test/connections/native_mysql/connection.rb
|
62
|
-
- test/
|
63
|
-
- test/
|
56
|
+
- test/connections/native_postgresql/connection.rb
|
57
|
+
- test/connections/native_sqlite/connection.rb
|
58
|
+
- test/dummy_test.rb
|
59
|
+
- test/env_test.rb
|
60
|
+
- test/fixtures/.DS_Store
|
64
61
|
- test/fixtures/adjectives.yml
|
65
|
-
- test/fixtures/group_tag.yml
|
66
|
-
- test/fixtures/fun_users.yml
|
67
62
|
- test/fixtures/adjectives_fun_users.yml
|
68
|
-
- test/fixtures/group_memberships.yml
|
69
|
-
- test/fixtures/db_definitions/postgresql.sql
|
70
|
-
- test/fixtures/db_definitions/mysql.sql
|
71
|
-
- test/fixtures/db_definitions/postgresql.drop.sql
|
72
63
|
- test/fixtures/db_definitions/mysql.drop.sql
|
73
|
-
-
|
74
|
-
-
|
75
|
-
-
|
76
|
-
-
|
77
|
-
-
|
64
|
+
- test/fixtures/db_definitions/mysql.sql
|
65
|
+
- test/fixtures/db_definitions/postgresql.sql
|
66
|
+
- test/fixtures/db_definitions/sqlite.sql
|
67
|
+
- test/fixtures/fun_users.yml
|
68
|
+
- test/fixtures/group_memberships.yml
|
69
|
+
- test/fixtures/group_tag.yml
|
70
|
+
- test/fixtures/groups.yml
|
71
|
+
- test/foreign_keys_test.rb
|
72
|
+
- test/fun_user_plus.rb
|
73
|
+
- test/invisible_model_access_test.rb
|
74
|
+
- test/invisible_model_assoc_test.rb
|
75
|
+
- test/invisible_model_classes_test.rb
|
76
|
+
- test/magic_module_test.rb
|
77
|
+
- website/index.html
|
78
78
|
- website/index.txt
|
79
|
+
- website/javascripts/rounded_corners_lite.inc.js
|
80
|
+
- website/stylesheets/screen.css
|
79
81
|
- website/template.js
|
82
|
+
- website/template.rhtml
|
80
83
|
- website/version-raw.js
|
81
|
-
- website/index.html
|
82
84
|
- website/version-raw.txt
|
83
|
-
- website/
|
84
|
-
- website/
|
85
|
-
- scripts/rubyforge-orig
|
86
|
-
- scripts/txt2html
|
87
|
-
- scripts/http-access2-2.0.6.gem
|
88
|
-
- scripts/txt2js
|
85
|
+
- website/version.js
|
86
|
+
- website/version.txt
|
89
87
|
test_files: []
|
90
88
|
|
91
|
-
rdoc_options:
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
- README
|
89
|
+
rdoc_options: []
|
90
|
+
|
91
|
+
extra_rdoc_files: []
|
92
|
+
|
96
93
|
executables: []
|
97
94
|
|
98
95
|
extensions: []
|
Binary file
|
data/scripts/rubyforge-orig
DELETED
@@ -1,217 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# RENAME THIS to rubyorge, and change username/password below to your rubyforge details.
|
4
|
-
# Set rubyforge file to Ignore on Subversion.
|
5
|
-
# libs
|
6
|
-
#
|
7
|
-
$VERBOSE = nil
|
8
|
-
require "getoptlong"
|
9
|
-
require "enumerator"
|
10
|
-
require "http-access2"
|
11
|
-
#
|
12
|
-
# config
|
13
|
-
#
|
14
|
-
config = {
|
15
|
-
"username" => "username", # this must be your username
|
16
|
-
"password" => "password", # this must be your password
|
17
|
-
|
18
|
-
"group_id" => 1953, # see source of http://rubyforge.org/frs/admin/qrs.php?package=&group_id=1953
|
19
|
-
|
20
|
-
"package_ids" => { # configure shortcuts for your packages here
|
21
|
-
"compositekeys" => 2327,
|
22
|
-
},
|
23
|
-
|
24
|
-
"uri" => "http://rubyforge.org",
|
25
|
-
"cookie_jar" => File::join(File::expand_path("~"), ".rubyforge.cookie_jar"),
|
26
|
-
}
|
27
|
-
|
28
|
-
opts =
|
29
|
-
GetoptLong::new(
|
30
|
-
[ "--username" , "-u" , GetoptLong::REQUIRED_ARGUMENT ] ,
|
31
|
-
[ "--password" , "-p" , GetoptLong::REQUIRED_ARGUMENT ] ,
|
32
|
-
[ "--cookie_jar" , "-c" , GetoptLong::REQUIRED_ARGUMENT ]
|
33
|
-
).enum_for.inject({}){|h,kv| h.update Hash[*kv]}
|
34
|
-
|
35
|
-
username = opts['username'] || config['username']
|
36
|
-
password = opts['password'] || config['password']
|
37
|
-
cookie_jar = opts["cookie_jar"] || config['cookie_jar']
|
38
|
-
#
|
39
|
-
# setup
|
40
|
-
#
|
41
|
-
mode = ARGV.shift
|
42
|
-
abort "#{ $0 } [login|create_package (package_name)|add_package (package_id release_name release.ext)]" unless mode
|
43
|
-
|
44
|
-
page, form, method = nil
|
45
|
-
extheader = {}
|
46
|
-
|
47
|
-
case mode
|
48
|
-
|
49
|
-
when %r/login/
|
50
|
-
page = "/account/login.php"
|
51
|
-
method = "post_content"
|
52
|
-
|
53
|
-
form = {
|
54
|
-
"return_to" => "",
|
55
|
-
"form_loginname" => username,
|
56
|
-
"form_pw" => password,
|
57
|
-
"login" => "Login"
|
58
|
-
}
|
59
|
-
|
60
|
-
when %r/create_package/
|
61
|
-
page = "/frs/admin/index.php"
|
62
|
-
method = "post_content"
|
63
|
-
|
64
|
-
opts =
|
65
|
-
GetoptLong::new(
|
66
|
-
[ "--group_id" , "-g" , GetoptLong::REQUIRED_ARGUMENT ] ,
|
67
|
-
[ "--is_private" , "-P" , GetoptLong::REQUIRED_ARGUMENT ]
|
68
|
-
).enum_for.inject({}){|h,kv| h.update Hash[*kv]}
|
69
|
-
|
70
|
-
package_name = ARGV.shift
|
71
|
-
abort "#{ $0 } package_name" unless package_name
|
72
|
-
|
73
|
-
group_id = opts["group_id"] || config["group_id"]
|
74
|
-
is_public = opts["is_private"] ? 0 : 1
|
75
|
-
|
76
|
-
form = {
|
77
|
-
"group_id" => group_id,
|
78
|
-
"package_name" => package_name,
|
79
|
-
"func" => "add_package",
|
80
|
-
"is_public" => is_public,
|
81
|
-
"submit" => "Create This Package",
|
82
|
-
}
|
83
|
-
|
84
|
-
when %r/add_release/
|
85
|
-
page = "/frs/admin/qrs.php"
|
86
|
-
method = "post_content"
|
87
|
-
|
88
|
-
opts =
|
89
|
-
GetoptLong::new(
|
90
|
-
[ "--group_id" , "-g" , GetoptLong::REQUIRED_ARGUMENT ] ,
|
91
|
-
[ "--release_date" , "-r" , GetoptLong::REQUIRED_ARGUMENT ] ,
|
92
|
-
[ "--type_id" , "-t" , GetoptLong::REQUIRED_ARGUMENT ] ,
|
93
|
-
[ "--processor_id" , "-P" , GetoptLong::REQUIRED_ARGUMENT ] ,
|
94
|
-
[ "--release_nots" , "-n" , GetoptLong::REQUIRED_ARGUMENT ] ,
|
95
|
-
[ "--release_changes" , "-a" , GetoptLong::REQUIRED_ARGUMENT ]
|
96
|
-
).enum_for.inject({}){|h,kv| h.update Hash[*kv]}
|
97
|
-
|
98
|
-
package_id, release_name, userfile, ignored = ARGV
|
99
|
-
abort "#{ $0 } package_name" unless
|
100
|
-
package_id and release_name and userfile
|
101
|
-
|
102
|
-
package_id = config["package_ids"][package_id] unless
|
103
|
-
package_id =~ %r/^\d+$/
|
104
|
-
|
105
|
-
group_id = opts["group_id"] || config["group_id"]
|
106
|
-
release_date = opts["release_date"] || Time::now.strftime('%Y-%m-%d %H:%M')
|
107
|
-
|
108
|
-
type_id = opts['type_id'] || userfile[%r|\.[^\./]+$|]
|
109
|
-
type_id = {
|
110
|
-
".deb" => 1000,
|
111
|
-
".rpm" => 2000,
|
112
|
-
".zip" => 3000,
|
113
|
-
".bz2" => 3100,
|
114
|
-
".gz" => 3110,
|
115
|
-
".src.zip" => 5000,
|
116
|
-
".src.bz2" => 5010,
|
117
|
-
".src.gz" => 5020,
|
118
|
-
".src.rpm" => 5100,
|
119
|
-
".src" => 5900,
|
120
|
-
".jpg" => 8000,
|
121
|
-
".txt" => 8100,
|
122
|
-
".text" => 8100,
|
123
|
-
".htm" => 8200,
|
124
|
-
".html" => 8200,
|
125
|
-
".pdf" => 8300,
|
126
|
-
".oth" => 9999,
|
127
|
-
".ebuild" => 1300,
|
128
|
-
".exe" => 1100,
|
129
|
-
".dmg" => 1200,
|
130
|
-
".tar.gz" => 5000,
|
131
|
-
".tgz" => 5000,
|
132
|
-
".gem" => 1400,
|
133
|
-
".pgp" => 8150,
|
134
|
-
".sig" => 8150,
|
135
|
-
}[type_id]
|
136
|
-
|
137
|
-
processor_id = opts['processor_id'] || 'Any'
|
138
|
-
processor_id = {
|
139
|
-
"i386" => 1000,
|
140
|
-
"IA64" => 6000,
|
141
|
-
"Alpha" => 7000,
|
142
|
-
"Any" => 8000,
|
143
|
-
"PPC" => 2000,
|
144
|
-
"MIPS" => 3000,
|
145
|
-
"Sparc" => 4000,
|
146
|
-
"UltraSparc" => 5000,
|
147
|
-
"Other" => 9999,
|
148
|
-
}[processor_id]
|
149
|
-
|
150
|
-
release_notes = opts['release_notes'] || nil
|
151
|
-
release_notes = open(release_notes) if release_notes
|
152
|
-
|
153
|
-
release_changes = opts['release_changes'] || nil
|
154
|
-
release_changes = open(release_changes) if release_changes
|
155
|
-
|
156
|
-
userfile = open(userfile)
|
157
|
-
|
158
|
-
preformatted = '1'
|
159
|
-
|
160
|
-
form = {
|
161
|
-
"group_id" => group_id,
|
162
|
-
"package_id" => package_id,
|
163
|
-
"release_name" => release_name,
|
164
|
-
"release_date" => release_date,
|
165
|
-
"type_id" => type_id,
|
166
|
-
"processor_id" => processor_id,
|
167
|
-
"preformatted" => preformatted,
|
168
|
-
"userfile" => userfile,
|
169
|
-
"submit" => "Release File"
|
170
|
-
}
|
171
|
-
|
172
|
-
boundary = Array::new(8){ "%2.2d" % rand(42) }.join('__')
|
173
|
-
extheader['content-type'] = "multipart/form-data; boundary=___#{ boundary }___"
|
174
|
-
|
175
|
-
else
|
176
|
-
abort "#{ $0 } login create_package add_release"
|
177
|
-
|
178
|
-
end
|
179
|
-
#
|
180
|
-
# http transaction
|
181
|
-
#
|
182
|
-
client = HTTPAccess2::Client::new ENV['HTTP_PROXY']
|
183
|
-
client.debug_dev = STDERR if ENV['DEBUG']
|
184
|
-
|
185
|
-
client.set_cookie_store cookie_jar
|
186
|
-
|
187
|
-
# fixes http-access2 bug
|
188
|
-
client.redirect_uri_callback = lambda do |res|
|
189
|
-
page = res.header['location'].first
|
190
|
-
page = page =~ %r/http/ ? page : "#{ config['uri'] }/#{ page }"
|
191
|
-
page
|
192
|
-
end
|
193
|
-
|
194
|
-
response = client.send "#{ method }", "#{ config['uri'] }/#{ page }", form, extheader
|
195
|
-
|
196
|
-
client.save_cookie_store
|
197
|
-
|
198
|
-
# fixes http-access2 bug
|
199
|
-
BEGIN {
|
200
|
-
require "http-access2"
|
201
|
-
module WebAgent::CookieUtils
|
202
|
-
def domain_match(host, domain)
|
203
|
-
case domain
|
204
|
-
when /\d+\.\d+\.\d+\.\d+/
|
205
|
-
return (host == domain)
|
206
|
-
when '.'
|
207
|
-
return true
|
208
|
-
when /^\./
|
209
|
-
#return tail_match?(domain, host)
|
210
|
-
return tail_match?(host, domain)
|
211
|
-
else
|
212
|
-
return (host == domain)
|
213
|
-
end
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
}
|