schofield 0.1.5 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.bundle/config +2 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +28 -0
- data/{LICENSE → LICENSE.txt} +1 -1
- data/README.rdoc +11 -9
- data/Rakefile +28 -24
- data/VERSION +1 -1
- data/lib/generators/schofield/association.rb +94 -0
- data/lib/generators/schofield/attribute.rb +76 -0
- data/lib/generators/schofield/attributes.rb +204 -0
- data/lib/generators/schofield/level.rb +287 -0
- data/lib/generators/schofield/levels.rb +74 -0
- data/lib/generators/schofield/responses.rb +46 -0
- data/lib/generators/schofield/routes.rb +46 -0
- data/lib/generators/schofield/schofield_generator.rb +124 -0
- data/lib/generators/templates/controller.erb +25 -0
- data/lib/generators/templates/form.erb +31 -0
- data/lib/generators/templates/index.erb +5 -0
- data/lib/generators/templates/join_controller.erb +15 -0
- data/lib/generators/templates/model.erb +109 -0
- data/lib/generators/templates/show.erb +21 -0
- data/schofield.gemspec +48 -46
- data/spec/spec_helper.rb +7 -4
- metadata +82 -47
- data/.gitignore +0 -21
- data/generators/schofield_controller/schofield_controller_generator.rb +0 -157
- data/generators/schofield_controller/templates/controller_spec.rb +0 -25
- data/generators/schofield_controller/templates/helper_spec.rb +0 -11
- data/generators/schofield_controller/templates/index_partial.rb +0 -26
- data/generators/schofield_controller/templates/nested/controller.rb +0 -106
- data/generators/schofield_controller/templates/nested/edit.rb +0 -5
- data/generators/schofield_controller/templates/nested/index.rb +0 -3
- data/generators/schofield_controller/templates/nested/new.rb +0 -1
- data/generators/schofield_controller/templates/nested/show.rb +0 -12
- data/generators/schofield_controller/templates/unnested/controller.rb +0 -94
- data/generators/schofield_controller/templates/unnested/edit.rb +0 -5
- data/generators/schofield_controller/templates/unnested/index.rb +0 -3
- data/generators/schofield_controller/templates/unnested/new.rb +0 -1
- data/generators/schofield_controller/templates/unnested/show.rb +0 -12
- data/generators/schofield_controller/templates/view_spec.rb +0 -12
- data/generators/schofield_form/schofield_form_generator.rb +0 -22
- data/generators/schofield_form/templates/view__form.html.haml +0 -11
- data/lib/schofield.rb +0 -111
- data/lib/schofield/tasks.rb +0 -3
- data/lib/schofield/tasks/schofield.rake +0 -7
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
1
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
3
4
|
require 'schofield'
|
4
|
-
require 'spec'
|
5
|
-
require 'spec/autorun'
|
6
5
|
|
7
|
-
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
8
11
|
|
9
12
|
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schofield
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Marc Tauber
|
@@ -14,107 +15,141 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-12-14 00:00:00 +00:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
22
|
+
prerelease: false
|
23
|
+
type: :development
|
21
24
|
name: rspec
|
25
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 11
|
31
|
+
segments:
|
32
|
+
- 2
|
33
|
+
- 1
|
34
|
+
- 0
|
35
|
+
version: 2.1.0
|
36
|
+
requirement: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
22
38
|
prerelease: false
|
23
|
-
|
39
|
+
type: :development
|
40
|
+
name: bundler
|
41
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
24
43
|
requirements:
|
25
|
-
- -
|
44
|
+
- - ~>
|
26
45
|
- !ruby/object:Gem::Version
|
46
|
+
hash: 23
|
27
47
|
segments:
|
28
48
|
- 1
|
29
|
-
-
|
30
|
-
-
|
31
|
-
version: 1.
|
49
|
+
- 0
|
50
|
+
- 0
|
51
|
+
version: 1.0.0
|
52
|
+
requirement: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
prerelease: false
|
32
55
|
type: :development
|
33
|
-
|
56
|
+
name: jeweler
|
57
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ~>
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
hash: 1
|
63
|
+
segments:
|
64
|
+
- 1
|
65
|
+
- 5
|
66
|
+
- 1
|
67
|
+
version: 1.5.1
|
68
|
+
requirement: *id003
|
34
69
|
- !ruby/object:Gem::Dependency
|
35
|
-
name: formtastic
|
36
70
|
prerelease: false
|
37
|
-
|
71
|
+
type: :development
|
72
|
+
name: rcov
|
73
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
38
75
|
requirements:
|
39
76
|
- - ">="
|
40
77
|
- !ruby/object:Gem::Version
|
78
|
+
hash: 3
|
41
79
|
segments:
|
42
80
|
- 0
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
type: :development
|
47
|
-
version_requirements: *id002
|
48
|
-
description: Create views and controllers from routes defined in admin namespace. Very, very basic and very specific to my needs.'
|
81
|
+
version: "0"
|
82
|
+
requirement: *id004
|
83
|
+
description: longer description of your gem
|
49
84
|
email: marc@marctauber.com
|
50
85
|
executables: []
|
51
86
|
|
52
87
|
extensions: []
|
53
88
|
|
54
89
|
extra_rdoc_files:
|
55
|
-
- LICENSE
|
90
|
+
- LICENSE.txt
|
56
91
|
- README.rdoc
|
57
92
|
files:
|
93
|
+
- .bundle/config
|
58
94
|
- .document
|
59
|
-
-
|
60
|
-
-
|
95
|
+
- Gemfile
|
96
|
+
- Gemfile.lock
|
97
|
+
- LICENSE.txt
|
61
98
|
- README.rdoc
|
62
99
|
- Rakefile
|
63
100
|
- VERSION
|
64
|
-
- generators/
|
65
|
-
- generators/
|
66
|
-
- generators/
|
67
|
-
- generators/
|
68
|
-
- generators/
|
69
|
-
- generators/
|
70
|
-
- generators/
|
71
|
-
- generators/
|
72
|
-
- generators/
|
73
|
-
- generators/
|
74
|
-
- generators/
|
75
|
-
- generators/
|
76
|
-
- generators/
|
77
|
-
- generators/
|
78
|
-
- generators/schofield_controller/templates/view_spec.rb
|
79
|
-
- generators/schofield_form/schofield_form_generator.rb
|
80
|
-
- generators/schofield_form/templates/view__form.html.haml
|
81
|
-
- lib/schofield.rb
|
82
|
-
- lib/schofield/tasks.rb
|
83
|
-
- lib/schofield/tasks/schofield.rake
|
101
|
+
- lib/generators/schofield/association.rb
|
102
|
+
- lib/generators/schofield/attribute.rb
|
103
|
+
- lib/generators/schofield/attributes.rb
|
104
|
+
- lib/generators/schofield/level.rb
|
105
|
+
- lib/generators/schofield/levels.rb
|
106
|
+
- lib/generators/schofield/responses.rb
|
107
|
+
- lib/generators/schofield/routes.rb
|
108
|
+
- lib/generators/schofield/schofield_generator.rb
|
109
|
+
- lib/generators/templates/controller.erb
|
110
|
+
- lib/generators/templates/form.erb
|
111
|
+
- lib/generators/templates/index.erb
|
112
|
+
- lib/generators/templates/join_controller.erb
|
113
|
+
- lib/generators/templates/model.erb
|
114
|
+
- lib/generators/templates/show.erb
|
84
115
|
- schofield.gemspec
|
85
116
|
- spec/schofield_spec.rb
|
86
117
|
- spec/spec.opts
|
87
118
|
- spec/spec_helper.rb
|
88
119
|
has_rdoc: true
|
89
120
|
homepage: http://github.com/sauberia/schofield
|
90
|
-
licenses:
|
91
|
-
|
121
|
+
licenses:
|
122
|
+
- MIT
|
92
123
|
post_install_message:
|
93
|
-
rdoc_options:
|
94
|
-
|
124
|
+
rdoc_options: []
|
125
|
+
|
95
126
|
require_paths:
|
96
127
|
- lib
|
97
128
|
required_ruby_version: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
98
130
|
requirements:
|
99
131
|
- - ">="
|
100
132
|
- !ruby/object:Gem::Version
|
133
|
+
hash: 3
|
101
134
|
segments:
|
102
135
|
- 0
|
103
136
|
version: "0"
|
104
137
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
|
+
none: false
|
105
139
|
requirements:
|
106
140
|
- - ">="
|
107
141
|
- !ruby/object:Gem::Version
|
142
|
+
hash: 3
|
108
143
|
segments:
|
109
144
|
- 0
|
110
145
|
version: "0"
|
111
146
|
requirements: []
|
112
147
|
|
113
148
|
rubyforge_project:
|
114
|
-
rubygems_version: 1.3.
|
149
|
+
rubygems_version: 1.3.7
|
115
150
|
signing_key:
|
116
151
|
specification_version: 3
|
117
|
-
summary:
|
152
|
+
summary: one-line summary of your gem
|
118
153
|
test_files:
|
119
154
|
- spec/schofield_spec.rb
|
120
155
|
- spec/spec_helper.rb
|
data/.gitignore
DELETED
@@ -1,157 +0,0 @@
|
|
1
|
-
class SchofieldControllerGenerator < Rails::Generator::NamedBase
|
2
|
-
|
3
|
-
def initialize(runtime_args, runtime_options = {})
|
4
|
-
super
|
5
|
-
usage if runtime_args.empty?
|
6
|
-
|
7
|
-
@args = runtime_args.dup
|
8
|
-
base_name = @args.shift
|
9
|
-
assign_names!(base_name)
|
10
|
-
end
|
11
|
-
|
12
|
-
|
13
|
-
def manifest
|
14
|
-
record do |m|
|
15
|
-
|
16
|
-
template_directory = has_parents? ? 'nested' : 'unnested'
|
17
|
-
|
18
|
-
sco_class = class_name.gsub('Admin::', '').singularize
|
19
|
-
sco_underscored = sco_class.underscore
|
20
|
-
sco_humanized_uc = sco_underscored.humanize
|
21
|
-
sco_underscored_plural = sco_underscored.pluralize
|
22
|
-
sco_titleized_plural = sco_underscored_plural.titleize
|
23
|
-
sco_humanized = sco_humanized_uc.downcase
|
24
|
-
|
25
|
-
sco_parents = []
|
26
|
-
if has_parents?
|
27
|
-
options[:parents].each do |parent|
|
28
|
-
sco_parent_class = has_parents? ? parent.classify : ''
|
29
|
-
sco_parent_underscored = sco_parent_class.underscore.downcase
|
30
|
-
sco_parent_underscored_plural = sco_parent_underscored.pluralize
|
31
|
-
sco_parent_titleized_plural = sco_parent_underscored.titleize.pluralize
|
32
|
-
sco_parents << {
|
33
|
-
:class => sco_parent_class,
|
34
|
-
:underscored => sco_parent_underscored,
|
35
|
-
:underscored_plural => sco_parent_underscored_plural,
|
36
|
-
:titleized_plural => sco_parent_titleized_plural,
|
37
|
-
}
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
sco_children = []
|
42
|
-
if has_children?
|
43
|
-
options[:children].each do |child|
|
44
|
-
sco_child_class = has_children? ? child.classify : ''
|
45
|
-
sco_child_underscored = sco_child_class.underscore.downcase
|
46
|
-
sco_child_underscored_plural = sco_child_underscored.pluralize
|
47
|
-
sco_child_titleized_plural = sco_child_underscored.titleize.pluralize
|
48
|
-
sco_child_humanized = sco_child_underscored.humanize.downcase
|
49
|
-
sco_children << {
|
50
|
-
:class => sco_child_class,
|
51
|
-
:underscored => sco_child_underscored,
|
52
|
-
:underscored_plural => sco_child_underscored_plural,
|
53
|
-
:titleized_plural => sco_child_titleized_plural,
|
54
|
-
:humanized => sco_child_humanized
|
55
|
-
}
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
assigns = { :sco_underscored => sco_underscored,
|
60
|
-
:sco_underscored_plural => sco_underscored_plural,
|
61
|
-
:sco_class => sco_class,
|
62
|
-
:sco_humanized_uc => sco_humanized_uc,
|
63
|
-
:sco_parents => sco_parents,
|
64
|
-
:sco_titleized_plural => sco_titleized_plural,
|
65
|
-
:sco_humanized => sco_humanized,
|
66
|
-
:non_restful_actions => non_restful_actions,
|
67
|
-
:sco_children => sco_children }
|
68
|
-
|
69
|
-
|
70
|
-
# Check for class naming collisions.
|
71
|
-
m.class_collisions class_path, "#{class_name}Controller", "#{class_name}Helper"
|
72
|
-
|
73
|
-
# Controller, helper, views, and spec directories.
|
74
|
-
m.directory File.join('app/controllers', class_path)
|
75
|
-
m.directory File.join('app/helpers', class_path)
|
76
|
-
m.directory File.join('app/views', class_path, file_name)
|
77
|
-
m.directory File.join('spec/controllers', class_path)
|
78
|
-
m.directory File.join('spec/helpers', class_path)
|
79
|
-
m.directory File.join('spec/views', class_path, file_name)
|
80
|
-
|
81
|
-
# Controller spec, class, and helper.
|
82
|
-
m.template 'controller_spec.rb',
|
83
|
-
File.join('spec/controllers', class_path, "#{file_name}_controller_spec.rb")
|
84
|
-
|
85
|
-
m.template 'helper_spec.rb',
|
86
|
-
File.join('spec/helpers', class_path, "#{file_name}_helper_spec.rb")
|
87
|
-
|
88
|
-
m.template "#{template_directory}/controller.rb",
|
89
|
-
File.join('app/controllers', class_path, "#{file_name}_controller.rb"),
|
90
|
-
:assigns => assigns
|
91
|
-
|
92
|
-
m.template 'controller:helper.rb',
|
93
|
-
File.join('app/helpers', class_path, "#{file_name}_helper.rb")
|
94
|
-
|
95
|
-
# Spec and view template for each action.
|
96
|
-
actions.each do |action|
|
97
|
-
|
98
|
-
m.template 'view_spec.rb',
|
99
|
-
File.join('spec/views', class_path, file_name, "#{action}.haml_spec.rb"),
|
100
|
-
:assigns => { :action => action, :model => file_name }
|
101
|
-
|
102
|
-
m.template "#{template_directory}/#{action}.rb",
|
103
|
-
File.join('app/views', class_path, file_name, "#{action}.haml"),
|
104
|
-
:assigns => assigns if actions_with_view.include?(action)
|
105
|
-
end
|
106
|
-
|
107
|
-
if actions.include?('index') || has_parents?
|
108
|
-
m.template 'index_partial.rb',
|
109
|
-
File.join('app/views/shared', "_#{sco_underscored_plural}.haml"),
|
110
|
-
:assigns => assigns
|
111
|
-
end
|
112
|
-
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
def actions_with_view
|
120
|
-
non_restful_actions + %w( index show new edit )
|
121
|
-
end
|
122
|
-
|
123
|
-
def restful_actions
|
124
|
-
%w( index show new create edit update destroy sort )
|
125
|
-
end
|
126
|
-
|
127
|
-
def non_restful_actions
|
128
|
-
restful_actions - %w( index show new create edit update destroy sort )
|
129
|
-
end
|
130
|
-
|
131
|
-
|
132
|
-
protected
|
133
|
-
|
134
|
-
def add_options!(opt)
|
135
|
-
opt.separator ''
|
136
|
-
opt.separator 'Options:'
|
137
|
-
opt.on('--parents PARENTS', 'Specify the parent models') { |v| options[:parents] = v if v.present? }
|
138
|
-
opt.on('--children CHILDREN', 'Specify the children models') { |v| options[:children] = v if v.present? }
|
139
|
-
end
|
140
|
-
|
141
|
-
def has_parents?
|
142
|
-
options[:parents].present?
|
143
|
-
end
|
144
|
-
|
145
|
-
def has_children?
|
146
|
-
options[:children].present?
|
147
|
-
end
|
148
|
-
|
149
|
-
def filter_actions array
|
150
|
-
array.map { |item| actions.include?(item) ? ":#{item}" : nil }.compact.join(', ')
|
151
|
-
end
|
152
|
-
|
153
|
-
def banner
|
154
|
-
"Usage: #{$0} schofield_controller ControllerName [--parents PARENTS --children CHILDREN]"
|
155
|
-
end
|
156
|
-
|
157
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe <%= class_name %>Controller do
|
4
|
-
|
5
|
-
<% if actions.empty? -%>
|
6
|
-
#Delete this example and add some real ones
|
7
|
-
<% else -%>
|
8
|
-
#Delete these examples and add some real ones
|
9
|
-
<% end -%>
|
10
|
-
it "should use <%= class_name %>Controller" do
|
11
|
-
controller.should be_an_instance_of(<%= class_name %>Controller)
|
12
|
-
end
|
13
|
-
|
14
|
-
<% unless actions.empty? -%>
|
15
|
-
<% for action in actions -%>
|
16
|
-
|
17
|
-
describe "GET '<%= action %>'" do
|
18
|
-
it "should be successful" do
|
19
|
-
get '<%= action %>'
|
20
|
-
response.should be_success
|
21
|
-
end
|
22
|
-
end
|
23
|
-
<% end -%>
|
24
|
-
<% end -%>
|
25
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe <%= class_name %>Helper do
|
4
|
-
|
5
|
-
#Delete this example and add some real ones or delete this file
|
6
|
-
it "should be included in the object returned by #helper" do
|
7
|
-
included_modules = (class << helper; self; end).send :included_modules
|
8
|
-
included_modules.should include(<%= class_name %>Helper)
|
9
|
-
end
|
10
|
-
|
11
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
- if <%= sco_underscored_plural %>.any?
|
2
|
-
|
3
|
-
%table#<%= sco_underscored_plural %>
|
4
|
-
|
5
|
-
= render :partial => 'shared/admin/table_header', :locals => { :columns => %w( Title ), :buttons => <%= %w(show edit destroy).inject(0) {|count,item| count += actions.include?(item) ? 1 : 0 } %> }
|
6
|
-
|
7
|
-
%tbody
|
8
|
-
|
9
|
-
- <%= sco_underscored_plural %>.each do |<%= sco_underscored %>|
|
10
|
-
|
11
|
-
%tr<%- if actions.include?('sort') -%>{ :class => 'dragable', :id => "<%= sco_underscored %>_#{<%= sco_underscored %>.id}"}<%- end -%>
|
12
|
-
|
13
|
-
%td&= <%= sco_underscored %>
|
14
|
-
<%- if actions.include?('show') -%>
|
15
|
-
%td= link_to_button 'Show', admin_<%= sco_underscored %>_path(<%= sco_underscored %>)
|
16
|
-
<%- end -%>
|
17
|
-
<%- if actions.include?('edit') -%>
|
18
|
-
%td= link_to_button 'Edit', edit_admin_<%= sco_underscored %>_path(<%= sco_underscored %>)
|
19
|
-
<%- end -%>
|
20
|
-
<%- if actions.include?('destroy') -%>
|
21
|
-
%td= link_to_button 'Delete', admin_<%= sco_underscored %>_path(<%= sco_underscored %>), :method => 'delete', :confirm => "Are you sure you want to delete the <%= sco_humanized %>: #{h(<%= sco_underscored %>)}?"
|
22
|
-
<%- end -%>
|
23
|
-
<%- if actions.include?('sort') -%>
|
24
|
-
|
25
|
-
= sortable_element('<%= sco_underscored_plural %>', :items => 'tr.dragable', :url => sort_admin_<%= sco_underscored_plural %>_path)
|
26
|
-
<%- end -%>
|