merb-admin 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +6 -1
- data/Rakefile +1 -1
- data/app/controllers/application.rb +1 -1
- data/lib/abstract_model.rb +14 -2
- data/lib/activerecord_support.rb +0 -24
- data/lib/datamapper_support.rb +0 -24
- data/lib/merb-admin/slicetasks.rb +1 -1
- data/lib/merb-admin.rb +1 -1
- data/lib/sequel_support.rb +9 -38
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -3,10 +3,13 @@
|
|
3
3
|
It currently offers the features listed here[http://sferik.tadalist.com/lists/1352791/public].
|
4
4
|
|
5
5
|
The status of the latest build is available here[http://runcoderun.com/sferik/merb-admin].
|
6
|
+
== Screenshots
|
7
|
+
http://github.com/sferik/merb-admin/raw/master/screenshots/list.png
|
8
|
+
http://github.com/sferik/merb-admin/raw/master/screenshots/edit.png
|
6
9
|
== Installation
|
7
10
|
$ gem install merb-admin -s http://gemcutter.org
|
8
11
|
In your app, add the following dependency to <tt>config/dependencies.rb</tt>:
|
9
|
-
dependency "merb-admin", "0.6.
|
12
|
+
dependency "merb-admin", "0.6.1"
|
10
13
|
Add the following route to <tt>config/router.rb</tt>:
|
11
14
|
add_slice(:merb_admin, :path_prefix => "admin")
|
12
15
|
Then, run the following rake task:
|
@@ -32,6 +35,7 @@ There are many ways to contribute:
|
|
32
35
|
* by writing documentation
|
33
36
|
* by writing specifications
|
34
37
|
* by writing code (no patch is too small: fix typos in comments or inconsistent whitespace)
|
38
|
+
* by reviewing patches
|
35
39
|
* financially[http://pledgie.com/campaigns/5428]
|
36
40
|
|
37
41
|
All contributors will be added to the credits below and will receive the respect and gratitude of the author.
|
@@ -43,4 +47,5 @@ Many thanks to:
|
|
43
47
|
* {Aaron Wheeler}[http://fightinjoe.com/] for contributing libraries from {Merb AutoScaffold}[http://github.com/fightinjoe/merb-autoscaffold]
|
44
48
|
* {Lori Holden}[http://loriholden.com/] for contributing the merb-pagination[http://github.com/lholden/merb-pagination] helper
|
45
49
|
* {Jacques Crocker}[http://merbjedi.com] for adding support for {namespaced models}[http://github.com/merbjedi/merb-admin/commit/8139e2241038baf9b72452056fcdc7c340d79275]
|
50
|
+
* {Jeremy Evans}[http://code.jeremyevans.net] and {Pavel Kunc}[http://www.merboutpost.com] reviewing the {patch}[http://github.com/sferik/merb-admin/commit/061fa28f652fc9214e9cf480d66870140181edef] to add Sequel[http://sequel.rubyforge.org/] support
|
46
51
|
Also, thanks to beer[http://www.21st-amendment.com].
|
data/Rakefile
CHANGED
@@ -9,7 +9,7 @@ AUTHOR = "Erik Michaels-Ober"
|
|
9
9
|
EMAIL = "sferik@gmail.com"
|
10
10
|
HOMEPAGE = "http://github.com/sferik/merb-admin"
|
11
11
|
SUMMARY = "MerbAdmin is a Merb plugin that provides an easy-to-use interface for managing your data."
|
12
|
-
GEM_VERSION = "0.6.
|
12
|
+
GEM_VERSION = "0.6.1"
|
13
13
|
|
14
14
|
spec = Gem::Specification.new do |s|
|
15
15
|
s.rubyforge_project = "merb"
|
data/lib/abstract_model.rb
CHANGED
@@ -48,11 +48,11 @@ module MerbAdmin
|
|
48
48
|
|
49
49
|
case Merb.orm
|
50
50
|
when :activerecord
|
51
|
-
return model if model.
|
51
|
+
return model if superclasses(model).include?(ActiveRecord::Base)
|
52
52
|
when :datamapper
|
53
53
|
return model if model.include?(DataMapper::Resource)
|
54
54
|
when :sequel
|
55
|
-
return model if model.
|
55
|
+
return model if superclasses(model).include?(Sequel::Model)
|
56
56
|
end
|
57
57
|
nil
|
58
58
|
end
|
@@ -77,5 +77,17 @@ module MerbAdmin
|
|
77
77
|
raise "MerbAdmin does not support the #{Merb.orm} ORM"
|
78
78
|
end
|
79
79
|
end
|
80
|
+
|
81
|
+
private
|
82
|
+
|
83
|
+
def self.superclasses(klass)
|
84
|
+
superclasses = []
|
85
|
+
while klass
|
86
|
+
superclasses << klass.superclass if klass && klass.superclass
|
87
|
+
klass = klass.superclass
|
88
|
+
end
|
89
|
+
superclasses
|
90
|
+
end
|
91
|
+
|
80
92
|
end
|
81
93
|
end
|
data/lib/activerecord_support.rb
CHANGED
@@ -143,33 +143,9 @@ module MerbAdmin
|
|
143
143
|
end
|
144
144
|
|
145
145
|
module InstanceMethods
|
146
|
-
def id
|
147
|
-
super
|
148
|
-
end
|
149
|
-
|
150
|
-
def save
|
151
|
-
super
|
152
|
-
end
|
153
|
-
|
154
|
-
def destroy
|
155
|
-
super
|
156
|
-
end
|
157
|
-
|
158
|
-
def update_attributes(attributes)
|
159
|
-
super
|
160
|
-
end
|
161
|
-
|
162
|
-
def errors
|
163
|
-
super
|
164
|
-
end
|
165
|
-
|
166
146
|
def clear_association(association)
|
167
147
|
association.clear
|
168
148
|
end
|
169
|
-
|
170
|
-
def reset
|
171
|
-
super
|
172
|
-
end
|
173
149
|
end
|
174
150
|
|
175
151
|
end
|
data/lib/datamapper_support.rb
CHANGED
@@ -133,33 +133,9 @@ module MerbAdmin
|
|
133
133
|
end
|
134
134
|
|
135
135
|
module InstanceMethods
|
136
|
-
def id
|
137
|
-
super
|
138
|
-
end
|
139
|
-
|
140
|
-
def save
|
141
|
-
super
|
142
|
-
end
|
143
|
-
|
144
|
-
def destroy
|
145
|
-
super
|
146
|
-
end
|
147
|
-
|
148
|
-
def update_attributes(attributes)
|
149
|
-
super
|
150
|
-
end
|
151
|
-
|
152
|
-
def errors
|
153
|
-
super
|
154
|
-
end
|
155
|
-
|
156
136
|
def clear_association(association)
|
157
137
|
association.clear
|
158
138
|
end
|
159
|
-
|
160
|
-
def reset
|
161
|
-
super
|
162
|
-
end
|
163
139
|
end
|
164
140
|
|
165
141
|
end
|
@@ -92,7 +92,7 @@ def load_data
|
|
92
92
|
end
|
93
93
|
|
94
94
|
puts "Loading current MLB leagues, divisions, teams, and players"
|
95
|
-
MLB.
|
95
|
+
MLB::Teams.all.each do |mlb_team|
|
96
96
|
unless league = MerbAdmin::AbstractModel.new("League").first(:conditions => ["name = ?", mlb_team.league])
|
97
97
|
league = MerbAdmin::AbstractModel.new("League").create(:name => mlb_team.league)
|
98
98
|
end
|
data/lib/merb-admin.rb
CHANGED
@@ -23,7 +23,7 @@ if defined?(Merb::Plugins)
|
|
23
23
|
|
24
24
|
# Slice metadata
|
25
25
|
self.description = "MerbAdmin is a Merb plugin that provides an easy-to-use interface for managing your data."
|
26
|
-
self.version = "0.6.
|
26
|
+
self.version = "0.6.1"
|
27
27
|
self.author = "Erik Michaels-Ober"
|
28
28
|
|
29
29
|
# Stub classes loaded hook - runs before LoadClasses BootLoader
|
data/lib/sequel_support.rb
CHANGED
@@ -29,8 +29,7 @@ module MerbAdmin
|
|
29
29
|
|
30
30
|
def count(options = {})
|
31
31
|
if options[:conditions] && !options[:conditions].empty?
|
32
|
-
|
33
|
-
model.where(options[:conditions].clone).count
|
32
|
+
model.where(options[:conditions]).count
|
34
33
|
else
|
35
34
|
model.count
|
36
35
|
end
|
@@ -41,8 +40,7 @@ module MerbAdmin
|
|
41
40
|
sort_order = options.delete(:sort_reverse) ? :desc : :asc
|
42
41
|
|
43
42
|
if options[:conditions] && !options[:conditions].empty?
|
44
|
-
|
45
|
-
model.order(sort.to_sym.send(sort_order)).first(options[:conditions].clone).extend(InstanceMethods)
|
43
|
+
model.order(sort.to_sym.send(sort_order)).first(options[:conditions]).extend(InstanceMethods)
|
46
44
|
else
|
47
45
|
model.order(sort.to_sym.send(sort_order)).first.extend(InstanceMethods)
|
48
46
|
end
|
@@ -56,8 +54,7 @@ module MerbAdmin
|
|
56
54
|
sort_order = options.delete(:sort_reverse) ? :desc : :asc
|
57
55
|
|
58
56
|
if options[:conditions] && !options[:conditions].empty?
|
59
|
-
|
60
|
-
model.where(options[:conditions].clone).order(sort.to_sym.send(sort_order))
|
57
|
+
model.where(options[:conditions]).order(sort.to_sym.send(sort_order))
|
61
58
|
else
|
62
59
|
model.order(sort.to_sym.send(sort_order))
|
63
60
|
end
|
@@ -72,8 +69,7 @@ module MerbAdmin
|
|
72
69
|
sort_order = options.delete(:sort_reverse) ? :desc : :asc
|
73
70
|
|
74
71
|
if options[:conditions] && !options[:conditions].empty?
|
75
|
-
|
76
|
-
[page_count, model.paginate(page.to_i, per_page).where(options[:conditions].clone).order(sort.to_sym.send(sort_order))]
|
72
|
+
[page_count, model.paginate(page.to_i, per_page).where(options[:conditions]).order(sort.to_sym.send(sort_order))]
|
77
73
|
else
|
78
74
|
[page_count, model.paginate(page.to_i, per_page).order(sort.to_sym.send(sort_order))]
|
79
75
|
end
|
@@ -88,9 +84,7 @@ module MerbAdmin
|
|
88
84
|
end
|
89
85
|
|
90
86
|
def destroy_all!
|
91
|
-
model.
|
92
|
-
object.destroy
|
93
|
-
end
|
87
|
+
model.destroy
|
94
88
|
end
|
95
89
|
|
96
90
|
def has_many_associations
|
@@ -197,7 +191,7 @@ module MerbAdmin
|
|
197
191
|
association[:name]
|
198
192
|
end
|
199
193
|
when :many_to_one
|
200
|
-
|
194
|
+
association[:name]
|
201
195
|
else
|
202
196
|
raise "Unknown association type"
|
203
197
|
end
|
@@ -271,36 +265,13 @@ module MerbAdmin
|
|
271
265
|
end
|
272
266
|
|
273
267
|
module InstanceMethods
|
274
|
-
def id
|
275
|
-
super
|
276
|
-
end
|
277
|
-
|
278
|
-
def save
|
279
|
-
super
|
280
|
-
end
|
281
|
-
|
282
|
-
def destroy
|
283
|
-
super
|
284
|
-
end
|
285
|
-
|
286
268
|
def update_attributes(attributes)
|
287
|
-
|
288
|
-
# Argument Error: wrong number of arguments (1 for 0)
|
289
|
-
# but this seems to work:
|
290
|
-
set(attributes)
|
291
|
-
save
|
292
|
-
end
|
293
|
-
|
294
|
-
def errors
|
295
|
-
super
|
269
|
+
update(attributes)
|
296
270
|
end
|
297
271
|
|
298
272
|
def clear_association(association)
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
def reset
|
303
|
-
super
|
273
|
+
# FIXME: This should be changed to use the remove_all_* association method.
|
274
|
+
association.clear
|
304
275
|
end
|
305
276
|
end
|
306
277
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: merb-admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erik Michaels-Ober
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-11-02 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|