excursion 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 970c66c03bce9f7cc650641b90518f7b81d0c716
4
- data.tar.gz: d63f0475015ad67d34e5ef75a84d12f1f723cc81
3
+ metadata.gz: 5051561169a6698e74f8d5a2c7b6e4e52f76e7d9
4
+ data.tar.gz: 6ef2e2dc1242941eaa65346109310c0f6e11fd35
5
5
  SHA512:
6
- metadata.gz: 4922ab494d86409741c2229dc85a5cfd5ffa5696bfdb44545c08f74c646608ab40e9ba35b012c3329fd8c7d7c178cabd5253819ab34c48d50c81217fa32f11dd
7
- data.tar.gz: e219ee026b5d0d6615869a72efb30a18a911c5de42e6a214fa42c1a630f17e1926858b1566e953b6bc339754b05939d9208912cb1fc2654f33007f9fda8add16
6
+ metadata.gz: 2d633f5c68f9034e696f633d93100465eacd80a1eb7a5c4ece829cc98f7f1f3f799904cb5487b3758494a7a3cb1da46861b4cc285f47d0c7ef123cc6891856da
7
+ data.tar.gz: 5541d5df8aa7be16528f8743800a87fef0848978ed76251710a7a6c7e67d9cebb0685758aaa5d966359e2aa4145b4813a59c233a348d61c0e797ebb93b3a0419
@@ -20,6 +20,10 @@ module Excursion
20
20
  end
21
21
  end
22
22
 
23
+ def respond_to_missing?(meth, include_private=false)
24
+ app_exists?(meth.to_s) || super
25
+ end
26
+
23
27
  protected
24
28
 
25
29
  def app_exists?(app_name)
@@ -9,36 +9,59 @@ module Excursion
9
9
 
10
10
  def method_missing(meth, *args)
11
11
  if meth.to_s.match(/\A(#{routes.collect { |name,route| name }.join("|")})_(url|path)\Z/)
12
- if Excursion.rails4?
13
- ActionDispatch::Routing::RouteSet::NamedRouteCollection::UrlHelper.create(routes.get($1.to_sym), @application.default_url_options).call(Rails.application.routes, args)
14
- elsif Excursion.rails3?
12
+ route = routes.get($1.to_sym)
13
+
14
+ url_opts = @application.default_url_options.clone
15
+ url_opts.merge!(args.slice!(args.length-1)) if args.last.is_a?(Hash) #&& args.last.has_key?(:host)
16
+
17
+ return ActionDispatch::Http::URL.url_for(url_opts.merge({path: replaced_path(route, args)}))
18
+
19
+ # This stuff is being deprecated.
20
+ # We're transitioning towards using our custom path replacement and the uniform call to the base url_for method.
21
+
22
+ #if Excursion.rails4?
23
+ #ActionDispatch::Routing::RouteSet::NamedRouteCollection::UrlHelper.create(route, url_opts).call(Rails.application.routes, args)
24
+ #elsif Excursion.rails3?
15
25
  # Playing with getting Rails3 working
16
26
  #mapping = ActionDispatch::Routing::Mapper::Mapping.new(routes, {}, routes.get($1.to_sym).path.spec.to_s.dup, {:controller => 'dummy', :action => 'dummy'})
17
27
  #puts mapping.send(:instance_variable_get, :@path)
18
- ActionDispatch::Http::URL.url_for(@application.default_url_options.merge({path: replaced_path(routes.get($1.to_sym), args)}))
19
- end
28
+ #end
20
29
  else
21
30
  super
22
31
  end
23
32
  end
24
33
 
34
+ def respond_to_missing?(meth, include_private=false)
35
+ meth.to_s.match(/\A(#{routes.collect { |name,route| name }.join("|")})_(url|path)\Z/) || super
36
+ end
37
+
25
38
  protected
26
39
 
27
40
  def initialize(app)
28
41
  @application = app
29
42
  end
30
43
 
31
- # Playing with getting Rails3 working
44
+ # Very hacky method to replace path parts with values
45
+ #
46
+ # Needs work, particularly around formatting which is basically ignored right now.
32
47
  def replaced_path(route, args)
33
- path = route.path.spec.to_s.dup # ActionDispatch::Routing::Mapper.normalize_path(route.path.spec.to_s.dup)
48
+ path = route.path.spec.to_s.dup
34
49
 
35
50
  route.required_parts.zip(args) do |part, arg|
36
- path.gsub!(/(\*|:)#{part}/, Journey::Router::Utils.escape_fragment(arg.to_param))
51
+ path.gsub!(/(\*|:)#{part}/, journey_utils_class.escape_fragment(arg.to_param))
37
52
  end
38
53
 
39
54
  path.gsub!(/\(\.:format\)/, '') # This is really gross, and :format should actually be supported
40
55
  path
41
56
  end
57
+
58
+ def journey_utils_class
59
+ if Excursion.rails3?
60
+ Journey::Router::Utils
61
+ elsif Excursion.rails4?
62
+ ActionDispatch::Journey::Router::Utils
63
+ end
64
+ end
42
65
  end
43
66
  end
44
67
  end
@@ -1,3 +1,3 @@
1
1
  module Excursion
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.7'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: excursion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Rebec
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-19 00:00:00.000000000 Z
11
+ date: 2013-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails