survey_generator 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +15 -0
  2. data/lib/generators/survey/USAGE +10 -10
  3. data/lib/generators/survey/metamodels/survey_metamodel.rb +6 -5
  4. data/lib/generators/survey/survey_generator.rb +15 -15
  5. data/lib/generators/survey/templates/app/app.tpl +4 -6
  6. data/lib/generators/survey/templates/app/assets/assets.tpl +4 -0
  7. data/lib/generators/survey/templates/app/assets/stylesheets/stylesheet.tpl +188 -183
  8. data/lib/generators/survey/templates/app/controllers/application_controller.tpl +15 -0
  9. data/lib/generators/survey/templates/app/controllers/controllers.tpl +7 -0
  10. data/lib/generators/survey/templates/app/controllers/sessions_controller.tpl +26 -0
  11. data/lib/generators/survey/templates/app/controllers/static_pages_controller.tpl +20 -0
  12. data/lib/generators/survey/templates/app/controllers/survey_controller.tpl +0 -19
  13. data/lib/generators/survey/templates/app/controllers/users_controller.tpl +82 -0
  14. data/lib/generators/survey/templates/app/helpers/helpers.tpl +5 -0
  15. data/lib/generators/survey/templates/app/helpers/sessions_helper.tpl +46 -0
  16. data/lib/generators/survey/templates/app/helpers/users_helper.tpl +14 -0
  17. data/lib/generators/survey/templates/app/models/models.tpl +6 -0
  18. data/lib/generators/survey/templates/app/models/question.tpl +10 -0
  19. data/lib/generators/survey/templates/app/models/survey.tpl +10 -0
  20. data/lib/generators/survey/templates/app/models/test.tpl +15 -0
  21. data/lib/generators/survey/templates/app/models/user.tpl +28 -0
  22. data/lib/generators/survey/templates/app/views/layouts/footer.tpl +2 -2
  23. data/lib/generators/survey/templates/app/views/layouts/header.tpl +21 -13
  24. data/lib/generators/survey/templates/app/views/sessions/new.tpl +28 -0
  25. data/lib/generators/survey/templates/app/views/shared/error_messages.tpl +1 -1
  26. data/lib/generators/survey/templates/app/views/static_pages/home.tpl +1 -1
  27. data/lib/generators/survey/templates/app/views/survey/form.tpl +40 -0
  28. data/lib/generators/survey/templates/app/views/survey/index.tpl +40 -0
  29. data/lib/generators/survey/templates/app/views/survey/table.tpl +20 -0
  30. data/lib/generators/survey/templates/app/views/survey/textfield.tpl +21 -0
  31. data/lib/generators/survey/templates/app/views/users/edit.tpl +19 -0
  32. data/lib/generators/survey/templates/app/views/users/fields.tpl +24 -0
  33. data/lib/generators/survey/templates/app/views/users/index.tpl +17 -0
  34. data/lib/generators/survey/templates/app/views/users/new.tpl +15 -0
  35. data/lib/generators/survey/templates/app/views/users/show.tpl +15 -0
  36. data/lib/generators/survey/templates/app/views/users/user.tpl +11 -0
  37. data/lib/generators/survey/templates/app/views/views.tpl +11 -2
  38. data/lib/generators/survey/templates/config/routes.tpl +7 -0
  39. data/lib/generators/survey/templates/db/db.tpl +0 -1
  40. data/lib/generators/survey/templates/db/migrate/create_questions.tpl +5 -2
  41. data/lib/generators/survey/templates/db/migrate/create_surveys.tpl +4 -1
  42. data/lib/generators/survey/templates/db/migrate/create_users.tpl +1 -1
  43. data/lib/tasks/sample_data.rake +20 -0
  44. metadata +31 -11
  45. data/lib/generators/survey/templates/app/models/survey_model.tpl +0 -45
  46. data/lib/generators/survey/templates/app/views/survey/survey_form_view.tpl +0 -37
  47. data/lib/generators/survey/templates/app/views/survey/survey_index_view.tpl +0 -38
  48. data/lib/generators/survey/templates/db/migrate/create_pages.tpl +0 -18
@@ -0,0 +1,40 @@
1
+ <% define 'form', for: Survey do %>
2
+ <% file "app/views/" + name.pluralize.downcase + "/_form.html.erb" do %>
3
+ <%% @post.tags.build %>
4
+ <%%= form_for(@post) do |post_form| %><%iinc%>
5
+ <%% if @post.errors.any? %><%iinc%>
6
+ <div id="errorExplanation"><%iinc%>
7
+ <h2><%%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2>
8
+ <ul><%iinc%>
9
+ <%% @post.errors.full_messages.each do |msg| %><%iinc%>
10
+ <li><%%= msg %></li>
11
+ <%idec%><%% end %>
12
+ <%idec%></ul>
13
+ <%idec%></div>
14
+ <%idec%><%% end %>
15
+
16
+ <%nl%>
17
+ <div class="field"><%iinc%>
18
+ <%%= post_form.label :name %><br />
19
+ <%%= post_form.text_field :name %>
20
+ <%idec%></div>
21
+ <div class="field"><%iinc%>
22
+ <%%= post_form.label :title %><br />
23
+ <%%= post_form.text_field :title %>
24
+ <%idec%></div>
25
+ <div class="field"><%iinc%>
26
+ <%%= post_form.label :content %><br />
27
+ <%%= post_form.text_area :content %>
28
+ <%idec%></div>
29
+
30
+ <%nl%>
31
+ <h2>Tags</h2>
32
+ <%%= render :partial => 'tags/form', :locals => {:form => post_form} %>
33
+
34
+ <%nl%>
35
+ <div class="actions"><%iinc%>
36
+ <%%= post_form.submit %>
37
+ <%idec%></div>
38
+ <%idec%><%% end %>
39
+ <% end %>
40
+ <% end %>
@@ -0,0 +1,40 @@
1
+ <% define 'index', for: Survey do %>
2
+ <% file "app/views/" + name.pluralize.downcase + "/index.html.erb" do %>
3
+ <%% provide(:title, "<%= title.capitalize %>") %>
4
+ <h1><%= title.capitalize %></h1>
5
+ <div class="author">by <%= author %></div>
6
+
7
+ <%nl%>
8
+ <div class="row"><%iinc%>
9
+ <div class="span6 offset3"><%iinc%>
10
+ <%%= form_tag <%= name.pluralize.downcase %>_path do %><%iinc%>
11
+ <%%# render 'shared/error_messages', object: f.object %>
12
+ <% expand 'question', foreach: questions %>
13
+ <%idec%><%% end %>
14
+
15
+ <%nl%>
16
+ <div class="actions"><%iinc%>
17
+ <%%= submit_tag "Submit", class: "btn btn-large btn-primary" %>
18
+ <%idec%></div>
19
+ <%idec%></div>
20
+ <%idec%></div>
21
+ <% end %>
22
+ <% end %>
23
+
24
+ <% define 'question', for: Question do %>
25
+ <% answers.each do |answer| %>
26
+ <% if answer.is_a?(Table) %>
27
+ <% expand 'table::table', for: answer %>
28
+ <% elsif answer.is_a?(Answer) %>
29
+ <% expand 'answer', for: answer %>
30
+ <% end %>
31
+ <% end %>
32
+ <% end %>
33
+
34
+ <% define 'answer', for: Answer do %>
35
+ <% options.each do |option| %>
36
+ <% if option.is_a?(Textfield) %>
37
+ <% expand 'textfield::textfield', for: option %>
38
+ <% end %>
39
+ <% end %>
40
+ <% end %>
@@ -0,0 +1,20 @@
1
+ <% define 'table', for: Table do %>
2
+ <%%= label_tag :title, "<%= title %>" %>
3
+
4
+ <%nl%>
5
+ <table border="1"><%iinc%>
6
+ <tr><%iinc%>
7
+ <th></th>
8
+ <% columns.each do |column| %>
9
+ <th><%= column.name %></th>
10
+ <% end %>
11
+ <%idec%></tr>
12
+
13
+ <%nl%>
14
+ <% rows.each do |row| %>
15
+ <tr><%iinc%>
16
+ <th><%= row.name %></th>
17
+ <%idec%></tr>
18
+ <% end %>
19
+ <%idec%></table>
20
+ <% end %>
@@ -0,0 +1,21 @@
1
+ <% define 'textfield', for: Textfield do %>
2
+ <div class="<%= name %>"><%iinc%>
3
+ <%%= label_tag :title, "<%= title %>" %>
4
+
5
+ <% if prefix != "" %>
6
+ <%%= label_tag :title, "<%= prefix %>" %>
7
+ <% end %>
8
+
9
+ <% if isSmall %>
10
+ <%%= text_field_tag(:title, "", size: 20) %>
11
+ <% elsif isMultiLine %>
12
+ <%%= text_area_tag(:title, "", size: "24x6") %>
13
+ <% else %>
14
+ <%%= text_field_tag :title %>
15
+ <% end %>
16
+
17
+ <% if suffix != "" %>
18
+ <%%= label_tag :title, "<%= suffix %>" %>
19
+ <% end %>
20
+ <%idec%></div>
21
+ <% end %>
@@ -0,0 +1,19 @@
1
+ <% define 'edit', for: Survey do %>
2
+ <% file "app/views/users/edit.html.erb" do %>
3
+ <%% provide(:title, "Edit user") %>
4
+ <h1>Update your profile</h1>
5
+
6
+ <%nl%>
7
+ <div class="row"><%iinc%>
8
+ <div class="span6 offset3"><%iinc%>
9
+ <%%= form_for(@user) do |f| %><%iinc%>
10
+ <%%= render 'fields', f: f, password_confirm_label: "Confirm Password", submit_label: "Save changes" %>
11
+ <%idec%><%% end %>
12
+
13
+ <%nl%>
14
+ <%%= gravatar_for @user, 80 %>
15
+ <%%= link_to "change", "http://gravatar.com/emails", target: "_blank"%>
16
+ <%idec%></div>
17
+ <%idec%></div>
18
+ <% end %>
19
+ <% end %>
@@ -0,0 +1,24 @@
1
+ <% define 'fields', for: Survey do %>
2
+ <% file "app/views/users/_fields.html.erb" do %>
3
+ <%%= render 'shared/error_messages', object: f.object %>
4
+
5
+ <%nl%>
6
+ <%%= f.label :name %>
7
+ <%%= f.text_field :name %>
8
+
9
+ <%nl%>
10
+ <%%= f.label :email %>
11
+ <%%= f.text_field :email %>
12
+
13
+ <%nl%>
14
+ <%%= f.label :password %>
15
+ <%%= f.password_field :password %>
16
+
17
+ <%nl%>
18
+ <%%= f.label :password_confirmation, password_confirm_label %>
19
+ <%%= f.password_field :password_confirmation %>
20
+
21
+ <%nl%>
22
+ <%%= f.submit submit_label , class: "btn btn-large btn-primary" %>
23
+ <% end %>
24
+ <% end %>
@@ -0,0 +1,17 @@
1
+ <% define 'index', for: Survey do %>
2
+ <% file "app/views/users/index.html.erb" do %>
3
+ <%% provide(:title, 'All users') %>
4
+ <h1>All users</h1>
5
+
6
+ <%nl%>
7
+ <%%= will_paginate %>
8
+
9
+ <%nl%>
10
+ <ul class="users"><%iinc%>
11
+ <%%= render @users %>
12
+ <%idec%></ul>
13
+
14
+ <%nl%>
15
+ <%%= will_paginate %>
16
+ <% end %>
17
+ <% end %>
@@ -0,0 +1,15 @@
1
+ <% define 'new', for: Survey do %>
2
+ <% file "app/views/users/new.html.erb" do %>
3
+ <%% provide(:title, 'Sign up') %>
4
+ <h1>Sign up</h1>
5
+
6
+ <%nl%>
7
+ <div class="row"><%iinc%>
8
+ <div class="span6 offset3"><%iinc%>
9
+ <%%= form_for(@user) do |f| %><%iinc%>
10
+ <%%= render 'fields', f: f, password_confirm_label: "Confirmation", submit_label:"Create my account" %>
11
+ <%idec%><%% end %>
12
+ <%idec%></div>
13
+ <%idec%></div>
14
+ <% end %>
15
+ <% end %>
@@ -0,0 +1,15 @@
1
+ <% define 'show', for: Survey do %>
2
+ <% file "app/views/users/show.html.erb" do %>
3
+ <%% provide(:title, @user.name) %>
4
+ <div class="row"><%iinc%>
5
+ <aside class="span4"><%iinc%>
6
+ <section><%iinc%>
7
+ <h1><%iinc%>
8
+ <%%= gravatar_for @user, 80 %>
9
+ <%%= @user.name %>
10
+ <%idec%></h1>
11
+ <%idec%></section>
12
+ <%idec%></aside>
13
+ </div>
14
+ <% end %>
15
+ <% end %>
@@ -0,0 +1,11 @@
1
+ <% define 'user', for: Survey do %>
2
+ <% file "app/views/users/_user.html.erb" do %>
3
+ <li><%iinc%>
4
+ <%%= gravatar_for user, 52 %>
5
+ <%%= link_to user.name, user %>
6
+ <%% if current_user.admin? && !current_user?(user) %><%iinc%>
7
+ | <%%= link_to "delete", user, method: :delete, data: { confirm: "You sure?" } %>
8
+ <%% end %>
9
+ <%idec%></li>
10
+ <% end %>
11
+ <% end %>
@@ -4,6 +4,8 @@
4
4
  <% expand 'layouts/footer::footer' %>
5
5
  <% expand 'layouts/shim::shim' %>
6
6
 
7
+ <% expand 'sessions/new::new' %>
8
+
7
9
  <% expand 'shared/error_messages::error_messages' %>
8
10
 
9
11
  <% expand 'static_pages/about::about' %>
@@ -11,6 +13,13 @@
11
13
  <% expand 'static_pages/help::help' %>
12
14
  <% expand 'static_pages/home::home' %>
13
15
 
14
- <% expand 'survey/survey_index_view::survey_index_view' %>
15
- <% expand 'survey/survey_form_view::survey_form_view' %>
16
+ <% expand 'survey/index::index' %>
17
+ <% expand 'survey/form::form' %>
18
+
19
+ <% expand 'users/new::new' %>
20
+ <% expand 'users/fields::fields' %>
21
+ <% expand 'users/edit::edit' %>
22
+ <% expand 'users/show::show' %>
23
+ <% expand 'users/index::index' %>
24
+ <% expand 'users/user::user' %>
16
25
  <% end %>
@@ -2,10 +2,17 @@
2
2
  <% file "config/routes.rb" do %>
3
3
  Generator::Application.routes.draw do<%iinc%>
4
4
  resources :<%= name.pluralize.downcase %>
5
+ resources :users
6
+ resources :sessions, only: [:new, :create, :destroy]
5
7
 
6
8
  <%nl%>
7
9
  root to: 'static_pages#home'
8
10
 
11
+ <%nl%>
12
+ match '/signup', to: 'users#new'
13
+ match '/signin', to: 'sessions#new'
14
+ match '/signout', to: 'sessions#destroy', via: :delete
15
+
9
16
  <%nl%>
10
17
  match '/help', to: 'static_pages#help'
11
18
  match '/about', to: 'static_pages#about'
@@ -1,6 +1,5 @@
1
1
  <% define 'root' do %>
2
2
  <% expand 'migrate/create_surveys::create_surveys' %>
3
- <% expand 'migrate/create_pages::create_pages' %>
4
3
  <% expand 'migrate/create_questions::create_questions' %>
5
4
  <% expand 'migrate/create_users::create_users' %>
6
5
  <% end %>
@@ -1,15 +1,18 @@
1
1
  <% define 'create_questions' do %>
2
- <% file "db/migrate/create_questions.rb" do %>
2
+ <% file "db/migrate/#{DateTime.new(2013, 1, 1, 0, 0, 2).to_s(:number)}_create_questions.rb" do %>
3
3
  class CreateQuestions < ActiveRecord::Migration<%iinc%>
4
4
  def change<%iinc%>
5
5
  create_table :questions do |t|<%iinc%>
6
6
  t.string :name
7
7
  t.string :content
8
- t.integer :page_id
8
+ t.integer :survey_id
9
9
 
10
10
  <%nl%>
11
11
  t.timestamps
12
12
  <%idec%>end
13
+
14
+ <%nl%>
15
+ add_index :questions, [:survey_id, :created_at]
13
16
  <%idec%>end
14
17
  <%idec%>end
15
18
  <% end %>
@@ -1,5 +1,5 @@
1
1
  <% define 'create_surveys' do %>
2
- <% file "db/migrate/create_surveys.rb" do %>
2
+ <% file "db/migrate/#{DateTime.new(2013, 1, 1, 0, 0, 3).to_s(:number)}_create_surveys.rb" do %>
3
3
  class CreateSurveys < ActiveRecord::Migration<%iinc%>
4
4
  def change<%iinc%>
5
5
  create_table :surveys do |t|<%iinc%>
@@ -11,6 +11,9 @@
11
11
  <%nl%>
12
12
  t.timestamps
13
13
  <%idec%>end
14
+
15
+ <%nl%>
16
+ add_index :surveys, [:user_id, :created_at]
14
17
  <%idec%>end
15
18
  <%idec%>end
16
19
  <% end %>
@@ -1,5 +1,5 @@
1
1
  <% define 'create_users' do %>
2
- <% file "db/migrate/create_users.rb" do %>
2
+ <% file "db/migrate/#{DateTime.new(2013, 1, 1, 0, 0, 4).to_s(:number)}_create_users.rb" do %>
3
3
  class CreateUsers < ActiveRecord::Migration<%iinc%>
4
4
  def change<%iinc%>
5
5
  create_table :users do |t|<%iinc%>
@@ -0,0 +1,20 @@
1
+ namespace :db do
2
+ desc "Fill database with sample data"
3
+ task populate: :environment do
4
+ make_users
5
+ end
6
+ end
7
+
8
+ def make_users
9
+ admin = User.create!(name: "Example User", email: "example@railstutorial.org", password: "foobar", password_confirmation: "foobar")
10
+ admin.toggle!(:admin)
11
+ admin2 = User.create!(name: "Daniel Kemper", email: "dkemp04@gmail.com", password: "foobar", password_confirmation: "foobar")
12
+ admin2.toggle!(:admin)
13
+
14
+ 99.times do |n|
15
+ name = Faker::Name.name
16
+ email = "example-#{n + 1}@railstutorial.org"
17
+ password = "password"
18
+ User.create!(name: name, email: email, password: password, password_confirmation: password)
19
+ end
20
+ end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: survey_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Dkemp04
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-05-12 00:00:00.000000000 Z
11
+ date: 2013-05-14 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: A generator for surveys based on model-driven development with RGen.
15
14
  email: dkemp04@gmail.com
@@ -21,54 +20,75 @@ files:
21
20
  - lib/generators/survey/metamodels/survey_metamodel_ext.rb
22
21
  - lib/generators/survey/survey_generator.rb
23
22
  - lib/generators/survey/templates/app/app.tpl
23
+ - lib/generators/survey/templates/app/assets/assets.tpl
24
24
  - lib/generators/survey/templates/app/assets/javascripts/application.tpl
25
25
  - lib/generators/survey/templates/app/assets/stylesheets/stylesheet.tpl
26
+ - lib/generators/survey/templates/app/controllers/application_controller.tpl
27
+ - lib/generators/survey/templates/app/controllers/controllers.tpl
28
+ - lib/generators/survey/templates/app/controllers/sessions_controller.tpl
29
+ - lib/generators/survey/templates/app/controllers/static_pages_controller.tpl
26
30
  - lib/generators/survey/templates/app/controllers/survey_controller.tpl
31
+ - lib/generators/survey/templates/app/controllers/users_controller.tpl
27
32
  - lib/generators/survey/templates/app/helpers/application_helper.tpl
28
- - lib/generators/survey/templates/app/models/survey_model.tpl
33
+ - lib/generators/survey/templates/app/helpers/helpers.tpl
34
+ - lib/generators/survey/templates/app/helpers/sessions_helper.tpl
35
+ - lib/generators/survey/templates/app/helpers/users_helper.tpl
36
+ - lib/generators/survey/templates/app/models/models.tpl
37
+ - lib/generators/survey/templates/app/models/question.tpl
38
+ - lib/generators/survey/templates/app/models/survey.tpl
39
+ - lib/generators/survey/templates/app/models/test.tpl
40
+ - lib/generators/survey/templates/app/models/user.tpl
29
41
  - lib/generators/survey/templates/app/views/layouts/application.tpl
30
42
  - lib/generators/survey/templates/app/views/layouts/footer.tpl
31
43
  - lib/generators/survey/templates/app/views/layouts/header.tpl
32
44
  - lib/generators/survey/templates/app/views/layouts/shim.tpl
45
+ - lib/generators/survey/templates/app/views/sessions/new.tpl
33
46
  - lib/generators/survey/templates/app/views/shared/error_messages.tpl
34
47
  - lib/generators/survey/templates/app/views/static_pages/about.tpl
35
48
  - lib/generators/survey/templates/app/views/static_pages/contact.tpl
36
49
  - lib/generators/survey/templates/app/views/static_pages/help.tpl
37
50
  - lib/generators/survey/templates/app/views/static_pages/home.tpl
38
- - lib/generators/survey/templates/app/views/survey/survey_form_view.tpl
39
- - lib/generators/survey/templates/app/views/survey/survey_index_view.tpl
51
+ - lib/generators/survey/templates/app/views/survey/form.tpl
52
+ - lib/generators/survey/templates/app/views/survey/index.tpl
53
+ - lib/generators/survey/templates/app/views/survey/table.tpl
54
+ - lib/generators/survey/templates/app/views/survey/textfield.tpl
55
+ - lib/generators/survey/templates/app/views/users/edit.tpl
56
+ - lib/generators/survey/templates/app/views/users/fields.tpl
57
+ - lib/generators/survey/templates/app/views/users/index.tpl
58
+ - lib/generators/survey/templates/app/views/users/new.tpl
59
+ - lib/generators/survey/templates/app/views/users/show.tpl
60
+ - lib/generators/survey/templates/app/views/users/user.tpl
40
61
  - lib/generators/survey/templates/app/views/views.tpl
41
62
  - lib/generators/survey/templates/config/config.tpl
42
63
  - lib/generators/survey/templates/config/routes.tpl
43
64
  - lib/generators/survey/templates/db/db.tpl
44
- - lib/generators/survey/templates/db/migrate/create_pages.tpl
45
65
  - lib/generators/survey/templates/db/migrate/create_questions.tpl
46
66
  - lib/generators/survey/templates/db/migrate/create_surveys.tpl
47
67
  - lib/generators/survey/templates/db/migrate/create_users.tpl
48
68
  - lib/generators/survey/templates/main.tpl
49
69
  - lib/generators/survey/USAGE
70
+ - lib/tasks/sample_data.rake
50
71
  homepage: http://rubygems.org/gems/survey_generator
51
72
  licenses: []
73
+ metadata: {}
52
74
  post_install_message:
53
75
  rdoc_options: []
54
76
  require_paths:
55
77
  - lib
56
78
  required_ruby_version: !ruby/object:Gem::Requirement
57
- none: false
58
79
  requirements:
59
80
  - - ! '>='
60
81
  - !ruby/object:Gem::Version
61
82
  version: '0'
62
83
  required_rubygems_version: !ruby/object:Gem::Requirement
63
- none: false
64
84
  requirements:
65
85
  - - ! '>='
66
86
  - !ruby/object:Gem::Version
67
87
  version: '0'
68
88
  requirements: []
69
89
  rubyforge_project:
70
- rubygems_version: 1.8.24
90
+ rubygems_version: 2.0.3
71
91
  signing_key:
72
- specification_version: 3
92
+ specification_version: 4
73
93
  summary: A generator for surveys based on model-driven development with RGen.
74
94
  test_files: []