diff --git a/.rspec b/.rspec deleted file mode 100644 index c99d2e7..0000000 --- a/.rspec +++ /dev/null @@ -1 +0,0 @@ ---require spec_helper diff --git a/app/helpers/merged/merged_helper.rb b/app/helpers/merged/merged_helper.rb index 567a805..3797ee6 100644 --- a/app/helpers/merged/merged_helper.rb +++ b/app/helpers/merged/merged_helper.rb @@ -3,15 +3,19 @@ require "redcarpet" module Merged module MergedHelper include OptionsHelper - @@renderer = nil def renderer - return @@renderer unless @@renderer.nil? options = {hard_wrap: true , autolink: true, no_intra_emphasis: true , safe_links_only: true, no_styles: true , link_attributes: { target: '_blank' }} html = Redcarpet::Render::HTML.new(options) - @@renderer = Redcarpet::Markdown.new(html, options) + Redcarpet::Markdown.new(html, options) + end + + def markdown(text) + text = text.text unless text.is_a?(String) + return "" if text.blank? + self.renderer.render(text).html_safe end def aspect_ratio image @@ -19,11 +23,6 @@ module Merged "#{x} / #{y}" end - def markdown(text) - text = text.text unless text.is_a?(String) - return "" if text.blank? - renderer.render(text).html_safe - end def field_name(card) name = card.header name += "*" unless card.option("compulsory") == "no" diff --git a/config/initializers/active_file.rb b/app/models/merged/active_base.rb similarity index 89% rename from config/initializers/active_file.rb rename to app/models/merged/active_base.rb index b16b952..ad79422 100644 --- a/config/initializers/active_file.rb +++ b/app/models/merged/active_base.rb @@ -1,7 +1,5 @@ -require "active_hash" - -module ActiveYaml - Base.class_eval do +module Merged + class ActiveBase < ActiveYaml::Base def save super diff --git a/app/models/merged/image.rb b/app/models/merged/image.rb index 9be3d52..d8399f5 100644 --- a/app/models/merged/image.rb +++ b/app/models/merged/image.rb @@ -1,7 +1,7 @@ require "mini_magick" module Merged - class Image < ActiveYaml::Base + class Image < ActiveBase set_root_path Rails.root diff --git a/app/models/merged/option_definition.rb b/app/models/merged/option_definition.rb index bbeceaa..90ab6ac 100644 --- a/app/models/merged/option_definition.rb +++ b/app/models/merged/option_definition.rb @@ -1,5 +1,5 @@ module Merged - class OptionDefinition < ActiveYaml::Base + class OptionDefinition < ActiveBase set_root_path Engine.root + "config" fields :name , :default , :description , :values , :type diff --git a/app/models/merged/style.rb b/app/models/merged/style.rb index d89016a..36d948c 100644 --- a/app/models/merged/style.rb +++ b/app/models/merged/style.rb @@ -1,5 +1,5 @@ module Merged - class Style < ActiveYaml::Base + class Style < ActiveBase set_root_path Engine.root + "config" diff --git a/app/models/merged/view_base.rb b/app/models/merged/view_base.rb index 334b4b1..4ec03b1 100644 --- a/app/models/merged/view_base.rb +++ b/app/models/merged/view_base.rb @@ -4,7 +4,7 @@ module Merged # they share the template idea, options , change tracking, # and the fact that they persist in ActiveYaml - class ViewBase < ActiveYaml::Base + class ViewBase < ActiveBase set_root_path Rails.root #ouside engines not necessary include ActiveHash::Associations