datalab-generators 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +116 -0
- data/LICENSE +20 -0
- data/README.markdown +25 -0
- data/Rakefile +4 -0
- data/lib/generators/datalab.rb +28 -0
- data/lib/generators/datalab/administrators/USAGE +1 -0
- data/lib/generators/datalab/administrators/administrators_generator.rb +14 -0
- data/lib/generators/datalab/administrators/templates/administrators.rb +1 -0
- data/lib/generators/datalab/administrators/templates/administrators.yml +2 -0
- data/lib/generators/datalab/layout/USAGE +3 -0
- data/lib/generators/datalab/layout/layout_generator.rb +35 -0
- data/lib/generators/datalab/layout/templates/admin.css.scss +83 -0
- data/lib/generators/datalab/layout/templates/admin.html.erb +19 -0
- data/lib/generators/datalab/layout/templates/admin_helper.rb +18 -0
- data/lib/generators/datalab/layout/templates/layout.html.erb +19 -0
- data/lib/generators/datalab/layout/templates/layout_helper.rb +22 -0
- data/lib/generators/datalab/layout/templates/public.css.scss +83 -0
- data/lib/generators/datalab/layout/templates/public.html.erb +19 -0
- data/lib/generators/datalab/layout/templates/public_helper.rb +18 -0
- data/lib/generators/datalab/layout/templates/stylesheet.css.scss +83 -0
- data/lib/generators/datalab/scaffold/USAGE +51 -0
- data/lib/generators/datalab/scaffold/scaffold_generator.rb +301 -0
- data/lib/generators/datalab/scaffold/templates/actions/create.rb +8 -0
- data/lib/generators/datalab/scaffold/templates/actions/destroy.rb +5 -0
- data/lib/generators/datalab/scaffold/templates/actions/edit.rb +3 -0
- data/lib/generators/datalab/scaffold/templates/actions/index.rb +3 -0
- data/lib/generators/datalab/scaffold/templates/actions/new.rb +3 -0
- data/lib/generators/datalab/scaffold/templates/actions/show.rb +3 -0
- data/lib/generators/datalab/scaffold/templates/actions/update.rb +8 -0
- data/lib/generators/datalab/scaffold/templates/controller.rb +3 -0
- data/lib/generators/datalab/scaffold/templates/fixtures.yml +9 -0
- data/lib/generators/datalab/scaffold/templates/helper.rb +2 -0
- data/lib/generators/datalab/scaffold/templates/migration.rb +16 -0
- data/lib/generators/datalab/scaffold/templates/model.rb +4 -0
- data/lib/generators/datalab/scaffold/templates/tests/rspec/actions/create.rb +11 -0
- data/lib/generators/datalab/scaffold/templates/tests/rspec/actions/destroy.rb +6 -0
- data/lib/generators/datalab/scaffold/templates/tests/rspec/actions/edit.rb +4 -0
- data/lib/generators/datalab/scaffold/templates/tests/rspec/actions/index.rb +4 -0
- data/lib/generators/datalab/scaffold/templates/tests/rspec/actions/new.rb +4 -0
- data/lib/generators/datalab/scaffold/templates/tests/rspec/actions/show.rb +4 -0
- data/lib/generators/datalab/scaffold/templates/tests/rspec/actions/update.rb +11 -0
- data/lib/generators/datalab/scaffold/templates/tests/rspec/controller.rb +8 -0
- data/lib/generators/datalab/scaffold/templates/tests/rspec/model.rb +7 -0
- data/lib/generators/datalab/scaffold/templates/views/erb/_form.html.erb +10 -0
- data/lib/generators/datalab/scaffold/templates/views/erb/edit.html.erb +14 -0
- data/lib/generators/datalab/scaffold/templates/views/erb/index.html.erb +29 -0
- data/lib/generators/datalab/scaffold/templates/views/erb/new.html.erb +7 -0
- data/lib/generators/datalab/scaffold/templates/views/erb/show.html.erb +20 -0
- metadata +119 -0
data/CHANGELOG
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
datalab-generators (0.4.6)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
actionmailer (3.1.1)
|
10
|
+
actionpack (= 3.1.1)
|
11
|
+
mail (~> 2.3.0)
|
12
|
+
actionpack (3.1.1)
|
13
|
+
activemodel (= 3.1.1)
|
14
|
+
activesupport (= 3.1.1)
|
15
|
+
builder (~> 3.0.0)
|
16
|
+
erubis (~> 2.7.0)
|
17
|
+
i18n (~> 0.6)
|
18
|
+
rack (~> 1.3.2)
|
19
|
+
rack-cache (~> 1.1)
|
20
|
+
rack-mount (~> 0.8.2)
|
21
|
+
rack-test (~> 0.6.1)
|
22
|
+
sprockets (~> 2.0.2)
|
23
|
+
activemodel (3.1.1)
|
24
|
+
activesupport (= 3.1.1)
|
25
|
+
builder (~> 3.0.0)
|
26
|
+
i18n (~> 0.6)
|
27
|
+
activerecord (3.1.1)
|
28
|
+
activemodel (= 3.1.1)
|
29
|
+
activesupport (= 3.1.1)
|
30
|
+
arel (~> 2.2.1)
|
31
|
+
tzinfo (~> 0.3.29)
|
32
|
+
activeresource (3.1.1)
|
33
|
+
activemodel (= 3.1.1)
|
34
|
+
activesupport (= 3.1.1)
|
35
|
+
activesupport (3.1.1)
|
36
|
+
multi_json (~> 1.0)
|
37
|
+
arel (2.2.1)
|
38
|
+
builder (3.0.0)
|
39
|
+
diff-lcs (1.1.3)
|
40
|
+
erubis (2.7.0)
|
41
|
+
hike (1.2.1)
|
42
|
+
i18n (0.6.0)
|
43
|
+
json (1.6.1)
|
44
|
+
mail (2.3.0)
|
45
|
+
i18n (>= 0.4.0)
|
46
|
+
mime-types (~> 1.16)
|
47
|
+
treetop (~> 1.4.8)
|
48
|
+
metaclass (0.0.1)
|
49
|
+
mime-types (1.17.2)
|
50
|
+
mocha (0.10.0)
|
51
|
+
metaclass (~> 0.0.1)
|
52
|
+
multi_json (1.0.3)
|
53
|
+
polyglot (0.3.3)
|
54
|
+
rack (1.3.5)
|
55
|
+
rack-cache (1.1)
|
56
|
+
rack (>= 0.4)
|
57
|
+
rack-mount (0.8.3)
|
58
|
+
rack (>= 1.0.0)
|
59
|
+
rack-ssl (1.3.2)
|
60
|
+
rack
|
61
|
+
rack-test (0.6.1)
|
62
|
+
rack (>= 1.0)
|
63
|
+
rails (3.1.1)
|
64
|
+
actionmailer (= 3.1.1)
|
65
|
+
actionpack (= 3.1.1)
|
66
|
+
activerecord (= 3.1.1)
|
67
|
+
activeresource (= 3.1.1)
|
68
|
+
activesupport (= 3.1.1)
|
69
|
+
bundler (~> 1.0)
|
70
|
+
railties (= 3.1.1)
|
71
|
+
railties (3.1.1)
|
72
|
+
actionpack (= 3.1.1)
|
73
|
+
activesupport (= 3.1.1)
|
74
|
+
rack-ssl (~> 1.3.2)
|
75
|
+
rake (>= 0.8.7)
|
76
|
+
rdoc (~> 3.4)
|
77
|
+
thor (~> 0.14.6)
|
78
|
+
rake (0.9.2.2)
|
79
|
+
rdoc (3.11)
|
80
|
+
json (~> 1.4)
|
81
|
+
rspec (2.7.0)
|
82
|
+
rspec-core (~> 2.7.0)
|
83
|
+
rspec-expectations (~> 2.7.0)
|
84
|
+
rspec-mocks (~> 2.7.0)
|
85
|
+
rspec-core (2.7.1)
|
86
|
+
rspec-expectations (2.7.0)
|
87
|
+
diff-lcs (~> 1.1.2)
|
88
|
+
rspec-mocks (2.7.0)
|
89
|
+
rspec-rails (2.7.0)
|
90
|
+
actionpack (~> 3.0)
|
91
|
+
activesupport (~> 3.0)
|
92
|
+
railties (~> 3.0)
|
93
|
+
rspec (~> 2.7.0)
|
94
|
+
sprockets (2.0.3)
|
95
|
+
hike (~> 1.2)
|
96
|
+
rack (~> 1.0)
|
97
|
+
tilt (~> 1.1, != 1.3.0)
|
98
|
+
sqlite3 (1.3.4)
|
99
|
+
sqlite3-ruby (1.3.3)
|
100
|
+
sqlite3 (>= 1.3.3)
|
101
|
+
thor (0.14.6)
|
102
|
+
tilt (1.3.3)
|
103
|
+
treetop (1.4.10)
|
104
|
+
polyglot
|
105
|
+
polyglot (>= 0.3.1)
|
106
|
+
tzinfo (0.3.31)
|
107
|
+
|
108
|
+
PLATFORMS
|
109
|
+
ruby
|
110
|
+
|
111
|
+
DEPENDENCIES
|
112
|
+
mocha
|
113
|
+
datalab-generators!
|
114
|
+
rails
|
115
|
+
rspec-rails
|
116
|
+
sqlite3-ruby
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 dataLAB
|
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.markdown
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# dataLAB Generators
|
2
|
+
|
3
|
+
Rails generator scripts designed to be used as a starting point with default dataLAB projects. Derived from Ryan Bates' Nifty Generator scripts.
|
4
|
+
|
5
|
+
|
6
|
+
## Setup
|
7
|
+
|
8
|
+
Add the gem to your Gemfile.
|
9
|
+
|
10
|
+
gem "datalab-generators", :group => :development
|
11
|
+
|
12
|
+
Then you can run any of the included generators.
|
13
|
+
|
14
|
+
rails g datalab:scaffold Recipe name:string index new
|
15
|
+
|
16
|
+
## Included Generators
|
17
|
+
|
18
|
+
* datalab:layout: generates generic layout, stylesheet, and helper files.
|
19
|
+
* datalab:scaffold: generates a controller and optional model/migration.
|
20
|
+
* datalab:administrators: generates an administrators YAML file and loader.
|
21
|
+
|
22
|
+
To view the README for each generator, run it with the --help option.
|
23
|
+
|
24
|
+
rails g datalab:layout --help
|
25
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rails/generators/base'
|
2
|
+
|
3
|
+
module Datalab
|
4
|
+
module Generators
|
5
|
+
class Base < Rails::Generators::Base #:nodoc:
|
6
|
+
def self.source_root
|
7
|
+
@_datalab_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'datalab', generator_name, 'templates'))
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.banner
|
11
|
+
"rails generate datalab:#{generator_name} #{self.arguments.map{ |a| a.usage }.join(' ')} [options]"
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def add_gem(name, options = {})
|
17
|
+
gemfile_content = File.read(destination_path("Gemfile"))
|
18
|
+
File.open(destination_path("Gemfile"), 'a') { |f| f.write("\n") } unless gemfile_content =~ /\n\Z/
|
19
|
+
gem name, options unless gemfile_content.include? name
|
20
|
+
end
|
21
|
+
|
22
|
+
def print_usage
|
23
|
+
self.class.help(Thor::Base.shell.new)
|
24
|
+
exit
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
* rails generate datalab:administrators
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'generators/datalab'
|
2
|
+
|
3
|
+
module Datalab
|
4
|
+
module Generators
|
5
|
+
class AdministratorsGenerator < Base
|
6
|
+
|
7
|
+
def create_config
|
8
|
+
template "administrators.rb", "config/initializers/administrators.rb"
|
9
|
+
copy_file "administrators.yml", "config/administrators.yml"
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
ADMINISTRATORS = YAML.load_file("#{Rails.root}/config/administrators.yml")
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'generators/datalab'
|
2
|
+
|
3
|
+
module Datalab
|
4
|
+
module Generators
|
5
|
+
class LayoutGenerator < Base
|
6
|
+
argument :layout_name, :type => :string, :default => 'application', :banner => 'layout_name'
|
7
|
+
|
8
|
+
class_option :admin, :desc => 'Generate basic admin layout elements.', :type => :boolean
|
9
|
+
|
10
|
+
class_option :public, :desc => 'Generate basic public layout elements.', :type => :boolean
|
11
|
+
|
12
|
+
def create_layout
|
13
|
+
if options.admin?
|
14
|
+
template 'admin.html.erb', "app/views/layouts/#{file_name}.html.erb"
|
15
|
+
copy_file 'admin.css.scss', "app/assets/stylesheets/#{file_name}.css.scss"
|
16
|
+
copy_file 'admin_helper.rb', 'app/helpers/admin_helper.rb'
|
17
|
+
elsif options.public?
|
18
|
+
template 'public.html.erb', "app/views/layouts/#{file_name}.html.erb"
|
19
|
+
copy_file 'public.css.scss', "app/assets/stylesheets/#{file_name}.css.scss"
|
20
|
+
copy_file 'public_helper.rb', 'app/helpers/public_helper.rb'
|
21
|
+
else
|
22
|
+
template 'layout.html.erb', "app/views/layouts/#{file_name}.html.erb"
|
23
|
+
copy_file 'stylesheet.css.scss', "app/assets/stylesheets/#{file_name}.css.scss"
|
24
|
+
copy_file 'layout_helper.rb', 'app/helpers/layout_helper.rb'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def file_name
|
31
|
+
layout_name.underscore
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
html, body {
|
2
|
+
background-color: #4B7399;
|
3
|
+
font-family: Verdana, Helvetica, Arial;
|
4
|
+
font-size: 14px;
|
5
|
+
}
|
6
|
+
|
7
|
+
a img {
|
8
|
+
border: none;
|
9
|
+
}
|
10
|
+
|
11
|
+
a {
|
12
|
+
color: #0000FF;
|
13
|
+
}
|
14
|
+
|
15
|
+
.clear {
|
16
|
+
clear: both;
|
17
|
+
height: 0;
|
18
|
+
overflow: hidden;
|
19
|
+
}
|
20
|
+
|
21
|
+
#container {
|
22
|
+
width: 75%;
|
23
|
+
margin: 0 auto;
|
24
|
+
background-color: #FFF;
|
25
|
+
padding: 20px 40px;
|
26
|
+
border: solid 1px black;
|
27
|
+
margin-top: 20px;
|
28
|
+
}
|
29
|
+
|
30
|
+
#flash_notice, #flash_error, #flash_alert {
|
31
|
+
padding: 5px 8px;
|
32
|
+
margin: 10px 0;
|
33
|
+
}
|
34
|
+
|
35
|
+
#flash_notice {
|
36
|
+
background-color: #CFC;
|
37
|
+
border: solid 1px #6C6;
|
38
|
+
}
|
39
|
+
|
40
|
+
#flash_error, #flash_alert {
|
41
|
+
background-color: #FCC;
|
42
|
+
border: solid 1px #C66;
|
43
|
+
}
|
44
|
+
|
45
|
+
.error_messages {
|
46
|
+
width: 400px;
|
47
|
+
border: 2px solid #CF0000;
|
48
|
+
padding: 0px;
|
49
|
+
padding-bottom: 12px;
|
50
|
+
margin-bottom: 20px;
|
51
|
+
background-color: #f0f0f0;
|
52
|
+
font-size: 12px;
|
53
|
+
}
|
54
|
+
|
55
|
+
.error_messages h2 {
|
56
|
+
text-align: left;
|
57
|
+
font-weight: bold;
|
58
|
+
padding: 5px 10px;
|
59
|
+
font-size: 12px;
|
60
|
+
margin: 0;
|
61
|
+
background-color: #c00;
|
62
|
+
color: #fff;
|
63
|
+
}
|
64
|
+
|
65
|
+
.error_messages p {
|
66
|
+
margin: 8px 10px;
|
67
|
+
}
|
68
|
+
|
69
|
+
.error_messages ul {
|
70
|
+
margin: 0;
|
71
|
+
}
|
72
|
+
|
73
|
+
.field_with_errors {
|
74
|
+
display: inline;
|
75
|
+
}
|
76
|
+
|
77
|
+
form .field, form .actions {
|
78
|
+
margin: 10px 0;
|
79
|
+
}
|
80
|
+
|
81
|
+
form label {
|
82
|
+
display: block;
|
83
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title><%%= content_for?(:title) ? yield(:title) : "Untitled" %></title>
|
5
|
+
<%%= stylesheet_link_tag "<%= file_name %>" %>
|
6
|
+
<%%= javascript_include_tag :defaults %>
|
7
|
+
<%%= csrf_meta_tag %>
|
8
|
+
<%%= yield(:head) %>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<div id="container">
|
12
|
+
<%% flash.each do |name, msg| %>
|
13
|
+
<%%= content_tag :div, msg, :id => "flash_#{name}" %>
|
14
|
+
<%% end %>
|
15
|
+
<%%= content_tag :h1, yield(:title) if show_title? %>
|
16
|
+
<%%= yield %>
|
17
|
+
</div>
|
18
|
+
</body>
|
19
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module AdminHelper
|
2
|
+
def title(page_title, show_title = true)
|
3
|
+
content_for(:title) { h(page_title.to_s) }
|
4
|
+
@show_title = show_title
|
5
|
+
end
|
6
|
+
|
7
|
+
def show_title?
|
8
|
+
@show_title
|
9
|
+
end
|
10
|
+
|
11
|
+
def stylesheet(*args)
|
12
|
+
content_for(:head) { stylesheet_link_tag(*args) }
|
13
|
+
end
|
14
|
+
|
15
|
+
def javascript(*args)
|
16
|
+
content_for(:head) { javascript_include_tag(*args) }
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title><%%= content_for?(:title) ? yield(:title) : "Untitled" %></title>
|
5
|
+
<%%= stylesheet_link_tag "<%= file_name %>" %>
|
6
|
+
<%%= javascript_include_tag :defaults %>
|
7
|
+
<%%= csrf_meta_tag %>
|
8
|
+
<%%= yield(:head) %>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<div id="container">
|
12
|
+
<%% flash.each do |name, msg| %>
|
13
|
+
<%%= content_tag :div, msg, :id => "flash_#{name}" %>
|
14
|
+
<%% end %>
|
15
|
+
<%%= content_tag :h1, yield(:title) if show_title? %>
|
16
|
+
<%%= yield %>
|
17
|
+
</div>
|
18
|
+
</body>
|
19
|
+
</html>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# These helper methods can be called in your template to set variables to be used in the layout
|
2
|
+
# This module should be included in all views globally,
|
3
|
+
# to do so you may need to add this line to your ApplicationController
|
4
|
+
# helper :layout
|
5
|
+
module LayoutHelper
|
6
|
+
def title(page_title, show_title = true)
|
7
|
+
content_for(:title) { h(page_title.to_s) }
|
8
|
+
@show_title = show_title
|
9
|
+
end
|
10
|
+
|
11
|
+
def show_title?
|
12
|
+
@show_title
|
13
|
+
end
|
14
|
+
|
15
|
+
def stylesheet(*args)
|
16
|
+
content_for(:head) { stylesheet_link_tag(*args) }
|
17
|
+
end
|
18
|
+
|
19
|
+
def javascript(*args)
|
20
|
+
content_for(:head) { javascript_include_tag(*args) }
|
21
|
+
end
|
22
|
+
end
|