Hello community,

here is the log from the commit of package rubygem-js-routes for 
openSUSE:Factory checked in at 2016-09-12 13:26:31
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-js-routes (Old)
 and      /work/SRC/openSUSE:Factory/.rubygem-js-routes.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "rubygem-js-routes"

Changes:
--------
--- /work/SRC/openSUSE:Factory/rubygem-js-routes/rubygem-js-routes.changes      
2016-08-25 09:54:58.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.rubygem-js-routes.new/rubygem-js-routes.changes 
2016-09-12 13:26:33.000000000 +0200
@@ -1,0 +2,6 @@
+Thu Aug 18 04:31:27 UTC 2016 - [email protected]
+
+- updated to version 1.3.0
+ see installed CHANGELOG.md
+
+-------------------------------------------------------------------

Old:
----
  js-routes-1.2.9.gem

New:
----
  js-routes-1.3.0.gem

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ rubygem-js-routes.spec ++++++
--- /var/tmp/diff_new_pack.tpaB0r/_old  2016-09-12 13:26:35.000000000 +0200
+++ /var/tmp/diff_new_pack.tpaB0r/_new  2016-09-12 13:26:35.000000000 +0200
@@ -24,7 +24,7 @@
 #
 
 Name:           rubygem-js-routes
-Version:        1.2.9
+Version:        1.3.0
 Release:        0
 %define mod_name js-routes
 %define mod_full_name %{mod_name}-%{version}

++++++ js-routes-1.2.9.gem -> js-routes-1.3.0.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Readme.md new/Readme.md
--- old/Readme.md       2016-08-10 15:02:17.000000000 +0200
+++ new/Readme.md       2016-08-17 16:01:51.000000000 +0200
@@ -71,6 +71,10 @@
   * 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
+  * This options is required because JS doesn't provide a difference between 
an object and a hash
+  * Default: `_options`
+
 ### Very Advanced Setup
 
 In case you need multiple route files for different parts of your application, 
you have to create the files manually.
@@ -168,6 +172,22 @@
 Routes.user_path.required_params // => ['id']
 ```
 
+
+## Rails Compatibilities
+
+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.
+
+### Object and Hash distinction issue
+
+Sometimes the destinction between JS Hash and Object can not be found by 
js-routes.
+In this case you would need to pass a special key to help:
+
+``` js
+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
Files old/checksums.yaml.gz and new/checksums.yaml.gz differ
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        2016-08-10 15:02:17.000000000 +0200
+++ new/lib/js_routes/version.rb        2016-08-17 16:01:51.000000000 +0200
@@ -1,3 +1,3 @@
 class JsRoutes
-  VERSION = "1.2.9"
+  VERSION = "1.3.0"
 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        2016-08-10 15:02:17.000000000 +0200
+++ new/lib/js_routes.rb        2016-08-17 16:01:51.000000000 +0200
@@ -20,7 +20,8 @@
     camel_case: false,
     default_url_options: {},
     compact: false,
-    serializer: nil
+    serializer: nil,
+    special_options_key: "_options",
   }
 
   NODE_TYPES = {
@@ -107,8 +108,9 @@
       "DEFAULT_URL_OPTIONS" => 
json(@options[:default_url_options].merge(deprecate_url_options)),
       "PREFIX"              => @options[:prefix] || 
Rails.application.config.relative_url_root || "",
       "NODE_TYPES"          => json(NODE_TYPES),
-      "SERIALIZER"          => @options[:serializer] || "null",
+      "SERIALIZER"          => @options[:serializer] || json(nil),
       "ROUTES"              => js_routes,
+      "SPECIAL_OPTIONS_KEY" => @options[:special_options_key].to_s
     }.inject(File.read(File.dirname(__FILE__) + "/routes.js")) do |js, (key, 
value)|
       js.gsub!(key, value)
     end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/routes.js new/lib/routes.js
--- old/lib/routes.js   2016-08-10 15:02:17.000000000 +0200
+++ new/lib/routes.js   2016-08-17 16:01:51.000000000 +0200
@@ -4,7 +4,7 @@
  */
 
 (function() {
-  var NodeTypes, ParameterMissing, ReservedOptions, Utils, 
createGlobalJsRoutesObject, defaults, root,
+  var NodeTypes, ParameterMissing, ReservedOptions, SpecialOptionsKey, Utils, 
createGlobalJsRoutesObject, defaults, root,
     hasProp = {}.hasOwnProperty,
     slice = [].slice;
 
@@ -23,6 +23,8 @@
 
   NodeTypes = NODE_TYPES;
 
+  SpecialOptionsKey = "SPECIAL_OPTIONS_KEY";
+
   ReservedOptions = ['anchor', 'trailing_slash', 'host', 'port', 'protocol'];
 
   Utils = {
@@ -86,16 +88,18 @@
       return path.join("://");
     },
     extract_options: function(number_of_params, args) {
-      var last_el;
+      var last_el, options;
       last_el = args[args.length - 1];
       if ((args.length > number_of_params && last_el === void 0) || ((last_el 
!= null) && "object" === this.get_object_type(last_el) && 
!this.looks_like_serialized_model(last_el))) {
-        return args.pop() || {};
+        options = args.pop() || {};
+        delete options[SpecialOptionsKey];
+        return options;
       } else {
         return {};
       }
     },
     looks_like_serialized_model: function(object) {
-      return "id" in object || "to_param" in object;
+      return !object[SpecialOptionsKey] && ("id" in object || "to_param" in 
object);
     },
     path_identifier: function(object) {
       var property;
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    2016-08-10 15:02:17.000000000 +0200
+++ new/lib/routes.js.coffee    2016-08-17 16:01:51.000000000 +0200
@@ -12,6 +12,7 @@
   default_url_options: DEFAULT_URL_OPTIONS
 
 NodeTypes = NODE_TYPES
+SpecialOptionsKey = "SPECIAL_OPTIONS_KEY"
 
 ReservedOptions = [
   'anchor'
@@ -64,13 +65,14 @@
   extract_options: (number_of_params, args) ->
     last_el = args[args.length - 1]
     if (args.length > number_of_params and last_el == undefined) or(last_el? 
and "object" is @get_object_type(last_el) and 
!@looks_like_serialized_model(last_el))
-      args.pop() || {}
+      options = args.pop() || {}
+      delete options[SpecialOptionsKey]
+      options
     else
       {}
 
   looks_like_serialized_model: (object) ->
-    # consider object a model if it have a path identifier properties like id 
and to_param
-    "id" of object or "to_param" of object
+    !object[SpecialOptionsKey] and ("id" of object or "to_param" of object)
 
 
   path_identifier: (object) ->
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata        2016-08-10 15:02:17.000000000 +0200
+++ new/metadata        2016-08-17 16:01:51.000000000 +0200
@@ -1,14 +1,14 @@
 --- !ruby/object:Gem::Specification
 name: js-routes
 version: !ruby/object:Gem::Version
-  version: 1.2.9
+  version: 1.3.0
 platform: ruby
 authors:
 - Bogdan Gusiev
 autorequire: 
 bindir: bin
 cert_chain: []
-date: 2016-08-10 00:00:00.000000000 Z
+date: 2016-08-17 00:00:00.000000000 Z
 dependencies:
 - !ruby/object:Gem::Dependency
   name: railties
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  2016-08-10 15:02:17.000000000 +0200
+++ new/spec/js_routes/options_spec.rb  2016-08-17 16:01:51.000000000 +0200
@@ -476,4 +476,14 @@
       end
     end
   end
+
+  describe "special_options_key" do
+    let(:_options) { { special_options_key: :__options__ } }
+    it "can be redefined" do
+      expect {
+        expect(evaljs("Routes.inbox_message_path({inbox_id: 1, id: 2, 
_options: true})")).to eq("")
+      }.to raise_error(js_error_class)
+      expect(evaljs("Routes.inbox_message_path({inbox_id: 1, id: 2, 
__options__: true})")).to eq(routes.inbox_message_path(inbox_id: 1, id: 2))
+    end
+  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       2016-08-10 
15:02:17.000000000 +0200
+++ new/spec/js_routes/rails_routes_compatibility_spec.rb       2016-08-17 
16:01:51.000000000 +0200
@@ -18,14 +18,6 @@
     expect(evaljs("Routes.inbox_path(0)")).to eq(routes.inbox_path(0))
   end
 
-  it "should support 0 as a to_param option" do
-    expect(evaljs("Routes.inbox_path({to_param: 0})")).to 
eq(routes.inbox_path(0))
-  end
-
-  it "should support 0 as an id option" do
-    expect(evaljs("Routes.inbox_path({id: 0})")).to eq(routes.inbox_path(0))
-  end
-
   it "should generate nested routing with one parameter" do
     expect(evaljs("Routes.inbox_messages_path(1)")).to 
eq(routes.inbox_messages_path(1))
   end
@@ -253,7 +245,27 @@
 
   context "when arguments are objects" do
 
-    let(:inbox) {Struct.new(:id, :to_param).new(1,"my")}
+    let(:klass) { Struct.new(:id, :to_param) }
+    let(:inbox) { klass.new(1,"my") }
+
+    it "should support 0 as a to_param option" do
+      expect(evaljs("Routes.inbox_path({to_param: 0})")).to 
eq(routes.inbox_path(0))
+    end
+
+    it "should check for options special key" do
+      expect(evaljs("Routes.inbox_path({id: 7, q: 'hello', _options: 
true})")).to eq(routes.inbox_path(id: 7, q: 'hello'))
+      expect {
+        evaljs("Routes.inbox_path({to_param: 7, _options: true})")
+      }.to raise_error(js_error_class)
+      expect(evaljs("Routes.inbox_message_path(5, {id: 7, q: 'hello', 
_options: true})")).to eq(routes.inbox_message_path(5, id: 7, q: 'hello'))
+    end
+
+    it "should check for options special key" do
+    end
+
+    it "should support 0 as an id option" do
+      expect(evaljs("Routes.inbox_path({id: 0})")).to eq(routes.inbox_path(0))
+    end
 
     it "should use id property of the object in path" do
       expect(evaljs("Routes.inbox_path({id: 1})")).to eq(routes.inbox_path(1))


Reply via email to