public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
change Mephisto::Plugin to MephistoPlugin and Mephisto::Plugins to 
MephistoPlugins to keep them from being auto-loaded by rails

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@2671 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Sun Jan 14 01:19:35 -0800 2007
commit  e8c27bf1e34aa668824ba277c8dc34c236dd33d3
tree    90c682dd3239def0c3aaf96af48821df6c285a3f
parent  9b505575dd8139841313ed111327b6d3835c31de
...
1
2
3
4
5
6
7
8
...
24
25
26
27
 
28
29
30
...
 
 
 
 
 
1
2
3
...
19
20
21
 
22
23
24
25
0
@@ -1,8 +1,3 @@
0
-require 'mephisto/plugin'
0
-require 'mephisto/plugins'
0
-require 'mephisto/directory_plugin'
0
-require 'yaml'
0
-
0
 class Admin::PluginsController < Admin::BaseController
0
   before_filter :find_plugin, :except => :index
0
 
0
@@ -24,6 +19,6 @@ class Admin::PluginsController < Admin::BaseController
0
   
0
   protected
0
     def find_plugin
0
- @plugin = Mephisto::Plugin[params[:id]]
0
+ @plugin = MephistoPlugin[params[:id]]
0
     end
0
 end
0
\ No newline at end of file
...
37
38
39
40
 
41
42
43
44
45
 
46
47
48
...
37
38
39
 
40
41
42
43
44
 
45
46
47
48
0
@@ -37,12 +37,12 @@
0
   <%= form_tag({:action => :update, :id => @plugin.plugin_name}, {:id => 'plugin-config-form'}) %>
0
 <% end -%>
0
 
0
-<% if @plugin.default_options -%>
0
+<% if @plugin.default_options.any? -%>
0
 <div class="group">
0
   <dl>
0
     <dt><label for="plugin_config">Configuration</label></dt>
0
       <% @plugin.default_options.keys.each do |key| %>
0
- <dd><label for="options_<%= key %>"><%= key.to_s.humanize %></label></dt> <dd> <%= text_field_tag "options[#{key}]", @plugin.send(key) %> </dd>
0
+ <dd><label for="options_<%= key %>"><%= key.to_s.humanize %></label></dt> <dd> <%= send "#{@plugin.default_options[key]}_tag", "options[#{key}]", @plugin.send(key) %> </dd>
0
       <% end %>
0
   </dl>
0
     
...
31
32
33
34
 
35
36
37
...
41
42
43
44
 
45
46
47
...
31
32
33
 
34
35
36
37
...
41
42
43
 
44
45
46
47
0
@@ -31,7 +31,7 @@
0
             <li><%= link_to 'Overview', :controller => '/admin/overview' %></li>
0
             <li><%= link_to 'Articles', :controller => '/admin/articles' %></li>
0
             <li><%= link_to 'Assets', :controller => '/admin/assets' %></li>
0
- <% Mephisto::Plugin.tabs.each do |tab| -%>
0
+ <% MephistoPlugin.tabs.each do |tab| -%>
0
             <li><%= link_to tab.first, tab.last %></li>
0
           <% end -%>
0
           </ul>
0
@@ -41,7 +41,7 @@
0
             <li><%= link_to 'Design', :controller => '/admin/design' %></li>
0
             <li><%= link_to "Users", :controller => "users" %></li>
0
             <li><%= link_to 'Plugins', :controller => '/admin/plugins' %></li>
0
- <% Mephisto::Plugin.admin_tabs.each do |tab| -%>
0
+ <% MephistoPlugin.admin_tabs.each do |tab| -%>
0
             <li><%= link_to tab.first, tab.last %></li>
0
           <% end -%>
0
           </ul>
...
25
26
27
28
 
29
30
31
...
25
26
27
 
28
29
30
31
0
@@ -25,7 +25,7 @@ module Mephisto
0
       map.connect ':controller/:action/:id/:version', :version => nil, :controller => /routing_navigator|account|(admin\/\w+)/, :id => /[^\/]*/
0
 
0
       yield if block_given?
0
- Mephisto::Plugin.custom_routes.each do |path, options|
0
+ MephistoPlugin.custom_routes.each do |path, options|
0
         map.connect path, options
0
       end
0
       
...
1
2
3
4
5
6
 
 
 
 
 
7
8
9
10
11
12
 
 
13
14
15
...
 
 
 
 
 
 
1
2
3
4
5
6
 
 
 
 
 
7
8
9
10
11
0
@@ -1,14 +1,10 @@
0
-module Mephisto
0
- module Plugins
0
- class TestPlugin < Mephisto::Plugin
0
- homepage 'http://foo.com'
0
- author 'Captain Problematic'
0
- version 'deathstar'
0
+module MephistoPlugins
0
+ class TestPlugin < MephistoPlugin
0
+ homepage 'http://foo.com'
0
+ author 'Captain Problematic'
0
+ version 'deathstar'
0
 
0
- default_options \
0
- :config => {'one' => 'test'},
0
- :notes => 'notes'
0
-
0
- end
0
+ option :config, 'one' => 'test'
0
+ option :notes, 'notes'
0
   end
0
 end
0
\ No newline at end of file
...
35
36
37
38
 
39
40
41
...
35
36
37
 
38
39
40
41
0
@@ -35,7 +35,7 @@ class Admin::PluginsControllerTest < Test::Unit::TestCase
0
   end
0
   
0
   def test_should_show_plugin
0
- assert_not_nil Mephisto::Plugins::TestPlugin.new
0
+ assert_not_nil MephistoPlugins::TestPlugin.new
0
     get :show, :id => 'test_plugin'
0
     assert_response :success
0
   end
...
4
5
6
7
 
8
9
10
11
 
12
13
14
15
16
 
17
18
19
20
21
 
22
23
 
24
25
26
27
28
 
29
30
31
32
33
34
35
 
36
37
38
...
51
52
53
54
55
56
57
 
 
 
 
58
59
60
61
62
 
63
64
65
66
 
67
68
69
...
71
72
73
74
75
 
 
76
77
78
...
80
81
82
83
 
84
85
86
...
94
95
96
97
 
98
99
100
...
4
5
6
 
7
8
9
10
 
11
12
13
14
15
 
16
17
18
19
20
 
21
22
 
23
24
25
26
27
 
28
29
30
31
32
33
34
 
35
36
37
38
...
51
52
53
 
 
 
 
54
55
56
57
58
59
60
61
 
62
63
64
65
 
66
67
68
69
...
71
72
73
 
 
74
75
76
77
78
...
80
81
82
 
83
84
85
86
...
94
95
96
 
97
98
99
100
0
@@ -4,35 +4,35 @@ class PluginTest < Test::Unit::TestCase
0
   fixtures :mephisto_plugins
0
 
0
   def test_should_create_plugin_name
0
- assert_equal 'plugin_whammy_jammy', Mephisto::Plugins::PluginWhammyJammy.plugin_name
0
+ assert_equal 'plugin_whammy_jammy', MephistoPlugins::PluginWhammyJammy.plugin_name
0
   end
0
   
0
   def test_should_find_plugin_class_by_name
0
- assert_equal Mephisto::Plugins::PluginWhammyJammy, Mephisto::Plugin.find_class(:plugin_whammy_jammy)
0
+ assert_equal MephistoPlugins::PluginWhammyJammy, MephistoPlugin.find_class(:plugin_whammy_jammy)
0
   end
0
   
0
   def test_should_not_find_missing_class
0
     assert_raises NameError do
0
- Mephisto::Plugin[:blah]
0
+ MephistoPlugin[:blah]
0
     end
0
   end
0
   
0
   def test_should_not_find_a_non_model
0
- assert Mephisto::Plugins.const_defined?(:NonPlugin)
0
+ assert MephistoPlugins.const_defined?(:NonPlugin)
0
     assert_raises NameError do
0
- Mephisto::Plugin[:non_plugin]
0
+ MephistoPlugin[:non_plugin]
0
     end
0
   end
0
   
0
   def test_plugin_option_defaults
0
- plugin = Mephisto::Plugins::PluginWhammyJammy.new
0
+ plugin = MephistoPlugins::PluginWhammyJammy.new
0
     assert_equal 'one', plugin.foo
0
     assert_equal 2, plugin.bar
0
     assert_equal [3], plugin.baz
0
   end
0
   
0
   def test_should_set_plugin_options
0
- plugin = Mephisto::Plugins::PluginWhammyJammy.new
0
+ plugin = MephistoPlugins::PluginWhammyJammy.new
0
     
0
     plugin.foo = 'two'
0
     plugin.bar = 3
0
@@ -51,19 +51,19 @@ class PluginTest < Test::Unit::TestCase
0
   def test_should_get_and_set_plugin_properties
0
     properties = %w(desc author version homepage)
0
     properties.each do |property|
0
- assert_nil Mephisto::Plugins::PluginWhammyJammy.send(property)
0
- Mephisto::Plugins::PluginWhammyJammy.send(property, 'foo')
0
- assert_equal 'foo', Mephisto::Plugins::PluginWhammyJammy.send(property)
0
- assert_equal 'foo', Mephisto::Plugins::PluginWhammyJammy.new.send(property)
0
+ assert_nil MephistoPlugins::PluginWhammyJammy.send(property)
0
+ MephistoPlugins::PluginWhammyJammy.send(property, 'foo')
0
+ assert_equal 'foo', MephistoPlugins::PluginWhammyJammy.send(property)
0
+ assert_equal 'foo', MephistoPlugins::PluginWhammyJammy.new.send(property)
0
     end
0
   end
0
   
0
   def test_should_find_plugin
0
- assert_equal Mephisto::Plugins::PluginWhammyJammy.find(1), Mephisto::Plugin[:plugin_whammy_jammy]
0
+ assert_equal MephistoPlugins::PluginWhammyJammy.find(1), MephistoPlugin[:plugin_whammy_jammy]
0
   end
0
   
0
   def test_should_persist_options
0
- plugin = Mephisto::Plugin[:plugin_whammy_jammy]
0
+ plugin = MephistoPlugin[:plugin_whammy_jammy]
0
     assert_equal 'one', plugin.foo
0
     plugin.foo = 'two'
0
     plugin.save!
0
@@ -71,8 +71,8 @@ class PluginTest < Test::Unit::TestCase
0
   end
0
   
0
   def test_should_persist_options_on_new_plugin_record
0
- Mephisto::Plugins::PluginWhammyJammy.delete_all
0
- plugin = Mephisto::Plugin[:plugin_whammy_jammy]
0
+ MephistoPlugins::PluginWhammyJammy.delete_all
0
+ plugin = MephistoPlugin[:plugin_whammy_jammy]
0
     klass1 = plugin.class.name
0
     
0
     assert plugin.new_record?
0
@@ -80,7 +80,7 @@ class PluginTest < Test::Unit::TestCase
0
     plugin.save!
0
     assert plugin.reload.options.empty?
0
 
0
- plugin2 = Mephisto::Plugin[:plugin_whammy_jammy]
0
+ plugin2 = MephistoPlugin[:plugin_whammy_jammy]
0
     assert_equal 'one', plugin2.foo
0
     reloaded_klass = plugin2.class.name
0
     
0
@@ -94,7 +94,7 @@ class PluginTest < Test::Unit::TestCase
0
   end
0
   
0
   # def test_should_load_or_initialize_plugin_list
0
- # plugins = Mephisto::Plugin.load(%w(plugin_whammy_jammy foo_bar baz))
0
+ # plugins = MephistoPlugin.load(%w(plugin_whammy_jammy foo_bar baz))
0
  # assert_equal 2, plugins.size
0
  # assert plugins['foo_bar'].new_record?
0
  # end
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
 
 
 
 
 
 
 
 
 
 
 
15
16
17
...
1
2
3
 
 
 
 
 
 
 
 
 
 
 
4
5
6
7
8
9
10
11
12
13
14
15
16
17
0
@@ -1,16 +1,16 @@
0
 require File.expand_path(File.dirname(__FILE__) + '/../../../../test/test_helper.rb')
0
 Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + '/fixtures'
0
 
0
-module Mephisto
0
- module Plugins
0
- class PluginWhammyJammy < Mephisto::Plugin
0
- default_options :foo => 'one', :bar => 2, :baz => [3]
0
- end
0
-
0
- class FooBar < Mephisto::Plugin
0
- end
0
-
0
- class NonPlugin
0
- end
0
+module MephistoPlugins
0
+ class PluginWhammyJammy < MephistoPlugin
0
+ option :foo, 'one'
0
+ option :bar, 2
0
+ option :baz, [3]
0
+ end
0
+
0
+ class FooBar < MephistoPlugin
0
+ end
0
+
0
+ class NonPlugin
0
   end
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.