From e4e5ec6e15e326ac1ecc71d64d8458785f49dc00 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Mon, 25 Mar 2013 16:40:16 +0100 Subject: [PATCH] SONAR-4193 Move interprete macro function from application helper to a new dedicated class --- .../api/manual_measures_controller.rb | 2 +- .../WEB-INF/app/helpers/application_helper.rb | 3 --- .../WEB-INF/app/models/macro_interpreter.rb | 27 +++++++++++++++++++ .../WEB-INF/app/views/rules/_show.html.erb | 4 +-- .../WEB-INF/app/views/rules/show.html.erb | 4 +-- .../rules_configuration/_rule_note.html.erb | 4 +-- 6 files changed, 34 insertions(+), 10 deletions(-) create mode 100644 sonar-server/src/main/webapp/WEB-INF/app/models/macro_interpreter.rb diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/manual_measures_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/manual_measures_controller.rb index fabae0f67db..cebc0616f8e 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/manual_measures_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/manual_measures_controller.rb @@ -58,7 +58,7 @@ class Api::ManualMeasuresController < Api::ApiController value=params[:val] bad_request("Not a numeric value: #{value}") if value && !Api::Utils.is_number?(value) - measure=ManualMeasure.find(:first, :conditions => ['resource_id=? and metric_id=?', resource.id, metric.id]) + measure=ManualMeasure.first(:conditions => ['resource_id=? and metric_id=?', resource.id, metric.id]) if measure.nil? measure=ManualMeasure.new(:resource => resource, :user_login => current_user.login, :metric_id => metric.id) end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb index 5c11180c912..c1916516d90 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb @@ -787,7 +787,4 @@ module ApplicationHelper html end - def interpret_macro(text) - Java::OrgSonarServerUi::JRubyFacade.getInstance().getMacroInterpreter().interpret(text) - end end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/macro_interpreter.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/macro_interpreter.rb new file mode 100644 index 00000000000..23589356bc6 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/macro_interpreter.rb @@ -0,0 +1,27 @@ +# +# Sonar, entreprise quality control tool. +# Copyright (C) 2008-2012 SonarSource +# mailto:contact AT sonarsource DOT com +# +# Sonar is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# Sonar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with Sonar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 +# + +class MacroInterpreter + + def self.interpret_macro(text) + Java::OrgSonarServerUi::JRubyFacade.getInstance().getMacroInterpreter().interpret(text) + end + +end \ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/rules/_show.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/rules/_show.html.erb index e20d3a4aac1..ad8be3d63d0 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/rules/_show.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/rules/_show.html.erb @@ -19,9 +19,9 @@