]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4193 Move interprete macro function from application helper to a new dedicated...
authorJulien Lancelot <julien.lancelot@gmail.com>
Mon, 25 Mar 2013 15:40:16 +0000 (16:40 +0100)
committerJulien Lancelot <julien.lancelot@gmail.com>
Mon, 25 Mar 2013 15:40:34 +0000 (16:40 +0100)
sonar-server/src/main/webapp/WEB-INF/app/controllers/api/manual_measures_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb
sonar-server/src/main/webapp/WEB-INF/app/models/macro_interpreter.rb [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/app/views/rules/_show.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/rules/show.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule_note.html.erb

index fabae0f67dbf62b9cd15203e9f0e9a2b033c6c76..cebc0616f8e8417240236a76a5fccb03708bfd61 100644 (file)
@@ -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
index 5c11180c91211853aa9fe3c6019f43005fdbd8d2..c1916516d907523336aa89ce67351afb85e43e7f 100644 (file)
@@ -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 (file)
index 0000000..2358935
--- /dev/null
@@ -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
index e20d3a4aac11ed3d3d3ba29a76a2b1b545fdd22d..ad8be3d63d0c0fd6dabff5c1862b0c98c501380c 100644 (file)
@@ -19,9 +19,9 @@
 
 <div class="modal-body">
   <% if @rule.description.strip.start_with?('<p>') %>
-    <%= interpret_macro @rule.description %>
+    <%= MacroInterpreter.interpret_macro @rule.description %>
   <% else %>
-    <p><%= interpret_macro @rule.description %></p>
+    <p><%= MacroInterpreter.interpret_macro @rule.description %></p>
   <% end %>
 
   <% if @rule.note && !@rule.note.text.strip.blank? %>
index 0242ce092957d5e369c3a602f75cf2aaf0ee61b6..30f6109d17578bc906dd54c6c2e9a6fdc1c3a6c1 100644 (file)
@@ -17,9 +17,9 @@
 
 <div class="doc">
   <% if @rule.description.strip.start_with?('<p>') %>
-    <%= interpret_macro @rule.description %>
+    <%=  MacroInterpreter.interpret_macro @rule.description %>
   <% else %>
-    <p><%= interpret_macro @rule.description %></p>
+    <p><%= MacroInterpreter.interpret_macro @rule.description %></p>
   <% end %>
 
   <% if @rule.note && !@rule.note.text.strip.blank? %>
index 1c1723e41b41cf698e552f03cbcc2b51679015ae..ab64fd530e49f1936091fcb7028e1d488c20bf05 100644 (file)
@@ -9,9 +9,9 @@
 
 <div id="<%= note_detail_div_id -%>">
   <% if rule.description.strip.start_with?('<p>') %>
-    <%= interpret_macro rule.description %>
+    <%= MacroInterpreter.interpret_macro rule.description %>
   <% else %>
-    <p><%= interpret_macro rule.description %></p>
+    <p><%= MacroInterpreter.interpret_macro rule.description %></p>
   <% end %>
   
   <% if note && !note.text.strip.blank? %>