Hello community,
here is the log from the commit of package rubygem-js-routes for
openSUSE:Factory checked in at 2019-06-19 21:00:11
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-js-routes (Old)
and /work/SRC/openSUSE:Factory/.rubygem-js-routes.new.4811 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-js-routes"
Wed Jun 19 21:00:11 2019 rev:18 rq:705998 version:1.4.6
Changes:
--------
--- /work/SRC/openSUSE:Factory/rubygem-js-routes/rubygem-js-routes.changes
2018-07-18 22:50:11.835705507 +0200
+++
/work/SRC/openSUSE:Factory/.rubygem-js-routes.new.4811/rubygem-js-routes.changes
2019-06-19 21:00:12.598078344 +0200
@@ -1,0 +2,16 @@
+Sun May 5 09:32:27 UTC 2019 - Stephan Kulow <[email protected]>
+
+- updated to version 1.4.6
+ see installed CHANGELOG.md
+
+ ## v1.4.6
+
+ * Fix regression of #244 in #243
+
+ ## v1.4.5
+
+ * Fix escaping inside route parameters and globbing #244
+
+ ## v1.4.4
+
+-------------------------------------------------------------------
Old:
----
js-routes-1.4.4.gem
New:
----
js-routes-1.4.6.gem
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ rubygem-js-routes.spec ++++++
--- /var/tmp/diff_new_pack.luo5Ww/_old 2019-06-19 21:00:13.838079455 +0200
+++ /var/tmp/diff_new_pack.luo5Ww/_new 2019-06-19 21:00:13.842079458 +0200
@@ -1,7 +1,7 @@
#
# spec file for package rubygem-js-routes
#
-# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -12,7 +12,7 @@
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
@@ -24,7 +24,7 @@
#
Name: rubygem-js-routes
-Version: 1.4.4
+Version: 1.4.6
Release: 0
%define mod_name js-routes
%define mod_full_name %{mod_name}-%{version}
++++++ js-routes-1.4.4.gem -> js-routes-1.4.6.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/.travis.yml new/.travis.yml
--- old/.travis.yml 2018-05-07 13:15:41.000000000 +0200
+++ new/.travis.yml 2019-04-04 16:00:06.000000000 +0200
@@ -5,17 +5,14 @@
- gem install bundler # need for jruby and ruby-head
rvm:
- - 2.0
- - 2.1
- - 2.2.5
- 2.3.1
- 2.4.1
- - jruby-19mode
+ - 2.5.3
+ - 2.6.0
- ruby-head
- - jruby-head
+ - jruby
gemfile:
- - gemfiles/rails32.gemfile
- gemfiles/rails40_sprockets_2.gemfile
- gemfiles/rails40_sprockets_3.gemfile
- gemfiles/rails41_sprockets_2.gemfile
@@ -24,8 +21,10 @@
- gemfiles/rails42_sprockets_3.gemfile
- gemfiles/rails50_sprockets_3.gemfile
- gemfiles/rails51_sprockets_3.gemfile
+ - gemfiles/rails52_sprockets_3.gemfile
sudo: false
+dist: xenial
notifications:
email:
@@ -36,24 +35,32 @@
- master
matrix:
+ fast_finish: true
allow_failures:
- - rvm: jruby-19mode
- rvm: ruby-head
- - rvm: jruby-head
+ - rvm: jruby
exclude:
- - rvm: 2.0
- gemfile: gemfiles/rails50_sprockets_3.gemfile
- - rvm: 2.1
- gemfile: gemfiles/rails50_sprockets_3.gemfile
- - rvm: 2.0
- gemfile: gemfiles/rails51_sprockets_3.gemfile
- - rvm: 2.1
- gemfile: gemfiles/rails51_sprockets_3.gemfile
+ - rvm: 2.6.0
+ gemfile: gemfiles/rails40_sprockets_2.gemfile # Segmentation fault
+ - rvm: 2.6.0
+ gemfile: gemfiles/rails40_sprockets_3.gemfile # Segmentation fault
+ - rvm: 2.6.0
+ gemfile: gemfiles/rails41_sprockets_2.gemfile # Segmentation fault
+ - rvm: 2.6.0
+ gemfile: gemfiles/rails41_sprockets_3.gemfile # Segmentation fault
+ - rvm: 2.5.3
+ gemfile: gemfiles/rails40_sprockets_2.gemfile # Segmentation fault
+ - rvm: 2.5.3
+ gemfile: gemfiles/rails40_sprockets_3.gemfile # Segmentation fault
+ - rvm: 2.5.3
+ gemfile: gemfiles/rails41_sprockets_2.gemfile # Segmentation fault
+ - rvm: 2.5.3
+ gemfile: gemfiles/rails41_sprockets_3.gemfile # Segmentation fault
- rvm: 2.4.1
- gemfile: gemfiles/rails40_sprockets_2.gemfile # Segmentation fault (core
dumped) for 2.4
+ gemfile: gemfiles/rails40_sprockets_2.gemfile # Segmentation fault
- rvm: 2.4.1
- gemfile: gemfiles/rails40_sprockets_3.gemfile # Segmentation fault (core
dumped) for 2.4
+ gemfile: gemfiles/rails40_sprockets_3.gemfile # Segmentation fault
- rvm: 2.4.1
- gemfile: gemfiles/rails41_sprockets_2.gemfile # Segmentation fault (core
dumped) for 2.4
+ gemfile: gemfiles/rails41_sprockets_2.gemfile # Segmentation fault
- rvm: 2.4.1
- gemfile: gemfiles/rails41_sprockets_3.gemfile # Segmentation fault (core
dumped) for 2.4
+ gemfile: gemfiles/rails41_sprockets_3.gemfile # Segmentation fault
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Appraisals new/Appraisals
--- old/Appraisals 2018-05-07 13:15:41.000000000 +0200
+++ new/Appraisals 2019-04-04 16:00:06.000000000 +0200
@@ -1,8 +1,3 @@
-appraise "rails32" do
- gem "railties", "~> 3.2.22.5"
- gem 'tzinfo'
-end
-
def define_appraisal(rails, version, sprockets)
sprockets.each do |sprocket|
appraise "#{rails}-sprockets-#{sprocket}" do
@@ -17,7 +12,8 @@
[:rails41, '4.1.16', [2, 3]],
[:rails42, '4.2.9', [2, 3]],
[:rails50, '5.0.5', [3]],
- [:rails51, '5.1.3', [3]]
+ [:rails51, '5.1.3', [3]],
+ [:rails52, '5.2.3', [3]]
].each do |name, version, sprockets|
define_appraisal(name, version, sprockets)
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md
--- old/CHANGELOG.md 2018-05-07 13:15:41.000000000 +0200
+++ new/CHANGELOG.md 2019-04-04 16:00:06.000000000 +0200
@@ -1,5 +1,15 @@
## master
+## v1.4.6
+
+* Fix regression of #244 in #243
+
+## v1.4.5
+
+* Fix escaping inside route parameters and globbing #244
+
+## v1.4.4
+
* More informative stack trace for ParameterMissing error #235
## v1.4.3
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Readme.md new/Readme.md
--- old/Readme.md 2018-05-07 13:15:41.000000000 +0200
+++ new/Readme.md 2019-04-04 16:00:06.000000000 +0200
@@ -14,7 +14,7 @@
### Basic Setup
-Require js routes file in `application.js` or other bundle
+Require JsRoutes in `application.js` or other bundle
``` js
//= require js-routes
@@ -30,9 +30,9 @@
**Important:** If routes.js file is not updated after some configuration
change you need to run this rake task again.
-### Advanced Setup
+### Configuration
-If you need to customize routes file create initializer, like
`config/initializers/jsroutes.rb`:
+You can configure JsRoutes in two main ways. Either with an initializer (e.g.
`config/initializers/jsroutes.rb`):
``` ruby
JsRoutes.setup do |config|
@@ -40,7 +40,7 @@
end
```
-Or make a more dynamic configuration in JavaScript, but only specific options
support the possibility of such configuration(see the list below):
+Or dynamically in JavaScript, although not all configuration options are
supported:
``` js
Routes.configure({
@@ -55,10 +55,10 @@
* Option is configurable at JS level with `Routes.configure()`
* Example: {:format => "json", :trailing\_slash => true, :protocol =>
"https", :subdomain => "api", :host => "example.com", :port => 3000}
* Default: {}
-* `exclude` - Array of regexps to exclude from js routes.
+* `exclude` - Array of regexps to exclude from routes.
* Default: []
* The regexp applies only to the name before the `_path` suffix, eg: you
want to match exactly `settings_path`, the regexp should be `/^settings$/`
-* `include` - Array of regexps to include in js routes.
+* `include` - Array of regexps to include in routes.
* Default: []
* The regexp applies only to the name before the `_path` suffix, eg: you
want to match exactly `settings_path`, the regexp should be `/^settings$/`
* `namespace` - global object used to access routes.
@@ -83,7 +83,7 @@
* Example: `jQuery.param` - use jQuery's serializer algorithm. You can
attach serialize function from your favorite AJAX framework.
* Example: `MyApp.custom_serialize` - use completely custom serializer of
your application.
-* `special_options_key` - a special key that helps js-routes to destinguish
serialized model from options hash
+* `special_options_key` - a special key that helps JsRoutes to destinguish
serialized model from options hash
* This option is required because JS doesn't provide a difference between an
object and a hash
* Option is configurable at JS level with `Routes.configure()`
* Default: `_options`
@@ -189,39 +189,30 @@
```
-## Rails Compatibilities
+## Rails Compatibility
-JsRoutes ties to be as close as possible to rails behaviour in all aspects of
routing API.
-Please make and issue in case of any incomtibilities found outside of
described below.
+JsRoutes tries to replicate the Rails routing API as closely as possible. If
you find any incompatibilities (outside of what is described below), please
[open an issue](https://github.com/railsware/js-routes/issues/new).
### Object and Hash distinction issue
-Sometimes the destinction between JS Hash and Object can not be found by
js-routes.
+Sometimes the destinction between JS Hash and Object can not be found by
JsRoutes.
In this case you would need to pass a special key to help:
``` js
-Routes.company_project_path({company_id: 1, id: 2}) // => Not Enough parameters
+Routes.company_project_path({company_id: 1, id: 2}) // => Not enough parameters
Routes.company_project_path({company_id: 1, id: 2, _options: true}) // =>
"/companies/1/projects/2"
```
## What about security?
-js-routes itself do not have security holes. It makes URLs
+JsRoutes itself do not have security holes. It makes URLs
without access protection more reachable by potential attacker.
In order to prevent this use `:exclude` option for sensitive urls like
`/admin_/`
-## Spork
+## JsRoutes and Heroku
-When using Spork and `Spork.trap_method(Rails::Application::RoutesReloader,
:reload!)` you should also do:
-
-``` ruby
-Spork.trap_method(JsRoutes, :generate!)
-```
-
-## JS-Routes and heroku
-
-Heroku environment has a specific problems with setup. It is impossible to use
asset pipeline in this environment. You should use "Very Advanced Setup" schema
in this case.
+When using this setup on Heroku, it is impossible to use the asset pipeline.
You should use the "Very Advanced Setup" schema in this case.
For example create routes.js.erb in assets folder with needed content:
@@ -236,16 +227,16 @@
There are some alternatives available. Most of them has only basic feature and
don't reach the level of quality I accept.
Advantages of this one are:
-* Rails 3-5 support
+* Rails 4,5,6 support
* Rich options set
* Full rails compatibility
* Support Rails `#to_param` convention for seo optimized paths
* Well tested
-#### Thanks to
[Contributors](https://github.com/railsware/js-routes/contributors)
+#### Thanks to
[contributors](https://github.com/railsware/js-routes/contributors)
#### Have fun
## License
-[](https://app.fossa.io/projects/git%2Bgithub.com%2Frailsware%2Fjs-routes?ref=badge_large)
\ No newline at end of file
+[](https://app.fossa.io/projects/git%2Bgithub.com%2Frailsware%2Fjs-routes?ref=badge_large)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/app/assets/javascripts/js-routes.js.erb
new/app/assets/javascripts/js-routes.js.erb
--- old/app/assets/javascripts/js-routes.js.erb 2018-05-07 13:15:41.000000000
+0200
+++ new/app/assets/javascripts/js-routes.js.erb 2019-04-04 16:00:06.000000000
+0200
@@ -1,2 +1,2 @@
<%# encoding: UTF-8 %>
-<%= JsRoutes.assert_usable_configuration! && JsRoutes.generate %>
+<%= JsRoutes.generate %>
Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/gemfiles/rails32.gemfile new/gemfiles/rails32.gemfile
--- old/gemfiles/rails32.gemfile 2018-05-07 13:15:41.000000000 +0200
+++ new/gemfiles/rails32.gemfile 1970-01-01 01:00:00.000000000 +0100
@@ -1,8 +0,0 @@
-# This file was generated by Appraisal
-
-source "http://rubygems.org"
-
-gem "railties", "~> 3.2.22.5"
-gem "tzinfo"
-
-gemspec :path => "../"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/gemfiles/rails52_sprockets_3.gemfile
new/gemfiles/rails52_sprockets_3.gemfile
--- old/gemfiles/rails52_sprockets_3.gemfile 1970-01-01 01:00:00.000000000
+0100
+++ new/gemfiles/rails52_sprockets_3.gemfile 2019-04-04 16:00:06.000000000
+0200
@@ -0,0 +1,8 @@
+# This file was generated by Appraisal
+
+source "http://rubygems.org"
+
+gem "railties", "~> 5.2.3"
+gem "sprockets", "~> 3.0"
+
+gemspec :path => "../"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/js-routes.gemspec new/js-routes.gemspec
--- old/js-routes.gemspec 2018-05-07 13:15:41.000000000 +0200
+++ new/js-routes.gemspec 2019-04-04 16:00:06.000000000 +0200
@@ -20,7 +20,7 @@
s.require_paths = ["lib"]
s.summary = %q{Brings Rails named routes to javascript}
- s.add_runtime_dependency(%q<railties>, [">= 3.2"])
+ s.add_runtime_dependency(%q<railties>, [">= 4"])
s.add_runtime_dependency(%q<sprockets-rails>)
s.add_development_dependency(%q<rspec>, [">= 3.0.0"])
s.add_development_dependency(%q<bundler>, [">= 1.1.0"])
@@ -31,6 +31,6 @@
else
s.add_development_dependency(%q<byebug>)
s.add_development_dependency(%q<pry-byebug>)
- s.add_development_dependency(%q<therubyracer>, [">= 0.12.3"])
+ s.add_development_dependency(%q<mini_racer>, [">= 0.2.4"])
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/js_routes/engine.rb new/lib/js_routes/engine.rb
--- old/lib/js_routes/engine.rb 2018-05-07 13:15:41.000000000 +0200
+++ new/lib/js_routes/engine.rb 2019-04-04 16:00:06.000000000 +0200
@@ -42,30 +42,17 @@
raise StandardError, "Sprockets version
#{sprockets_version} is not supported"
end
- is_running_rails = defined?(Rails) && Rails.respond_to?(:version)
- is_running_rails_32 = is_running_rails && Rails.version.match(/3\.2/)
-
initializer 'js-routes.dependent_on_routes', initializer_args do
case sprockets_version
when -> (v) { v2.match?('', v) },
-> (v) { vgte3.match?('', v) }
- # It seems rails 3.2 is not working if
- # `Rails.application.config.assets.configure` is used for
- # registering preprocessor
- if is_running_rails_32
- Rails.application.assets.register_preprocessor(
+ # Other rails version, assumed newer
+ Rails.application.config.assets.configure do |config|
+ config.register_preprocessor(
"application/javascript",
SprocketsExtension,
)
- else
- # Other rails version, assumed newer
- Rails.application.config.assets.configure do |config|
- config.register_preprocessor(
- "application/javascript",
- SprocketsExtension,
- )
- end
end
else
raise StandardError, "Sprockets version #{sprockets_version} is not
supported"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/js_routes/version.rb new/lib/js_routes/version.rb
--- old/lib/js_routes/version.rb 2018-05-07 13:15:41.000000000 +0200
+++ new/lib/js_routes/version.rb 2019-04-04 16:00:06.000000000 +0200
@@ -1,3 +1,3 @@
class JsRoutes
- VERSION = "1.4.4"
+ VERSION = "1.4.6"
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/js_routes.rb new/lib/js_routes.rb
--- old/lib/js_routes.rb 2018-05-07 13:15:41.000000000 +0200
+++ new/lib/js_routes.rb 2019-04-04 16:00:06.000000000 +0200
@@ -98,16 +98,6 @@
new(opts).generate!(file_name)
end
- # Under rails 3.1.1 and higher, perform a check to ensure that the
- # full environment will be available during asset compilation.
- # This is required to ensure routes are loaded.
- def assert_usable_configuration!
- if 3 == Rails::VERSION::MAJOR &&
!Rails.application.config.assets.initialize_on_precompile
- raise("Cannot precompile js-routes unless environment is initialized.
Please set config.assets.initialize_on_precompile to true.")
- end
- true
- end
-
def json(string)
ActiveSupport::JSON.encode(string)
end
@@ -130,8 +120,9 @@
{
"GEM_VERSION" => JsRoutes::VERSION,
"ROUTES" => js_routes,
- "DEPRECATED_BEHAVIOR" => Rails.version < "4",
"NODE_TYPES" => json(NODE_TYPES),
+ "RAILS_VERSION" => ActionPack.version,
+ "DEPRECATED_GLOBBING_BEHAVIOR" => ActionPack::VERSION::MAJOR == 4 &&
ActionPack::VERSION::MINOR == 0,
"APP_CLASS" => application.class.to_s,
"NAMESPACE" => json(@configuration.namespace),
@@ -150,8 +141,15 @@
# https://github.com/railsware/js-routes/issues/7
Rails.configuration.after_initialize do
file_name ||= self.class.configuration['file']
- File.open(Rails.root.join(file_name), 'w') do |f|
- f.write generate
+ file_path = Rails.root.join(file_name)
+ js_content = generate
+
+ # We don't need to rewrite file if it already exist and have same
content.
+ # It helps asset pipeline or webpack understand that file wasn't changed.
+ return if File.exist?(file_path) && File.read(file_path) == js_content
+
+ File.open(file_path, 'w') do |f|
+ f.write js_content
end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/routes.js new/lib/routes.js
--- old/lib/routes.js 2018-05-07 13:15:41.000000000 +0200
+++ new/lib/routes.js 2019-04-04 16:00:06.000000000 +0200
@@ -1,18 +1,19 @@
/*
File generated by js-routes GEM_VERSION
-Based on Rails routes of APP_CLASS
+Based on Rails RAILS_VERSION routes of APP_CLASS
*/
(function() {
- var DeprecatedBehavior, NodeTypes, ParameterMissing, ReservedOptions,
SpecialOptionsKey, Utils, root,
+ var DeprecatedGlobbingBehavior, NodeTypes, ParameterMissing,
ReservedOptions, SpecialOptionsKey, UriEncoderSegmentRegex, Utils, root,
hasProp = {}.hasOwnProperty,
slice = [].slice;
root = typeof exports !== "undefined" && exports !== null ? exports : this;
- function ParameterMissing(message, fileName, lineNumber) {
- var instance = new Error(message, fileName, lineNumber);
- if(Object.setPrototypeOf) {
+ ParameterMissing = function(message, fileName, lineNumber) {
+ var instance;
+ instance = new Error(message, fileName, lineNumber);
+ if (Object.setPrototypeOf) {
Object.setPrototypeOf(instance, Object.getPrototypeOf(this));
} else {
instance.__proto__ = this.__proto__;
@@ -21,7 +22,7 @@
Error.captureStackTrace(instance, ParameterMissing);
}
return instance;
- }
+ };
ParameterMissing.prototype = Object.create(Error.prototype, {
constructor: {
@@ -32,7 +33,7 @@
}
});
- if (Object.setPrototypeOf){
+ if (Object.setPrototypeOf) {
Object.setPrototypeOf(ParameterMissing, Error);
} else {
ParameterMissing.__proto__ = Error;
@@ -40,9 +41,11 @@
NodeTypes = NODE_TYPES;
+ DeprecatedGlobbingBehavior = DEPRECATED_GLOBBING_BEHAVIOR;
+
SpecialOptionsKey = SPECIAL_OPTIONS_KEY;
- DeprecatedBehavior = DEPRECATED_BEHAVIOR;
+ UriEncoderSegmentRegex = /[^a-zA-Z0-9\-\._~!\$&'\(\)\*\+,;=:@]/g;
ReservedOptions = ['anchor', 'trailing_slash', 'subdomain', 'host', 'port',
'protocol'];
@@ -202,7 +205,7 @@
if (actual_parameters.length > parts.length) {
throw new Error("Too many parameters provided for path");
}
- use_all_parts = DeprecatedBehavior || actual_parameters.length >
required_parts.length;
+ use_all_parts = actual_parameters.length > required_parts.length;
parts_options = {};
for (key in options) {
if (!hasProp.call(options, key)) continue;
@@ -280,9 +283,9 @@
return "" + left_part + right_part;
case NodeTypes.SYMBOL:
value = parameters[left];
+ delete parameters[left];
if (value != null) {
- delete parameters[left];
- return this.path_identifier(value);
+ return this.encode_segment(this.path_identifier(value));
}
if (optional) {
return "";
@@ -294,6 +297,11 @@
throw new Error("Unknown Rails node type");
}
},
+ encode_segment: function(segment) {
+ return segment.replace(UriEncoderSegmentRegex, function(str) {
+ return encodeURIComponent(str);
+ });
+ },
is_optional_node: function(node) {
return this.indexOf([NodeTypes.STAR, NodeTypes.SYMBOL, NodeTypes.CAT],
node) >= 0;
},
@@ -332,10 +340,11 @@
route[1] = left = left.replace(/^\*/i, "");
}
value = parameters[left];
+ delete parameters[left];
if (value == null) {
return this.visit(route, parameters, optional);
}
- parameters[left] = (function() {
+ value = (function() {
switch (this.get_object_type(value)) {
case "array":
return value.join("/");
@@ -343,7 +352,11 @@
return value;
}
}).call(this);
- return this.visit(route, parameters, optional);
+ if (DeprecatedGlobbingBehavior) {
+ return this.path_identifier(value);
+ } else {
+ return encodeURI(this.path_identifier(value));
+ }
},
get_prefix: function() {
var prefix;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/routes.js.coffee new/lib/routes.js.coffee
--- old/lib/routes.js.coffee 2018-05-07 13:15:41.000000000 +0200
+++ new/lib/routes.js.coffee 2019-04-04 16:00:06.000000000 +0200
@@ -1,8 +1,7 @@
###
File generated by js-routes GEM_VERSION
-Based on Rails routes of APP_CLASS
+Based on Rails RAILS_VERSION routes of APP_CLASS
###
-# root is this
root = (exports ? this)
ParameterMissing = (message, fileName, lineNumber) ->
@@ -28,8 +27,9 @@
ParameterMissing.__proto__ = Error
NodeTypes = NODE_TYPES
+DeprecatedGlobbingBehavior = DEPRECATED_GLOBBING_BEHAVIOR
SpecialOptionsKey = SPECIAL_OPTIONS_KEY
-DeprecatedBehavior = DEPRECATED_BEHAVIOR
+UriEncoderSegmentRegex = /[^a-zA-Z0-9\-\._~!\$&'\(\)\*\+,;=:@]/g # this is
ActionDispatch::Journey::Router::Utils::UriEncoder::SEGMENT
ReservedOptions = [
'anchor'
@@ -135,7 +135,7 @@
if actual_parameters.length > parts.length
throw new Error("Too many parameters provided for path")
- use_all_parts = DeprecatedBehavior or actual_parameters.length >
required_parts.length
+ use_all_parts = actual_parameters.length > required_parts.length
parts_options = {}
for own key of options
@@ -211,9 +211,9 @@
"#{left_part}#{right_part}"
when NodeTypes.SYMBOL
value = parameters[left]
+ delete parameters[left]
if value?
- delete parameters[left]
- return @path_identifier(value)
+ return @encode_segment(@path_identifier(value))
if optional
"" # missing parameter
else
@@ -226,6 +226,7 @@
else
throw new Error("Unknown Rails node type")
+ encode_segment: (segment) -> segment.replace(UriEncoderSegmentRegex, (str)
-> encodeURIComponent(str))
is_optional_node: (node) -> @indexOf([NodeTypes.STAR, NodeTypes.SYMBOL,
NodeTypes.CAT], node) >= 0
@@ -260,13 +261,18 @@
# fix for rails 4 globbing
route[1] = left = left.replace(/^\*/i, "") if left.replace(/^\*/i, "")
isnt left
value = parameters[left]
+ delete parameters[left]
return @visit(route, parameters, optional) unless value?
- parameters[left] = switch @get_object_type(value)
+ value = switch @get_object_type(value)
when "array"
value.join("/")
else
value
- @visit route, parameters, optional
+
+ if DeprecatedGlobbingBehavior
+ @path_identifier(value)
+ else
+ encodeURI(@path_identifier(value))
#
# This method check and return prefix from options
@@ -397,7 +403,7 @@
routes.default_serializer = (object, prefix) ->
Utils.default_serializer(object, prefix)
Utils.namespace(root, NAMESPACE, routes)
-
+
# Set up Routes appropriately for the environment.
if typeof define is "function" and define.amd
# AMD
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata 2018-05-07 13:15:41.000000000 +0200
+++ new/metadata 2019-04-04 16:00:06.000000000 +0200
@@ -1,14 +1,14 @@
--- !ruby/object:Gem::Specification
name: js-routes
version: !ruby/object:Gem::Version
- version: 1.4.4
+ version: 1.4.6
platform: ruby
authors:
- Bogdan Gusiev
autorequire:
bindir: bin
cert_chain: []
-date: 2018-05-07 00:00:00.000000000 Z
+date: 2019-04-04 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
name: railties
@@ -16,14 +16,14 @@
requirements:
- - ">="
- !ruby/object:Gem::Version
- version: '3.2'
+ version: '4'
type: :runtime
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
- version: '3.2'
+ version: '4'
- !ruby/object:Gem::Dependency
name: sprockets-rails
requirement: !ruby/object:Gem::Requirement
@@ -123,19 +123,19 @@
- !ruby/object:Gem::Version
version: '0'
- !ruby/object:Gem::Dependency
- name: therubyracer
+ name: mini_racer
requirement: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
- version: 0.12.3
+ version: 0.2.4
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
- version: 0.12.3
+ version: 0.2.4
description: Generates javascript file that defines all Rails named routes as
javascript
helpers
email: [email protected]
@@ -155,7 +155,6 @@
- Rakefile
- Readme.md
- app/assets/javascripts/js-routes.js.erb
-- gemfiles/rails32.gemfile
- gemfiles/rails40_sprockets_2.gemfile
- gemfiles/rails40_sprockets_3.gemfile
- gemfiles/rails41_sprockets_2.gemfile
@@ -164,6 +163,7 @@
- gemfiles/rails42_sprockets_3.gemfile
- gemfiles/rails50_sprockets_3.gemfile
- gemfiles/rails51_sprockets_3.gemfile
+- gemfiles/rails52_sprockets_3.gemfile
- js-routes.gemspec
- lib/js-routes.rb
- lib/js_routes.rb
@@ -202,7 +202,7 @@
version: '0'
requirements: []
rubyforge_project:
-rubygems_version: 2.6.14
+rubygems_version: 2.7.8
signing_key:
specification_version: 4
summary: Brings Rails named routes to javascript
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/js_routes/generated_javascript_spec.rb
new/spec/js_routes/generated_javascript_spec.rb
--- old/spec/js_routes/generated_javascript_spec.rb 2018-05-07
13:15:41.000000000 +0200
+++ new/spec/js_routes/generated_javascript_spec.rb 2019-04-04
16:00:06.000000000 +0200
@@ -14,7 +14,7 @@
app_class = "App"
is_expected.to include("File generated by js-routes
#{JsRoutes::VERSION}")
- is_expected.to include("Based on Rails routes of #{app_class}")
+ is_expected.to include("Based on Rails #{ActionPack.version} routes of
#{app_class}")
end
it "should call route function for each route" do
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/js_routes/options_spec.rb
new/spec/js_routes/options_spec.rb
--- old/spec/js_routes/options_spec.rb 2018-05-07 13:15:41.000000000 +0200
+++ new/spec/js_routes/options_spec.rb 2019-04-04 16:00:06.000000000 +0200
@@ -6,9 +6,14 @@
evaljs(_presetup) if _presetup
with_warnings(_warnings) do
evaljs(JsRoutes.generate(_options))
+ App.routes.default_url_options = _options[:default_url_options] || {}
end
end
+ after(:each) do
+ App.routes.default_url_options = {}
+ end
+
let(:_presetup) { nil }
let(:_options) { {} }
let(:_warnings) { true }
@@ -134,12 +139,14 @@
let(:_options) { {:default_url_options => {format: "json"}} }
let(:_warnings) { nil }
- it "should render routing with default_format" do
- expect(evaljs("Routes.inbox_path(1)")).to eq(test_routes.inbox_path(1,
:format => "json"))
- end
+ if Rails.version >= "5"
+ it "should render routing with default_format" do
+ expect(evaljs("Routes.inbox_path(1)")).to eq(test_routes.inbox_path(1))
+ end
- it "should render routing with default_format and zero object" do
- expect(evaljs("Routes.inbox_path(0)")).to eq(test_routes.inbox_path(0,
:format => "json"))
+ it "should render routing with default_format and zero object" do
+ expect(evaljs("Routes.inbox_path(0)")).to eq(test_routes.inbox_path(0))
+ end
end
it "should override default_format when spefified implicitly" do
@@ -147,13 +154,11 @@
end
it "should override nullify implicitly when specified implicitly" do
- expect(evaljs("Routes.inbox_path(1, {format: null})")).to
eq(test_routes.inbox_path(1))
+ expect(evaljs("Routes.inbox_path(1, {format: null})")).to
eq(test_routes.inbox_path(1, format: nil))
end
-
it "shouldn't require the format" do
- pending if Rails.version < "4.0"
- expect(evaljs("Routes.json_only_path()")).to
eq(test_routes.json_only_path(:format => 'json'))
+ expect(evaljs("Routes.json_only_path()")).to
eq(test_routes.json_only_path)
end
end
@@ -201,14 +206,14 @@
context "provided" do
let(:_options) { { :default_url_options => { :optional_id => "12",
:format => "json" } } }
it "should use this opions to fill optional parameters" do
- expect(evaljs("Routes.things_path()")).to
eq(test_routes.things_path(:optional_id => 12, :format => "json"))
+ expect(evaljs("Routes.things_path()")).to eq(test_routes.things_path)
end
end
context "not provided" do
let(:_options) { { :default_url_options => { :format => "json" } } }
it "breaks" do
- expect(evaljs("Routes.foo_all_path()")).to
eq(test_routes.foo_all_path(:format => "json"))
+ expect(evaljs("Routes.foo_all_path()")).to
eq(test_routes.foo_all_path)
end
end
end
@@ -216,7 +221,7 @@
context "with required route parts" do
let(:_options) { {:default_url_options => {:inbox_id => "12"}} }
it "should use this opions to fill optional parameters" do
- expect(evaljs("Routes.inbox_messages_path()")).to
eq(test_routes.inbox_messages_path(:inbox_id => 12))
+ expect(evaljs("Routes.inbox_messages_path()")).to
eq(test_routes.inbox_messages_path)
end
end
@@ -248,7 +253,7 @@
end
it "should remove it by params" do
- expect(evaljs("Routes.inbox_path(1, {trailing_slash: false})")).to
eq(test_routes.inbox_path(1))
+ expect(evaljs("Routes.inbox_path(1, {trailing_slash: false})")).to
eq(test_routes.inbox_path(1, trailing_slash: false))
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/js_routes/rails_routes_compatibility_spec.rb
new/spec/js_routes/rails_routes_compatibility_spec.rb
--- old/spec/js_routes/rails_routes_compatibility_spec.rb 2018-05-07
13:15:41.000000000 +0200
+++ new/spec/js_routes/rails_routes_compatibility_spec.rb 2019-04-04
16:00:06.000000000 +0200
@@ -14,15 +14,15 @@
expect(evaljs("Routes.inbox_path(1)")).to eq(test_routes.inbox_path(1))
end
- it "should raise error if required argument is not passed" do
+ it "should raise error if required argument is not passed",
:aggregate_failures do
expect { evaljs("Routes.thing_path()") }
- .to raise_error('Route parameter missing: id')
+ .to raise_error(/Route parameter missing: id/)
expect { evaljs("Routes.search_path()") }
- .to raise_error('Route parameter missing: q')
+ .to raise_error(/Route parameter missing: q/)
expect { evaljs("Routes.book_path()") }
- .to raise_error('Route parameter missing: title')
+ .to raise_error(/Route parameter missing: title/)
expect { evaljs("Routes.book_title_path()") }
- .to raise_error('Route parameter missing: title')
+ .to raise_error(/Route parameter missing: title/)
end
it "should produce error stacktraces including function names" do
@@ -70,6 +70,10 @@
expect(evaljs("Routes.inbox_path(1, {expanded: true, anchor:
'hello'})")).to eq(test_routes.inbox_path(1, :expanded => true, :anchor =>
"hello"))
end
+ it "should support required paramters given as options hash" do
+ expect(evaljs("Routes.search_path({q: 'hello'})")).to
eq(test_routes.search_path(:q => 'hello'))
+ end
+
it "should use irregular ActiveSupport pluralizations" do
expect(evaljs("Routes.budgies_path()")).to eq(test_routes.budgies_path)
expect(evaljs("Routes.budgie_path(1)")).to eq(test_routes.budgie_path(1))
@@ -77,6 +81,16 @@
expect(evaljs("Routes.budgie_descendents_path(1)")).to
eq(test_routes.budgie_descendents_path(1))
end
+ it "should support route with parameters containing symbols that need
URI-encoding", :aggregate_failures do
+ expect(evaljs("Routes.inbox_path('#hello')")).to
eq(test_routes.inbox_path('#hello'))
+ expect(evaljs("Routes.inbox_path('some param')")).to
eq(test_routes.inbox_path('some param'))
+ expect(evaljs("Routes.inbox_path('some param with more & more encode
symbols')")).to eq(test_routes.inbox_path('some param with more & more encode
symbols'))
+ end
+ it "should support route with parameters containing symbols not need
URI-encoding", :aggregate_failures do
+ expect(evaljs("Routes.inbox_path(':some_id')")).to
eq(test_routes.inbox_path(':some_id'))
+ expect(evaljs("Routes.inbox_path('.+')")).to
eq(test_routes.inbox_path('.+'))
+ end
+
describe "when route has defaults" do
it "should support route default format" do
expect(evaljs("Routes.api_purchases_path()")).to
eq(test_routes.api_purchases_path)
@@ -158,6 +172,9 @@
expect(evaljs("Routes.inboxes_path({uri: 'http://example.com'})")).to
eq(test_routes.inboxes_path(:uri => 'http://example.com'))
end
+ it "should support nested object null parameters" do
+ expect(evaljs("Routes.inboxes_path({hello: {world: null}})")).to
eq(test_routes.inboxes_path(:hello => {:world => nil}))
+ end
end
@@ -170,14 +187,18 @@
expect(evaljs("Routes.book_path(['thrillers'], 1)")).to
eq(test_routes.book_path(['thrillers'], 1))
end
- it "should bee support routes globbing as array" do
+ it "should support routes globbing as array" do
expect(evaljs("Routes.book_path([1, 2, 3], 1)")).to
eq(test_routes.book_path([1, 2, 3], 1))
end
- it "should bee support routes globbing as hash" do
+ it "should support routes globbing with slash" do
expect(evaljs("Routes.book_path('a_test/b_test/c_test', 1)")).to
eq(test_routes.book_path('a_test/b_test/c_test', 1))
end
+ it "should support routes globbing as hash" do
+ expect(evaljs("Routes.book_path('a%b', 1)")).to
eq(test_routes.book_path('a%b', 1))
+ end
+
it "should support routes globbing as array with optional params" do
expect(evaljs("Routes.book_path([1, 2, 3, 5], 1, {c: '1'})")).to
eq(test_routes.book_path([1, 2, 3, 5], 1, { :c => "1" }))
end
@@ -189,14 +210,6 @@
it "should support routes globbing in book_title route as array with
optional params" do
expect(evaljs("Routes.book_title_path('john', ['thrillers', 'comedian'],
{some_key: 'some_value'})")).to eq(test_routes.book_title_path('john',
['thrillers', 'comedian'], {:some_key => 'some_value'}))
end
-
- it "should support required paramters given as options hash" do
- expect(evaljs("Routes.search_path({q: 'hello'})")).to
eq(test_routes.search_path(:q => 'hello'))
- end
-
- it "should support nested object null parameters" do
- expect(evaljs("Routes.inboxes_path({hello: {world: null}})")).to
eq(test_routes.inboxes_path(:hello => {:world => nil}))
- end
end
context "using optional path fragments" do
@@ -222,7 +235,7 @@
it "should raise error when passing non-full list of arguments and some
query params" do
expect { evaljs("Routes.thing_path(5, {q: 'hello'})") }
- .to raise_error('Route parameter missing: id')
+ .to raise_error(/Route parameter missing: id/)
end
it "should treat null as non-given optional part" do
@@ -234,19 +247,13 @@
end
it "should skip leading and trailing optional parts" do
- skip if Rails.version < '4'
expect(evaljs("Routes.thing_deep_path(1, 2)")).to
eq(test_routes.thing_deep_path(1, 2))
end
end
context "and including them" do
- if Rails.version < '4'
- it "should fail when insufficient arguments are given" do
- expect { evaljs("Routes.thing_deep_path(1)")}
- .to raise_error('Route parameter missing: second_required')
- expect { evaljs("Routes.thing_deep_path(1,2)")}
- .to raise_error('Route parameter missing: third_required')
- end
+ it "should fail when insufficient arguments are given" do
+ expect { evaljs("Routes.thing_deep_path(2)") }.to raise_error(/Route
parameter missing: third_required/)
end
it "should include the optional parts" do
@@ -258,6 +265,7 @@
expect(evaljs("Routes.thing_deep_path(3, { first_optional: 1,
second_required: 2 })")).to eq(test_routes.thing_deep_path(3, first_optional:
1, second_required: 2))
expect(evaljs("Routes.thing_deep_path(3, { first_optional: 1,
second_required: 2, forth_optional: 4 })")).to
eq(test_routes.thing_deep_path(3, first_optional: 1, second_required: 2,
forth_optional: 4))
expect(evaljs("Routes.thing_deep_path(4, { first_optional: 1,
second_required: 2, third_required: 3 })")).to
eq(test_routes.thing_deep_path(4, first_optional: 1, second_required: 2,
third_required: 3))
+ expect(evaljs("Routes.thing_deep_path(2, 3)")).to
eq(test_routes.thing_deep_path(2, 3))
expect(evaljs("Routes.thing_deep_path(1, 2, { third_required: 3
})")).to eq(test_routes.thing_deep_path(1, 2, third_required: 3))
expect(evaljs("Routes.thing_deep_path(1,2, {third_required: 3, q:
'bogdan'})")).to eq(test_routes.thing_deep_path(1,2, {third_required: 3, q:
'bogdan'}))
expect(evaljs("Routes.thing_deep_path(1, 2, { forth_optional: 4,
third_required: 3 })")).to eq(test_routes.thing_deep_path(1, 2, forth_optional:
4, third_required: 3))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/js_routes/zzz_last_post_rails_init_spec.rb
new/spec/js_routes/zzz_last_post_rails_init_spec.rb
--- old/spec/js_routes/zzz_last_post_rails_init_spec.rb 2018-05-07
13:15:41.000000000 +0200
+++ new/spec/js_routes/zzz_last_post_rails_init_spec.rb 2019-04-04
16:00:06.000000000 +0200
@@ -43,6 +43,21 @@
expect(File.exists?(NAME)).to be_truthy
end
+ it "should not rewrite routes file if nothing changed" do
+ routes_file_mtime = File.mtime(NAME)
+ JsRoutes.generate!(NAME)
+ expect(File.mtime(NAME)).to eq(routes_file_mtime)
+ end
+
+ it "should rewrite routes file if file content changed" do
+ # Change content of existed routes file (add space to the end of file).
+ File.open(NAME, 'a') { |f| f << ' ' }
+ routes_file_mtime = File.mtime(NAME)
+ sleep(1)
+ JsRoutes.generate!(NAME)
+ expect(File.mtime(NAME)).not_to eq(routes_file_mtime)
+ end
+
context "JsRoutes::Engine" do
TEST_ASSET_PATH = Rails.root.join('app','assets','javascripts','test.js')
@@ -86,11 +101,7 @@
Rails.application.config.assets.initialize_on_precompile = false
end
it "should raise an exception if 3 version" do
- if 3 == Rails::VERSION::MAJOR
- expect { evaluate(ctx, 'js-routes.js') }.to
raise_error(/Cannot precompile/)
- else
- expect(evaluate(ctx, 'js-routes.js')).to match(/routes = /)
- end
+ expect(evaluate(ctx, 'js-routes.js')).to match(/routes = /)
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/spec_helper.rb new/spec/spec_helper.rb
--- old/spec/spec_helper.rb 2018-05-07 13:15:41.000000000 +0200
+++ new/spec/spec_helper.rb 2019-04-04 16:00:06.000000000 +0200
@@ -7,15 +7,13 @@
require 'js-routes'
require 'active_support/core_ext/hash/slice'
require 'coffee-script'
-# fix ends_with? error for rails 3.2
-require 'active_support/core_ext/string/starts_ends_with' if 3 ==
Rails::VERSION::MAJOR
if defined?(JRUBY_VERSION)
require 'rhino'
JS_LIB_CLASS = Rhino
else
- require 'v8'
- JS_LIB_CLASS = V8
+ require 'mini_racer'
+ JS_LIB_CLASS = MiniRacer
end
def jscontext(force = false)
@@ -27,7 +25,11 @@
end
def js_error_class
- JS_LIB_CLASS::JSError
+ if defined?(JRUBY_VERSION)
+ JS_LIB_CLASS::JSError
+ else
+ JS_LIB_CLASS::Error
+ end
end
def evaljs(string, force = false)
@@ -60,13 +62,7 @@
config.assets.enabled = true
# initialize_on_precompile
config.assets.initialize_on_precompile = true
-
- if 3 == Rails::VERSION::MAJOR
- config.paths['config/routes'] << 'spec/config/routes.rb'
- else
- config.paths['config/routes.rb'] << 'spec/config/routes.rb'
- end
-
+ config.paths['config/routes.rb'] << 'spec/config/routes.rb'
config.root = File.expand_path('../dummy', __FILE__)
end
@@ -97,25 +93,14 @@
config.before :each do
evaljs("var window = this;", true)
- def inspectify(value)
- case value
- when V8::Array
- value.map do |v|
- inspectify(v)
- end
- when V8::Object
- value.to_h.map do |k,v|
- [k, inspectify(v)]
- end.to_h
- when String, nil, Integer, FalseClass, TrueClass
- value
- else
- raise "wtf #{value.class}?"
+ if defined?(JRUBY_VERSION)
+ jscontext[:log] = lambda do |context, value|
+ puts value
end
-
- end
- jscontext[:log] = lambda do |context, value|
- puts inspectify(value).to_json
+ else
+ jscontext.attach("log", proc do |value|
+ puts value
+ end)
end
end
end