champollion 0.1.5 → 0.1.6

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.
@@ -12,6 +12,12 @@ module Champollion
12
12
  ]
13
13
  }
14
14
 
15
+ let(:nested_translations) {[
16
+ { locale: :en, key: 'activerecord.errors.models.champollion/translation.attributes.locale.blank', value: 'Locale cannot be blank'},
17
+ { locale: :en, key: 'activerecord.errors.models.champollion/translation.attributes.key.blank', value: 'Key cannot be blank'},
18
+ { locale: :en, key: 'activerecord.errors.models.champollion/translation.attributes.value.blank', value: 'Value cannot be blank'}
19
+ ]}
20
+
15
21
  it "Does not allow the creation of invalid Translation record" do
16
22
  expect(FactoryGirl.build(:translation, locale: "")).to be_invalid
17
23
  end
@@ -20,6 +26,30 @@ module Champollion
20
26
  expect(FactoryGirl.build(:translation)).to be_valid
21
27
  end
22
28
 
29
+ it "Returns a hash with nested translations" do
30
+ Translation.create(nested_translations)
31
+
32
+ expected_hash = {
33
+ en: {
34
+ activerecord: {
35
+ errors: {
36
+ models: {
37
+ :"champollion/translation" => {
38
+ attributes: {
39
+ locale: { blank: "Locale cannot be blank"},
40
+ key: { blank: "Key cannot be blank" },
41
+ value: { blank: "Value cannot be blank"}
42
+ }
43
+ }
44
+ }
45
+ }
46
+ }
47
+ }
48
+ }
49
+
50
+ expect(Translation.all_hash).to eq(expected_hash)
51
+ end
52
+
23
53
  it "Returns a hash with all translations" do
24
54
  Translation.create(valid_parameters)
25
55
 
@@ -44,7 +74,20 @@ module Champollion
44
74
  }
45
75
  }
46
76
 
47
- expect(Translation.all_translations).to eq(expected_hash)
77
+ expect(Translation.all_hash).to eq(expected_hash)
78
+ end
79
+
80
+ it "Returns the last five revisions" do
81
+ translation = FactoryGirl.build(:translation)
82
+ translation.update_attributes({:value => "New Value"})
83
+ translation.update_attributes({:value => "Another change"})
84
+ translation.update_attributes({:value => "Third change"})
85
+ translation.update_attributes({:value => "Fourth change"})
86
+ translation.update_attributes({:value => "Fifth change"})
87
+ translation.update_attributes({:value => "Sixth change"})
88
+
89
+ expect(translation.versions.size).to eq(6)
90
+ expect(translation.last_five.size).to eq(5)
48
91
  end
49
92
 
50
93
  end
@@ -0,0 +1,8 @@
1
+ <%= bootstrap_form_for(@translation) do |f| %>
2
+ <%= f.text_field :locale %>
3
+ <%= f.text_field :key %>
4
+ <%= f.text_area :value %>
5
+ <%= f.text_field :interpolations %>
6
+ <%= f.check_box :is_proc %>
7
+ <%= f.submit 'Create' %>
8
+ <% end %>
@@ -0,0 +1,8 @@
1
+ <h1>Editing Translation</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <hr/>
6
+
7
+ <%= link_to 'Show', @tranlation %> |
8
+ <%= link_to 'Back', translations_path %>
@@ -0,0 +1,35 @@
1
+ <div class="row">
2
+ <div class="col-md-12">
3
+ <p id="notice"><%= notice %></p>
4
+
5
+ <h1>Listing Translations</h1>
6
+
7
+ <table class="table table-striped">
8
+ <thead>
9
+ <tr>
10
+ <th>Locale</th>
11
+ <th>Key</th>
12
+ <th>Value</th>
13
+ <th colspan="3"></th>
14
+ </tr>
15
+ </thead>
16
+
17
+ <tbody>
18
+ <% @translations.each do |translation| %>
19
+ <tr>
20
+ <td><%= translation.locale %></td>
21
+ <td><%= translation.key %></td>
22
+ <td><%= translation.value %></td>
23
+ <td><%= link_to 'Show', translation %></td>
24
+ <td><%= link_to 'Edit', edit_translation_path(translation) %></td>
25
+ <td><%= link_to 'Destroy', translation, method: :delete, data: { confirm: 'Are you sure?' } %></td>
26
+ </tr>
27
+ <% end %>
28
+ </tbody>
29
+ </table>
30
+
31
+ <br/>
32
+
33
+ <%= link_to 'New Translation', new_translation_path, class: 'btn btn-primary' %>
34
+ </div>
35
+ </div>
@@ -0,0 +1,7 @@
1
+ <h1>New Translation</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <hr/>
6
+
7
+ <%= link_to 'Back', translations_path, class: 'btn btn-primary' %>
@@ -0,0 +1,59 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <h2>Current Version</h2>
4
+
5
+ <p>
6
+ <strong>Locale:</strong>
7
+ <%= @translation.locale %>
8
+ </p>
9
+
10
+ <p>
11
+ <strong>Key:</strong>
12
+ <%= @translation.key %>
13
+ </p>
14
+
15
+ <p>
16
+ <strong>Value:</strong>
17
+ <%= @translation.value %>
18
+ </p>
19
+
20
+ <hr/>
21
+
22
+ <h2>Last 5 Revisions</h2>
23
+ <table class="table">
24
+ <thead>
25
+ <tr>
26
+ <th>Version</th>
27
+ <th>Event</th>
28
+ <td>Date Modified</th>
29
+ <th>Content</th>
30
+ </tr>
31
+ </thead>
32
+ <tbody>
33
+ <% @translation.last_five.each do |version| %>
34
+ <tr>
35
+ <td><%= version.index %></td>
36
+ <td><%= version.event %></td>
37
+ <td><%= version.created_at %></td>
38
+ <td>
39
+ <% unless version.reify.nil? %>
40
+ <dl class="dl-horizontal">
41
+ <dt>locale</dt>
42
+ <dd><%= version.reify.locale %></dd>
43
+ <dt>key</dt>
44
+ <dd><%= version.reify.key %></dd>
45
+ <dt>value</dt>
46
+ <dd><%= version.reify.value %></dd>
47
+ </dl>
48
+ <% end %>
49
+ </td>
50
+ </tr>
51
+ <% end %>
52
+ </tbody>
53
+ </table>
54
+ <ul>
55
+ </ul>
56
+ </p>
57
+
58
+ <%= link_to 'Edit', edit_translation_path(@translation) %> |
59
+ <%= link_to 'Back', translations_path %>
@@ -0,0 +1,20 @@
1
+ <nav class="navbar navbar-default navbar-fixed-top">
2
+ <!-- We use the fluid option here to avoid overriding the fixed width of a normal container within the narrow content columns. -->
3
+ <div class="container-fluid">
4
+ <div class="navbar-header">
5
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-6">
6
+ <span class="sr-only">Toggle navigation</span>
7
+ <span class="icon-bar"></span>
8
+ <span class="icon-bar"></span>
9
+ <span class="icon-bar"></span>
10
+ </button>
11
+ <%= link_to 'Champollion Admin Panel', root_url, class: 'navbar-brand' %>
12
+ </div>
13
+
14
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-6">
15
+ <ul class="nav navbar-nav">
16
+ <li class="active"><%= link_to 'Translations', translations_path %>
17
+ </ul>
18
+ </div><!-- /.navbar-collapse -->
19
+ </div>
20
+ </nav>
@@ -0,0 +1,18 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Champollion</title>
5
+ <%= stylesheet_link_tag "champollion/application", media: "all" %>
6
+ <%= javascript_include_tag "champollion/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <div class="container">
12
+ <%= render "layouts/champollion/navigation" %>
13
+
14
+ <%= yield %>
15
+ </div>
16
+
17
+ </body>
18
+ </html>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: champollion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Razvan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-08 00:00:00.000000000 Z
11
+ date: 2015-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -44,6 +44,26 @@ dependencies:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
46
  version: 4.0.0.beta
47
+ - !ruby/object:Gem::Dependency
48
+ name: bootstrap_form
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '2.1'
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 2.1.0
57
+ type: :runtime
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '2.1'
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 2.1.0
47
67
  - !ruby/object:Gem::Dependency
48
68
  name: sqlite3
49
69
  requirement: !ruby/object:Gem::Requirement
@@ -229,7 +249,6 @@ files:
229
249
  - spec/dummy/config/locales/en.yml
230
250
  - spec/dummy/config/routes.rb
231
251
  - spec/dummy/config/secrets.yml
232
- - spec/dummy/db/development.sqlite3
233
252
  - spec/dummy/db/migrate/20150504185150_create_translations.champollion.rb
234
253
  - spec/dummy/db/migrate/20150504193530_create_versions.champollion.rb
235
254
  - spec/dummy/db/schema.rb
@@ -246,6 +265,13 @@ files:
246
265
  - spec/models/champollion/translation_spec.rb
247
266
  - spec/routing/champollion/translations_routing_spec.rb
248
267
  - spec/spec_helper.rb
268
+ - spec/tmp/app/views/champollion/champollion/translations/_form.html.erb
269
+ - spec/tmp/app/views/champollion/champollion/translations/edit.html.erb
270
+ - spec/tmp/app/views/champollion/champollion/translations/index.html.erb
271
+ - spec/tmp/app/views/champollion/champollion/translations/new.html.erb
272
+ - spec/tmp/app/views/champollion/champollion/translations/show.html.erb
273
+ - spec/tmp/app/views/champollion/layouts/champollion/_navigation.html.erb
274
+ - spec/tmp/app/views/champollion/layouts/champollion/application.html.erb
249
275
  homepage: http://github.com/tzumby/champollion
250
276
  licenses:
251
277
  - MIT
@@ -266,56 +292,63 @@ required_rubygems_version: !ruby/object:Gem::Requirement
266
292
  version: '0'
267
293
  requirements: []
268
294
  rubyforge_project:
269
- rubygems_version: 2.4.5
295
+ rubygems_version: 2.2.2
270
296
  signing_key:
271
297
  specification_version: 4
272
298
  summary: Champollion is a Rails engine that allows storing I18n translation in a database.
273
299
  test_files:
274
- - spec/factories/translation.rb
275
- - spec/models/champollion/translation_spec.rb
276
- - spec/routing/champollion/translations_routing_spec.rb
277
- - spec/generators/views_generator_spec.rb
278
- - spec/generators/assets_generator_spec.rb
279
- - spec/dummy/config.ru
280
- - spec/dummy/config/environments/production.rb
281
- - spec/dummy/config/environments/development.rb
282
- - spec/dummy/config/environments/test.rb
300
+ - spec/controllers/champollion/translations_controller_spec.rb
301
+ - spec/dummy/app/assets/javascripts/application.js
302
+ - spec/dummy/app/assets/stylesheets/application.css
303
+ - spec/dummy/app/controllers/application_controller.rb
304
+ - spec/dummy/app/helpers/application_helper.rb
305
+ - spec/dummy/app/views/layouts/application.html.erb
306
+ - spec/dummy/bin/bundle
307
+ - spec/dummy/bin/rails
308
+ - spec/dummy/bin/rake
309
+ - spec/dummy/bin/setup
283
310
  - spec/dummy/config/application.rb
284
- - spec/dummy/config/routes.rb
285
- - spec/dummy/config/database.yml
286
311
  - spec/dummy/config/boot.rb
312
+ - spec/dummy/config/database.yml
313
+ - spec/dummy/config/environment.rb
314
+ - spec/dummy/config/environments/development.rb
315
+ - spec/dummy/config/environments/production.rb
316
+ - spec/dummy/config/environments/test.rb
317
+ - spec/dummy/config/initializers/assets.rb
318
+ - spec/dummy/config/initializers/backtrace_silencers.rb
287
319
  - spec/dummy/config/initializers/cookies_serializer.rb
288
- - spec/dummy/config/initializers/wrap_parameters.rb
289
- - spec/dummy/config/initializers/inflections.rb
290
320
  - spec/dummy/config/initializers/filter_parameter_logging.rb
291
- - spec/dummy/config/initializers/backtrace_silencers.rb
292
- - spec/dummy/config/initializers/session_store.rb
293
- - spec/dummy/config/initializers/assets.rb
321
+ - spec/dummy/config/initializers/inflections.rb
294
322
  - spec/dummy/config/initializers/mime_types.rb
323
+ - spec/dummy/config/initializers/session_store.rb
324
+ - spec/dummy/config/initializers/wrap_parameters.rb
295
325
  - spec/dummy/config/locales/en.yml
326
+ - spec/dummy/config/routes.rb
296
327
  - spec/dummy/config/secrets.yml
297
- - spec/dummy/config/environment.rb
328
+ - spec/dummy/config.ru
298
329
  - spec/dummy/db/migrate/20150504185150_create_translations.champollion.rb
299
330
  - spec/dummy/db/migrate/20150504193530_create_versions.champollion.rb
300
- - spec/dummy/db/test.sqlite3
301
331
  - spec/dummy/db/schema.rb
302
- - spec/dummy/db/development.sqlite3
303
- - spec/dummy/Rakefile
304
- - spec/dummy/app/views/layouts/application.html.erb
305
- - spec/dummy/app/assets/javascripts/application.js
306
- - spec/dummy/app/assets/stylesheets/application.css
307
- - spec/dummy/app/helpers/application_helper.rb
308
- - spec/dummy/app/controllers/application_controller.rb
309
- - spec/dummy/bin/setup
310
- - spec/dummy/bin/bundle
311
- - spec/dummy/bin/rails
312
- - spec/dummy/bin/rake
313
- - spec/dummy/public/favicon.ico
332
+ - spec/dummy/db/test.sqlite3
333
+ - spec/dummy/log/development.log
334
+ - spec/dummy/log/test.log
314
335
  - spec/dummy/public/404.html
315
336
  - spec/dummy/public/422.html
316
337
  - spec/dummy/public/500.html
317
- - spec/dummy/log/development.log
318
- - spec/dummy/log/test.log
338
+ - spec/dummy/public/favicon.ico
339
+ - spec/dummy/Rakefile
319
340
  - spec/dummy/README.rdoc
341
+ - spec/factories/translation.rb
342
+ - spec/generators/assets_generator_spec.rb
343
+ - spec/generators/views_generator_spec.rb
344
+ - spec/models/champollion/translation_spec.rb
345
+ - spec/routing/champollion/translations_routing_spec.rb
320
346
  - spec/spec_helper.rb
321
- - spec/controllers/champollion/translations_controller_spec.rb
347
+ - spec/tmp/app/views/champollion/champollion/translations/_form.html.erb
348
+ - spec/tmp/app/views/champollion/champollion/translations/edit.html.erb
349
+ - spec/tmp/app/views/champollion/champollion/translations/index.html.erb
350
+ - spec/tmp/app/views/champollion/champollion/translations/new.html.erb
351
+ - spec/tmp/app/views/champollion/champollion/translations/show.html.erb
352
+ - spec/tmp/app/views/champollion/layouts/champollion/_navigation.html.erb
353
+ - spec/tmp/app/views/champollion/layouts/champollion/application.html.erb
354
+ has_rdoc: