rieles 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
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.swp
19
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rieles.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Azarel Doroteo Pacheco
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Rieles
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'rieles'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install rieles
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,15 @@
1
+ Description:
2
+ Genera un archivo de inflections para obtener el plural y singular de las palabras, según las reglas en Español, incluye la traducción por omisión de rails para el locale es.yml y los templates para que al utilizar el sacffold, las vistas sean generadas también en Español
3
+
4
+ Example:
5
+ rails generate rieles
6
+
7
+ This will create:
8
+ config/initializers/inflections.rb
9
+ config/locales/es.rb
10
+ lib/templates/erb/scaffold/index.html.erb
11
+ lib/templates/erb/scaffold/edit.html.erb
12
+ lib/templates/erb/scaffold/new.html.erb
13
+ lib/templates/erb/scaffold/show.html.erb
14
+ lib/templates/erb/scaffold/_form.html.erb
15
+ app/views/application/_error_messages.html.erb
@@ -0,0 +1,22 @@
1
+ # encoding: UTF-8
2
+ class RielesGenerator < Rails::Generators::Base
3
+ source_root File.expand_path('../templates', __FILE__)
4
+ class_option :keep_current_inflections, :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)'
5
+
6
+ def copy_files
7
+ copy_file 'inflections.rb', "config/initializers/#{file_name}.rb"
8
+ copy_file 'es.yml', 'config/locales/es.yml'
9
+ copy_file 'index.html.erb', 'lib/templates/erb/scaffold/index.html.erb'
10
+ copy_file 'edit.html.erb', 'lib/templates/erb/scaffold/edit.html.erb'
11
+ copy_file 'new.html.erb', 'lib/templates/erb/scaffold/new.html.erb'
12
+ copy_file 'show.html.erb', 'lib/templates/erb/scaffold/show.html.erb'
13
+ copy_file '_form.html.erb', 'lib/templates/erb/scaffold/_form.html.erb'
14
+ copy_file '_error_messages.html.erb', 'app/views/application/_error_messages.html.erb'
15
+ end
16
+
17
+ private
18
+
19
+ def file_name
20
+ file_name = options.keep_current? ? 'inflections_es' : 'inflections'
21
+ end
22
+ 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,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,6 @@
1
+ <h1>Editar <%= human_name %></h1>
2
+
3
+ <%%= render 'form' %>
4
+
5
+ <%%= link_to 'Mostrar', @<%= singular_table_name %> %> |
6
+ <%%= link_to 'Listado', <%= index_helper %>_path %>
@@ -0,0 +1,219 @@
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}"
@@ -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('_')[0].ends_with?("a") ? 'Nueva' : 'Nuevo' -%>
37
+ <%%= link_to '<%= nuevo %> <%= human_name %>', new_<%= singular_table_name %>_path if can? :create, <%= singular_table_name.camelize %> %>
@@ -0,0 +1,28 @@
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
@@ -0,0 +1,10 @@
1
+ <% nuevo = singular_table_name.split('_')[0].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 if can? :read, <%= singular_table_name.camelize %> %>
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
+ <%- end -%>
9
+
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 %>
data/lib/rieles.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "rieles/version"
2
+
3
+ module Rieles
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,3 @@
1
+ module Rieles
2
+ VERSION = "0.0.1"
3
+ end
data/rieles.gemspec ADDED
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/rieles/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Azarel Doroteo Pacheco"]
6
+ gem.email = ["azarel.doroteo@logicalbricks.com"]
7
+ gem.description = %q{Instala el archivo de inflections para pluralizar y singularizar según las reglas en Español, incluye el locale en Español y agrega templates erb para que el scaffold genere las vistas en Español.}
8
+ gem.summary = %q{Instala inflections, locales y templates de scaffold para trabajar en Español.}
9
+ gem.homepage = ""
10
+
11
+
12
+ gem.files = `git ls-files`.split($\)
13
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
14
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
15
+ gem.name = "rieles"
16
+ gem.require_paths = ["lib"]
17
+ gem.version = Rieles::VERSION
18
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rieles
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Azarel Doroteo Pacheco
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-20 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Instala el archivo de inflections para pluralizar y singularizar según
15
+ las reglas en Español, incluye el locale en Español y agrega templates erb para
16
+ que el scaffold genere las vistas en Español.
17
+ email:
18
+ - azarel.doroteo@logicalbricks.com
19
+ executables: []
20
+ extensions: []
21
+ extra_rdoc_files: []
22
+ files:
23
+ - .gitignore
24
+ - Gemfile
25
+ - LICENSE
26
+ - README.md
27
+ - Rakefile
28
+ - lib/generators/rieles/USAGE
29
+ - lib/generators/rieles/rieles_generator.rb
30
+ - lib/generators/rieles/templates/_error_messages.html.erb
31
+ - lib/generators/rieles/templates/_form.html.erb
32
+ - lib/generators/rieles/templates/edit.html.erb
33
+ - lib/generators/rieles/templates/es.yml
34
+ - lib/generators/rieles/templates/index.html.erb
35
+ - lib/generators/rieles/templates/inflections.rb
36
+ - lib/generators/rieles/templates/new.html.erb
37
+ - lib/generators/rieles/templates/show.html.erb
38
+ - lib/rieles.rb
39
+ - lib/rieles/version.rb
40
+ - rieles.gemspec
41
+ homepage: ''
42
+ licenses: []
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubyforge_project:
61
+ rubygems_version: 1.8.22
62
+ signing_key:
63
+ specification_version: 3
64
+ summary: Instala inflections, locales y templates de scaffold para trabajar en Español.
65
+ test_files: []