Hello community, here is the log from the commit of package rubygem-js-routes for openSUSE:Factory checked in at 2016-07-20 09:24:54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 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-07-01 09:59:28.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.rubygem-js-routes.new/rubygem-js-routes.changes 2016-07-20 09:24:57.000000000 +0200 @@ -1,0 +2,13 @@ +Fri Jul 15 04:34:16 UTC 2016 - coolo@suse.com + +- updated to version 1.2.7 + see installed CHANGELOG.md + + ## v1.2.7 + + * Drop support 1.9.3 + * Add helper for indexOf, if no native implementation in JS engine + * Add sprockets3 compatibility + * Bugfix domain defaults to path #197 + +------------------------------------------------------------------- Old: ---- js-routes-1.2.6.gem New: ---- js-routes-1.2.7.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-js-routes.spec ++++++ --- /var/tmp/diff_new_pack.7GIkiC/_old 2016-07-20 09:24:58.000000000 +0200 +++ /var/tmp/diff_new_pack.7GIkiC/_new 2016-07-20 09:24:58.000000000 +0200 @@ -24,7 +24,7 @@ # Name: rubygem-js-routes -Version: 1.2.6 +Version: 1.2.7 Release: 0 %define mod_name js-routes %define mod_full_name %{mod_name}-%{version} ++++++ js-routes-1.2.6.gem -> js-routes-1.2.7.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.travis.yml new/.travis.yml --- old/.travis.yml 2016-06-02 13:06:54.000000000 +0200 +++ new/.travis.yml 2016-07-14 12:23:49.000000000 +0200 @@ -1,11 +1,13 @@ language: ruby cache: bundler +before_install: + - gem install bundler # need for jruby and ruby-head + rvm: - - 1.9.3 - 2.0 - 2.1 - - 2.2 + - 2.2.5 - 2.3.1 - jruby-19mode - ruby-head @@ -19,6 +21,8 @@ - gemfiles/rails41_sprockets3.gemfile - gemfiles/rails42.gemfile - gemfiles/rails42_sprockets3.gemfile + - gemfiles/rails50.gemfile + - gemfiles/rails50_sprockets3.gemfile sudo: false @@ -35,3 +39,13 @@ - rvm: jruby-19mode - rvm: ruby-head - rvm: jruby-head + - gemfile: gemfiles/rails50.gemfile + exclude: + - rvm: 2.0 + gemfile: gemfiles/rails50.gemfile + - rvm: 2.0 + gemfile: gemfiles/rails50_sprockets3.gemfile + - rvm: 2.1 + gemfile: gemfiles/rails50.gemfile + - rvm: 2.1 + gemfile: gemfiles/rails50_sprockets3.gemfile diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Appraisals new/Appraisals --- old/Appraisals 2016-06-02 13:06:54.000000000 +0200 +++ new/Appraisals 2016-07-14 12:23:49.000000000 +0200 @@ -3,7 +3,7 @@ gem 'tzinfo' end -{rails40: '4.0.5', rails41: '4.1.1', rails42: '4.2.1'}.each do |rails, version| +{rails40: '4.0.5', rails41: '4.1.1', rails42: '4.2.1', rails50: '5.0.0'}.each do |rails, version| appraise "#{rails}" do gem "railties", "~> #{version}" gem "sprockets", "< 3" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md --- old/CHANGELOG.md 2016-06-02 13:06:54.000000000 +0200 +++ new/CHANGELOG.md 2016-07-14 12:23:49.000000000 +0200 @@ -1,5 +1,12 @@ ## master +## v1.2.7 + +* Drop support 1.9.3 +* Add helper for indexOf, if no native implementation in JS engine +* Add sprockets3 compatibility +* Bugfix domain defaults to path #197 + ## v1.2.6 * Use default prefix from `Rails.application.config.relative_url_root` #186 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 2016-06-02 13:06:54.000000000 +0200 +++ new/app/assets/javascripts/js-routes.js.erb 2016-07-14 12:23:49.000000000 +0200 @@ -1,3 +1,2 @@ <%# encoding: UTF-8 %> -<% depend_on "#{Rails.root.join 'config', 'routes.rb'}" if JsRoutes::SPROCKETS3 %> <%= JsRoutes.assert_usable_configuration! && JsRoutes.generate %> Files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gemfiles/rails50.gemfile new/gemfiles/rails50.gemfile --- old/gemfiles/rails50.gemfile 1970-01-01 01:00:00.000000000 +0100 +++ new/gemfiles/rails50.gemfile 2016-07-14 12:23:49.000000000 +0200 @@ -0,0 +1,8 @@ +# This file was generated by Appraisal + +source "http://rubygems.org" + +gem "railties", "~> 5.0.0" +gem "sprockets", "< 3" + +gemspec :path => "../" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gemfiles/rails50_sprockets3.gemfile new/gemfiles/rails50_sprockets3.gemfile --- old/gemfiles/rails50_sprockets3.gemfile 1970-01-01 01:00:00.000000000 +0100 +++ new/gemfiles/rails50_sprockets3.gemfile 2016-07-14 12:23:49.000000000 +0200 @@ -0,0 +1,8 @@ +# This file was generated by Appraisal + +source "http://rubygems.org" + +gem "railties", "~> 5.0.0" +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 2016-06-02 13:06:54.000000000 +0200 +++ new/js-routes.gemspec 2016-07-14 12:23:49.000000000 +0200 @@ -29,9 +29,7 @@ if defined?(JRUBY_VERSION) s.add_development_dependency(%q<therubyrhino>, [">= 2.0.4"]) else - if RUBY_VERSION >= "2.0.0" - s.add_development_dependency(%q<byebug>) - end + s.add_development_dependency(%q<byebug>) s.add_development_dependency(%q<therubyracer>, [">= 0.12.1"]) 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 2016-06-02 13:06:54.000000000 +0200 +++ new/lib/js_routes/engine.rb 2016-07-14 12:23:49.000000000 +0200 @@ -4,15 +4,27 @@ SPROCKETS3 = Gem::Version.new(Sprockets::VERSION) >= Gem::Version.new('3.0.0') class Engine < ::Rails::Engine - initializer 'js-routes.dependent_on_routes', after: "sprockets.environment" do + if SPROCKETS3 + initializer 'js-routes.dependent_on_routes', after: :engines_blank_point, before: :finisher_hook do + Rails.application.config.assets.configure do |config| + routes = Rails.root.join('config', 'routes.rb').to_s + config.register_preprocessor 'application/javascript', :'js-routes_dependent_on_routes' do |ctx,data| + ctx.depend_on(routes) if ctx.logical_path == 'js-routes' + data + end + end + end + else + initializer 'js-routes.dependent_on_routes', after: "sprockets.environment" do - if Rails.application.assets.respond_to?(:register_preprocessor) - routes = Rails.root.join('config', 'routes.rb').to_s - Rails.application.assets.register_preprocessor 'application/javascript', :'js-routes_dependent_on_routes' do |ctx,data| - ctx.depend_on(routes) if ctx.logical_path == 'js-routes' - data + if Rails.application.assets.respond_to?(:register_preprocessor) + routes = Rails.root.join('config', 'routes.rb').to_s + Rails.application.assets.register_preprocessor 'application/javascript', :'js-routes_dependent_on_routes' do |ctx,data| + ctx.depend_on(routes) if ctx.logical_path == 'js-routes' + data + end end end - end unless SPROCKETS3 + end end end 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-06-02 13:06:54.000000000 +0200 +++ new/lib/js_routes/version.rb 2016-07-14 12:23:49.000000000 +0200 @@ -1,3 +1,3 @@ class JsRoutes - VERSION = "1.2.6" + VERSION = "1.2.7" 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-06-02 13:06:54.000000000 +0200 +++ new/lib/js_routes.rb 2016-07-14 12:23:49.000000000 +0200 @@ -36,6 +36,7 @@ LAST_OPTIONS_KEY = "options".freeze FILTERED_DEFAULT_PARTS = [:controller, :action, :subdomain] + URL_OPTIONS = [:protocol, :domain, :host, :port, :subdomain] class Options < Struct.new(*DEFAULTS.keys) def to_hash @@ -151,19 +152,22 @@ def js_routes js_routes = Rails.application.routes.named_routes.to_a.sort_by(&:first).flat_map do |_, route| - rails_engine_app = get_app_from_route(route) - if rails_engine_app.respond_to?(:superclass) && rails_engine_app.superclass == Rails::Engine && !route.path.anchored - rails_engine_app.routes.named_routes.map do |_, engine_route| - build_route_if_match(engine_route, route) - end - else - build_route_if_match(route) - end + [build_route_if_match(route)] + mounted_app_routes(route) end.compact - "{\n" + js_routes.join(",\n") + "}\n" end + def mounted_app_routes(route) + rails_engine_app = get_app_from_route(route) + if rails_engine_app.respond_to?(:superclass) && rails_engine_app.superclass == Rails::Engine && !route.path.anchored + rails_engine_app.routes.named_routes.map do |_, engine_route| + build_route_if_match(engine_route, route) + end + else + [] + end + end + def get_app_from_route(route) # rails engine in Rails 4.2 use additional ActionDispatch::Routing::Mapper::Constraints, which contain app if route.app.respond_to?(:app) && route.app.respond_to?(:constraints) @@ -204,8 +208,8 @@ def route_js_arguments(route, parent_spec) required_parts = route.required_parts.clone optional_parts = route.parts - required_parts - default_parts = route.defaults.reject do |part, _| - FILTERED_DEFAULT_PARTS.include?(part) + default_parts = route.defaults.select do |part, _| + FILTERED_DEFAULT_PARTS.exclude?(part) && URL_OPTIONS.include?(part) || required_parts.include?(part) end [ required_parts, optional_parts, serialize(route.path.spec, parent_spec), default_parts diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/routes.js new/lib/routes.js --- old/lib/routes.js 2016-06-02 13:06:54.000000000 +0200 +++ new/lib/routes.js 2016-07-14 12:23:49.000000000 +0200 @@ -173,7 +173,7 @@ for (key in options) { if (!hasProp.call(options, key)) continue; value = options[key]; - if (ReservedOptions.indexOf(key) >= 0) { + if (this.indexOf(ReservedOptions, key) >= 0) { result[key] = value; } else { url_parameters[key] = value; @@ -245,7 +245,7 @@ } }, is_optional_node: function(node) { - return node === NodeTypes.STAR || node === NodeTypes.SYMBOL || node === NodeTypes.CAT; + return this.indexOf([NodeTypes.STAR, NodeTypes.SYMBOL, NodeTypes.CAT], node) >= 0; }, build_path_spec: function(route, wildcard) { var left, right, type; @@ -375,6 +375,24 @@ } else { return typeof obj; } + }, + indexOf: function(array, element) { + if (Array.prototype.indexOf) { + return array.indexOf(element); + } else { + return this.indexOfImplementation(array, element); + } + }, + indexOfImplementation: function(array, element) { + var el, i, j, len, result; + result = -1; + for (i = j = 0, len = array.length; j < len; i = ++j) { + el = array[i]; + if (el === element) { + result = i; + } + } + return result; } }; 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-06-02 13:06:54.000000000 +0200 +++ new/lib/routes.js.coffee 2016-07-14 12:23:49.000000000 +0200 @@ -109,7 +109,7 @@ url_parameters = {} result['url_parameters'] = url_parameters for own key, value of options - if ReservedOptions.indexOf(key) >= 0 + if @indexOf(ReservedOptions, key) >= 0 result[key] = value else url_parameters[key] = value @@ -183,8 +183,7 @@ throw new Error("Unknown Rails node type") - is_optional_node: (node) -> - node == NodeTypes.STAR or node == NodeTypes.SYMBOL or node == NodeTypes.CAT + is_optional_node: (node) -> @indexOf([NodeTypes.STAR, NodeTypes.SYMBOL, NodeTypes.CAT], node) >= 0 # # This method build spec for route @@ -311,6 +310,13 @@ return "#{obj}" unless obj? (if typeof obj is "object" or typeof obj is "function" then @_classToType()[Object::toString.call(obj)] or "object" else typeof obj) + # indexOf helper + indexOf: (array, element) -> if Array::indexOf then array.indexOf(element) else @indexOfImplementation(array, element) + indexOfImplementation: (array, element) -> + result = -1 + (result = i for el, i in array when el is element) + result + # globalJsObject createGlobalJsRoutesObject = -> # namespace function, private diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2016-06-02 13:06:54.000000000 +0200 +++ new/metadata 2016-07-14 12:23:49.000000000 +0200 @@ -1,14 +1,14 @@ --- !ruby/object:Gem::Specification name: js-routes version: !ruby/object:Gem::Version - version: 1.2.6 + version: 1.2.7 platform: ruby authors: - Bogdan Gusiev autorequire: bindir: bin cert_chain: [] -date: 2016-06-02 00:00:00.000000000 Z +date: 2016-07-14 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: railties @@ -148,6 +148,8 @@ - gemfiles/rails41_sprockets3.gemfile - gemfiles/rails42.gemfile - gemfiles/rails42_sprockets3.gemfile +- gemfiles/rails50.gemfile +- gemfiles/rails50_sprockets3.gemfile - js-routes.gemspec - lib/js-routes.rb - lib/js_routes.rb 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 2016-06-02 13:06:54.000000000 +0200 +++ new/spec/js_routes/generated_javascript_spec.rb 2016-07-14 12:23:49.000000000 +0200 @@ -75,10 +75,6 @@ end describe "compiled javascript asset" do - if JsRoutes::SPROCKETS3 - let(:routes_path){ "#{Rails.root.join 'config', 'routes.rb'}" } - before { expect(self).to receive(:depend_on).with routes_path } - end subject { ERB.new(File.read("app/assets/javascripts/js-routes.js.erb")).result(binding) } it "should have js routes code" do is_expected.to include("inbox_message_path: Utils.route([\"inbox_id\",\"id\"]") 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-06-02 13:06:54.000000000 +0200 +++ new/spec/js_routes/options_spec.rb 2016-07-14 12:23:49.000000000 +0200 @@ -421,14 +421,7 @@ end before do - jscontext['window'] = { - :location => { - :protocol => current_protocol, - :hostname => current_hostname, - :port => current_port, - :host => current_host - } - } + jscontext.eval("window = {'location': {'protocol': '#{current_protocol}', 'hostname': '#{current_hostname}', 'port': '#{current_port}', 'host': '#{current_host}'}}") end context "without specifying a default host" do 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-06-02 13:06:54.000000000 +0200 +++ new/spec/js_routes/rails_routes_compatibility_spec.rb 2016-07-14 12:23:49.000000000 +0200 @@ -67,12 +67,19 @@ end it 'should support route default subdomain' do + # root inside namespace is broken + # https://github.com/rails/rails/pull/23235 + pending if Rails.version == '5.0.0' expect(evaljs("Routes.backend_root_path()")).to eq(routes.backend_root_path) end it "should support default format override" do expect(evaljs("Routes.api_purchases_path({format: 'xml'})")).to eq(routes.api_purchases_path(format: 'xml')) end + + it "doesn't apply defaults to path" do + expect(evaljs("Routes.with_defaults_path()")).to eq(routes.with_defaults_path) + end end context "with rails engines" do @@ -80,6 +87,10 @@ expect(evaljs("Routes.blog_app_posts_path()")).to eq(blog_routes.posts_path()) end + it "should support root route" do + expect(evaljs("Routes.blog_app_path()")).to eq(routes.blog_app_path()) + end + it "should support route with parameters" do expect(evaljs("Routes.blog_app_post_path(1)")).to eq(blog_routes.post_path(1)) 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 2016-06-02 13:06:54.000000000 +0200 +++ new/spec/spec_helper.rb 2016-07-14 12:23:49.000000000 +0200 @@ -14,7 +14,7 @@ require 'rhino' JS_LIB_CLASS = Rhino else - require "v8" + require 'v8' JS_LIB_CLASS = V8 end @@ -124,6 +124,8 @@ resources :portals, :port => 8080 + get '/with_defaults' => 'foo#foo', defaults: { bar: 'tested', format: :json }, format: :true + namespace :api, format: true, defaults: {format: 'json'} do get "/purchases" => "purchases#index" end