nu-generators 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .DS_Store
6
+ .rvmrc
7
+ .yardoc
8
+ Gemfile.lock
9
+ InstalledFiles
10
+ _yardoc
11
+ coverage
12
+ doc/
13
+ lib/bundler/man
14
+ pkg
15
+ rdoc
16
+ spec/reports
17
+ test/tmp
18
+ test/version_tmp
19
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in nu-generators.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # nu generators
2
+
3
+ personalized generator for scaffolds.
4
+
5
+ ## usage:
6
+
7
+ ### scaffold:
8
+
9
+ `$ rails generate nu:scaffold NAME [field:type field:type] [options]`
10
+
11
+ ### devise views:
12
+
13
+ `$ rails generate nu:devise_views [options]`
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,14 @@
1
+ module Nu
2
+ module Generators
3
+ class DeviseViewsGenerator < Rails::Generators::Base
4
+ source_root File.expand_path('../templates/devise_views', __FILE__)
5
+
6
+ def copy_views
7
+ directory "mailer", "app/views/devise/mailer"
8
+ directory "passwords", "app/views/devise/passwords"
9
+ directory "sessions", "app/views/devise/sessions"
10
+ directory "shared", "app/views/devise/shared"
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,27 @@
1
+ module Nu
2
+ module Generators
3
+ class ScaffoldGenerator < Rails::Generators::NamedBase
4
+ source_root File.expand_path('../templates/scaffold', __FILE__)
5
+
6
+ argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
7
+
8
+ hook_for :orm, :as => :model
9
+
10
+ def create_controller_file
11
+ template 'controller.rb', "app/controllers/#{plural_name}_controller.rb"
12
+ end
13
+
14
+ def create_views_files
15
+ views = %w(all edit show new _form)
16
+
17
+ views.each do |view|
18
+ template "views/#{view}.html.erb", "app/views/#{plural_name}/#{view}.html.erb"
19
+ end
20
+ end
21
+
22
+ def create_routes
23
+ route "resources :#{plural_name} do; get :all, on: :collection; end"
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,4 @@
1
+ <h1>olá, <%= @resource.email %></h1>
2
+ <p>você solicitou um link para alterar sua senha, o que pode ser feito através do link a seguir.</p>
3
+ <p><%= link_to 'alterar minha senha', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %></p>
4
+ <p>até logo!</p>
@@ -0,0 +1,27 @@
1
+ <div class="publisher small">
2
+ <h1>alterar sua senha</h1>
3
+
4
+ <%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %>
5
+ <%= devise_error_messages! %>
6
+ <%= f.hidden_field :reset_password_token %>
7
+
8
+ <div class="field-group">
9
+ <div class="field">
10
+ <%= f.label :password, "nova senha" %>
11
+ <%= f.password_field :password %>
12
+ </div>
13
+
14
+ <div class="field">
15
+ <%= f.label :password_confirmation, "confirmação da nova senha" %>
16
+ <%= f.password_field :password_confirmation %>
17
+ </div>
18
+
19
+ <div class="field actions-inline">
20
+ <%= f.submit "alterar senha", class: 'btn' %>
21
+ </div>
22
+ </div>
23
+ <% end %>
24
+
25
+ <%= render "devise/shared/links" %>
26
+
27
+ </div>
@@ -0,0 +1,20 @@
1
+ <div class="publisher small">
2
+ <h1>esqueceu sua senha?</h1>
3
+
4
+ <%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %>
5
+ <%= devise_error_messages! %>
6
+
7
+ <div class="field-group">
8
+ <div class="field">
9
+ <%= f.label :email %>
10
+ <%= f.email_field :email %>
11
+ </div>
12
+
13
+ <div class="field">
14
+ <%= f.submit "enviar instruções para recuperar senha", class: 'btn' %>
15
+ </div>
16
+ </div>
17
+ <% end %>
18
+
19
+ <%= render "devise/shared/links" %>
20
+ </div>
@@ -0,0 +1,24 @@
1
+ <div class="publisher small">
2
+ <h1>entrar</h1>
3
+
4
+ <%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
5
+ <div class="field-group">
6
+ <div class="field">
7
+ <%= f.label :email %>
8
+ <%= f.email_field :email %>
9
+ </div>
10
+
11
+ <div class="field">
12
+ <%= f.label :password %>
13
+ <%= f.password_field :password %>
14
+ <% if devise_mapping.rememberable? -%><%= f.check_box :remember_me %> <%= f.label :remember_me, class: 'inline' %><% end -%>
15
+ </div>
16
+
17
+ <div class="field actions-inline">
18
+ <%= f.submit "entrar", class: 'btn' %>
19
+ </div>
20
+ </div>
21
+ <% end %>
22
+
23
+ <%= render "devise/shared/links" %>
24
+ </div>
@@ -0,0 +1,9 @@
1
+ <div class="support-links">
2
+ <%- if controller_name != 'sessions' %>
3
+ <%= link_to "entrar", new_session_path(resource_name) %><br />
4
+ <% end -%>
5
+
6
+ <%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
7
+ <%= link_to "esqueceu sua senha?", new_password_path(resource_name) %><br />
8
+ <% end -%>
9
+ </div>
@@ -0,0 +1,72 @@
1
+ class <%= class_name.pluralize %>Controller < ApplicationController
2
+ #before_filter :authenticate_user!, except: [:show]
3
+
4
+ def all
5
+ @<%= plural_table_name %> = <%= class_name.singularize %>.all
6
+
7
+ respond_to do |format|
8
+ format.html # index.html.erb
9
+ format.json { render json: @<%= plural_table_name %> }
10
+ end
11
+ end
12
+
13
+ def show
14
+ @<%= singular_table_name %> = <%= class_name.singularize %>.find_by_slug(params[:id])
15
+
16
+ respond_to do |format|
17
+ format.html # show.html.erb
18
+ format.json { render json: @<%= singular_table_name %> }
19
+ end
20
+ end
21
+
22
+ def new
23
+ @<%= singular_table_name %> = <%= class_name.singularize %>.new
24
+
25
+ respond_to do |format|
26
+ format.html # new.html.erb
27
+ format.json { render json: @<%= singular_table_name %> }
28
+ end
29
+ end
30
+
31
+ def edit
32
+ @<%= singular_table_name %> = <%= class_name.singularize %>.find_by_slug(params[:id])
33
+ end
34
+
35
+ def create
36
+ @<%= singular_table_name %> = <%= class_name.singularize %>.new(params[:<%= singular_table_name %>])
37
+
38
+ respond_to do |format|
39
+ if @<%= singular_table_name %>.save
40
+ format.html { redirect_to edit_<%= singular_table_name %>_path(@<%= singular_table_name %>) }
41
+ format.json { render json: @<%= singular_table_name %>, status: :created, location: @<%= singular_table_name %> }
42
+ else
43
+ format.html { render action: "new" }
44
+ format.json { render json: @<%= singular_table_name %>.errors, status: :unprocessable_entity }
45
+ end
46
+ end
47
+ end
48
+
49
+ def update
50
+ @<%= singular_table_name %> = <%= class_name.singularize %>.find_by_slug(params[:id])
51
+
52
+ respond_to do |format|
53
+ if @<%= singular_table_name %>.update_attributes(params[:<%= singular_table_name %>])
54
+ format.html { redirect_to all_<%= plural_table_name %>_path }
55
+ format.json { head :ok }
56
+ else
57
+ format.html { render action: "edit" }
58
+ format.json { render json: @<%= singular_table_name %>.errors, status: :unprocessable_entity }
59
+ end
60
+ end
61
+ end
62
+
63
+ def destroy
64
+ @<%= singular_table_name %> = <%= class_name.singularize %>.find_by_slug(params[:id])
65
+ @<%= singular_table_name %>.destroy
66
+
67
+ respond_to do |format|
68
+ format.html { redirect_to all_<%= plural_table_name %>_url }
69
+ format.json { head :ok }
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,28 @@
1
+ <%%= form_for(@<%= singular_table_name %>) do |f| %>
2
+ <%%#= render 'form_messages', object: @<%= singular_table_name %> %>
3
+
4
+ <div class="field-group">
5
+ <%- attributes.each do |attribute| -%>
6
+ <div class="field">
7
+ <%%= f.label :<%= attribute.name %> %>
8
+ <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
9
+ </div>
10
+ <%- end -%>
11
+ </div>
12
+
13
+ <div class="actions">
14
+ <div class="field-group">
15
+ <%%= f.submit "save <%= singular_table_name %>", <%= key_value :class, "'btn btn-primary'" %> %>
16
+ <%%= link_to "cancel", :back, <%= key_value :class, "'btn'" %> %>
17
+ </div>
18
+
19
+ <%%#= render 'status', object: @<%= singular_table_name %>, f: f %>
20
+
21
+ <%%- unless @<%= singular_table_name %>.new_record? -%>
22
+ <div class="field-group">
23
+ <%%= link_to "visualize", @<%= singular_table_name %>, <%= key_value :class, "'btn'" %> %>
24
+ <%%= link_to "remove", @<%= singular_table_name %>, <%= key_value :method, ":delete" %>, <%= key_value :data, "{ confirm: 'Are you sure?' }" %>, <%= key_value :class, "'btn btn-danger'" %> %>
25
+ </div>
26
+ <%%- end -%>
27
+ </div>
28
+ <%% end %>
@@ -0,0 +1,27 @@
1
+ <h1>Listing <%= plural_table_name %></h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <% attributes.each do |attribute| -%>
6
+ <th><%= attribute.human_name %></th>
7
+ <% end -%>
8
+ <th></th>
9
+ <th></th>
10
+ <th></th>
11
+ </tr>
12
+
13
+ <%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %>
14
+ <tr>
15
+ <% attributes.each do |attribute| -%>
16
+ <td><%%= <%= singular_table_name %>.<%= attribute.name %> %></td>
17
+ <% end -%>
18
+ <td><%%= link_to 'Show', <%= singular_table_name %> %></td>
19
+ <td><%%= link_to 'Edit', edit_<%= singular_table_name %>_path(<%= singular_table_name %>) %></td>
20
+ <td><%%= link_to 'Destroy', <%= singular_table_name %>, <%= key_value :method, ":delete" %>, <%= key_value :data, "{ confirm: 'Are you sure?' }" %> %></td>
21
+ </tr>
22
+ <%% end %>
23
+ </table>
24
+
25
+ <br />
26
+
27
+ <%%= link_to 'New <%= human_name %>', new_<%= singular_table_name %>_path %>
@@ -0,0 +1,5 @@
1
+ <div class="publisher">
2
+ <h1>editing <%= singular_table_name %></h1>
3
+
4
+ <%%= render 'form' %>
5
+ </div>
@@ -0,0 +1,5 @@
1
+ <div class="publisher">
2
+ <h1>new <%= singular_table_name %></h1>
3
+
4
+ <%%= render 'form' %>
5
+ </div>
@@ -0,0 +1,12 @@
1
+ <p id="notice"><%%= notice %></p>
2
+
3
+ <% attributes.each do |attribute| -%>
4
+ <p>
5
+ <b><%= attribute.human_name %>:</b>
6
+ <%%= @<%= singular_table_name %>.<%= attribute.name %> %>
7
+ </p>
8
+
9
+ <% end -%>
10
+
11
+ <%%= link_to 'Edit', edit_<%= singular_table_name %>_path(@<%= singular_table_name %>) %> |
12
+ <%%= link_to 'Back', <%= index_helper %>_path %>
@@ -0,0 +1,5 @@
1
+ module Nu
2
+ module Generators
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1 @@
1
+ require "nu-generators/version"
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/nu-generators/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ['Lucas Renan', 'Rodrigo Brancher', 'Tiago Rafael Godinho']
6
+ gem.email = ['contato@lucasrenan.com', 'rbrancher@gmail.com', 'tiagogodinho3@gmail.com']
7
+ gem.description = %q{nu design custom generators}
8
+ gem.summary = %q{nu design custom generators}
9
+ gem.homepage = "https://github.com/nudesign/nu-generators"
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "nu-generators"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Nu::Generators::VERSION
17
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nu-generators
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Lucas Renan
9
+ - Rodrigo Brancher
10
+ - Tiago Rafael Godinho
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+ date: 2012-11-12 00:00:00.000000000 Z
15
+ dependencies: []
16
+ description: nu design custom generators
17
+ email:
18
+ - contato@lucasrenan.com
19
+ - rbrancher@gmail.com
20
+ - tiagogodinho3@gmail.com
21
+ executables: []
22
+ extensions: []
23
+ extra_rdoc_files: []
24
+ files:
25
+ - .gitignore
26
+ - Gemfile
27
+ - README.md
28
+ - Rakefile
29
+ - lib/generators/nu/devise_views_generator.rb
30
+ - lib/generators/nu/scaffold_generator.rb
31
+ - lib/generators/nu/templates/devise_views/mailer/reset_password_instructions.html.erb
32
+ - lib/generators/nu/templates/devise_views/passwords/edit.html.erb
33
+ - lib/generators/nu/templates/devise_views/passwords/new.html.erb
34
+ - lib/generators/nu/templates/devise_views/sessions/new.html.erb
35
+ - lib/generators/nu/templates/devise_views/shared/_links.erb
36
+ - lib/generators/nu/templates/scaffold/controller.rb
37
+ - lib/generators/nu/templates/scaffold/views/_form.html.erb
38
+ - lib/generators/nu/templates/scaffold/views/all.html.erb
39
+ - lib/generators/nu/templates/scaffold/views/edit.html.erb
40
+ - lib/generators/nu/templates/scaffold/views/new.html.erb
41
+ - lib/generators/nu/templates/scaffold/views/show.html.erb
42
+ - lib/nu-generators.rb
43
+ - lib/nu-generators/version.rb
44
+ - nu-generators.gemspec
45
+ homepage: https://github.com/nudesign/nu-generators
46
+ licenses: []
47
+ post_install_message:
48
+ rdoc_options: []
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ requirements: []
64
+ rubyforge_project:
65
+ rubygems_version: 1.8.24
66
+ signing_key:
67
+ specification_version: 3
68
+ summary: nu design custom generators
69
+ test_files: []