maiha-merb_inspector 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README +34 -0
- data/Rakefile +51 -0
- data/TODO +5 -0
- data/lib/merb_inspector/helper.rb +55 -0
- data/lib/merb_inspector/inspector.rb +87 -0
- data/lib/merb_inspector/inspectors/base.rb +60 -0
- data/lib/merb_inspector/inspectors/data_mapper.rb +103 -0
- data/lib/merb_inspector/merbtasks.rb +6 -0
- data/lib/merb_inspector.rb +29 -0
- data/mirror/public/stylesheets/merb_inspector.css +87 -0
- data/spec/merb_inspector_spec.rb +7 -0
- data/spec/spec_helper.rb +1 -0
- data/templates/data_mapper/collection/_records.html.erb +38 -0
- data/templates/data_mapper/resource/_edit.html.erb +15 -0
- data/templates/data_mapper/resource/_new.html.erb +24 -0
- data/templates/data_mapper/resource/_record.html.erb +42 -0
- data/templates/data_mapper/resource/_show.html.erb +13 -0
- data/test/merb_inspector_test.rb +0 -0
- data/test/test_helper.rb +1 -0
- metadata +80 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 Maiha <maiha@wota.jp>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
merb_inspector
|
2
|
+
==============
|
3
|
+
|
4
|
+
A plugin for the Merb framework that provides "inspect" helper.
|
5
|
+
Just inspect your objects! No longer need to prepare views, scaffold and pagination.
|
6
|
+
|
7
|
+
|
8
|
+
Setup
|
9
|
+
=====
|
10
|
+
|
11
|
+
1. load gem at the bottom of config/dependencies.rb
|
12
|
+
|
13
|
+
dependency "merb_inspector"
|
14
|
+
|
15
|
+
2. include css and js in your view or layout files
|
16
|
+
|
17
|
+
<%= css_include_tag "merb_inspector.css" -%>
|
18
|
+
<%= js_include_tag "jquery.js" -%>
|
19
|
+
|
20
|
+
|
21
|
+
Example
|
22
|
+
=======
|
23
|
+
|
24
|
+
just *inspect* the object you want to know!
|
25
|
+
|
26
|
+
<%= inspect [1, :hello] %>
|
27
|
+
<%= inspect User.all(:limit=>10) %>
|
28
|
+
<%= inspect @item %>
|
29
|
+
...
|
30
|
+
|
31
|
+
|
32
|
+
Copyright (c) 2008 maiha@wota.jp, released under the MIT license
|
33
|
+
|
34
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
|
4
|
+
require 'merb-core'
|
5
|
+
require 'merb-core/tasks/merb'
|
6
|
+
|
7
|
+
GEM_NAME = "merb_inspector"
|
8
|
+
GEM_VERSION = "0.0.1"
|
9
|
+
AUTHOR = "Your Name"
|
10
|
+
EMAIL = "Your Email"
|
11
|
+
HOMEPAGE = "http://merbivore.com/"
|
12
|
+
SUMMARY = "Merb plugin that provides ..."
|
13
|
+
|
14
|
+
spec = Gem::Specification.new do |s|
|
15
|
+
s.rubyforge_project = 'merb'
|
16
|
+
s.name = GEM_NAME
|
17
|
+
s.version = GEM_VERSION
|
18
|
+
s.platform = Gem::Platform::RUBY
|
19
|
+
s.has_rdoc = true
|
20
|
+
s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
|
21
|
+
s.summary = SUMMARY
|
22
|
+
s.description = s.summary
|
23
|
+
s.author = AUTHOR
|
24
|
+
s.email = EMAIL
|
25
|
+
s.homepage = HOMEPAGE
|
26
|
+
s.add_dependency('merb', '>= 1.0.6.1')
|
27
|
+
s.require_path = 'lib'
|
28
|
+
s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,spec}/**/*")
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
33
|
+
pkg.gem_spec = spec
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "install the plugin as a gem"
|
37
|
+
task :install do
|
38
|
+
Merb::RakeHelper.install(GEM_NAME, :version => GEM_VERSION)
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "Uninstall the gem"
|
42
|
+
task :uninstall do
|
43
|
+
Merb::RakeHelper.uninstall(GEM_NAME, :version => GEM_VERSION)
|
44
|
+
end
|
45
|
+
|
46
|
+
desc "Create a gemspec file"
|
47
|
+
task :gemspec do
|
48
|
+
File.open("#{GEM_NAME}.gemspec", "w") do |file|
|
49
|
+
file.puts spec.to_ruby
|
50
|
+
end
|
51
|
+
end
|
data/TODO
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
module Merb
|
2
|
+
module Inspector
|
3
|
+
module Helper
|
4
|
+
def inspect(object = nil, options = {})
|
5
|
+
return super() unless object
|
6
|
+
inspector = Merb::Inspector.lookup(object) || Merb::Inspector.default
|
7
|
+
inspector.new(object, self, options).execute
|
8
|
+
end
|
9
|
+
|
10
|
+
def column_header(p)
|
11
|
+
label = p.name.to_s
|
12
|
+
h(label)
|
13
|
+
# link_to label, "#", :onclick=>"return false;"
|
14
|
+
end
|
15
|
+
|
16
|
+
def column_value(record, p)
|
17
|
+
h(record.send p.name.to_s)
|
18
|
+
end
|
19
|
+
|
20
|
+
def column_form(record, p)
|
21
|
+
# first, search class prefixed method that user override
|
22
|
+
method = "#{record.class.name.demodulize}_#{p.name}_form"
|
23
|
+
return send(method, record, p) if respond_to?(method, true)
|
24
|
+
|
25
|
+
# second, search method that user override
|
26
|
+
method = "#{p.name}_form"
|
27
|
+
return send(method, record, p) if respond_to?(method, true)
|
28
|
+
|
29
|
+
# second, guess form from property type
|
30
|
+
if p.type == DataMapper::Types::Serial
|
31
|
+
record.send p.name
|
32
|
+
elsif p.type == DataMapper::Types::Text
|
33
|
+
text_area p.name
|
34
|
+
else
|
35
|
+
text_field p.name
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
######################################################################
|
40
|
+
### Patch for broken merb methods
|
41
|
+
|
42
|
+
def xxx_form_for(name, attrs = {}, &blk)
|
43
|
+
if !attrs[:action] and defined?(DataMapper::Resource) and name.is_a?(DataMapper::Resource)
|
44
|
+
if name.new_record?
|
45
|
+
model = name.class.name.demodulize.snake_case.pluralize.intern
|
46
|
+
attrs[:action] = resource(model, :new)
|
47
|
+
else
|
48
|
+
attrs[:action] = resource(name)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
super(name, attrs, &blk)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
module Merb
|
2
|
+
# A convinient way to get at Merb::Cache
|
3
|
+
def self.inspector
|
4
|
+
Merb::Inspector
|
5
|
+
end
|
6
|
+
|
7
|
+
module Inspector
|
8
|
+
|
9
|
+
def self.root
|
10
|
+
@root ||= File.expand_path(File.dirname(__FILE__) + "/../../")
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.default
|
14
|
+
Merb::Inspectors::Base
|
15
|
+
end
|
16
|
+
|
17
|
+
class << self
|
18
|
+
attr_accessor :stores
|
19
|
+
attr_accessor :caches
|
20
|
+
end
|
21
|
+
|
22
|
+
self.stores = Hash.new
|
23
|
+
self.caches = Hash.new
|
24
|
+
|
25
|
+
def self.reset
|
26
|
+
@caches = Hash.new
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.register(klass, inspector)
|
30
|
+
raise "#{klass} inspector already setup" if @stores.has_key?(klass)
|
31
|
+
@stores[klass] = inspector
|
32
|
+
log "registered %s -> %s" % [klass, inspector]
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.lookup(object)
|
36
|
+
if @caches.has_key?(object.class)
|
37
|
+
log "lookup: %s => %s (cached)" % [object.class, @caches[object.class] || 'nil']
|
38
|
+
return @caches[object.class]
|
39
|
+
end
|
40
|
+
klass = object.class.ancestors.find{|klass|
|
41
|
+
log "lookup: %s = %s ... %s" % [object.class, klass, @stores[klass]]
|
42
|
+
@stores.has_key?(klass)
|
43
|
+
}
|
44
|
+
@caches[object.class] = @stores[klass]
|
45
|
+
if klass
|
46
|
+
log "lookup: %s => %s (registered)" % [object.class, @caches[object.class]]
|
47
|
+
else
|
48
|
+
log "lookup: %s => nil (registered as negative cache)" % [object.class]
|
49
|
+
end
|
50
|
+
return @stores[klass]
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.log(message)
|
54
|
+
path = Merb.root / "log" / "inspector.log"
|
55
|
+
message = "[Inspector] %s" % message.to_s.strip
|
56
|
+
File.open(path, "a+") {|f| f.puts message}
|
57
|
+
end
|
58
|
+
|
59
|
+
######################################################################
|
60
|
+
### Install
|
61
|
+
|
62
|
+
def self.install
|
63
|
+
mirror("public/stylesheets")
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.mirror(dir)
|
67
|
+
source_dir = File.join(File.dirname(__FILE__), '..', '..', 'mirror', dir)
|
68
|
+
target_dir = File.join(Merb.root, dir)
|
69
|
+
FileUtils.mkdir_p(target_dir) unless File.exist?(target_dir)
|
70
|
+
|
71
|
+
Dir[source_dir + "/*"].each do |src|
|
72
|
+
time = File.mtime(src)
|
73
|
+
file = File.basename(src)
|
74
|
+
dst = File.join(target_dir, file)
|
75
|
+
|
76
|
+
next if File.directory?(src)
|
77
|
+
next if File.exist?(dst) and File.mtime(dst) >= time
|
78
|
+
FileUtils.copy(src, dst)
|
79
|
+
File.utime(time, time, dst)
|
80
|
+
command = File.exist?(dst) ? "update" : "install"
|
81
|
+
log "#{command}: #{dir}/#{file}"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Merb
|
2
|
+
module Inspectors
|
3
|
+
class Base
|
4
|
+
class << self
|
5
|
+
def register(klass)
|
6
|
+
Merb::Inspector.register(klass, self)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(object, caller, options = {})
|
11
|
+
@object = object
|
12
|
+
@caller = caller
|
13
|
+
@options = options
|
14
|
+
@options = {:action=>@options} unless @options.is_a?(Hash)
|
15
|
+
# @context = context || binding # not used yet
|
16
|
+
end
|
17
|
+
|
18
|
+
def execute
|
19
|
+
@object.inspect
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
def name
|
24
|
+
self.class.name.sub(/^Merb::Inspectors::/,'').sub(/Inspector$/,'').snake_case.gsub(/::/, '/')
|
25
|
+
end
|
26
|
+
|
27
|
+
def dir
|
28
|
+
File.join Merb::Inspector.root, "templates", name
|
29
|
+
end
|
30
|
+
|
31
|
+
def id
|
32
|
+
@object.object_id
|
33
|
+
end
|
34
|
+
|
35
|
+
def template_for(name)
|
36
|
+
File.join dir, name
|
37
|
+
end
|
38
|
+
|
39
|
+
def partial(name)
|
40
|
+
@caller.send :partial, template_for(name), current_options
|
41
|
+
end
|
42
|
+
|
43
|
+
def current_options
|
44
|
+
basic_options.merge(options)
|
45
|
+
end
|
46
|
+
|
47
|
+
def options
|
48
|
+
{}
|
49
|
+
end
|
50
|
+
|
51
|
+
def basic_options
|
52
|
+
{:inspector=>self, :options=>@options, :dir=>dir, :id=>id}
|
53
|
+
end
|
54
|
+
|
55
|
+
def method_missing(*args, &block)
|
56
|
+
@caller.send(*args, &block)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
module Merb
|
2
|
+
module Inspectors
|
3
|
+
module DataMapper
|
4
|
+
module Resourceful
|
5
|
+
def resource_name
|
6
|
+
model.name.demodulize.plural.snake_case
|
7
|
+
end
|
8
|
+
|
9
|
+
def link_to_new(label = 'New', opts = {})
|
10
|
+
@caller.link_to label, @caller.resource(resource_name, :new), opts
|
11
|
+
rescue Merb::Router::GenerationError
|
12
|
+
end
|
13
|
+
|
14
|
+
def link_to_show(record = @object, label = 'Show', opts = {})
|
15
|
+
@caller.link_to label, @caller.resource(record), opts
|
16
|
+
rescue Merb::Router::GenerationError
|
17
|
+
end
|
18
|
+
|
19
|
+
def link_to_edit(record = @object, label = 'Edit', opts = {})
|
20
|
+
@caller.link_to label, @caller.resource(record, :edit), opts
|
21
|
+
rescue Merb::Router::GenerationError
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class CollectionInspector < Base
|
26
|
+
register ::DataMapper::Collection
|
27
|
+
include Resourceful
|
28
|
+
|
29
|
+
def execute
|
30
|
+
partial "records"
|
31
|
+
end
|
32
|
+
|
33
|
+
def columns
|
34
|
+
@object.properties
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
def model
|
39
|
+
@object.query.model
|
40
|
+
end
|
41
|
+
|
42
|
+
def options
|
43
|
+
{:model=>model, :records=>@object}
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
class ResourceInspector < Base
|
48
|
+
register ::DataMapper::Resource
|
49
|
+
include Resourceful
|
50
|
+
|
51
|
+
def execute
|
52
|
+
partial template
|
53
|
+
end
|
54
|
+
|
55
|
+
def columns
|
56
|
+
model.properties
|
57
|
+
end
|
58
|
+
|
59
|
+
def edit_columns
|
60
|
+
columns.reject{|p| p.type == ::DataMapper::Types::Serial}
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
def id
|
65
|
+
oid = @object.new_record? ? "new" : @object.id
|
66
|
+
"#{resource_name}_#{oid}"
|
67
|
+
end
|
68
|
+
|
69
|
+
def model
|
70
|
+
@object.class
|
71
|
+
end
|
72
|
+
|
73
|
+
def template
|
74
|
+
if @options[:action].to_s == 'new'
|
75
|
+
"new"
|
76
|
+
else
|
77
|
+
"record"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def edit
|
82
|
+
%w( new edit ).include?(@options[:action].to_s)
|
83
|
+
end
|
84
|
+
|
85
|
+
def toggle
|
86
|
+
"$('##{id} .record').toggle();return false;"
|
87
|
+
end
|
88
|
+
|
89
|
+
def save_action
|
90
|
+
if @object.new_record?
|
91
|
+
"/" + resource_name
|
92
|
+
else
|
93
|
+
resource(@object)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def options
|
98
|
+
{:model=>model, :record=>@object, :edit=>edit, :save_action=>save_action, :toggle=>toggle}
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# make sure we're running inside Merb
|
2
|
+
if defined?(Merb::Plugins)
|
3
|
+
|
4
|
+
$: << File.dirname(__FILE__) unless $:.include?(File.dirname(__FILE__))
|
5
|
+
|
6
|
+
require "merb_inspector" / "inspector"
|
7
|
+
require "merb_inspector" / "helper"
|
8
|
+
require "merb_inspector" / "inspectors" / "base"
|
9
|
+
require "merb_inspector" / "inspectors" / "data_mapper" if defined?(DataMapper)
|
10
|
+
|
11
|
+
module Merb::GlobalHelpers
|
12
|
+
include Merb::Inspector::Helper
|
13
|
+
end
|
14
|
+
|
15
|
+
# Merb gives you a Merb::Plugins.config hash...feel free to put your stuff in your piece of it
|
16
|
+
Merb::Plugins.config[:merb_inspector] = {
|
17
|
+
:chickens => false
|
18
|
+
}
|
19
|
+
|
20
|
+
Merb::BootLoader.before_app_loads do
|
21
|
+
# require code that must be loaded before the application
|
22
|
+
Merb::Inspector.install
|
23
|
+
end
|
24
|
+
|
25
|
+
Merb::BootLoader.after_app_loads do
|
26
|
+
end
|
27
|
+
|
28
|
+
Merb::Plugins.add_rakefiles "merb_inspector/merbtasks"
|
29
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
table.data-mapper-collection {
|
2
|
+
border-collapse:collapse;
|
3
|
+
}
|
4
|
+
|
5
|
+
|
6
|
+
table.data-mapper-collection th {
|
7
|
+
background-color: #555;
|
8
|
+
text-align: left;
|
9
|
+
}
|
10
|
+
|
11
|
+
table.data-mapper-collection th a,
|
12
|
+
table.data-mapper-collection th p {
|
13
|
+
font: bold 11px arial, sans-serif;
|
14
|
+
display: block;
|
15
|
+
background-color: #555;
|
16
|
+
}
|
17
|
+
|
18
|
+
table.data-mapper-collection th a {
|
19
|
+
color: #fff;
|
20
|
+
padding: 2px 15px 2px 5px;
|
21
|
+
}
|
22
|
+
|
23
|
+
table.data-mapper-collection th p {
|
24
|
+
color: #eee;
|
25
|
+
padding: 2px 5px;
|
26
|
+
}
|
27
|
+
|
28
|
+
table.data-mapper-collection th a:hover {
|
29
|
+
background-color: #000;
|
30
|
+
color: #ff8;
|
31
|
+
}
|
32
|
+
|
33
|
+
table.data-mapper-collection > tbody > tr.record td {
|
34
|
+
background-color: #E6F2FF;
|
35
|
+
}
|
36
|
+
|
37
|
+
table.data-mapper-collection > tbody > tr.record > td {
|
38
|
+
padding: 5px 4px;
|
39
|
+
color: #333;
|
40
|
+
font-family: Verdana, sans-serif;
|
41
|
+
font-size: 11px;
|
42
|
+
border-bottom: solid 1px #C5DBF7;
|
43
|
+
border-left: solid 1px #C5DBF7;
|
44
|
+
}
|
45
|
+
|
46
|
+
table.data-mapper-collection > tbody > tr.even-record td {
|
47
|
+
background-color: #fff;
|
48
|
+
}
|
49
|
+
|
50
|
+
table.data-mapper-collection > tbody > tr.even-record > td {
|
51
|
+
border-left: solid 1px #ddd;
|
52
|
+
}
|
53
|
+
|
54
|
+
table.data-mapper-collection > tbody > tr.record > td.sorted {
|
55
|
+
background-color: #B9DCFF;
|
56
|
+
border-bottom: solid 1px #AFD0F5;
|
57
|
+
}
|
58
|
+
|
59
|
+
table.data-mapper-collection > tbody > tr.even-record > td.sorted {
|
60
|
+
background-color: #E6F2FF;
|
61
|
+
border-bottom: solid 1px #AFD0F5;
|
62
|
+
}
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
.record table
|
67
|
+
{
|
68
|
+
background-color: #fff;
|
69
|
+
border-collapse: collapse;
|
70
|
+
border-spacing: 0px;
|
71
|
+
}
|
72
|
+
.record table th
|
73
|
+
{
|
74
|
+
background-color: #dee7ec;
|
75
|
+
border: 1px solid #8cacbb;
|
76
|
+
padding: 3px;
|
77
|
+
}
|
78
|
+
.record table td
|
79
|
+
{
|
80
|
+
border: 1px solid #8cacbb;
|
81
|
+
padding: 3px;
|
82
|
+
}
|
83
|
+
|
84
|
+
table.logical th,
|
85
|
+
table.logical td {
|
86
|
+
border: 0px;
|
87
|
+
}
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
$:.push File.join(File.dirname(__FILE__), '..', 'lib')
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<div>
|
2
|
+
<table class="data-mapper-collection">
|
3
|
+
<thead>
|
4
|
+
<tr>
|
5
|
+
<%- inspector.columns.each do |p| -%>
|
6
|
+
<th><p><%= column_header(p) %></p></th>
|
7
|
+
<%- end -%>
|
8
|
+
<th></th>
|
9
|
+
</tr>
|
10
|
+
</thead>
|
11
|
+
<tbody class="records">
|
12
|
+
<%- records.each_with_index do |record, i| -%>
|
13
|
+
<%-
|
14
|
+
tr_class = (i % 2 == 0) ? "even-record" : ""
|
15
|
+
tr_class += " #{list_row_class(record)}" if respond_to? :list_row_class
|
16
|
+
-%>
|
17
|
+
<tr class="record <%=tr_class%>">
|
18
|
+
<%- inspector.columns.each do |p| -%>
|
19
|
+
<td><%=h column_value(record, p) %></td>
|
20
|
+
<%- end -%>
|
21
|
+
<td>
|
22
|
+
<table class="logical">
|
23
|
+
<tr>
|
24
|
+
<td><%= inspector.link_to_show(record) %></td>
|
25
|
+
<td><%= inspector.link_to_edit(record) %></td>
|
26
|
+
<td><%# delete_button(article, "Delete #{article.title}") %></td>
|
27
|
+
</tr>
|
28
|
+
</table>
|
29
|
+
</td>
|
30
|
+
</tr>
|
31
|
+
<%- end -%>
|
32
|
+
</tbody>
|
33
|
+
</table>
|
34
|
+
|
35
|
+
<%= inspector.link_to_new 'New' %>
|
36
|
+
|
37
|
+
</div>
|
38
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<div>
|
2
|
+
<%= form_for record do %>
|
3
|
+
<table class="record show">
|
4
|
+
<tbody>
|
5
|
+
<%- columns.each do |p| -%>
|
6
|
+
<tr>
|
7
|
+
<th><%= column_header(p) %></th>
|
8
|
+
<td><%=h column_form(record, p) %></td>
|
9
|
+
</tr>
|
10
|
+
<%- end -%>
|
11
|
+
</tbody>
|
12
|
+
</table>
|
13
|
+
<% end =%>
|
14
|
+
</div>
|
15
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<div id="<%=id%>" style="display:block;">
|
2
|
+
|
3
|
+
<div id="<%=id%>_edit" class="record edit" style="display:block;">
|
4
|
+
<%= form_for record, :action=>save_action do %>
|
5
|
+
<table>
|
6
|
+
<tbody>
|
7
|
+
<%- inspector.columns.each do |p| -%>
|
8
|
+
<tr>
|
9
|
+
<th><%= column_header(p) %></th>
|
10
|
+
<td><%= column_form(record, p) %></td>
|
11
|
+
</tr>
|
12
|
+
<%- end -%>
|
13
|
+
<tr>
|
14
|
+
<td colspan=2 align=center>
|
15
|
+
<%= submit "create".t %>
|
16
|
+
<%= link_to "cancel".t, "#", :onclick=>"$('##{id}').hide();return false;" %>
|
17
|
+
</td>
|
18
|
+
</tr>
|
19
|
+
</tbody>
|
20
|
+
</table>
|
21
|
+
<% end =%>
|
22
|
+
</div>
|
23
|
+
</div>
|
24
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
<div id="<%=id%>">
|
2
|
+
|
3
|
+
<div id="<%=id%>_show" class="record show" style="display:<%= edit ? 'none' : 'display' %>">
|
4
|
+
<table>
|
5
|
+
<tbody>
|
6
|
+
<%- inspector.columns.each do |p| -%>
|
7
|
+
<tr>
|
8
|
+
<th><%= column_header(p) %></th>
|
9
|
+
<td><%=h column_value(record, p) %></td>
|
10
|
+
</tr>
|
11
|
+
<%- end -%>
|
12
|
+
<tr>
|
13
|
+
<td colspan=2 align=center>
|
14
|
+
<%= link_to "edit", "#", :onclick=>toggle %>
|
15
|
+
</td>
|
16
|
+
</tr>
|
17
|
+
</tbody>
|
18
|
+
</table>
|
19
|
+
</div>
|
20
|
+
|
21
|
+
<div id="<%=id%>_edit" class="record edit" style="display:<%= edit ? 'display' : 'none' %>">
|
22
|
+
<%= form_for record, :action=>save_action do %>
|
23
|
+
<table>
|
24
|
+
<tbody>
|
25
|
+
<%- inspector.columns.each do |p| -%>
|
26
|
+
<tr>
|
27
|
+
<th><%= column_header(p) %></th>
|
28
|
+
<td><%= column_form(record, p) %></td>
|
29
|
+
</tr>
|
30
|
+
<%- end -%>
|
31
|
+
<tr>
|
32
|
+
<td colspan=2 align=center>
|
33
|
+
<%= submit (record.new_record? ? "create" : "update").t %>
|
34
|
+
<%= link_to "cancel", "#", :onclick=>toggle %>
|
35
|
+
</td>
|
36
|
+
</tr>
|
37
|
+
</tbody>
|
38
|
+
</table>
|
39
|
+
<% end =%>
|
40
|
+
</div>
|
41
|
+
</div>
|
42
|
+
|
File without changes
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
$:.push File.join(File.dirname(__FILE__), '..', 'lib')
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: maiha-merb_inspector
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: "0.1"
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- maiha
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-12-27 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: merb-core
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.0.7
|
23
|
+
version:
|
24
|
+
description: ""
|
25
|
+
email: maiha@wota.jp
|
26
|
+
executables: []
|
27
|
+
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files: []
|
31
|
+
|
32
|
+
files:
|
33
|
+
- LICENSE
|
34
|
+
- README
|
35
|
+
- Rakefile
|
36
|
+
- TODO
|
37
|
+
- lib/merb_inspector.rb
|
38
|
+
- lib/merb_inspector/helper.rb
|
39
|
+
- lib/merb_inspector/inspector.rb
|
40
|
+
- lib/merb_inspector/inspectors/base.rb
|
41
|
+
- lib/merb_inspector/inspectors/data_mapper.rb
|
42
|
+
- lib/merb_inspector/merbtasks.rb
|
43
|
+
- mirror/public/stylesheets/merb_inspector.css
|
44
|
+
- spec/merb_inspector_spec.rb
|
45
|
+
- spec/spec_helper.rb
|
46
|
+
- templates/data_mapper/collection/_records.html.erb
|
47
|
+
- templates/data_mapper/resource/_edit.html.erb
|
48
|
+
- templates/data_mapper/resource/_new.html.erb
|
49
|
+
- templates/data_mapper/resource/_record.html.erb
|
50
|
+
- templates/data_mapper/resource/_show.html.erb
|
51
|
+
- test/merb_inspector_test.rb
|
52
|
+
- test/test_helper.rb
|
53
|
+
has_rdoc: true
|
54
|
+
homepage: http://github.com/maiha/merb_inspector
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: "0"
|
65
|
+
version:
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: "0"
|
71
|
+
version:
|
72
|
+
requirements: []
|
73
|
+
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 1.2.0
|
76
|
+
signing_key:
|
77
|
+
specification_version: 2
|
78
|
+
summary: ""
|
79
|
+
test_files: []
|
80
|
+
|