Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

remove mephisto plugin, move mephisto_init code to config initializers

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@3073 567b1171-46fb-0310-a4c9-b4bef9110e78
  • Loading branch information...
commit 153067be229d13cb4c2d28e55635f59666e17afe 1 parent 12a136d
technoweenie authored
4 .gitignore
View
@@ -0,0 +1,4 @@
+.rake_tasks
+config/database.yml
+log
+tmp
85 config/initializers/mephisto_init.rb
View
@@ -23,86 +23,13 @@ def cleanup_application_with_plugins(force = false)
alias_method_chain :cleanup_application, :plugins
end
-module Liquid
- AllowedVariableCharacters = /[a-zA-Z_.-]/ unless Liquid.const_defined?(:AllowedVariableCharacters)
-end
-
ActionController::Dispatcher.register_liquid_tags
-WhiteListHelper.tags.merge %w(table tr td)
-
-ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.update \
- :standard => '%B %d, %Y @ %I:%M %p',
- :stub => '%B %d',
- :time_only => '%I:%M %p',
- :plain => '%B %d %I:%M %p',
- :mdy => '%B %d, %Y',
- :my => '%B %Y'
-
-class MissingTemplateError < StandardError
- attr_reader :template_type, :templates
- def initialize(template_type, templates)
- @template_type = template_type
- @templates = templates
- super "No template found for #{template_type}, checked #{templates.to_sentence}."
- end
-end
-
-class MissingThemesError < StandardError
- attr_reader :site
- def initialize(site)
- @site = site
- super "No themes found in '#{site.theme_path.to_s}/#{site.current_theme_path}'. This must be set correctly in the site settings."
- end
-end
-
-class ThemeError < StandardError
- attr_reader :theme
- def initialize(theme, message)
- @theme = theme
- super message
- end
+Inflector.inflections do |inflect|
+ #inflect.plural /^(ox)$/i, '\1en'
+ #inflect.singular /^(ox)en/i, '\1'
+ #inflect.irregular 'person', 'people'
+ inflect.uncountable %w( audio )
end
-class Time
- class << self
- # Used for getting multifield attributes like those generated by a
- # select_datetime into a new Time object. For example if you have
- # following <tt>params={:meetup=>{:"time(1i)=>..."}}</tt> just do
- # following:
- #
- # <tt>Time.parse_from_attributes(params[:meetup], :time)</tt>
- def parse_from_attributes(attrs, field, method=:gm)
- attrs = attrs.keys.sort.grep(/^#{field.to_s}\(.+\)$/).map { |k| attrs[k] }
- attrs.any? ? Time.send(method, *attrs) : nil
- end
-
- def delta(year, month = nil, day = nil)
- from = Time.local(year, month || 1, day || 1)
-
- to =
- if !day.blank?
- from.advance :days => 1
- elsif !month.blank?
- from.advance :months => 1
- else
- from.advance :years => 1
- end
- return [from.midnight, to.midnight-1]
- end
- end
-
- def to_delta(delta_type = :day)
- case delta_type
- when :year then self.class.delta(year)
- when :month then self.class.delta(year, month)
- else self.class.delta(year, month, day)
- end
- end
-end
-
-class Object
- def tap
- yield self; self;
- end
-end
+Dependencies.autoloaded_constants.delete "Mephisto"
26 vendor/plugins/mephisto/init.rb → config/initializers/metaprogramming.rb
View
@@ -1,24 +1,5 @@
-# monkey patches galore!
-
Object::RAILS_PATH = Pathname.new(File.expand_path(RAILS_ROOT))
-Inflector.inflections do |inflect|
- #inflect.plural /^(ox)$/i, '\1en'
- #inflect.singular /^(ox)en/i, '\1'
- #inflect.irregular 'person', 'people'
- inflect.uncountable %w( audio )
-end
-
-# Time.now.to_ordinalized_s :long
-# => "February 28th, 2006 21:10"
-module ActiveSupport::CoreExtensions::Time::Conversions
- def to_ordinalized_s(format = :default)
- format = ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS[format]
- return to_default_s if format.nil?
- strftime(format.gsub(/%d/, '_%d_')).gsub(/_(\d+)_/) { |s| s.to_i.ordinalize }
- end
-end
-
# need to make pathname safe for windows!
Pathname.class_eval do
def read(*args)
@@ -92,5 +73,8 @@ def self.to_fixture(fixture_path = nil)
expiring_attr_reader :referenced_cache_key, '"[#{[id, self.class.name] * ":"}]"'
end
-Liquid::For.send :include, Mephisto::Liquid::ForWithSorting
-Dependencies.autoloaded_constants.delete "Mephisto"
+class Object
+ def tap
+ yield self; self;
+ end
+end
32 config/initializers/templating.rb
View
@@ -0,0 +1,32 @@
+module Liquid
+ AllowedVariableCharacters = /[a-zA-Z_.-]/ unless Liquid.const_defined?(:AllowedVariableCharacters)
+end
+
+Liquid::For.send :include, Mephisto::Liquid::ForWithSorting
+
+WhiteListHelper.tags.merge %w(table tr td)
+
+class MissingTemplateError < StandardError
+ attr_reader :template_type, :templates
+ def initialize(template_type, templates)
+ @template_type = template_type
+ @templates = templates
+ super "No template found for #{template_type}, checked #{templates.to_sentence}."
+ end
+end
+
+class MissingThemesError < StandardError
+ attr_reader :site
+ def initialize(site)
+ @site = site
+ super "No themes found in '#{site.theme_path.to_s}/#{site.current_theme_path}'. This must be set correctly in the site settings."
+ end
+end
+
+class ThemeError < StandardError
+ attr_reader :theme
+ def initialize(theme, message)
+ @theme = theme
+ super message
+ end
+end
54 config/initializers/time_hacks.rb
View
@@ -0,0 +1,54 @@
+# Time.now.to_ordinalized_s :long
+# => "February 28th, 2006 21:10"
+module ActiveSupport::CoreExtensions::Time::Conversions
+ def to_ordinalized_s(format = :default)
+ format = ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS[format]
+ return to_default_s if format.nil?
+ strftime(format.gsub(/%d/, '_%d_')).gsub(/_(\d+)_/) { |s| s.to_i.ordinalize }
+ end
+end
+
+ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.update \
+ :standard => '%B %d, %Y @ %I:%M %p',
+ :stub => '%B %d',
+ :time_only => '%I:%M %p',
+ :plain => '%B %d %I:%M %p',
+ :mdy => '%B %d, %Y',
+ :my => '%B %Y'
+
+class Time
+ class << self
+ # Used for getting multifield attributes like those generated by a
+ # select_datetime into a new Time object. For example if you have
+ # following <tt>params={:meetup=>{:"time(1i)=>..."}}</tt> just do
+ # following:
+ #
+ # <tt>Time.parse_from_attributes(params[:meetup], :time)</tt>
+ def parse_from_attributes(attrs, field, method=:gm)
+ attrs = attrs.keys.sort.grep(/^#{field.to_s}\(.+\)$/).map { |k| attrs[k] }
+ attrs.any? ? Time.send(method, *attrs) : nil
+ end
+
+ def delta(year, month = nil, day = nil)
+ from = Time.local(year, month || 1, day || 1)
+
+ to =
+ if !day.blank?
+ from.advance :days => 1
+ elsif !month.blank?
+ from.advance :months => 1
+ else
+ from.advance :years => 1
+ end
+ return [from.midnight, to.midnight-1]
+ end
+ end
+
+ def to_delta(delta_type = :day)
+ case delta_type
+ when :year then self.class.delta(year)
+ when :month then self.class.delta(year, month)
+ else self.class.delta(year, month, day)
+ end
+ end
+end
0  ...plugins/mephisto/lib/mephisto/directory_plugin.rb → lib/mephisto/directory_plugin.rb
View
File renamed without changes
0  vendor/plugins/mephisto/lib/mephisto/plugin.rb → lib/mephisto/plugin.rb
View
File renamed without changes
0  vendor/plugins/mephisto/lib/mephisto/plugins.rb → lib/mephisto/plugins.rb
View
File renamed without changes
0  ...ugins/mephisto/test/fixtures/mephisto_plugins.yml → test/fixtures/mephisto_plugins.yml
View
File renamed without changes
0  vendor/plugins/mephisto/test/plugin_test.rb → test/unit/plugin_test.rb
View
File renamed without changes
18 vendor/plugins/mephisto/test/test_helper.rb
View
@@ -1,18 +0,0 @@
-require File.expand_path(File.dirname(__FILE__) + '/../../../../test/test_helper.rb')
-Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + '/fixtures'
-
-module Mephisto
- module Plugins
- class PluginWhammyJammy < Mephisto::Plugin
- option :foo, 'one'
- option :bar, 2
- option :baz, [3]
- end
-
- class FooBar < Mephisto::Plugin
- end
-
- class NonPlugin
- end
- end
-end
Please sign in to comment.
Something went wrong with that request. Please try again.