translatable_routes 1.3.3 → 1.3.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be4091ea73bb827796addc31258c8be2796284cc
4
- data.tar.gz: eeeee1ab0fb27a8072d7f8a939ff877cde527c1b
3
+ metadata.gz: ecc4e1233d650da515ed0955fba21811733a6fde
4
+ data.tar.gz: 9affcd41d274b05b0564ab2419523ea38aa8284f
5
5
  SHA512:
6
- metadata.gz: 062244dd2bb527f8f94bf4bea9da1dcd8af0660a852a91ea1fd3484848f43f3b4e5ccc9d6bdf6fffae6423a14ee9e5966a40d398a1306c44ea256e049b411f73
7
- data.tar.gz: 559de805002e6d4afb6d7128ca57ec9a56b7d53803ebf56298f3df4db84fe9a9178a207d6dbdddb6b5eac209e0541b23eea079aa03f67a34207d27f6bac0a3c0
6
+ metadata.gz: f8c336bf59fd5efca03f55d00fb27cfc21cef3c905c35842aacc0f11bc4840cb44a446bdb96091025318892c0290217aefee2d15015d6f8332a46f9c802733a7
7
+ data.tar.gz: 47b31ce99e9a6ae221a1852084a9f75af59f671d3600ae27a3c6ef88e5ac35bd415fd648ea49c3499d845358b441b2497b2dc91a7bb8e5ba63650b9ba6b49dfb
data/README.md ADDED
@@ -0,0 +1,63 @@
1
+ [![Gem Version](https://badge.fury.io/rb/translatable_routes.svg)](http://badge.fury.io/rb/translatable_routes) [![Code Climate](https://codeclimate.com/github/museways/translatable_routes/badges/gpa.svg)](https://codeclimate.com/github/museways/translatable_routes) [![Build Status](https://travis-ci.org/museways/translatable_routes.svg?branch=master)](https://travis-ci.org/museways/translatable_routes) [![Dependency Status](https://gemnasium.com/museways/translatable_routes.svg)](https://gemnasium.com/museways/translatable_routes)
2
+
3
+ # Translatable Routes
4
+
5
+ Minimalistic toolkit to translate routes in rails.
6
+
7
+ ## Install
8
+
9
+ Put this line in your Gemfile:
10
+ ```ruby
11
+ gem 'translatable_routes'
12
+ ```
13
+
14
+ Then bundle:
15
+ ```
16
+ $ bundle
17
+ ```
18
+
19
+ ## Configuration
20
+
21
+ In your config/routes.rb use the localized method to decide wich routes will be localized:
22
+ ```ruby
23
+ localized do
24
+ get 'about' => 'pages#about'
25
+ end
26
+ ```
27
+
28
+ Put your translations inside the routes key in your locales yamls:
29
+ ```yaml
30
+ es:
31
+ routes:
32
+ users: "usuarios"
33
+ profile: "perfil"
34
+ about: "nosotros"
35
+ ```
36
+
37
+ NOTE: There is no need to put the full path, just translate each part individually.
38
+
39
+ ## Usage
40
+
41
+ Helpers will continue working the same but I18n.locale will be use as default locale:
42
+ ```ruby
43
+ about_path # Will output /en/about in case I18n.locale is :en
44
+ ```
45
+
46
+ Here is an example of what you may want to add to your controllers to select the current locale:
47
+ ```ruby
48
+ before_action :select_locale
49
+
50
+ protected
51
+
52
+ def select_locale
53
+ I18n.locale = params[:locale]
54
+ end
55
+ ```
56
+
57
+ ## Credits
58
+
59
+ This gem is maintained and funded by [museways](http://museways.com).
60
+
61
+ ## License
62
+
63
+ It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
@@ -2,22 +2,34 @@ module TranslatableRoutes
2
2
  module ActionDispatch
3
3
  module NamedRouteCollection
4
4
  extend ActiveSupport::Concern
5
-
5
+
6
6
  def define_i18n_url_helper(name)
7
7
  %w(path url).each do |type|
8
8
  helper = :"#{name}_#{type}"
9
- @module.remove_possible_method helper
10
- @module.module_eval do
9
+
10
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
11
+ target = instance_variable_get("@#{type}_helpers_module")
12
+ else
13
+ target = @module
14
+ end
15
+
16
+ target.remove_possible_method helper
17
+ target.module_eval do
11
18
  define_method helper do |*args|
12
19
  options = args.extract_options!
13
20
  suffix = (options[:locale] || I18n.locale).to_s.gsub('-', '_').downcase
14
21
  send "#{name}_#{suffix}_#{type}", *(args << options)
15
22
  end
16
23
  end
17
- helpers << helper
24
+
25
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
26
+ instance_variable_get("@#{type}_helpers") << helper
27
+ else
28
+ helpers << helper
29
+ end
18
30
  end
19
31
  end
20
-
32
+
21
33
  end
22
34
  end
23
35
  end
@@ -2,8 +2,14 @@ module TranslatableRoutes
2
2
  class Railtie < Rails::Railtie
3
3
 
4
4
  initializer 'translatable_routes' do
5
- ::ActionDispatch::Routing::RouteSet::NamedRouteCollection.send :include, TranslatableRoutes::ActionDispatch::NamedRouteCollection
6
- ::ActionDispatch::Routing::Mapper.send :include, TranslatableRoutes::ActionDispatch::Mapper
5
+ ::ActionDispatch::Routing::RouteSet::NamedRouteCollection.send(
6
+ :include,
7
+ TranslatableRoutes::ActionDispatch::NamedRouteCollection
8
+ )
9
+ ::ActionDispatch::Routing::Mapper.send(
10
+ :include,
11
+ TranslatableRoutes::ActionDispatch::Mapper
12
+ )
7
13
  end
8
14
 
9
15
  end
@@ -1,5 +1,5 @@
1
1
  module TranslatableRoutes
2
2
 
3
- VERSION = '1.3.3'
3
+ VERSION = '1.3.4'
4
4
 
5
5
  end
@@ -20,7 +20,11 @@ Dummy::Application.configure do
20
20
  # config.action_dispatch.rack_cache = true
21
21
 
22
22
  # Disable Rails's static asset server (Apache or nginx will already do this).
23
- config.serve_static_assets = false
23
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
24
+ config.serve_static_files = false
25
+ else
26
+ config.serve_static_assets = false
27
+ end
24
28
 
25
29
  # Compress JavaScripts and CSS.
26
30
  config.assets.js_compressor = :uglifier
@@ -13,7 +13,11 @@ Dummy::Application.configure do
13
13
  config.eager_load = false
14
14
 
15
15
  # Configure static asset server for tests with Cache-Control for performance.
16
- config.serve_static_assets = true
16
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
17
+ config.serve_static_files = false
18
+ else
19
+ config.serve_static_assets = false
20
+ end
17
21
  config.static_cache_control = "public, max-age=3600"
18
22
 
19
23
  # Show full error reports and disable caching.
@@ -33,4 +37,8 @@ Dummy::Application.configure do
33
37
 
34
38
  # Print deprecation notices to the stderr.
35
39
  config.active_support.deprecation = :stderr
40
+
41
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
42
+ config.active_support.test_order = :random
43
+ end
36
44
  end
@@ -6494,3 +6494,178 @@ HelpersTest: test_create_helpers
6494
6494
  RoutesTest: test_translate_routes
6495
6495
  ---------------------------------
6496
6496
   (0.1ms) rollback transaction
6497
+  (0.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
6498
+  (0.1ms) select sqlite_version(*)
6499
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
6500
+  (0.1ms) SELECT version FROM "schema_migrations"
6501
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
6502
+  (0.1ms) begin transaction
6503
+ -------------------------
6504
+ HelpersTest: test_helpers
6505
+ -------------------------
6506
+  (0.1ms) rollback transaction
6507
+  (0.0ms) begin transaction
6508
+ -----------------------
6509
+ RoutesTest: test_routes
6510
+ -----------------------
6511
+  (0.1ms) rollback transaction
6512
+  (0.3ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
6513
+  (0.1ms) select sqlite_version(*)
6514
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
6515
+  (0.0ms) SELECT version FROM "schema_migrations"
6516
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
6517
+  (0.3ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
6518
+  (0.1ms) select sqlite_version(*)
6519
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
6520
+  (0.0ms) SELECT version FROM "schema_migrations"
6521
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
6522
+  (0.1ms) begin transaction
6523
+ -----------------------
6524
+ RoutesTest: test_routes
6525
+ -----------------------
6526
+  (0.1ms) rollback transaction
6527
+  (0.1ms) begin transaction
6528
+ -------------------------
6529
+ HelpersTest: test_helpers
6530
+ -------------------------
6531
+  (0.1ms) rollback transaction
6532
+  (0.3ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
6533
+  (0.1ms) select sqlite_version(*)
6534
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
6535
+  (0.0ms) SELECT version FROM "schema_migrations"
6536
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
6537
+  (0.4ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
6538
+  (0.1ms) select sqlite_version(*)
6539
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
6540
+  (0.1ms) SELECT version FROM "schema_migrations"
6541
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
6542
+  (0.1ms) begin transaction
6543
+ -------------------------
6544
+ HelpersTest: test_helpers
6545
+ -------------------------
6546
+  (0.0ms) rollback transaction
6547
+  (0.0ms) begin transaction
6548
+ -----------------------
6549
+ RoutesTest: test_routes
6550
+ -----------------------
6551
+  (0.1ms) rollback transaction
6552
+  (0.2ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
6553
+  (0.1ms) select sqlite_version(*)
6554
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
6555
+  (0.0ms) SELECT version FROM "schema_migrations"
6556
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
6557
+  (0.3ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
6558
+  (0.1ms) select sqlite_version(*)
6559
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
6560
+  (0.1ms) SELECT version FROM "schema_migrations"
6561
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
6562
+  (0.1ms) begin transaction
6563
+ -----------------------
6564
+ RoutesTest: test_routes
6565
+ -----------------------
6566
+  (0.1ms) rollback transaction
6567
+  (0.1ms) begin transaction
6568
+ -------------------------
6569
+ HelpersTest: test_helpers
6570
+ -------------------------
6571
+  (0.1ms) rollback transaction
6572
+  (0.3ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
6573
+  (0.1ms) select sqlite_version(*)
6574
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
6575
+  (0.0ms) SELECT version FROM "schema_migrations"
6576
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
6577
+  (0.3ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
6578
+  (0.1ms) select sqlite_version(*)
6579
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
6580
+  (0.1ms) SELECT version FROM "schema_migrations"
6581
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
6582
+  (0.1ms) begin transaction
6583
+ -------------------------
6584
+ HelpersTest: test_helpers
6585
+ -------------------------
6586
+  (0.0ms) rollback transaction
6587
+  (0.0ms) begin transaction
6588
+ -----------------------
6589
+ RoutesTest: test_routes
6590
+ -----------------------
6591
+  (0.2ms) rollback transaction
6592
+  (0.3ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
6593
+  (0.1ms) select sqlite_version(*)
6594
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
6595
+  (0.0ms) SELECT version FROM "schema_migrations"
6596
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
6597
+  (0.3ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
6598
+  (0.1ms) select sqlite_version(*)
6599
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
6600
+  (0.1ms) SELECT version FROM "schema_migrations"
6601
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
6602
+  (0.1ms) begin transaction
6603
+ -----------------------
6604
+ RoutesTest: test_routes
6605
+ -----------------------
6606
+  (0.1ms) rollback transaction
6607
+  (0.0ms) begin transaction
6608
+ -------------------------
6609
+ HelpersTest: test_helpers
6610
+ -------------------------
6611
+  (0.1ms) rollback transaction
6612
+  (0.3ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
6613
+  (0.1ms) select sqlite_version(*)
6614
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
6615
+  (0.1ms) SELECT version FROM "schema_migrations"
6616
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
6617
+  (0.3ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
6618
+  (0.1ms) select sqlite_version(*)
6619
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
6620
+  (0.1ms) SELECT version FROM "schema_migrations"
6621
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
6622
+  (0.1ms) begin transaction
6623
+ -----------------------
6624
+ RoutesTest: test_routes
6625
+ -----------------------
6626
+  (0.1ms) rollback transaction
6627
+  (0.1ms) begin transaction
6628
+ -------------------------
6629
+ HelpersTest: test_helpers
6630
+ -------------------------
6631
+  (0.1ms) rollback transaction
6632
+  (0.3ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
6633
+  (0.1ms) select sqlite_version(*)
6634
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
6635
+  (0.0ms) SELECT version FROM "schema_migrations"
6636
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
6637
+  (0.3ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
6638
+  (0.1ms) select sqlite_version(*)
6639
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
6640
+  (0.1ms) SELECT version FROM "schema_migrations"
6641
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
6642
+  (0.1ms) begin transaction
6643
+ -------------------------
6644
+ HelpersTest: test_helpers
6645
+ -------------------------
6646
+  (0.0ms) rollback transaction
6647
+  (0.0ms) begin transaction
6648
+ -----------------------
6649
+ RoutesTest: test_routes
6650
+ -----------------------
6651
+  (0.1ms) rollback transaction
6652
+  (0.3ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
6653
+  (0.1ms) select sqlite_version(*)
6654
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
6655
+  (0.0ms) SELECT version FROM "schema_migrations"
6656
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
6657
+  (0.4ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
6658
+  (0.1ms) select sqlite_version(*)
6659
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
6660
+  (0.1ms) SELECT version FROM "schema_migrations"
6661
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
6662
+  (0.1ms) begin transaction
6663
+ -------------------------
6664
+ HelpersTest: test_helpers
6665
+ -------------------------
6666
+  (0.0ms) rollback transaction
6667
+  (0.0ms) begin transaction
6668
+ -----------------------
6669
+ RoutesTest: test_routes
6670
+ -----------------------
6671
+  (0.1ms) rollback transaction
data/test/helpers_test.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class HelpersTest < ActionView::TestCase
4
+ include Rails.application.routes.url_helpers
4
5
 
5
- test "create helpers" do
6
+ test 'helpers' do
6
7
  I18n.available_locales.each do |locale|
7
8
  I18n.locale = locale
8
9
  assert_equal(
data/test/routes_test.rb CHANGED
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
 
3
3
  class RoutesTest < ActionDispatch::IntegrationTest
4
4
 
5
- test "translate routes" do
5
+ test 'routes' do
6
6
  I18n.available_locales.each do |locale|
7
7
  I18n.locale = locale
8
8
  assert_recognizes(
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: translatable_routes
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.3
4
+ version: 1.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Museways
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-24 00:00:00.000000000 Z
11
+ date: 2015-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,8 +16,8 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 3.2.0
20
- - - "<"
19
+ version: 4.0.0
20
+ - - "<="
21
21
  - !ruby/object:Gem::Version
22
22
  version: 4.2.0
23
23
  type: :runtime
@@ -26,8 +26,8 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 3.2.0
30
- - - "<"
29
+ version: 4.0.0
30
+ - - "<="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 4.2.0
33
33
  - !ruby/object:Gem::Dependency
@@ -52,7 +52,7 @@ extensions: []
52
52
  extra_rdoc_files: []
53
53
  files:
54
54
  - MIT-LICENSE
55
- - README.rdoc
55
+ - README.md
56
56
  - Rakefile
57
57
  - lib/translatable_routes.rb
58
58
  - lib/translatable_routes/action_dispatch/mapper.rb
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  version: '0'
129
129
  requirements: []
130
130
  rubyforge_project:
131
- rubygems_version: 2.2.2
131
+ rubygems_version: 2.4.5
132
132
  signing_key:
133
133
  specification_version: 4
134
134
  summary: Translatable routes for rails.
data/README.rdoc DELETED
@@ -1,51 +0,0 @@
1
- {<img src="https://badge.fury.io/rb/translatable_routes.png" alt="Gem Version" />}[http://badge.fury.io/rb/translatable_routes] {<img src="https://codeclimate.com/github/museways/translatable_routes.png" />}[https://codeclimate.com/github/museways/translatable_routes] {<img src="https://travis-ci.org/museways/translatable_routes.png?branch=master" alt="Build Status" />}[https://travis-ci.org/museways/translatable_routes]
2
-
3
- = Translatable Routes
4
-
5
- Minimalistic toolkit to translate routes in rails.
6
-
7
- = Install
8
-
9
- Put this line in your Gemfile:
10
- gem 'translatable_routes'
11
-
12
- Then bundle:
13
- $ bundle
14
-
15
- = Configuration
16
-
17
- In your config/routes.rb use the localized method to decide wich routes will be localized:
18
- localized do
19
- get 'about' => 'pages#about'
20
- end
21
-
22
- Put your translations inside the routes key in your locales yamls:
23
- es:
24
- routes:
25
- users: "usuarios"
26
- profile: "perfil"
27
- about: "nosotros"
28
-
29
- NOTE: There is no need to put the full path, just translate each part individually.
30
-
31
- = Usage
32
-
33
- Helpers will continue working the same but I18n.locale will be use as default locale:
34
- about_path # Will output /en/about in case I18n.locale is :en
35
-
36
- Here is an example of what you may want to add to your controllers to select the current locale:
37
- before_action :select_locale
38
-
39
- protected
40
-
41
- def select_locale
42
- I18n.locale = params[:locale]
43
- end
44
-
45
- = Credits
46
-
47
- This gem is maintained and funded by museways[http://museways.com].
48
-
49
- = License
50
-
51
- It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.