lbs-config 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lbs-config.gemspec +2 -0
- data/lib/generators/lbs/install/install_generator.rb +63 -0
- data/lib/generators/lbs/install/templates/_error_messages.html.erb +17 -0
- data/lib/generators/lbs/install/templates/_error_messages.html.haml +10 -0
- data/lib/generators/lbs/install/templates/_form.html.erb +14 -0
- data/lib/generators/lbs/install/templates/_form.html.haml +12 -0
- data/lib/generators/lbs/install/templates/_form_f.html.erb +6 -0
- data/lib/generators/lbs/install/templates/_form_f.html.haml +5 -0
- data/lib/generators/lbs/install/templates/_form_s.html.erb +6 -0
- data/lib/generators/lbs/install/templates/_form_s.html.haml +5 -0
- data/lib/generators/lbs/install/templates/controller.rb +101 -0
- data/lib/generators/lbs/install/templates/edit.html.erb +6 -0
- data/lib/generators/lbs/install/templates/edit.html.haml +7 -0
- data/lib/generators/lbs/install/templates/index.html.erb +37 -0
- data/lib/generators/lbs/install/templates/index.html.haml +31 -0
- data/lib/generators/lbs/install/templates/migration.rb +10 -0
- data/lib/generators/lbs/install/templates/model.rb +23 -0
- data/lib/generators/lbs/install/templates/new.html.erb +10 -0
- data/lib/generators/lbs/install/templates/new.html.haml +6 -0
- data/lib/generators/lbs/install/templates/show.html.erb +15 -0
- data/lib/generators/lbs/install/templates/show.html.haml +15 -0
- data/lib/lbs-config/version.rb +1 -1
- metadata +40 -8
- data/lib/generators/lbs/hispanizar/USAGE +0 -9
- data/lib/generators/lbs/hispanizar/hispanizar_generator.rb +0 -22
- data/lib/generators/lbs/hispanizar/templates/es.yml +0 -219
- data/lib/generators/lbs/hispanizar/templates/inflections.rb +0 -28
data/lbs-config.gemspec
CHANGED
@@ -0,0 +1,63 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Lbs
|
4
|
+
class InstallGenerator < Rails::Generators::NamedBase
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
|
7
|
+
argument :model_attributes, :type => :array, :default => []
|
8
|
+
|
9
|
+
class_option :engine,
|
10
|
+
:type => :string,
|
11
|
+
:default => 'erb',
|
12
|
+
:desc => 'Indica qué debe usarse para generar la vista [erb, haml]'
|
13
|
+
class_option :cancan,
|
14
|
+
:type => :boolean,
|
15
|
+
:default => false,
|
16
|
+
:desc => 'Indica si se debe validar por cancan (genera vistas con ligas validadas y adapta el controller)'
|
17
|
+
class_option :bootstrap,
|
18
|
+
:type => :boolean,
|
19
|
+
:default => false,
|
20
|
+
:desc => 'Indica si la vista se generará enfocada en boostrap'
|
21
|
+
class_option :form,
|
22
|
+
:type => :string,
|
23
|
+
:default => 'default',
|
24
|
+
:desc => 'Indica que estructura se debe utilizar para el formulario [default, formtastic, simple_form]'
|
25
|
+
|
26
|
+
no_tasks { attr_accessor :model_name, :table_name, :attributes}
|
27
|
+
|
28
|
+
def copy_views
|
29
|
+
template("index.html.#{engine_extension}", "lib/templates/#{engine_extension}/scaffold/index.html.#{engine_extension}")
|
30
|
+
template("edit.html.#{engine_extension}", "lib/templates/#{engine_extension}/scaffold/edit.html.#{engine_extension}")
|
31
|
+
template("new.html.#{engine_extension}", "lib/templates/#{engine_extension}/scaffold/new.html.#{engine_extension}")
|
32
|
+
template("show.html.#{engine_extension}", "lib/templates/#{engine_extension}/scaffold/show.html.#{engine_extension}")
|
33
|
+
|
34
|
+
if form == 'default'
|
35
|
+
template("_form.html.#{engine_extension}", "lib/templates/#{engine_extension}/scaffold/_form.html.#{engine_extension}")
|
36
|
+
copy_file("_error_messages.html.#{engine_extension}", "app/views/application/_error_messages.html.#{engine_extension}")
|
37
|
+
elsif form == 'formtastic'
|
38
|
+
template("_form_f.html.#{engine_extension}", "lib/templates/#{engine_extension}/scaffold/_form.html.#{engine_extension}")
|
39
|
+
elsif form == 'simple_form'
|
40
|
+
template("_form_s.html.#{engine_extension}", "lib/templates/#{engine_extension}/scaffold/_form.html.#{engine_extension}")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def copy_controller
|
45
|
+
template("controller.rb", "lib/templates/rails/scaffold_controller/controller.rb")
|
46
|
+
end
|
47
|
+
|
48
|
+
def copy_model
|
49
|
+
#template 'model.rb', "app/models/#{singular_table_name}.rb"
|
50
|
+
end
|
51
|
+
|
52
|
+
#####################
|
53
|
+
private
|
54
|
+
#####################
|
55
|
+
|
56
|
+
def engine_extension
|
57
|
+
::Rails.application.config.generators.options[:rails][:template_engine] || filter_engine_user_param
|
58
|
+
end
|
59
|
+
|
60
|
+
def filter_engine_user_param
|
61
|
+
%w(erb haml).member?(options.engine) ? options.engine : 'erb'
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<% if target.errors.any? %>
|
2
|
+
<% gender ||= target.class.name.ends_with?("a") ? "female" : "male" %>
|
3
|
+
<% model_name ||= target.class.name.underscore.humanize.downcase %>
|
4
|
+
<div id="error_explanation">
|
5
|
+
<h2>
|
6
|
+
<%= t('activerecord.errors.template.header', :count => target.errors.count, :model => model_name, :article => (gender == "male" ? "El" : "La")) %>
|
7
|
+
</h2>
|
8
|
+
<%= t('activerecord.errors.template.body') %>
|
9
|
+
<ul>
|
10
|
+
<% target.errors.full_messages.each do |msg| %>
|
11
|
+
<li>
|
12
|
+
<%= msg %>
|
13
|
+
</li>
|
14
|
+
<% end %>
|
15
|
+
</ul>
|
16
|
+
</div>
|
17
|
+
<% end %>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
- if target.errors.any?
|
2
|
+
- gender ||= target.class.name.ends_with?("a") ? "female" : "male"
|
3
|
+
- model_name ||= target.class.name.underscore.humanize.downcase
|
4
|
+
#error_explanation
|
5
|
+
%h2
|
6
|
+
= t('activerecord.errors.template.header', :count => target.errors.count, :model => model_name, :article => (gender == "male" ? "El" : "La"))
|
7
|
+
= t('activerecord.errors.template.body')
|
8
|
+
%ul
|
9
|
+
- target.errors.full_messages.each do |msg|
|
10
|
+
%li= msg
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<%%%= form_for(@<%%= singular_table_name %>) do |f| %>
|
2
|
+
<%% object = "@#{singular_table_name}" -%>
|
3
|
+
<%%%= render 'error_messages', <%%= key_value :target, object %> %>
|
4
|
+
|
5
|
+
<%% attributes.each do |attribute| -%>
|
6
|
+
<div class="field">
|
7
|
+
<%%%= f.label :<%%= attribute.name %> %><br />
|
8
|
+
<%%%= f.<%%= attribute.field_type %> :<%%= attribute.name %> %>
|
9
|
+
</div>
|
10
|
+
<%% end -%>
|
11
|
+
<div class="actions">
|
12
|
+
<%%%= f.submit %>
|
13
|
+
</div>
|
14
|
+
<%%% end %>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
= form_for(@<%%= singular_table_name %>) do |f|
|
2
|
+
<%%- object = "@#{singular_table_name}" -%>
|
3
|
+
= render 'error_messages', :target => <%%= object %>
|
4
|
+
|
5
|
+
<%% attributes.each do |attribute| -%>
|
6
|
+
.field
|
7
|
+
= f.label :<%%= attribute.name %>
|
8
|
+
%br
|
9
|
+
= f.<%%= attribute.field_type %> :<%%= attribute.name %>
|
10
|
+
<%% end -%>
|
11
|
+
.actions
|
12
|
+
= f.submit
|
@@ -0,0 +1,101 @@
|
|
1
|
+
<%% module_namespacing do -%>
|
2
|
+
class <%%= controller_class_name %>Controller < ApplicationController
|
3
|
+
<%= 'load_and_authorize_resource' if options.cancan? %>
|
4
|
+
|
5
|
+
# GET <%%= route_url %>
|
6
|
+
# GET <%%= route_url %>.json
|
7
|
+
def index
|
8
|
+
<%%- unless options.cancan? -%>
|
9
|
+
@<%%= plural_table_name %> = <%%= orm_class.all(class_name) %>
|
10
|
+
|
11
|
+
<%%- end -%>
|
12
|
+
respond_to do |format|
|
13
|
+
format.html # index.html.erb
|
14
|
+
format.json { render <%%= key_value :json, "@#{plural_table_name}" %> }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# GET <%%= route_url %>/1
|
19
|
+
# GET <%%= route_url %>/1.json
|
20
|
+
def show
|
21
|
+
<%%- unless options.cancan? -%>
|
22
|
+
@<%%= singular_table_name %> = <%%= orm_class.find(class_name, "params[:id]") %>
|
23
|
+
|
24
|
+
<%%- end -%>
|
25
|
+
respond_to do |format|
|
26
|
+
format.html # show.html.erb
|
27
|
+
format.json { render <%%= key_value :json, "@#{singular_table_name}" %> }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# GET <%%= route_url %>/new
|
32
|
+
# GET <%%= route_url %>/new.json
|
33
|
+
def new
|
34
|
+
<%%- unless options.cancan? -%>
|
35
|
+
@<%%= singular_table_name %> = <%%= orm_class.build(class_name) %>
|
36
|
+
|
37
|
+
<%%- end -%>
|
38
|
+
respond_to do |format|
|
39
|
+
format.html # new.html.erb
|
40
|
+
format.json { render <%%= key_value :json, "@#{singular_table_name}" %> }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# GET <%%= route_url %>/1/edit
|
45
|
+
def edit
|
46
|
+
<%%- unless options.cancan? -%>
|
47
|
+
@<%%= singular_table_name %> = <%%= orm_class.find(class_name, "params[:id]") %>
|
48
|
+
<%%- end -%>
|
49
|
+
end
|
50
|
+
|
51
|
+
# POST <%%= route_url %>
|
52
|
+
# POST <%%= route_url %>.json
|
53
|
+
def create
|
54
|
+
<%%- unless options.cancan? -%>
|
55
|
+
@<%%= singular_table_name %> = <%%= orm_class.build(class_name, "params[:#{singular_table_name}]") %>
|
56
|
+
|
57
|
+
<%%- end -%>
|
58
|
+
respond_to do |format|
|
59
|
+
if @<%%= orm_instance.save %>
|
60
|
+
format.html { redirect_to @<%%= singular_table_name %>, <%%= key_value :notice, "'#{human_name} was successfully created.'" %> }
|
61
|
+
format.json { render <%%= key_value :json, "@#{singular_table_name}" %>, <%%= key_value :status, ':created' %>, <%%= key_value :location, "@#{singular_table_name}" %> }
|
62
|
+
else
|
63
|
+
format.html { render <%%= key_value :action, '"new"' %> }
|
64
|
+
format.json { render <%%= key_value :json, "@#{orm_instance.errors}" %>, <%%= key_value :status, ':unprocessable_entity' %> }
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# PATCH/PUT <%%= route_url %>/1
|
70
|
+
# PATCH/PUT <%%= route_url %>/1.json
|
71
|
+
def update
|
72
|
+
<%%- unless options.cancan? -%>
|
73
|
+
@<%%= singular_table_name %> = <%%= orm_class.find(class_name, "params[:id]") %>
|
74
|
+
|
75
|
+
<%%- end -%>
|
76
|
+
respond_to do |format|
|
77
|
+
if @<%%= orm_instance.update_attributes("params[:#{singular_table_name}]") %>
|
78
|
+
format.html { redirect_to @<%%= singular_table_name %>, <%%= key_value :notice, "'#{human_name} was successfully updated.'" %> }
|
79
|
+
format.json { head :no_content }
|
80
|
+
else
|
81
|
+
format.html { render <%%= key_value :action, '"edit"' %> }
|
82
|
+
format.json { render <%%= key_value :json, "@#{orm_instance.errors}" %>, <%%= key_value :status, ':unprocessable_entity' %> }
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# DELETE <%%= route_url %>/1
|
88
|
+
# DELETE <%%= route_url %>/1.json
|
89
|
+
def destroy
|
90
|
+
<%%- unless options.cancan? -%>
|
91
|
+
@<%%= singular_table_name %> = <%%= orm_class.find(class_name, "params[:id]") %>
|
92
|
+
<%%- end -%>
|
93
|
+
@<%%= orm_instance.destroy %>
|
94
|
+
|
95
|
+
respond_to do |format|
|
96
|
+
format.html { redirect_to <%%= index_helper %>_url }
|
97
|
+
format.json { head :no_content }
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
<%% end -%>
|
@@ -0,0 +1,37 @@
|
|
1
|
+
<h1>Listado de <%%= plural_table_name.humanize %></h1>
|
2
|
+
|
3
|
+
<table>
|
4
|
+
<thead>
|
5
|
+
<tr>
|
6
|
+
<%% attributes.each do |attribute| -%>
|
7
|
+
<th><%%= attribute.human_name %></th>
|
8
|
+
<%% end -%>
|
9
|
+
<th></th>
|
10
|
+
<th></th>
|
11
|
+
<th></th>
|
12
|
+
</tr>
|
13
|
+
</thead>
|
14
|
+
|
15
|
+
<tbody>
|
16
|
+
<%%% @<%%= plural_table_name %>.each do |<%%= singular_table_name %>| %>
|
17
|
+
<tr>
|
18
|
+
<%% attributes.each do |attribute| -%>
|
19
|
+
<td><%%%= <%%= singular_table_name %>.<%%= attribute.name %> %></td>
|
20
|
+
<%% end -%>
|
21
|
+
<%- if options.cancan? -%>
|
22
|
+
<td><%%%= link_to 'Mostrar', <%%= singular_table_name %> if can? :read, @<%%= singular_table_name %> %></td>
|
23
|
+
<td><%%%= link_to 'Editar', edit_<%%= singular_table_name %>_path(<%%= singular_table_name %>) if can? :update, @<%%= singular_table_name %> %></td>
|
24
|
+
<td><%%%= link_to 'Eliminar', <%%= singular_table_name %>, <%%= key_value :confirm, "'¿Está usted seguro?'" %>, <%%= key_value :method, ":delete" %> if can? :destroy, @<%%= singular_table_name %> %></td>
|
25
|
+
<%- else -%>
|
26
|
+
<td><%%%= link_to 'Mostrar', <%%= singular_table_name %> %></td>
|
27
|
+
<td><%%%= link_to 'Editar', edit_<%%= singular_table_name %>_path(<%%= singular_table_name %>) %></td>
|
28
|
+
<td><%%%= link_to 'Eliminar', <%%= singular_table_name %>, <%%= key_value :confirm, "'¿Está usted seguro?'" %>, <%%= key_value :method, ":delete" %> %></td>
|
29
|
+
<%- end -%>
|
30
|
+
</tr>
|
31
|
+
<%%% end %>
|
32
|
+
</tbody>
|
33
|
+
</table>
|
34
|
+
|
35
|
+
<br />
|
36
|
+
<%% nuevo = singular_table_name.split('_').first.ends_with?("a") ? 'Nueva' : 'Nuevo' -%>
|
37
|
+
<%%%= link_to '<%%= nuevo %> <%%= human_name %>', new_<%%= singular_table_name %>_path %>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
%h1 Listado de <%%= plural_table_name.humanize %>
|
2
|
+
|
3
|
+
%table
|
4
|
+
%thead
|
5
|
+
%tr
|
6
|
+
<%%- attributes.each do |attribute| -%>
|
7
|
+
%th <%%= attribute.human_name %>
|
8
|
+
<%%- end -%>
|
9
|
+
%th
|
10
|
+
%th
|
11
|
+
%th
|
12
|
+
|
13
|
+
%tbody
|
14
|
+
- @<%%= plural_table_name %>.each do |<%%= singular_table_name %>|
|
15
|
+
%tr
|
16
|
+
<%%- attributes.each do |attribute| -%>
|
17
|
+
%td= <%%= singular_table_name %>.<%%= attribute.name %>
|
18
|
+
<%%- end -%>
|
19
|
+
<%%- if options.cancan? -%>
|
20
|
+
%td= link_to 'Mostrar', <%%= singular_table_name %> if can? :read, @<%%= singular_table_name %>
|
21
|
+
%td= link_to 'Editar', edit_<%%= singular_table_name %>_path(<%%= singular_table_name %>) if can? :update, @<%%= singular_table_name %>
|
22
|
+
%td= link_to 'Eliminar', <%%= singular_table_name %>, :confirm => '¿Está usted seguro?', :method => :delete if can? :destroy, @<%%= singular_table_name %>
|
23
|
+
<%%- else -%>
|
24
|
+
%td= link_to 'Mostrar', <%%= singular_table_name %>
|
25
|
+
%td= link_to 'Editar', edit_<%%= singular_table_name %>_path(<%%= singular_table_name %>)
|
26
|
+
%td= link_to 'Eliminar', <%%= singular_table_name %>, :confirm => '¿Está usted seguro?', :method => :delete
|
27
|
+
<%%- end -%>
|
28
|
+
|
29
|
+
%br
|
30
|
+
<%% nuevo = singular_table_name.split('_').first.ends_with?("a") ? 'Nueva' : 'Nuevo' -%>
|
31
|
+
= link_to '<%%= nuevo %> <%%= human_name %>', new_<%%= singular_table_name %>_path
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class Create<%= class_name.pluralize.delete('::') %> < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :<%= table_name || plural_name.split('/').last %> do |t|
|
4
|
+
<%- for attribute in model_attributes -%>
|
5
|
+
t.<%= attribute.type %> :<%= attribute.name %>
|
6
|
+
<%- end -%>
|
7
|
+
t.timestamps
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class <%= class_name %> < ActiveRecord::Base
|
2
|
+
attr_accessible <%= model_attributes.map { |a| ":#{a.name}" if accessible_attribute?(a.name) }.compact.join(", ") %>
|
3
|
+
|
4
|
+
# Associations
|
5
|
+
<% model_belongs_to_attributes.each do |bt| %>
|
6
|
+
<%= "belongs_to :" + bt %>
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
# Validations
|
10
|
+
<% if model_uniq_attributes.any? %>
|
11
|
+
<%= "validates #{model_uniq_attributes.map { |a| a.name.to_sym}.join(', ') }, :presence => true, uniqueness => true " %>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
# Scopes
|
15
|
+
|
16
|
+
# Methods
|
17
|
+
|
18
|
+
|
19
|
+
#####################
|
20
|
+
private
|
21
|
+
#####################
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<%% nuevo = singular_table_name.split('_').first.ends_with?("a") ? 'Nueva' : 'Nuevo' -%>
|
2
|
+
<h1><%%= nuevo %> <%%= human_name %></h1>
|
3
|
+
|
4
|
+
<%%%= render 'form' %>
|
5
|
+
|
6
|
+
<%- if options.cancan? -%>
|
7
|
+
<%%%= link_to 'Listado', <%%= index_helper %>_path %>
|
8
|
+
<%- else -%>
|
9
|
+
<%%%= link_to 'Listado', <%%= index_helper %>_path %>
|
10
|
+
<%- end -%>
|
@@ -0,0 +1,15 @@
|
|
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
|
+
<%- if options.cancan? -%>
|
11
|
+
<%%%= link_to 'Editar', edit_<%%= singular_table_name %>_path(@<%%= singular_table_name %>) if can? :update <%%= singular_table_name.camelize %> %>
|
12
|
+
<%- else -%>
|
13
|
+
<%%%= link_to 'Editar', edit_<%%= singular_table_name %>_path(@<%%= singular_table_name %>) %>
|
14
|
+
<%- end -%>
|
15
|
+
| <%%%= link_to 'Listado', <%%= index_helper %>_path %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
%p#notice notice
|
2
|
+
|
3
|
+
<%% attributes.each do |attribute| -%>
|
4
|
+
%p
|
5
|
+
%b <%%= attribute.human_name %>:
|
6
|
+
= @<%%= singular_table_name %>.<%%= attribute.name %>
|
7
|
+
|
8
|
+
<%% end -%>
|
9
|
+
<%%- if options.cancan? -%>
|
10
|
+
= link_to 'Editar', edit_<%%= singular_table_name %>_path(@<%%= singular_table_name %>) if can? :update <%%= singular_table_name.camelize %>
|
11
|
+
<%%- else -%>
|
12
|
+
= link_to 'Editar', edit_<%%= singular_table_name %>_path(@<%%= singular_table_name %>)
|
13
|
+
<%%- end -%>
|
14
|
+
\|
|
15
|
+
= link_to 'Regresar al listado', <%%= index_helper %>_path
|
data/lib/lbs-config/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lbs-config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
13
|
-
dependencies:
|
12
|
+
date: 2012-04-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rieles
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
14
30
|
description: Instala templates para el scaffold, incluye opciones para generarlos
|
15
31
|
con erb, haml, simple_form, formtastic, bootstrap y cancan. Incluye la posibilidad
|
16
32
|
de generarlos en Inglés y Español, con su respectivo inflection.
|
@@ -26,10 +42,26 @@ files:
|
|
26
42
|
- README.md
|
27
43
|
- Rakefile
|
28
44
|
- lbs-config.gemspec
|
29
|
-
- lib/generators/lbs/
|
30
|
-
- lib/generators/lbs/
|
31
|
-
- lib/generators/lbs/
|
32
|
-
- lib/generators/lbs/
|
45
|
+
- lib/generators/lbs/install/install_generator.rb
|
46
|
+
- lib/generators/lbs/install/templates/_error_messages.html.erb
|
47
|
+
- lib/generators/lbs/install/templates/_error_messages.html.haml
|
48
|
+
- lib/generators/lbs/install/templates/_form.html.erb
|
49
|
+
- lib/generators/lbs/install/templates/_form.html.haml
|
50
|
+
- lib/generators/lbs/install/templates/_form_f.html.erb
|
51
|
+
- lib/generators/lbs/install/templates/_form_f.html.haml
|
52
|
+
- lib/generators/lbs/install/templates/_form_s.html.erb
|
53
|
+
- lib/generators/lbs/install/templates/_form_s.html.haml
|
54
|
+
- lib/generators/lbs/install/templates/controller.rb
|
55
|
+
- lib/generators/lbs/install/templates/edit.html.erb
|
56
|
+
- lib/generators/lbs/install/templates/edit.html.haml
|
57
|
+
- lib/generators/lbs/install/templates/index.html.erb
|
58
|
+
- lib/generators/lbs/install/templates/index.html.haml
|
59
|
+
- lib/generators/lbs/install/templates/migration.rb
|
60
|
+
- lib/generators/lbs/install/templates/model.rb
|
61
|
+
- lib/generators/lbs/install/templates/new.html.erb
|
62
|
+
- lib/generators/lbs/install/templates/new.html.haml
|
63
|
+
- lib/generators/lbs/install/templates/show.html.erb
|
64
|
+
- lib/generators/lbs/install/templates/show.html.haml
|
33
65
|
- lib/lbs-config.rb
|
34
66
|
- lib/lbs-config/version.rb
|
35
67
|
homepage: ''
|
@@ -52,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
84
|
version: '0'
|
53
85
|
requirements: []
|
54
86
|
rubyforge_project:
|
55
|
-
rubygems_version: 1.8.
|
87
|
+
rubygems_version: 1.8.23
|
56
88
|
signing_key:
|
57
89
|
specification_version: 3
|
58
90
|
summary: Instala archivos de templates usuales en LogicalBricks Solutions para el
|
@@ -1,9 +0,0 @@
|
|
1
|
-
Description:
|
2
|
-
Genera un archivo de inflections para obtener el plural y singular de las palabras, según las reglas en Español e incluye la traducción por omisión de rails para el locale es.yml
|
3
|
-
|
4
|
-
Example:
|
5
|
-
rails generate lbs:hispanizar
|
6
|
-
|
7
|
-
This will create:
|
8
|
-
config/initializers/inflections.rb
|
9
|
-
config/locales/es.rb
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require 'rails/generators'
|
3
|
-
|
4
|
-
module Lbs
|
5
|
-
module Generators
|
6
|
-
class HispanizarGenerator < Rails::Generators::Base
|
7
|
-
source_root File.expand_path('../templates', __FILE__)
|
8
|
-
class_option :keep_current, :type => :boolean, :default => false, :desc => 'Indica si en lugar de tratar de sobreescribir el archivo de inflections, se debe crear un archivo adicional (inflections_es)'
|
9
|
-
|
10
|
-
def generate_inflections
|
11
|
-
copy_file 'inflections.rb', "config/initializers/#{file_name}.rb"
|
12
|
-
copy_file 'es.yml', 'config/locales/es.yml'
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
def file_name
|
18
|
-
file_name = options.keep_current? ? 'inflections_es' : 'inflections'
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,219 +0,0 @@
|
|
1
|
-
# Basado en https://github.com/svenfuchs/rails-i18n/blob/master/rails/locale/es-MX.yml
|
2
|
-
|
3
|
-
es:
|
4
|
-
number:
|
5
|
-
percentage:
|
6
|
-
format:
|
7
|
-
delimiter: ","
|
8
|
-
currency:
|
9
|
-
format:
|
10
|
-
format: "%u%n"
|
11
|
-
unit: "$"
|
12
|
-
separator: "."
|
13
|
-
delimiter: ","
|
14
|
-
precision: 2
|
15
|
-
significant: false
|
16
|
-
strip_insignificant_zeros: false
|
17
|
-
format:
|
18
|
-
delimiter: ","
|
19
|
-
precision: 2
|
20
|
-
significant: false
|
21
|
-
strip_insignificant_zeros: false
|
22
|
-
separator: "."
|
23
|
-
human:
|
24
|
-
format:
|
25
|
-
delimiter: ","
|
26
|
-
precision: 3
|
27
|
-
significant: true
|
28
|
-
strip_insignificant_zeros: true
|
29
|
-
storage_units:
|
30
|
-
format: "%n %u"
|
31
|
-
units:
|
32
|
-
byte:
|
33
|
-
one: "Byte"
|
34
|
-
other: "Bytes"
|
35
|
-
kb: "KB"
|
36
|
-
mb: "MB"
|
37
|
-
gb: "GB"
|
38
|
-
tb: "TB"
|
39
|
-
decimal_units:
|
40
|
-
format: "%n %u"
|
41
|
-
units:
|
42
|
-
unit: ""
|
43
|
-
thousand: "Mil"
|
44
|
-
million: "Millón"
|
45
|
-
billion: "Mil millones"
|
46
|
-
trillion: "Trillón"
|
47
|
-
quadrillion: "Cuatrillón"
|
48
|
-
precision:
|
49
|
-
format:
|
50
|
-
delimiter: ","
|
51
|
-
|
52
|
-
date:
|
53
|
-
order:
|
54
|
-
- :day
|
55
|
-
- :month
|
56
|
-
- :year
|
57
|
-
abbr_day_names:
|
58
|
-
- dom
|
59
|
-
- lun
|
60
|
-
- mar
|
61
|
-
- mié
|
62
|
-
- jue
|
63
|
-
- vie
|
64
|
-
- sáb
|
65
|
-
abbr_month_names:
|
66
|
-
- ~
|
67
|
-
- ene
|
68
|
-
- feb
|
69
|
-
- mar
|
70
|
-
- abr
|
71
|
-
- may
|
72
|
-
- jun
|
73
|
-
- jul
|
74
|
-
- ago
|
75
|
-
- sep
|
76
|
-
- oct
|
77
|
-
- nov
|
78
|
-
- dic
|
79
|
-
day_names:
|
80
|
-
- domingo
|
81
|
-
- lunes
|
82
|
-
- martes
|
83
|
-
- miércoles
|
84
|
-
- jueves
|
85
|
-
- viernes
|
86
|
-
- sábado
|
87
|
-
month_names:
|
88
|
-
- ~
|
89
|
-
- enero
|
90
|
-
- febrero
|
91
|
-
- marzo
|
92
|
-
- abril
|
93
|
-
- mayo
|
94
|
-
- junio
|
95
|
-
- julio
|
96
|
-
- agosto
|
97
|
-
- septiembre
|
98
|
-
- octubre
|
99
|
-
- noviembre
|
100
|
-
- diciembre
|
101
|
-
formats:
|
102
|
-
short: "%d de %b"
|
103
|
-
default: "%d/%m/%Y"
|
104
|
-
long: "%A, %d de %B de %Y"
|
105
|
-
time:
|
106
|
-
formats:
|
107
|
-
short: "%d de %b a las %H:%M hrs"
|
108
|
-
default: "%a, %d de %b de %Y a las %H:%M:%S %Z"
|
109
|
-
long: "%A, %d de %B de %Y a las %I:%M %p"
|
110
|
-
am: "am"
|
111
|
-
pm: "pm"
|
112
|
-
|
113
|
-
support:
|
114
|
-
array:
|
115
|
-
words_connector: ", "
|
116
|
-
two_words_connector: " y "
|
117
|
-
last_word_connector: " y "
|
118
|
-
|
119
|
-
select:
|
120
|
-
prompt: "Por favor selecciona"
|
121
|
-
|
122
|
-
datetime:
|
123
|
-
distance_in_words:
|
124
|
-
half_a_minute: "medio minuto"
|
125
|
-
less_than_x_seconds:
|
126
|
-
one: "menos de 1 segundo"
|
127
|
-
other: "menos de %{count} segundos"
|
128
|
-
x_seconds:
|
129
|
-
one: "1 segundo"
|
130
|
-
other: "%{count} segundos"
|
131
|
-
less_than_x_minutes:
|
132
|
-
one: "menos de 1 minuto"
|
133
|
-
other: "menos de %{count} minutos"
|
134
|
-
x_minutes:
|
135
|
-
one: "1 minuto"
|
136
|
-
other: "%{count} minutos"
|
137
|
-
about_x_hours:
|
138
|
-
one: "cerca de 1 hora"
|
139
|
-
other: "cerca de %{count} horas"
|
140
|
-
x_days:
|
141
|
-
one: "1 día"
|
142
|
-
other: "%{count} días"
|
143
|
-
about_x_months:
|
144
|
-
one: "cerca de 1 mes"
|
145
|
-
other: "cerca de %{count} meses"
|
146
|
-
x_months:
|
147
|
-
one: "1 mes"
|
148
|
-
other: "%{count} meses"
|
149
|
-
about_x_years:
|
150
|
-
other: "cerca de %{count} años"
|
151
|
-
one: "cerca de 1 año"
|
152
|
-
over_x_years:
|
153
|
-
one: "más de 1 año"
|
154
|
-
other: "más de %{count} años"
|
155
|
-
almost_x_years:
|
156
|
-
one: "casi 1 año"
|
157
|
-
other: "casi %{count} años"
|
158
|
-
prompts:
|
159
|
-
year: 'Año'
|
160
|
-
month: 'Mes'
|
161
|
-
day: 'Día'
|
162
|
-
hour: 'Hora'
|
163
|
-
minute: 'Minuto'
|
164
|
-
second: 'Segundos'
|
165
|
-
|
166
|
-
helpers:
|
167
|
-
select:
|
168
|
-
prompt: "Por favor selecciona"
|
169
|
-
|
170
|
-
submit:
|
171
|
-
create: 'Crear %{model}'
|
172
|
-
update: 'Actualizar %{model}'
|
173
|
-
submit: 'Guardar %{model}'
|
174
|
-
|
175
|
-
errors:
|
176
|
-
format: "%{attribute} %{message}"
|
177
|
-
|
178
|
-
messages: &errors_messages
|
179
|
-
inclusion: "no está incluído en la lista"
|
180
|
-
exclusion: "está reservado"
|
181
|
-
invalid: "es inválido"
|
182
|
-
confirmation: "no coincide con la confirmación"
|
183
|
-
blank: "no puede estar en blanco"
|
184
|
-
empty: "no puede estar vacío"
|
185
|
-
not_a_number: "no es un número"
|
186
|
-
not_an_integer: "debe ser un entero"
|
187
|
-
less_than: "debe ser menor que %{count}"
|
188
|
-
less_than_or_equal_to: "debe ser menor o igual que %{count}"
|
189
|
-
greater_than: "debe ser mayor que %{count}"
|
190
|
-
greater_than_or_equal_to: "debe ser mayor o igual que %{count}"
|
191
|
-
too_short:
|
192
|
-
one: "es demasiado corto (mínimo 1 caracter)"
|
193
|
-
other: "es demasiado corto (mínimo %{count} caracteres)"
|
194
|
-
too_long:
|
195
|
-
one: "es demasiado largo (máximo 1 caracter)"
|
196
|
-
other: "es demasiado largo (máximo %{count} caracteres)"
|
197
|
-
equal_to: "debe ser igual a %{count}"
|
198
|
-
wrong_length:
|
199
|
-
one: "longitud errónea (debe ser de 1 caracter)"
|
200
|
-
other: "longitud errónea (debe ser de %{count} caracteres)"
|
201
|
-
accepted: "debe ser aceptado"
|
202
|
-
even: "debe ser un número par"
|
203
|
-
odd: "debe ser un número non"
|
204
|
-
|
205
|
-
activerecord:
|
206
|
-
errors:
|
207
|
-
template:
|
208
|
-
header:
|
209
|
-
one: "%{article} %{model} no pudo guardarse debido a 1 error"
|
210
|
-
other: "%{article} %{model} no pudo guardarse debido a %{count} errores"
|
211
|
-
body: "Revise que los siguientes campos sean válidos:"
|
212
|
-
|
213
|
-
messages:
|
214
|
-
taken: "ya ha sido tomado"
|
215
|
-
record_invalid: "La validación falló: %{errors}"
|
216
|
-
<<: *errors_messages
|
217
|
-
|
218
|
-
full_messages:
|
219
|
-
format: "%{attribute} %{message}"
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# Be sure to restart your server when you modify this file.
|
2
|
-
|
3
|
-
ActiveSupport::Inflector.inflections do |inflect|
|
4
|
-
inflect.plural(/([rndl])([A-Z]|_|$)/, '\1es\2')
|
5
|
-
inflect.plural(/([aeiou])([A-Z]|_|$)/, '\1s\2')
|
6
|
-
inflect.plural(/([aeiou])([A-Z]|_)([a-z]+)([rndl])([A-Z]|_|$)/,
|
7
|
-
'\1s\2\3\4es\5')
|
8
|
-
inflect.plural(/([rndl])([A-Z]|_)([a-z]+)([aeiou])([A-Z]|_|$)/,
|
9
|
-
'\1es\2\3\4s\5')
|
10
|
-
inflect.plural(/(z)$/i, 'ces')
|
11
|
-
|
12
|
-
final_plural_rndl = /([aeiou][rndl])es([A-Z]|_|$)/
|
13
|
-
final_plural_vocal = /((?<![aeiou][nrdl])[aeiou])s([A-Z]|_|$)/
|
14
|
-
palabra_compuesta_1 = /#{final_plural_rndl}([a-z]+)#{final_plural_vocal}/
|
15
|
-
palabra_compuesta_2 = /#{final_plural_vocal}([a-z]+)#{final_plural_rndl}/
|
16
|
-
|
17
|
-
inflect.singular(/(ia)$/i, '\1')
|
18
|
-
inflect.singular(final_plural_rndl, '\1\2')
|
19
|
-
inflect.singular(final_plural_vocal, '\1\2')
|
20
|
-
inflect.singular(palabra_compuesta_1, '\1\2\3\4\5')
|
21
|
-
inflect.singular(palabra_compuesta_2, '\1\2\3\4\5')
|
22
|
-
inflect.singular(/ces$/, 'z')
|
23
|
-
|
24
|
-
inflect.irregular 'pais', 'paises'
|
25
|
-
inflect.singular /(pais)([A-Z]|_|$)/, '\1\2'
|
26
|
-
|
27
|
-
inflect.uncountable %w( campus lunes martes miercoles jueves viernes )
|
28
|
-
end
|