public this repo is viewable by everyone
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/halorgium/mephisto.git
Merge branch 'rel-0.8'
technoweenie (author)
3 months ago
commit  2772ec18227b04b3cb618748a2900a7b93b84d94
tree    4381c9dcb98d67e4ad78416831a93b6afdb80cdc
parent  1cd5005248cd280b894971da122345a1616d280f parent  b9b07612fbb61a73530bd0920ef62ddbddfb2aa7
...
2
3
4
5
 
6
7
 
8
9
10
...
23
24
25
26
 
27
28
29
30
 
31
32
33
34
35
36
 
37
38
 
39
40
 
41
42
 
43
44
45
...
49
50
51
52
 
53
54
55
...
2
3
4
 
5
6
 
7
8
9
10
...
23
24
25
 
26
27
28
29
 
30
31
32
33
34
35
 
36
37
 
38
39
 
40
41
 
42
43
44
45
...
49
50
51
 
52
53
54
55
0
@@ -2,9 +2,9 @@
0
 
0
 * Experimental comment preview. [court3nay]
0
 
0
-* Add multi-site admin interface [Vincent, j2m]
0
+* Add multi-site admin interface. [Vincent, j2m]
0
 
0
-* Update Wordpress converter to support Wordpress 2.3+ [Aubrey]
0
+* Update Wordpress converter to support Wordpress 2.3+. [Aubrey]
0
 
0
 * refactor so that admin/comments is more restful, allow inline comment editing in the admin. [court3nay]
0
 
0
@@ -23,23 +23,23 @@
0
   # use this order: :text, :title, :id, :class, :rel
0
   link_to_article article, "click here", "this article", "article-1", "articles", "whatever-rel-means"
0
 
0
-* encode search/tag urls properly [rob-twf]
0
+* encode search/tag urls properly. [rob-twf]
0
 
0
 * update article forms to explain new tag syntax (comma and space delimited tags) [xavier, rick]
0
 
0
-* start converting tests to rspec
0
+* start converting tests to rspec.
0
 
0
 * tweak mephisto_init to support the new ActionController::Dispatcher class. [Rob Anderton]
0
 
0
 * Don't generate an article event for unversioned changes. [Marcus Brito]
0
 
0
-* Switch to will_paginate plugin [Mislav]
0
+* Switch to will_paginate plugin. [Mislav]
0
 
0
-* unit test fixes for those not using mysql or psql [Mislav]
0
+* unit test fixes for those not using mysql or psql. [Mislav]
0
 
0
-* add comment moderation links to the overview [court3nay]
0
+* add comment moderation links to the overview. [court3nay]
0
 
0
-* convert tests to use test/spec instead of simply bdd [Chris McGrath]
0
+* convert tests to use test/spec instead of simply bdd. [Chris McGrath]
0
 
0
 * move xmlrpc stuff to plugin. rails doesn't include AWS anymore. May need some simple autodetection so the plugin just prints a warning if AWS isn't found.
0
 
0
@@ -49,7 +49,7 @@
0
 
0
 * Fix controllers so include_into works with them.
0
 
0
-* Change plugin class/module to Mephisto::Plugin and Mephisto::Plugins. Sorry for the breakage (still technically experimental!)
0
+* Change plugin class/module to Mephisto::Plugin and Mephisto::Plugins. Sorry for the breakage (still technically experimental!).
0
 
0
 * Fix admin overview date timezone. [Ben Wyrosdick]
0
 
...
38
39
40
41
 
42
43
44
...
46
47
48
49
 
50
51
52
...
54
55
56
57
 
58
59
60
61
 
62
...
38
39
40
 
41
42
43
44
...
46
47
48
 
49
50
51
52
...
54
55
56
 
57
58
59
 
60
61
62
0
@@ -38,7 +38,7 @@
0
     <li><a href="#">&nbsp;</a></li>
0
   </ul>
0
   <ul id="attributes">
0
- <% if @article && controller.controller_name == 'articles' && controller.action_name == 'edit' %>
0
+ <% if @article && controller.controller_name == 'articles' && controller.action_name == 'edit' -%>
0
     <li><label for="search">Revision:</label></li>
0
     <li>
0
       <select name="filter" id="revisionnum">
0
@@ -46,7 +46,7 @@
0
         <%= options_from_collection_for_select @article.versions.reverse, :version, :version, params[:version].to_i %>
0
       </select>
0
     </li>
0
- <% end %>
0
+ <% end -%>
0
     <% if controller.controller_name == 'comments' && controller.action_name == 'index' -%>
0
     <li><label for="comments_view">Show comments:</label></li>
0
     <li>
0
@@ -54,7 +54,7 @@
0
         <%= options_for_select ['All', 'Unapproved', 'Approved'], params[:filter].to_s.humanize %>
0
       </select>
0
     </li>
0
- <% end %>
0
+ <% end -%>
0
   </ul>
0
 </div>
0
-<% end unless @article.new_record? && @article.comments.empty? -%>
0
\ No newline at end of file
0
+<% end unless @article && @article.new_record? && @article.comments.size == 0 -%>
0
\ No newline at end of file
...
3
4
5
6
 
7
8
9
...
11
12
13
 
 
 
 
 
 
 
 
 
 
 
14
15
 
16
17
 
18
19
20
21
 
22
23
24
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
27
28
...
3
4
5
 
6
7
8
9
...
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
0
@@ -3,7 +3,7 @@
0
 
0
 Module.class_eval do
0
   # A hash that maps Class names to an array of Modules to mix in when the class is instantiated.
0
- @@class_mixins = {}
0
+ @@class_mixins = {} unless defined?(@@class_mixins)
0
   mattr_reader :class_mixins
0
 
0
   # Specifies that this module should be included into the given classes when they are instantiated.
0
@@ -11,18 +11,46 @@ Module.class_eval do
0
   # module FooMethods
0
   # include_into "Foo", "Bar"
0
   # end
0
+ #
0
+ # You can also specify a hash to have your module's methods alias_method_chained to the target
0
+ # class' methods.
0
+ #
0
+ # module FooMethods
0
+ # include_into "Foo", :method => :feature
0
+ # end
0
+ #
0
+ # This will alias Foo#method to the newly included FooMethods#method_with_feature. The former
0
+ # method Foo#method will continue to be available as Foo#method_without_feature.
0
+ #
0
   def include_into(*klasses)
0
     klasses.flatten!
0
+ aliases = klasses.last.is_a?(Hash) ? klasses.pop : {}
0
     klasses.each do |klass|
0
- (@@class_mixins[klass] ||= []) << name.to_s
0
+ (@@class_mixins[klass] ||= []) << [name.to_s, aliases]
0
       @@class_mixins[klass].uniq!
0
     end
0
   end
0
-
0
+
0
   # add any class mixins that have been registered for this class
0
   def auto_include!
0
- mixins = @@class_mixins[name]
0
- send(:include, *mixins.collect { |name| name.constantize }) if mixins
0
+ if mixins = @@class_mixins[name]
0
+ mixins.each do |name, aliases|
0
+ include name.constantize
0
+ aliases.each { |args| alias_chain *args }
0
+ end
0
+ end
0
+ end
0
+
0
+ def alias_chain(target, feature)
0
+ (class << self; self end).class_eval <<-EOC, __FILE__, __LINE__
0
+ def method_added_with_#{target}_#{feature}(method)
0
+ if method == :#{target} && !method_defined?(:#{target}_without_#{feature})
0
+ alias_method_chain :#{target}, :#{feature}
0
+ end
0
+ method_added_without_#{target}_#{feature}(method)
0
+ end
0
+ alias_method_chain :method_added, :#{target}_#{feature}
0
+ EOC
0
   end
0
 end
0
 
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
...
1
2
3
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
39
40
41
42
43
44
45
46
0
@@ -0,0 +1,45 @@
0
+ENV['RAILS_ENV'] = 'test'
0
+RAILS_ROOT = File.join(File.dirname(__FILE__), '../../../../')
0
+
0
+require 'rubygems'
0
+require 'active_support'
0
+require 'test/unit'
0
+
0
+require File.join(File.dirname(__FILE__), '..', 'init.rb')
0
+
0
+module Chocolate
0
+ include_into 'Cookie', 'Coffee', :taste => :chocolate
0
+ def taste_with_chocolate; "#{self.class.name} with chocolate!" end
0
+end
0
+
0
+module Latte
0
+ include_into 'Coffee', 'Chai'
0
+end
0
+
0
+class Cookie
0
+ def taste; "just a #{self.class.name}" end
0
+end
0
+
0
+class Coffee
0
+ def taste; "just a #{self.class.name}" end
0
+end
0
+
0
+class Chai
0
+end
0
+
0
+class IncludeIntoTest < Test::Unit::TestCase
0
+ def test_module_should_be_included_to_given_classes
0
+ assert Cookie.included_modules.include?(Chocolate)
0
+ assert Coffee.included_modules.include?(Chocolate)
0
+ end
0
+
0
+ def test_methods_should_be_alias_chained_in_given_classes
0
+ assert_equal 'Cookie with chocolate!', Cookie.new.taste
0
+ assert_equal 'Coffee with chocolate!', Coffee.new.taste
0
+ end
0
+
0
+ def test_should_work_without_alias_option
0
+ assert Coffee.included_modules.include?(Latte)
0
+ assert Chai.included_modules.include?(Latte)
0
+ end
0
+end
0
\ No newline at end of file

Comments

    No one has commented yet.