rails_codebook 0.0.1.alpha

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +17 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +10 -0
  7. data/Gemfile +6 -0
  8. data/LICENSE.txt +22 -0
  9. data/MIT-LICENSE +22 -0
  10. data/README.md +31 -0
  11. data/Rakefile +1 -0
  12. data/app/assets/javascripts/rails_codebook/application.js +16 -0
  13. data/app/assets/javascripts/rails_codebook/bootstrap.js +5 -0
  14. data/app/assets/javascripts/rails_codebook/codebooks.js +27 -0
  15. data/app/assets/javascripts/rails_codebook/jquery.autosize.js +192 -0
  16. data/app/assets/stylesheets/rails_codebook/application.css +13 -0
  17. data/app/assets/stylesheets/rails_codebook/bootstrap_and_overrides.css +7 -0
  18. data/app/assets/stylesheets/rails_codebook/codebooks.css +44 -0
  19. data/app/controllers/rails_codebook/admin/codebooks_controller.rb +65 -0
  20. data/app/controllers/rails_codebook/api/codebooks_controller.rb +44 -0
  21. data/app/helpers/rails_codebook/admin/codebooks_helper.rb +43 -0
  22. data/app/models/rails_codebook/codebook.rb +44 -0
  23. data/app/views/layouts/rails_codebook/application.html.erb +35 -0
  24. data/app/views/rails_codebook/admin/codebooks/_codebook.html.erb +44 -0
  25. data/app/views/rails_codebook/admin/codebooks/create.js.erb +9 -0
  26. data/app/views/rails_codebook/admin/codebooks/destroy.js.erb +2 -0
  27. data/app/views/rails_codebook/admin/codebooks/index.html.erb +90 -0
  28. data/config/initializers/will_paginate.rb +3 -0
  29. data/config/locales/cs.yml +268 -0
  30. data/config/locales/en.yml +11 -0
  31. data/config/routes.rb +25 -0
  32. data/lib/generators/rails_codebook/install/USAGE +9 -0
  33. data/lib/generators/rails_codebook/install/install_generator.rb +21 -0
  34. data/lib/generators/rails_codebook/install/templates/seeds.rb.erb +271 -0
  35. data/lib/rails_codebook/acts_as_codebook.rb +88 -0
  36. data/lib/rails_codebook/controller/base.rb +27 -0
  37. data/lib/rails_codebook/engine.rb +6 -0
  38. data/lib/rails_codebook/has_codebooks.rb +115 -0
  39. data/lib/rails_codebook/model/base.rb +73 -0
  40. data/lib/rails_codebook/version.rb +3 -0
  41. data/lib/rails_codebook.rb +50 -0
  42. data/rails_codebook.gemspec +40 -0
  43. data/script/rails +8 -0
  44. data/test/test_helper.rb +45 -0
  45. metadata +326 -0
@@ -0,0 +1,35 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html lang="<%= I18n.locale %>">
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>
6
+ <%= content_for?(:title) ? (yield(:title) + " - Rails Codebook") : "Rails Codebook" %>
7
+ </title>
8
+ <meta content="width=device-width, initial-scale=1.0" name="viewport"/>
9
+ <meta content="Fourmach.com" name="author"/>
10
+ <%= stylesheet_link_tag "rails_codebook/application", media: nil %>
11
+ <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements
12
+ -->
13
+ <!--[if lt IE 9]
14
+ <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
15
+ -->
16
+ <%= csrf_meta_tag %>
17
+ </head>
18
+ <body id="<%= controller.controller_name %>-<%= controller.action_name %>">
19
+
20
+ <div class="container">
21
+ <h1>
22
+ <a href="<%= admin_codebooks_path %>"><%= yield(:title) %></a>
23
+ </h1>
24
+
25
+ <%= yield %>
26
+
27
+ </div>
28
+
29
+ <div id="footer">
30
+ <div class="container">
31
+ </div>
32
+ </div>
33
+ <%= javascript_include_tag "rails_codebook/application" %>
34
+ </body>
35
+ </html>
@@ -0,0 +1,44 @@
1
+ <% codebook ||= @codebook %>
2
+ <tr id="codebook_<%= id %>" class="<%= (codebook.deleted == 1) ? "red" : ''%>">
3
+ <td>
4
+ <div class="btn-group">
5
+ <a class="btn btn-primary" href="#"><i class="icon-book icon-white"> </i><%= codebook.id %></a>
6
+ <a class="btn btn-primary dropdown-toggle" data-toggle="dropdown" href="#"><span class="caret"></span></a>
7
+ <ul class="dropdown-menu">
8
+ <li>
9
+ <%= link_to '#', id: "#{codebook.id}", data: {id: codebook.id, value: codebook.value, name: codebook.name, sequence: codebook.sequence, deleted: codebook.deleted, cb_name: codebook.cb_name, toggle: "modal", target: '#add-codebook'}, class: "edit-codebook" do %>
10
+ <i class="icon-pencil"></i> Edit
11
+ <% end %>
12
+ </li>
13
+ <li>
14
+ <%= link_to admin_codebook_path(codebook.id), id: "destroy-#{codebook.id}", method: :delete, data: {confirm: "Do you really want to proceed ?"}, remote: true do %>
15
+ <i class="icon-trash"></i> Delete
16
+ <% end %>
17
+ </li>
18
+ </ul>
19
+ </div>
20
+ </td>
21
+ <td>
22
+ <%= codebook.value %>
23
+ </td>
24
+ <td>
25
+ <%= I18n.t(!codebook.name.blank? ? codebook.name : "name.missing") %>
26
+ </td>
27
+ <td>
28
+ <a href="<%= admin_codebooks_path(cb_name: codebook.cb_name) %>">
29
+ <%= codebook.cb_name %>
30
+ </a>
31
+ </td>
32
+ <td>
33
+ <%= codebook.sequence %>
34
+ </td>
35
+ <td>
36
+ <%= codebook.deleted %>
37
+ </td>
38
+ <td>
39
+ <%= codebook.created_at.to_s(:short) %>
40
+ </td>
41
+ <td>
42
+ <%= codebook.updated_at.to_s(:short) %>
43
+ </td>
44
+ </tr>
@@ -0,0 +1,9 @@
1
+ $('#add-codebook').modal('hide');
2
+ partial = '<%= escape_javascript(render 'codebook', id: @codebook.id) %>';
3
+ codebook = "#codebook_<%= @codebook.id %>";
4
+
5
+ if( $(codebook).size() > 0 ){
6
+ $(codebook).replaceWith(partial);
7
+ } else {
8
+ $('#codebooks-table tbody').prepend(' <%= escape_javascript(render 'codebook', id: @codebook.id ) %> ');
9
+ }
@@ -0,0 +1,2 @@
1
+ codebook = "#codebook_<%= params[:id] %>";
2
+ $(codebook).remove();
@@ -0,0 +1,90 @@
1
+ <% title "Codebooks" %>
2
+
3
+ <div id="add-codebook" class="modal hide fade">
4
+ <div class="modal-header">
5
+ <a class="close" data-dismiss="modal">×</a>
6
+ <h3>Codebook</h3>
7
+ </div>
8
+ <div class="modal-body">
9
+ <div class="row">
10
+ <%= form_tag admin_codebooks_path, id: 'form-codebook', remote: true do %>
11
+ <div class="span4">
12
+ <%= label_tag "codebook[value]", "Value" %>
13
+ <%= text_field_tag "codebook[value]", '', class: 'span4', autofocus: true %>
14
+ </div>
15
+ <div class="span5">
16
+ <%= label_tag "codebook[name]", "Name" %>
17
+ <%= text_field_tag "codebook[name]", '', class: 'span4' %>
18
+ </div>
19
+ <div class="span5">
20
+ <%= label_tag "codebook[cb_name]", "Codebook name" %>
21
+ <%= text_field_tag "codebook[cb_name]", '', class: 'span4' %>
22
+ </div>
23
+ <div class="span1">
24
+ <%= label_tag "codebook[sequence]", "Sequence" %>
25
+ <%= text_field_tag "codebook[sequence]", '100', class: 'span1' %>
26
+ </div>
27
+ <div class="span4">
28
+ <%= label_tag "codebook[deleted]", "Deleted" %>
29
+ <%= text_field_tag "codebook[deleted]", '0', class: 'span1' %>
30
+ </div>
31
+ <%= hidden_field_tag 'codebook[id]', ''%>
32
+ <div class="span2">
33
+ <br />
34
+ <%= button_tag "Submit", class: 'btn' %>
35
+ <a href="#" class="btn" onclick="$('#add-codebook').modal('hide');">Close</a>
36
+ </div>
37
+ <% end %>
38
+ </div>
39
+ </div>
40
+ </div>
41
+
42
+ <div class="left_panel">
43
+ <div class="navbar">
44
+ <div class="navbar-inner">
45
+ <%= form_tag admin_codebooks_path, class: 'navbar-form pull-left', method: :get, id: 'search-form' do %>
46
+ <%= text_field_tag :query, params[:query], hint: 'Search', placeholder: 'Search', autofocus: true %>
47
+ <%= button_tag 'search', class: 'btn' %>
48
+ <%= select_tag :cb_name, options_from_collection_for_select(all_codebooks, "cb_name", "cb_name", params[:cb_name]), include_blank: true %>
49
+ <% end %>
50
+
51
+ <div class="clear_button">
52
+ <%= link_to 'clear', admin_codebooks_path, class: 'btn' %>
53
+ </div>
54
+
55
+ <div class="new_button">
56
+ <%= link_to 'new', '#', data: { toggle: "modal", target: '#add-codebook'}, id: 'add-codebook-link', class: 'btn' %>
57
+ </div>
58
+
59
+ </div>
60
+ </div>
61
+ </div>
62
+
63
+ <div class="right_panel">
64
+ <div class="apple_pagination">
65
+ <%= will_paginate @codebooks, :container => false %>
66
+ </div>
67
+
68
+ <table class="table table-hover" id="codebooks-table">
69
+ <thead>
70
+ <th></th>
71
+ <th>value</th>
72
+ <th>name</th>
73
+ <th>codebook</th>
74
+ <th>sequence</th>
75
+ <th>deleted</th>
76
+ <th>created</th>
77
+ <th>updated</th>
78
+ </thead>
79
+ <tbody>
80
+ <% @codebooks.each do |codebook| %>
81
+ <%= render 'codebook', codebook: codebook, id: codebook.id %>
82
+ <% end %>
83
+ </tbody>
84
+ </table>
85
+
86
+
87
+ <div class="apple_pagination">
88
+ <%= will_paginate @codebooks, :container => false %>
89
+ </div>
90
+ </div>
@@ -0,0 +1,3 @@
1
+ require 'will_paginate/array'
2
+
3
+ WillPaginate.per_page = 10
@@ -0,0 +1,268 @@
1
+ cs:
2
+ name:
3
+ missing: "Není zadana překladová kotva"
4
+ codebook:
5
+ boolean:
6
+ 'yes': 'ano'
7
+ 'no': 'ne'
8
+ importance:
9
+ low: 'nízká'
10
+ medium: 'střední'
11
+ high: 'vysoká'
12
+ country:
13
+ afg: 'Afghánistán'
14
+ ala: 'Ålandy'
15
+ alb: 'Albánie'
16
+ dza: 'Alžírsko'
17
+ asm: 'Americká Samoa'
18
+ vir: 'Americké Panenské ostrovy'
19
+ and: 'Andorra'
20
+ ago: 'Angola'
21
+ aia: 'Anguilla'
22
+ ata: 'Antarktida'
23
+ atg: 'Antigua a Barbuda'
24
+ arg: 'Argentina'
25
+ arm: 'Arménie'
26
+ abw: 'Aruba'
27
+ aus: 'Austrálie'
28
+ aze: 'Ázerbájdžán'
29
+ bhs: 'Bahamy'
30
+ bhr: 'Bahrajn'
31
+ bgd: 'Bangladéš'
32
+ brb: 'Barbados'
33
+ bel: 'Belgie'
34
+ blz: 'Belize'
35
+ blr: 'Bělorusko'
36
+ ben: 'Benin'
37
+ bmu: 'Bermudy'
38
+ btn: 'Bhútán'
39
+ bol: 'Bolívie'
40
+ bih: 'Bosna a Hercegovina'
41
+ bwa: 'Botswana'
42
+ bvt: 'Bouvetův ostrov'
43
+ bra: 'Brazílie'
44
+ iot: 'Britské indickooceánské území'
45
+ vgb: 'Britské Panenské ostrovy'
46
+ brn: 'Brunej'
47
+ bgr: 'Bulharsko'
48
+ bfa: 'Burkina Faso'
49
+ bdi: 'Burundi'
50
+ cok: 'Cookovy ostrovy'
51
+ tcd: 'Čad'
52
+ mne: 'Černá Hora'
53
+ cze: 'Česká republika'
54
+ chn: 'Čína'
55
+ dnk: 'Dánsko'
56
+ cod: 'Demokratická republika Kongo'
57
+ dma: 'Dominika'
58
+ dom: 'Dominikánská republika'
59
+ dji: 'Džibutsko'
60
+ egy: 'Egypt'
61
+ ecu: 'Ekvádor'
62
+ eri: 'Eritrea'
63
+ est: 'Estonsko'
64
+ eth: 'Etiopie'
65
+ fro: 'Faerské ostrovy'
66
+ flk: 'Falklandy (Malvíny)'
67
+ fji: 'Fidži'
68
+ phl: 'Filipíny'
69
+ fin: 'Finsko'
70
+ fra: 'Francie'
71
+ guf: 'Francouzská Guyana'
72
+ atf: 'Francouzská jižní a antarktická území'
73
+ pyf: 'Francouzská Polynésie'
74
+ gab: 'Gabon'
75
+ gmb: 'Gambie'
76
+ gha: 'Ghana'
77
+ gib: 'Gibraltar'
78
+ grd: 'Grenada'
79
+ grl: 'Grónsko'
80
+ geo: 'Gruzie'
81
+ glp: 'Guadeloupe'
82
+ gum: 'Guam'
83
+ gtm: 'Guatemala'
84
+ gin: 'Guinea'
85
+ gnb: 'Guinea-Bissau'
86
+ ggy: 'Guernsey'
87
+ guy: 'Guyana'
88
+ hti: 'Haiti'
89
+ hmd: 'Heardův ostrov a McDonaldovy ostrovy'
90
+ hnd: 'Honduras'
91
+ hkg: 'Hongkong'
92
+ chl: 'Chile'
93
+ hrv: 'Chorvatsko'
94
+ ind: 'Indie'
95
+ idn: 'Indonésie'
96
+ irq: 'Irák'
97
+ irn: 'Írán'
98
+ irl: 'Irsko'
99
+ isl: 'Island'
100
+ ita: 'Itálie'
101
+ isr: 'Izrael'
102
+ jam: 'Jamajka'
103
+ jpn: 'Japonsko'
104
+ yem: 'Jemen'
105
+ jey: 'Jersey'
106
+ zaf: 'Jihoafrická republika'
107
+ sgs: 'Jižní Georgie a Jižní Sandwichovy ostrovy'
108
+ kor: 'Jižní Korea'
109
+ jor: 'Jordánsko'
110
+ cym: 'Kajmanské ostrovy'
111
+ khm: 'Kambodža'
112
+ cmr: 'Kamerun'
113
+ can: 'Kanada'
114
+ cpv: 'Kapverdy'
115
+ qat: 'Katar'
116
+ kaz: 'Kazachstán'
117
+ ken: 'Keňa'
118
+ kir: 'Kiribati'
119
+ cck: 'Kokosové ostrovy'
120
+ col: 'Kolumbie'
121
+ com: 'Komory'
122
+ cog: 'Kongo'
123
+ cri: 'Kostarika'
124
+ cub: 'Kuba'
125
+ kwt: 'Kuvajt'
126
+ cyp: 'Kypr'
127
+ kgz: 'Kyrgyzstán'
128
+ lao: 'Laos'
129
+ lso: 'Lesotho'
130
+ lbn: 'Libanon'
131
+ lbr: 'Libérie'
132
+ lby: 'Libye'
133
+ lie: 'Lichtenštejnsko'
134
+ ltu: 'Litva'
135
+ lva: 'Lotyšsko'
136
+ lux: 'Lucembursko'
137
+ mac: 'Macao'
138
+ mdg: 'Madagaskar'
139
+ hun: 'Maďarsko'
140
+ mkd: 'Makedonie'
141
+ mys: 'Malajsie'
142
+ mwi: 'Malawi'
143
+ mdv: 'Maledivy'
144
+ mli: 'Mali'
145
+ mlt: 'Malta'
146
+ imn: 'Ostrov Man'
147
+ mar: 'Maroko'
148
+ mhl: 'Marshallovy ostrovy'
149
+ mtq: 'Martinik'
150
+ mus: 'Mauricius'
151
+ mrt: 'Mauritánie'
152
+ myt: 'Mayotte'
153
+ umi: 'Menší odlehlé ostrovy USA'
154
+ mex: 'Mexiko'
155
+ fsm: 'Mikronésie'
156
+ mda: 'Moldavsko'
157
+ mco: 'Monako'
158
+ mng: 'Mongolsko'
159
+ msr: 'Montserrat'
160
+ moz: 'Mosambik'
161
+ mmr: 'Myanmar'
162
+ nam: 'Namibie'
163
+ nru: 'Nauru'
164
+ deu: 'Německo'
165
+ npl: 'Nepál'
166
+ ner: 'Niger'
167
+ nga: 'Nigérie'
168
+ nic: 'Nikaragua'
169
+ niu: 'Niue'
170
+ ant: 'Nizozemské Antily'
171
+ nld: 'Nizozemsko'
172
+ nfk: 'Norfolk'
173
+ nor: 'Norsko'
174
+ ncl: 'Nová Kaledonie'
175
+ nzl: 'Nový Zéland'
176
+ omn: 'Omán'
177
+ pak: 'Pákistán'
178
+ plw: 'Palau'
179
+ pse: 'Palestinská autonomie'
180
+ pan: 'Panama'
181
+ png: 'Papua-Nová Guinea'
182
+ pry: 'Paraguay'
183
+ per: 'Peru'
184
+ pcn: 'Pitcairnovy ostrovy'
185
+ civ: 'Pobřeží slonoviny'
186
+ pol: 'Polsko'
187
+ pri: 'Portoriko'
188
+ prt: 'Portugalsko'
189
+ aut: 'Rakousko'
190
+ gnq: 'Rovníková Guinea'
191
+ rou: 'Rumunsko'
192
+ rus: 'Rusko'
193
+ rwa: 'Rwanda'
194
+ grc: 'Řecko'
195
+ blm: 'Saint-Barthélemy'
196
+ maf: 'Saint-Martin'
197
+ spm: 'Saint-Pierre a Miquelon'
198
+ slv: 'Salvador'
199
+ wsm: 'Samoa'
200
+ smr: 'San Marino'
201
+ sau: 'Saúdská Arábie'
202
+ sen: 'Senegal'
203
+ prk: 'Severní Korea'
204
+ mnp: 'Severní Mariany'
205
+ syc: 'Seychely'
206
+ sle: 'Sierra Leone'
207
+ sgp: 'Singapur'
208
+ svk: 'Slovensko'
209
+ svn: 'Slovinsko'
210
+ som: 'Somálsko'
211
+ are: 'Spojené arabské emiráty'
212
+ gbr: 'Spojené království'
213
+ usa: 'Spojené státy americké'
214
+ srb: 'Srbsko'
215
+ caf: 'Středoafrická republika'
216
+ sdn: 'Súdán'
217
+ sur: 'Surinam'
218
+ shn: 'Svatá Helena'
219
+ lca: 'Svatá Lucie'
220
+ kna: 'Svatý Kryštof a Nevis'
221
+ stp: 'Svatý Tomáš a Princův ostrov'
222
+ vct: 'Svatý Vincenc a Grenadiny'
223
+ swz: 'Svazijsko'
224
+ syr: 'Sýrie'
225
+ slb: 'Šalamounovy ostrovy'
226
+ esp: 'Španělsko'
227
+ sjm: 'Špicberky a Jan Mayen'
228
+ lka: 'Šrí Lanka'
229
+ swe: 'Švédsko'
230
+ che: 'Švýcarsko'
231
+ tjk: 'Tádžikistán'
232
+ tza: 'Tanzanie'
233
+ tha: 'Thajsko'
234
+ twn: 'Tchaj-wan'
235
+ tgo: 'Togo'
236
+ tkl: 'Tokelau'
237
+ ton: 'Tonga'
238
+ tto: 'Trinidad a Tobago'
239
+ tun: 'Tunisko'
240
+ tur: 'Turecko'
241
+ tkm: 'Turkmenistán'
242
+ tca: 'Turks a Caicos'
243
+ tuv: 'Tuvalu'
244
+ uga: 'Uganda'
245
+ ukr: 'Ukrajina'
246
+ ury: 'Uruguay'
247
+ uzb: 'Uzbekistán'
248
+ cxr: 'Vánoční ostrov'
249
+ vut: 'Vanuatu'
250
+ vat: 'Vatikán'
251
+ ven: 'Venezuela'
252
+ vnm: 'Vietnam'
253
+ tls: 'Východní Timor'
254
+ wlf: 'Wallis a Futuna'
255
+ zmb: 'Zambie'
256
+ esh: 'Západní Sahara'
257
+ zwe: 'Zimbabwe'
258
+ svk: 'Slovenská republika'
259
+ currency:
260
+ aud: 'australský dolar'
261
+ cad: 'kanadský dolar'
262
+ chf: 'švýcarský frank'
263
+ czk: 'česká koruna'
264
+ eur: 'euro'
265
+ gbp: 'anglická libra'
266
+ jpy: 'japonský jen'
267
+ rub: 'ruský rubl'
268
+ usd: 'americký dolar'
@@ -0,0 +1,11 @@
1
+ en:
2
+ name:
3
+ missing: "No translation key given"
4
+ codebook:
5
+ boolean:
6
+ 'yes': 'Yes'
7
+ 'no': 'No'
8
+ importance:
9
+ low: 'Low'
10
+ medium: 'Medium'
11
+ high: 'High'
data/config/routes.rb ADDED
@@ -0,0 +1,25 @@
1
+ RailsCodebook::Engine.routes.draw do
2
+
3
+ get "/(:lang)" => "admin/codebooks#index", as: :rails_codebook_root, lang: /[a-z]{2}/
4
+
5
+ namespace :api do
6
+ get "/(:lang)" => "codebooks#index", as: :rail_codebook_root, lang: /[a-z]{2}/
7
+ # resources :codebooks, only: [:index, :create, :destroy]
8
+ get "/(:lang)/:cb_name" => "codebooks#codebook_index", cb_name: /[a-z]+/, lang: /[a-z]{2}/
9
+ get "/(:lang)/:cb_name/:id" => "codebooks#show", cb_name: /[a-z]+/, lang: /[a-z]{2}/
10
+ end
11
+
12
+ namespace :admin do
13
+ get '/(:lang)' => 'codebooks#index', as: :codebooks
14
+ post '/' => 'codebooks#create', as: :create_codebooks
15
+ delete '/codebooks/:id(.:format)' => 'codebooks#destroy', as: :codebook
16
+ # POST /admin/codebooks(.:format) rails_codebook/admin/codebooks#create
17
+ # new_admin_codebook_path GET /admin/codebooks/new(.:format) rails_codebook/admin/codebooks#new
18
+ # edit_admin_codebook_path GET /admin/codebooks/:id/edit(.:format) rails_codebook/admin/codebooks#edit
19
+ # admin_codebook_path GET /admin/codebooks/:id(.:format) rails_codebook/admin/codebooks#show
20
+ # PATCH /admin/codebooks/:id(.:format) rails_codebook/admin/codebooks#update
21
+ # PUT /admin/codebooks/:id(.:format) rails_codebook/admin/codebooks#update
22
+ # DELETE /admin/codebooks/:id(.:format) rails_codebook/admin/codebooks#destroy
23
+ end
24
+
25
+ end
@@ -0,0 +1,9 @@
1
+ Description:
2
+ Generates few of basic codebooks country/currency/importance/boolean
3
+
4
+ Example:
5
+ rails generate rails_codebook:install
6
+
7
+ This will create:
8
+ create db/seeds/default_codebooks.rb
9
+ rake db:seed
@@ -0,0 +1,21 @@
1
+ module RailsCodebook
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+
5
+ source_root File.expand_path('../templates', __FILE__)
6
+
7
+ def create_default_seed
8
+ template 'seeds.rb.erb', 'db/seeds/default_codebooks.rb'
9
+ end
10
+
11
+ def alter_seed_file
12
+ File.open('db/seeds.rb', 'a') { |f| f.write("\n\nload \"\#{Rails.root}/db/seeds/default_codebooks.rb\"") }
13
+ end
14
+
15
+ def seed_it
16
+ rake "db:seed"
17
+ end
18
+
19
+ end
20
+ end
21
+ end