route_translator 4.1.0 → 4.2.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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -0
  3. data/LICENSE +21 -0
  4. data/README.md +231 -0
  5. data/lib/route_translator/extensions/action_controller.rb +5 -2
  6. data/lib/route_translator/extensions/mapper.rb +5 -5
  7. data/lib/route_translator/extensions/route_set.rb +1 -1
  8. data/lib/route_translator/host.rb +4 -5
  9. data/lib/route_translator/translator.rb +17 -13
  10. data/lib/route_translator/version.rb +1 -1
  11. data/lib/route_translator.rb +1 -1
  12. metadata +92 -59
  13. data/test/dummy/Rakefile +0 -7
  14. data/test/dummy/app/controllers/dummy_controller.rb +0 -11
  15. data/test/dummy/app/views/dummy/show.html.erb +0 -1
  16. data/test/dummy/config/application.rb +0 -21
  17. data/test/dummy/config/boot.rb +0 -0
  18. data/test/dummy/config/environment.rb +0 -5
  19. data/test/dummy/config/initializers/secret_token.rb +0 -7
  20. data/test/dummy/config/initializers/session_store.rb +0 -8
  21. data/test/dummy/config/locales/all.yml +0 -15
  22. data/test/dummy/config/routes.rb +0 -12
  23. data/test/dummy/config.ru +0 -4
  24. data/test/dummy/dummy_mounted_app.rb +0 -5
  25. data/test/dummy/script/rails +0 -6
  26. data/test/host_test.rb +0 -108
  27. data/test/integration/generated_path_test.rb +0 -37
  28. data/test/integration/host_locales_test.rb +0 -59
  29. data/test/integration/routing_test.rb +0 -22
  30. data/test/integration/thread_safety_test.rb +0 -16
  31. data/test/locales/routes.yml +0 -13
  32. data/test/routing_test.rb +0 -664
  33. data/test/support/assertion_helper.rb +0 -27
  34. data/test/support/configuration_helper.rb +0 -52
  35. data/test/support/i18n_helper.rb +0 -24
  36. data/test/support/integration_helper.rb +0 -6
  37. data/test/support/routes_helper.rb +0 -60
  38. data/test/test_helper.rb +0 -32
@@ -1,52 +0,0 @@
1
- module RouteTranslator
2
- module ConfigurationHelper
3
- def config_reset
4
- config_force_locale false
5
- config_hide_locale false
6
- config_generate_unlocalized_routes false
7
- config_generate_unnamed_unlocalized_routes false
8
- config_host_locales(host_locales_config_hash)
9
-
10
- config_default_locale_settings(:en)
11
- end
12
-
13
- alias :setup_config :config_reset
14
- alias :teardown_config :config_reset
15
-
16
- def config_default_locale_settings(locale)
17
- I18n.default_locale = locale
18
- end
19
-
20
- def config_force_locale(boolean)
21
- RouteTranslator.config.force_locale = boolean
22
- end
23
-
24
- def config_hide_locale(boolean)
25
- RouteTranslator.config.hide_locale = boolean
26
- end
27
-
28
- def config_generate_unlocalized_routes(boolean)
29
- RouteTranslator.config.generate_unlocalized_routes = boolean
30
- end
31
-
32
- def config_generate_unnamed_unlocalized_routes(boolean)
33
- RouteTranslator.config.generate_unnamed_unlocalized_routes = boolean
34
- end
35
-
36
- def config_host_locales(hash)
37
- RouteTranslator.config.host_locales = hash
38
- end
39
-
40
- def config_available_locales(arr)
41
- RouteTranslator.config.available_locales = arr
42
- end
43
-
44
- def config_disable_fallback(boolean)
45
- RouteTranslator.config.disable_fallback = boolean
46
- end
47
-
48
- def host_locales_config_hash
49
- ::Hash.new
50
- end
51
- end
52
- end
@@ -1,24 +0,0 @@
1
-
2
- module RouteTranslator
3
- module I18nHelper
4
-
5
- def setup_i18n
6
- @i18n_backend = I18n.backend
7
- @i18n_load_path = I18n.load_path
8
-
9
- I18n.locale = I18n.default_locale
10
- I18n.backend = I18n::Backend::Simple.new
11
- I18n.load_path = [ File.expand_path('../../locales/routes.yml', __FILE__) ]
12
-
13
- I18n.reload!
14
- end
15
-
16
- def teardown_i18n
17
- I18n.backend = @i18n_backend
18
- I18n.load_path = @i18n_load_path
19
-
20
- I18n.reload!
21
- end
22
-
23
- end
24
- end
@@ -1,6 +0,0 @@
1
- require File.expand_path('../../dummy/dummy_mounted_app', __FILE__)
2
- require File.expand_path('../../dummy/config/environment', __FILE__)
3
-
4
- def integration_test_suite_parent_class
5
- defined?(ActionDispatch::IntegrationTest) ? ActionDispatch::IntegrationTest : ActionController::IntegrationTest
6
- end
@@ -1,60 +0,0 @@
1
-
2
- module RouteTranslator
3
- module RoutesHelper
4
-
5
- def draw_routes(&block)
6
- @routes.draw(&block)
7
- if @routes.respond_to?(:install_helpers)
8
- @routes.install_helpers
9
- else
10
- ActionView::Base.send(:include, @routes.url_helpers)
11
- ActionController::Base.send(:include, @routes.url_helpers)
12
- end
13
- end
14
-
15
- def path_string(route)
16
- path = route.respond_to?(:path) ? route.path : route.to_s.split(' ')[1]
17
- path.respond_to?(:spec) ? path.spec.to_s : path.to_s
18
- end
19
-
20
- def named_route(name)
21
- @routes.routes.detect{ |r| r.name == name }
22
- end
23
-
24
- def formatted_root_route?
25
- b = ActionPack::VERSION::MAJOR == 3 && ActionPack::VERSION::MINOR > 0
26
- b ||= ActionPack::VERSION::MAJOR == 4
27
- !b
28
- end
29
-
30
- def print_routes(route_set)
31
- all_routes = route_set.routes
32
-
33
- routes = all_routes.collect do |route|
34
-
35
- reqs = route.requirements.dup
36
- reqs[:to] = route.app unless route.app.class.name.to_s =~ /^ActionDispatch::Routing/
37
- reqs = reqs.empty? ? "" : reqs.inspect
38
-
39
- path = route.path
40
- path = path.spec if path.respond_to?(:spec)
41
- path = path.to_s
42
-
43
- {:name => route.name.to_s, :verb => route.verb.to_s, :path => path, :reqs => reqs}
44
- end
45
-
46
- name_width = routes.map{ |r| r[:name].length }.max
47
- verb_width = routes.map{ |r| r[:verb].length }.max
48
- path_width = routes.map{ |r| r[:path].to_s.length }.max
49
-
50
- puts
51
- routes.each do |r|
52
- puts "#{r[:name].rjust(name_width)} #{r[:verb].ljust(verb_width)} #{r[:path].to_s.ljust(path_width)} #{r[:reqs]}"
53
- end
54
- puts
55
-
56
- rescue LoadError
57
- end
58
-
59
- end
60
- end
data/test/test_helper.rb DELETED
@@ -1,32 +0,0 @@
1
- #encoding: utf-8
2
-
3
- require 'minitest/autorun'
4
- require 'minitest/mock'
5
-
6
- require 'i18n'
7
- begin
8
- I18n.enforce_available_locales = true
9
- rescue NoMethodError
10
- end
11
-
12
- require "rails"
13
- require "action_controller/railtie"
14
- require "action_mailer/railtie"
15
-
16
- require 'route_translator'
17
-
18
- module ActionDispatch
19
- class TestRequest < Request
20
- def initialize(env = {})
21
- super(DEFAULT_ENV.merge(env))
22
-
23
- self.host = 'test.host'
24
- self.remote_addr = '0.0.0.0'
25
- self.user_agent = 'Rails Testing'
26
- end
27
- end
28
- end
29
-
30
- Dir[File.expand_path('../support/*.rb', __FILE__)].each do |helper|
31
- require helper
32
- end