rails-rfc6570 1.1.0 → 1.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fe0a2171639cd02d609193683e4537b8c13a0af9
4
- data.tar.gz: d407c343aa810e9d88ed85e40a5c842b55d3ba49
3
+ metadata.gz: ce4faf89b39d74647128aad91ec3233979cbd752
4
+ data.tar.gz: d9d52f9c09e13853b7bc16cddb652f2fb4e05cbb
5
5
  SHA512:
6
- metadata.gz: 651b5ca68c7b084d95f5af70fd0534558e16bfb565e473d06f5ca831b6be3c28caf7dc391d79fe470c016791f34d6b9f638bd1e791e738ea08be56d002398904
7
- data.tar.gz: 5dc1887c8c6845f3096804f0d2df102f574b51c2e3f2a697ee6db8ed8cb34937dc5c9acaaf1a3c0cc4e6d4ce611040a77ef19c185c8e6f475ea76067879b3bda
6
+ metadata.gz: 34bed45b1b3f614ba054418fcedcb35d8bc08f79daa381702703a692ec2c4bdbc4f932c0f5de322eb15ff341420e97daed3e1a081d9c88019450fc4ec62fe58b
7
+ data.tar.gz: c7afddd77cabf3d33174bcd827abdbb92b3f2193066f1c285fec21890834134905ebe466e4a2710af98042b29c34db311c1b6069067217e0eae7cc297ddb0742
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.1
4
+
5
+ * Fix full URL generation to not use `root_url` helper to avoid depending on that and to improve compatibility with e.g. rails engines.
6
+
3
7
  ## 1.1.0
4
8
 
5
9
  * Added support for Rails 5.0
data/README.md CHANGED
@@ -8,7 +8,7 @@ Pragmatical access to your Rails 4.0 or 4.1 or 4.2 or 5.0 routes as RFC6570 URI
8
8
 
9
9
  Add this line to your application's Gemfile:
10
10
 
11
- gem 'rails-rfc6570', '~> 0.3'
11
+ gem 'rails-rfc6570', '~> 1.1'
12
12
 
13
13
  And then execute:
14
14
 
@@ -3,7 +3,7 @@ module Rails
3
3
  module VERSION
4
4
  MAJOR = 1
5
5
  MINOR = 1
6
- PATCH = 0
6
+ PATCH = 1
7
7
  STAGE = nil
8
8
 
9
9
  STRING = [MAJOR, MINOR, PATCH, STAGE].reject(&:nil?).join('.').freeze
data/lib/rails/rfc6570.rb CHANGED
@@ -222,15 +222,7 @@ module Rails
222
222
 
223
223
  mod.module_eval do
224
224
  define_method(rfc6570_name) do |opts = {}|
225
- template = route.to_rfc6570(opts)
226
-
227
- if opts.fetch(:path_only, false)
228
- template
229
- else
230
- root_uri = Addressable::URI.parse(root_url)
231
-
232
- Addressable::Template.new root_uri.join(template.pattern).to_s
233
- end
225
+ ::Rails::RFC6570::build_url_template(self, route, opts)
234
226
  end
235
227
 
236
228
  define_method(rfc6570_url_name) do |opts = {}|
@@ -304,15 +296,7 @@ module Rails
304
296
  raise KeyError.new "No named routed for `#{name}'."
305
297
  end
306
298
 
307
- template = route.to_rfc6570(opts)
308
-
309
- if opts.fetch(:path_only, false)
310
- template
311
- else
312
- root_uri = Addressable::URI.parse(root_url)
313
-
314
- Addressable::Template.new root_uri.join(template.pattern).to_s
315
- end
299
+ ::Rails::RFC6570::build_url_template(self, route, opts)
316
300
  end
317
301
  end
318
302
 
@@ -330,6 +314,21 @@ module Rails
330
314
  end
331
315
  end
332
316
 
317
+ def build_url_template(t, route, options)
318
+ template = route.to_rfc6570(options)
319
+
320
+ if options.fetch(:path_only, false)
321
+ template
322
+ else
323
+ options = t.url_options.merge(options)
324
+ options[:path] = template.pattern
325
+
326
+ url = ActionDispatch::Http::URL.url_for options
327
+
328
+ ::Addressable::Template.new url
329
+ end
330
+ end
331
+
333
332
  def params_for(controller, action)
334
333
  ctr = "#{controller.camelize}Controller".constantize
335
334
  ctr.rfc6570_defs[action.to_sym] if ctr.respond_to?(:rfc6570_defs)
@@ -1,3 +1,3 @@
1
1
  Dummy::Application.routes.draw do
2
- root to: 'application#index'
2
+ get '/' => 'application#index'
3
3
  end