excursion 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/excursion/helpers/application_helper.rb +4 -0
- data/lib/excursion/helpers/url_helper.rb +31 -8
- data/lib/excursion/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5051561169a6698e74f8d5a2c7b6e4e52f76e7d9
|
4
|
+
data.tar.gz: 6ef2e2dc1242941eaa65346109310c0f6e11fd35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d633f5c68f9034e696f633d93100465eacd80a1eb7a5c4ece829cc98f7f1f3f799904cb5487b3758494a7a3cb1da46861b4cc285f47d0c7ef123cc6891856da
|
7
|
+
data.tar.gz: 5541d5df8aa7be16528f8743800a87fef0848978ed76251710a7a6c7e67d9cebb0685758aaa5d966359e2aa4145b4813a59c233a348d61c0e797ebb93b3a0419
|
@@ -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
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
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
|
-
#
|
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
|
48
|
+
path = route.path.spec.to_s.dup
|
34
49
|
|
35
50
|
route.required_parts.zip(args) do |part, arg|
|
36
|
-
path.gsub!(/(\*|:)#{part}/,
|
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
|
data/lib/excursion/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2013-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|