autolink 1.0.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'autolink'
3
- gem.version = "1.0.0"
3
+ gem.version = "3.0.0"
4
4
 
5
5
  gem.author, gem.email = 'Burke Libbey', "burke@burkelibbey.org"
6
6
  gem.homepage = "http://github.com/burke/autolink"
@@ -1,26 +1,25 @@
1
- module ActionController #:nodoc:
2
- class Base
1
+ module ActionDispatch
2
+ module Routing
3
+ module UrlFor
3
4
 
4
- def autolink(obj)
5
- polymorphic_url(obj.default_lineage)
6
- end
5
+ def autolink(obj) # +
6
+ polymorphic_url(obj.default_lineage) # +
7
+ end # +
7
8
 
8
- def url_for(options = {})
9
- options ||= {}
10
- case options
11
- when ActiveRecord::Base # +
12
- @@__url = @url # +
13
- autolink(options) # +
14
- when String
15
- options
16
- when Hash
17
- @url = @@__url unless @url # +
18
- @url.rewrite(rewrite_options(options))
19
- else
20
- polymorphic_url(options)
9
+ def url_for(options = nil)
10
+ case options
11
+ when ActiveRecord::Base # +
12
+ autolink(options) # +
13
+ when String
14
+ options
15
+ when nil, Hash
16
+ _routes.url_for((options || {}).reverse_merge!(url_options).symbolize_keys)
17
+ else
18
+ polymorphic_url(options)
19
+ end
21
20
  end
22
- end
23
21
 
22
+ end
24
23
  end
25
24
  end
26
25
 
@@ -1,28 +1,24 @@
1
1
  module ActionView
2
2
  module Helpers
3
3
  module UrlHelper
4
+
4
5
  def url_for(options = {})
5
6
  options ||= {}
6
- url = case options
7
+ case options
7
8
  when ActiveRecord::Base # This method is the same as 2.3.8,
8
9
  polymorphic_path(options.default_lineage) # Except for the addition of these two lines.
9
10
  when String
10
- escape = true
11
11
  options
12
12
  when Hash
13
- options = { :only_path => options[:host].nil? }.update(options.symbolize_keys)
14
- escape = options.key?(:escape) ? options.delete(:escape) : true
15
- @controller.send(:url_for, options)
13
+ options = options.symbolize_keys.reverse_merge!(:only_path => options[:host].nil?)
14
+ super
16
15
  when :back
17
- escape = false
18
- @controller.request.env["HTTP_REFERER"] || 'javascript:history.back()'
16
+ controller.request.env["HTTP_REFERER"] || 'javascript:history.back()'
19
17
  else
20
- escape = false
21
18
  polymorphic_path(options)
22
19
  end
23
-
24
- escape ? escape_once(url).html_safe : url
25
20
  end
21
+
26
22
  end
27
23
  end
28
24
  end
@@ -1,3 +1,31 @@
1
+ # This is a really bad idea. There's a reason this isn't supported out of the box.
2
+ # ...but I don't want to refactor thousands of specs.
3
+ module Spec
4
+ module Mocks
5
+ class Mock
6
+ def antimock(*methods)
7
+ methods.each do |method|
8
+ __mock_proxy.instance_eval <<-CODE
9
+ def @target.#{method}
10
+ syms = __mock_proxy.instance_variable_get("@stubs").map(&:sym)
11
+ @__sub = #{self.class}.new
12
+ syms.each do |sym|
13
+ # Define this method to call the same method on @target.
14
+ that = self
15
+ (class << @__sub; self; end).send(:define_method, sym) do
16
+ that.send(sym)
17
+ end
18
+ end
19
+ @__sub.#{method}
20
+ end
21
+ CODE
22
+ end
23
+ self
24
+ end
25
+ end
26
+ end
27
+ end
28
+
1
29
  module Spec
2
30
  module Rails
3
31
  module Matchers
@@ -25,24 +53,7 @@ module Spec
25
53
  module Mocks
26
54
 
27
55
  def __post_mock_model(model_class, mock)
28
-
29
- mock.__send__(:__mock_proxy).instance_eval <<-CODE
30
- def @target.default_lineage
31
- # self == @target
32
- syms = __mock_proxy.instance_variable_get("@stubs").map(&:sym)
33
- @__sub = #{model_class}.new
34
- syms.each do |sym|
35
- # Define this method to call the same method on @target.
36
- that = self
37
- (class << @__sub; self; end).send(:define_method, sym) do
38
- that.send(sym)
39
- end
40
- end
41
- @__sub.default_lineage
42
- end
43
- CODE
44
-
45
- mock
56
+ mock.antimock(:default_lineage)
46
57
  end
47
58
 
48
59
  alias __mock_model mock_model
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autolink
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 7
5
5
  prerelease: false
6
6
  segments:
7
- - 1
7
+ - 3
8
8
  - 0
9
9
  - 0
10
- version: 1.0.0
10
+ version: 3.0.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Burke Libbey
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-25 00:00:00 -05:00
18
+ date: 2010-10-13 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies: []
21
21