| Name | Total Lines | Lines of Code | Total Coverage | Code Coverage |
|---|---|---|---|---|
| app/controllers/application_controller.rb | 71 | 45 | 85.92%
|
80.00%
|
Code reported as executed by Ruby looks like this...and this: this line is also marked as covered.Lines considered as run by rcov, but not reported by Ruby, look like this,and this: these lines were inferred by rcov (using simple heuristics).Finally, here's a line marked as not executed.
1 # Filters added to this controller apply to all controllers in the application. |
2 # Likewise, all the methods added will be available for all controllers. |
3 |
4 class ApplicationController < ActionController::Base |
5 include SessionHandler |
6 |
7 protect_from_forgery |
8 |
9 layout "content" |
10 |
11 helper :all # include all helpers in the views, all the time |
12 |
13 # activate i18n for renaming constants in views |
14 before_filter :set_locale, :set_markus_version, :set_remote_user |
15 # check for active session on every page |
16 before_filter :authenticate, :except => [:login, :page_not_found] |
17 |
18 # Define default URL options to include the locale |
19 def default_url_options(options={}) |
20 { :locale => I18n.locale } |
21 end |
22 |
23 protected |
24 |
25 # Set version for MarkUs to be available in |
26 # any view |
27 def set_markus_version |
28 version_file=File.expand_path(File.join(::Rails.root.to_s, "app", "MARKUS_VERSION")) |
29 if !File.exist?(version_file) |
30 @markus_version = "unknown" |
31 return |
32 end |
33 content = File.new(version_file).read |
34 version_info = Hash.new |
35 content.split(',').each do |token| |
36 k,v = token.split('=') |
37 version_info[k.downcase] = v |
38 end |
39 @markus_version = "#{version_info["version"]}.#{version_info["patch_level"]}" |
40 end |
41 |
42 def set_remote_user |
43 if !request.env["HTTP_X_FORWARDED_USER"].blank? |
44 @markus_auth_remote_user = request.env["HTTP_X_FORWARDED_USER"] |
45 end |
46 end |
47 |
48 # Set locale according to URL parameter. If unknown parameter is |
49 # requested, fall back to default locale. |
50 def set_locale |
51 @available_locales = AVAILABLE_LANGS if @available_locales.nil? |
52 I18n.locale = params[:locale] || I18n.default_locale # for now, always |
53 # resorts to |
54 # I18n.default_locale |
55 |
56 locale_path = File.join(LOCALES_DIRECTORY, "#{I18n.locale}.yml") |
57 |
58 unless I18n.load_path.include? locale_path |
59 I18n.load_path << locale_path |
60 I18n.backend.send(:init_translations) |
61 end |
62 |
63 # handle unknown locales |
64 rescue Exception => err |
65 logger.error err |
66 flash.now[:notice] = I18n.t("locale_not_available", :locale => I18n.locale) |
67 |
68 I18n.load_path -= [locale_path] |
69 I18n.locale = I18n.default_locale |
70 end |
71 end |
Generated on Tue Feb 07 00:07:35 -0500 2012 with rcov 0.9.10