js-routes 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c68aed8760da61aa1ff4977b8d69f09cfc609f18
4
- data.tar.gz: f4362dcdb29332048b5a19d3ed40dce4717b6bd9
3
+ metadata.gz: d01616a12162f3955743143d09ce4e4e0297284a
4
+ data.tar.gz: b515223e7fa4122852861fbe5e6cddbe927aadec
5
5
  SHA512:
6
- metadata.gz: cd44c50605191eda0663671b1d7bf46bcffa7e4e13705e8ca9177fc3c8ac332ea1abac89448a7dfc27e4e9eee5d98ad340f602fea6b082c0af144449e5e46c31
7
- data.tar.gz: bc598e7e2a6c51477162b6e76d4d423e4e6bd6454247305593d343934abd04ae20a829301695e7707ed86bc38c8da7ce00a3c224f3b9e3e5e3b3e35e8ce2320c
6
+ metadata.gz: 847807d48bf2c431609b98eeb940d0c8da008bbebf8a04d5c857b02aeab54e9c3648c3d7039bfcdc508a367ae05be86d77db153950270ccce0f68461d7a30ad7
7
+ data.tar.gz: d72dc26e1a9a7ac2cfeb1795cad81567a7a3885ed9ad9f6e6f9121cf444fa2371a77da7cd2505994010e9f0521be78a55033f9bd9ec1858a871d42545646ba93
data/.travis.yml CHANGED
@@ -13,10 +13,10 @@ rvm:
13
13
  gemfile:
14
14
  - gemfiles/rails32.gemfile
15
15
  - gemfiles/rails40.gemfile
16
- - gemfiles/rails41.gemfile
17
- - gemfiles/rails42.gemfile
18
16
  - gemfiles/rails40_sprockets3.gemfile
17
+ - gemfiles/rails41.gemfile
19
18
  - gemfiles/rails41_sprockets3.gemfile
19
+ - gemfiles/rails42.gemfile
20
20
  - gemfiles/rails42_sprockets3.gemfile
21
21
 
22
22
  sudo: false
@@ -30,7 +30,12 @@ branches:
30
30
  - master
31
31
 
32
32
  matrix:
33
+ include:
34
+ - gemfile: gemfiles/rails_edge.gemfile
35
+ rvm: 2.2
33
36
  allow_failures:
34
37
  - rvm: jruby-19mode
35
38
  - rvm: ruby-head
36
39
  - rvm: jruby-head
40
+ - gemfile: gemfiles/rails_edge.gemfile
41
+ rvm: 2.2
data/Appraisals CHANGED
@@ -3,7 +3,7 @@ appraise "rails32" do
3
3
  gem 'tzinfo'
4
4
  end
5
5
 
6
- {rails40: '4.0.5', rails41: '4.1.1', rails42: '4.2.0'}.each do |rails, version|
6
+ {rails40: '4.0.5', rails41: '4.1.1', rails42: '4.2.1'}.each do |rails, version|
7
7
  appraise "#{rails}" do
8
8
  gem "railties", "~> #{version}"
9
9
  gem "sprockets", "< 3"
@@ -14,3 +14,8 @@ end
14
14
  gem "sprockets", "~> 3.0"
15
15
  end
16
16
  end
17
+
18
+ appraise "rails-edge" do
19
+ gem "railties", github: 'rails/rails'
20
+ gem "sprockets", "~> 3.0"
21
+ end
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  ## master
2
2
 
3
+ ## v1.1.0
4
+
5
+ * Ensure routes are loaded, prior to generating them [#148](https://github.com/railsware/js-routes/pull/148)
6
+ * Use `flat_map` rather than `map{...}.flatten` [#149](https://github.com/railsware/js-routes/pull/149)
7
+ * URL escape routes.rb url to fix bad URI(is not URI?) error [#150](https://github.com/railsware/js-routes/pull/150)
8
+ * Fix for rails 5 - test rails-edge on travis allowing failure [#151](https://github.com/railsware/js-routes/pull/151)
9
+ * Adds `serializer` option [#155](https://github.com/railsware/js-routes/pull/155/files)
10
+
11
+ ## v1.0.1
12
+
13
+ * Support sprockets-3
14
+ * Performance optimization of include/exclude options
15
+
3
16
  ## v1.0.0
4
17
 
5
18
  * Add the compact mode [#125](https://github.com/railsware/js-routes/pull/125)
data/Readme.md CHANGED
@@ -69,6 +69,10 @@ Available options:
69
69
  * `compact` (version > 0.9.9) - Remove `_path` suffix in path routes(`*_url` routes stay untouched if they were enabled)
70
70
  * Default: false
71
71
  * Sample route call when option is set to true: Routes.users() => `/users`
72
+ * `serializer` (version >= 1.1.0) - Puts a JS function here that serializes a Javascript Hash object into URL paramters: `{a: 1, b: 2} => "a=1&b=2"`.
73
+ * Default: `nil`. Uses built-in serializer
74
+ * Example: `jQuery.param` - use jQuery's serializer algorithm. You can attach serialize function from your favorite AJAX framework.
75
+ * Example: `MyApp.custom_serialize` - use completely custom serializer of your application.
72
76
 
73
77
  ### Very Advanced Setup
74
78
 
@@ -91,7 +95,7 @@ If your application has an `admin` and an `application` namespace for example:
91
95
  #= require application/routes
92
96
  ```
93
97
 
94
- In order to generate the routes to a string:
98
+ In order to generate the routes JS code to a string:
95
99
 
96
100
  ```ruby
97
101
  routes_js = JsRoutes.generate(options)
@@ -2,7 +2,7 @@
2
2
 
3
3
  source "http://rubygems.org"
4
4
 
5
- gem "railties", "~> 4.2.0"
5
+ gem "railties", "~> 4.2.1"
6
6
  gem "sprockets", "< 3"
7
7
 
8
8
  gemspec :path => "../"
@@ -2,7 +2,7 @@
2
2
 
3
3
  source "http://rubygems.org"
4
4
 
5
- gem "railties", "~> 4.2.0"
5
+ gem "railties", "~> 4.2.1"
6
6
  gem "sprockets", "~> 3.0"
7
7
 
8
8
  gemspec :path => "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "railties", :github => "rails/rails"
6
+ gem "sprockets", "~> 3.0"
7
+
8
+ gemspec :path => "../"
data/js-routes.gemspec CHANGED
@@ -30,6 +30,9 @@ Gem::Specification.new do |s|
30
30
  if defined?(JRUBY_VERSION)
31
31
  s.add_development_dependency(%q<therubyrhino>, [">= 2.0.4"])
32
32
  else
33
+ if RUBY_VERSION >= "2.0.0"
34
+ s.add_development_dependency(%q<byebug>)
35
+ end
33
36
  s.add_development_dependency(%q<therubyracer>, [">= 0.12.1"])
34
37
  end
35
38
  end
data/lib/js_routes.rb CHANGED
@@ -19,7 +19,8 @@ class JsRoutes
19
19
  url_links: nil,
20
20
  camel_case: false,
21
21
  default_url_options: {},
22
- compact: false
22
+ compact: false,
23
+ serializer: nil
23
24
  }
24
25
 
25
26
  NODE_TYPES = {
@@ -57,6 +58,11 @@ class JsRoutes
57
58
  end
58
59
 
59
60
  def generate(opts = {})
61
+ # Ensure routes are loaded. If they're not, load them.
62
+ if Rails.application.routes.named_routes.routes.keys.empty?
63
+ Rails.application.reload_routes!
64
+ end
65
+
60
66
  new(opts).generate
61
67
  end
62
68
 
@@ -93,10 +99,13 @@ class JsRoutes
93
99
 
94
100
  def generate
95
101
  js = File.read(File.dirname(__FILE__) + "/routes.js")
102
+ js.gsub!("GEM_VERSION", JsRoutes::VERSION)
103
+ js.gsub!("APP_CLASS", Rails.application.class.to_s)
96
104
  js.gsub!("NAMESPACE", @options[:namespace])
97
105
  js.gsub!("DEFAULT_URL_OPTIONS", json(@options[:default_url_options].merge(deprecated_default_format)))
98
106
  js.gsub!("PREFIX", @options[:prefix] || "")
99
107
  js.gsub!("NODE_TYPES", json(NODE_TYPES))
108
+ js.gsub!("SERIALIZER", @options[:serializer] || "null")
100
109
  js.gsub!("ROUTES", js_routes)
101
110
  end
102
111
 
@@ -124,7 +133,7 @@ class JsRoutes
124
133
  protected
125
134
 
126
135
  def js_routes
127
- js_routes = Rails.application.routes.named_routes.routes.sort_by(&:to_s).map do |_, route|
136
+ js_routes = Rails.application.routes.named_routes.routes.sort_by(&:to_s).flat_map do |_, route|
128
137
  rails_engine_app = get_app_from_route(route)
129
138
  if rails_engine_app.respond_to?(:superclass) && rails_engine_app.superclass == Rails::Engine && !route.path.anchored
130
139
  rails_engine_app.routes.named_routes.map do |_, engine_route|
@@ -133,7 +142,7 @@ class JsRoutes
133
142
  else
134
143
  build_route_if_match(route)
135
144
  end
136
- end.flatten.compact
145
+ end.compact
137
146
 
138
147
  "{\n" + js_routes.join(",\n") + "}\n"
139
148
  end
@@ -157,7 +166,7 @@ class JsRoutes
157
166
 
158
167
  def any_match?(route, parent_route, matchers)
159
168
  full_route = [parent_route.try(:name), route.name].compact.join('_')
160
-
169
+
161
170
  matchers = Array(matchers)
162
171
  matchers.any? {|regex| full_route =~ regex}
163
172
  end
@@ -165,7 +174,7 @@ class JsRoutes
165
174
  def build_js(route, parent_route)
166
175
  name = [parent_route.try(:name), route.name].compact
167
176
  parent_spec = parent_route.try(:path).try(:spec)
168
- required_parts, optional_parts = route.required_parts.clone, route.optional_parts.clone
177
+ required_parts, optional_parts = route.required_parts.clone, (route.parts-route.required_parts)
169
178
  optional_parts.push(required_parts.delete :format) if required_parts.include?(:format)
170
179
  route_name = generate_route_name(name, (:path unless @options[:compact]))
171
180
  url_link = generate_url_link(name, route_name, required_parts, route)
@@ -14,7 +14,7 @@ class JsRoutes
14
14
 
15
15
  # only sprockets >= 3.0
16
16
  if Rails.application.assets.respond_to?(:depend_on)
17
- Rails.application.assets.depend_on "file-digest://#{routes}"
17
+ Rails.application.assets.depend_on Rack::Utils.escape("file-digest://#{routes}")
18
18
  end
19
19
  end
20
20
  end
@@ -1,3 +1,3 @@
1
1
  class JsRoutes
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
data/lib/routes.js CHANGED
@@ -1,3 +1,9 @@
1
+ /*
2
+ File generated by js-routes GEM_VERSION
3
+ Based on Rails routes of APP_CLASS
4
+ */
5
+
6
+
1
7
  (function() {
2
8
  var NodeTypes, ParameterMissing, Utils, createGlobalJsRoutesObject, defaults, root,
3
9
  __hasProp = {}.hasOwnProperty;
@@ -18,8 +24,8 @@
18
24
  NodeTypes = NODE_TYPES;
19
25
 
20
26
  Utils = {
21
- serialize: function(object, prefix) {
22
- var element, i, key, prop, result, s, _i, _len;
27
+ default_serializer: function(object, prefix) {
28
+ var element, i, key, prop, s, _i, _len;
23
29
 
24
30
  if (prefix == null) {
25
31
  prefix = null;
@@ -30,16 +36,12 @@
30
36
  if (!prefix && !(this.get_object_type(object) === "object")) {
31
37
  throw new Error("Url parameters should be a javascript hash");
32
38
  }
33
- if (root.jQuery) {
34
- result = root.jQuery.param(object);
35
- return (!result ? "" : result);
36
- }
37
39
  s = [];
38
40
  switch (this.get_object_type(object)) {
39
41
  case "array":
40
42
  for (i = _i = 0, _len = object.length; _i < _len; i = ++_i) {
41
43
  element = object[i];
42
- s.push(this.serialize(element, prefix + "[]"));
44
+ s.push(this.default_serializer(element, prefix + "[]"));
43
45
  }
44
46
  break;
45
47
  case "object":
@@ -52,7 +54,7 @@
52
54
  if (prefix != null) {
53
55
  key = "" + prefix + "[" + key + "]";
54
56
  }
55
- s.push(this.serialize(prop, key));
57
+ s.push(this.default_serializer(prop, key));
56
58
  }
57
59
  break;
58
60
  default:
@@ -65,6 +67,16 @@
65
67
  }
66
68
  return s.join("&");
67
69
  },
70
+ serialize: function(object) {
71
+ var custom_serializer;
72
+
73
+ custom_serializer = SERIALIZER;
74
+ if (custom_serializer) {
75
+ return custom_serializer(object);
76
+ } else {
77
+ return this.default_serializer(object);
78
+ }
79
+ },
68
80
  clean_path: function(path) {
69
81
  var last_index;
70
82
 
@@ -351,6 +363,9 @@
351
363
  namespace(root, "NAMESPACE");
352
364
  root.NAMESPACE = ROUTES;
353
365
  root.NAMESPACE.options = defaults;
366
+ root.NAMESPACE.default_serializer = function(object, prefix) {
367
+ return Utils.default_serializer(object, prefix);
368
+ };
354
369
  return root.NAMESPACE;
355
370
  };
356
371
 
data/lib/routes.js.coffee CHANGED
@@ -1,3 +1,7 @@
1
+ ###
2
+ File generated by js-routes GEM_VERSION
3
+ Based on Rails routes of APP_CLASS
4
+ ###
1
5
  # root is this
2
6
  root = (exports ? this)
3
7
 
@@ -11,24 +15,20 @@ NodeTypes = NODE_TYPES
11
15
 
12
16
  Utils =
13
17
 
14
- serialize: (object, prefix = null) ->
18
+ default_serializer: (object, prefix = null) ->
15
19
  return "" unless object
16
20
  if !prefix and !(@get_object_type(object) is "object")
17
21
  throw new Error("Url parameters should be a javascript hash")
18
22
 
19
- if root.jQuery
20
- result = root.jQuery.param(object)
21
- return (if not result then "" else result)
22
-
23
23
  s = []
24
24
  switch @get_object_type(object)
25
25
  when "array"
26
26
  for element, i in object
27
- s.push @serialize(element, prefix + "[]")
27
+ s.push @default_serializer(element, prefix + "[]")
28
28
  when "object"
29
29
  for own key, prop of object when prop?
30
30
  key = "#{prefix}[#{key}]" if prefix?
31
- s.push @serialize(prop, key)
31
+ s.push @default_serializer(prop, key)
32
32
  else
33
33
  if object
34
34
  s.push "#{encodeURIComponent(prefix.toString())}=#{encodeURIComponent(object.toString())}"
@@ -36,6 +36,13 @@ Utils =
36
36
  return "" unless s.length
37
37
  s.join("&")
38
38
 
39
+ serialize: (object) ->
40
+ custom_serializer = SERIALIZER
41
+ if custom_serializer
42
+ custom_serializer(object)
43
+ else
44
+ @default_serializer(object)
45
+
39
46
  clean_path: (path) ->
40
47
  path = path.split("://")
41
48
  last_index = path.length - 1
@@ -273,6 +280,8 @@ createGlobalJsRoutesObject = ->
273
280
  namespace(root, "NAMESPACE")
274
281
  root.NAMESPACE = ROUTES
275
282
  root.NAMESPACE.options = defaults
283
+ root.NAMESPACE.default_serializer = (object, prefix) ->
284
+ Utils.default_serializer(object, prefix)
276
285
  root.NAMESPACE
277
286
  # Set up Routes appropriately for the environment.
278
287
  if typeof define is "function" and define.amd
@@ -280,4 +289,4 @@ if typeof define is "function" and define.amd
280
289
  define [], -> createGlobalJsRoutesObject()
281
290
  else
282
291
  # Browser globals
283
- createGlobalJsRoutesObject()
292
+ createGlobalJsRoutesObject()
@@ -0,0 +1,13 @@
1
+ describe JsRoutes, "#default_serializer" do
2
+
3
+ before(:each) do
4
+ evaljs(JsRoutes.generate({}))
5
+ end
6
+
7
+ it "should provide this method" do
8
+ expect(evaljs("Routes.default_serializer({a: 1, b: [2,3], c: {d: 4, e: 5}})")).to eq(
9
+ "a=1&b%5B%5D=2&b%5B%5D=3&c%5Bd%5D=4&c%5Be%5D=5"
10
+ )
11
+ end
12
+
13
+ end
@@ -9,6 +9,18 @@ describe JsRoutes do
9
9
 
10
10
  describe "generated js" do
11
11
  subject { JsRoutes.generate }
12
+
13
+ it "should set the default serializer when none is configured" do
14
+ is_expected.to match(%r(serialize: function\(object\) {\s+var custom_serializer;\s+custom_serializer = null;\s+if \(custom_serializer\) {\s+return custom_serializer\(object\);\s+} else {\s+return this.default_serializer\(object\);\s+}\s+},))
15
+ end
16
+
17
+ it "should include a comment in the header" do
18
+ app_class = "App"
19
+
20
+ is_expected.to include("File generated by js-routes #{JsRoutes::VERSION}")
21
+ is_expected.to include("Based on Rails routes of #{app_class}")
22
+ end
23
+
12
24
  it "should call route function for each route" do
13
25
  is_expected.to include("inboxes_path: Utils.route(")
14
26
  end
@@ -13,6 +13,21 @@ describe JsRoutes, "options" do
13
13
  let(:_options) { {} }
14
14
  let(:_warnings) { true }
15
15
 
16
+ context "when serializer is specified" do
17
+ let(:_options) { {:serializer => "myCustomSerializer"} }
18
+
19
+ it "should set configurable serializer" do
20
+ # define custom serializer
21
+ # this is a nonsense serializer, which always returns foo=bar
22
+ # for all inputs
23
+ evaljs(%q(function myCustomSerializer(object, prefix) { return "foo=bar"; }))
24
+
25
+ # expect the nonsense serializer above to have appened foo=bar
26
+ # to the end of the path
27
+ expect(evaljs(%q(Routes.inboxes_path()))).to eql("/inboxes?foo=bar")
28
+ end
29
+ end
30
+
16
31
  context "when exclude is specified" do
17
32
 
18
33
  let(:_options) { {:exclude => /^admin_/} }
@@ -292,11 +307,11 @@ describe JsRoutes, "options" do
292
307
 
293
308
  context "when only host option is specified" do
294
309
  let(:_options) { { :url_links => true, :default_url_options => {:host => "example.com"} } }
295
-
310
+
296
311
  it "uses the specified host, defaults protocol to http, defaults port to 80 (leaving it blank)" do
297
312
  expect(evaljs("Routes.inbox_url(1)")).to eq("http://example.com#{routes.inbox_path(1)}")
298
313
  end
299
-
314
+
300
315
  it "does not override protocol when specified in route" do
301
316
  expect(evaljs("Routes.new_session_url()")).to eq("https://example.com#{routes.new_session_path}")
302
317
  end
@@ -316,7 +331,7 @@ describe JsRoutes, "options" do
316
331
  it "uses the specified protocol and host, defaults port to 80 (leaving it blank)" do
317
332
  expect(evaljs("Routes.inbox_url(1)")).to eq("ftp://example.com#{routes.inbox_path(1)}")
318
333
  end
319
-
334
+
320
335
  it "does not override protocol when specified in route" do
321
336
  expect(evaljs("Routes.new_session_url()")).to eq("https://example.com#{routes.new_session_path}")
322
337
  end
@@ -340,11 +355,11 @@ describe JsRoutes, "options" do
340
355
  it "does not override protocol when specified in route" do
341
356
  expect(evaljs("Routes.new_session_url()")).to eq("https://example.com:3000#{routes.new_session_path}")
342
357
  end
343
-
358
+
344
359
  it "does not override host, protocol, or port when host is specified in route" do
345
360
  expect(evaljs("Routes.sso_url()")).to eq(routes.sso_url)
346
361
  end
347
-
362
+
348
363
  it "does not override port when specified in route" do
349
364
  expect(evaljs("Routes.portals_url()")).to eq("http://example.com:8080#{routes.portals_path}")
350
365
  end
@@ -397,7 +412,7 @@ describe JsRoutes, "options" do
397
412
  example.run
398
413
  end
399
414
  end
400
-
415
+
401
416
  let(:_options) { { :compact => true, :url_links => "http://localhost" } }
402
417
  it "should not strip urls" do
403
418
  expect(evaljs("Routes.inbox(1)")).to eq(routes.inbox_path(1))
@@ -147,45 +147,6 @@ describe JsRoutes, "compatibility with Rails" do
147
147
  end
148
148
  end
149
149
 
150
- context "when jQuery is present" do
151
- before do
152
- evaljs("window.jQuery = {};")
153
- jscontext[:parameterizeFunc] = lambda {|object| _value.to_param}
154
- evaljs("window.jQuery.param = parameterizeFunc")
155
- end
156
-
157
- shared_examples_for "serialization" do
158
- it "should support serialization of objects" do
159
- expect(evaljs("window.jQuery.param(#{_value.to_json})")).to eq(_value.to_param)
160
- expect(evaljs("Routes.inboxes_path(#{_value.to_json})")).to eq(routes.inboxes_path(_value))
161
- expect(evaljs("Routes.inbox_path(1, #{_value.to_json})")).to eq(routes.inbox_path(1, _value))
162
- end
163
- end
164
- context "when parameters is a hash" do
165
- let(:_value) do
166
- {:a => {:b => 'c'}, :q => [1,2]}
167
- end
168
- it_should_behave_like 'serialization'
169
- end
170
- context "when parameters is null" do
171
- let(:_value) do
172
- {:hello => {world: nil}}
173
- end
174
- it_should_behave_like 'serialization'
175
- end
176
- context "when parameters is null" do
177
- let(:_value) do
178
- nil
179
- end
180
-
181
- before do
182
- pending("This test is invalid for nil/null and jruby #{JRUBY_VERSION}") if defined?(JRUBY_VERSION) && '1.7.13' == JRUBY_VERSION
183
- end
184
-
185
- it_should_behave_like 'serialization'
186
- end
187
- end
188
-
189
150
  context "using optional path fragments" do
190
151
  context "including not optional parts" do
191
152
  it "should include everything that is not optional" do
@@ -204,17 +165,11 @@ describe JsRoutes, "compatibility with Rails" do
204
165
  expect(evaljs("Routes.thing_path(null, 5)")).to eq(routes.thing_path(nil, 5))
205
166
  end
206
167
 
207
- # Fail for rails 4.2. Reason: https://github.com/rails/rails/issues/12178
208
168
  it "should treat undefined as non-given optional part" do
209
- # TODO: remove me after release of rails 4.2.1 (change Appraisals to "~> 4.2.1")
210
- pending("This test is invalid for rails 4.2. Reason: https://github.com/rails/rails/issues/12178") if [4, 2, 0] == [Rails::VERSION::MAJOR, Rails::VERSION::MINOR, Rails::VERSION::TINY]
211
169
  expect(evaljs("Routes.thing_path(5, {optional_id: undefined})")).to eq(routes.thing_path(5, :optional_id => nil))
212
170
  end
213
171
 
214
- # Fail for rails 4.2. Reason: https://github.com/rails/rails/issues/12178
215
172
  it "should treat null as non-given optional part" do
216
- # TODO: remove me after release of rails 4.2.1 (change Appraisals to "~> 4.2.1")
217
- pending("This test is invalid for rails 4.2. Reason: https://github.com/rails/rails/issues/12178") if [4, 2, 0] == [Rails::VERSION::MAJOR, Rails::VERSION::MINOR, Rails::VERSION::TINY]
218
173
  expect(evaljs("Routes.thing_path(5, {optional_id: null})")).to eq(routes.thing_path(5, :optional_id => nil))
219
174
  end
220
175
  end
data/spec/spec_helper.rb CHANGED
@@ -135,7 +135,9 @@ RSpec.configure do |config|
135
135
  config.before(:all) do
136
136
  # compile all js files begin
137
137
  Dir["#{File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))}/**/*.coffee"].each do |coffee|
138
- File.open(coffee.gsub(/\.coffee$/, ""), 'w') {|f| f.write(CoffeeScript.compile(File.read(coffee))) }
138
+ File.open(coffee.gsub(/\.coffee$/, ""), 'w') do |f|
139
+ f.write(CoffeeScript.compile(File.read(coffee)).lstrip)
140
+ end
139
141
  end
140
142
  # compile all js files end
141
143
  draw_routes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: js-routes
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bogdan Gusiev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-17 00:00:00.000000000 Z
11
+ date: 2015-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: 0.5.2
111
+ - !ruby/object:Gem::Dependency
112
+ name: byebug
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: therubyracer
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -149,6 +163,7 @@ files:
149
163
  - gemfiles/rails41_sprockets3.gemfile
150
164
  - gemfiles/rails42.gemfile
151
165
  - gemfiles/rails42_sprockets3.gemfile
166
+ - gemfiles/rails_edge.gemfile
152
167
  - js-routes.gemspec
153
168
  - lib/js-routes.rb
154
169
  - lib/js_routes.rb
@@ -160,6 +175,7 @@ files:
160
175
  - spec/dummy/app/assets/javascripts/.gitkeep
161
176
  - spec/dummy/config/routes.rb
162
177
  - spec/js_routes/amd_compatibility_spec.rb
178
+ - spec/js_routes/default_serializer_spec.rb
163
179
  - spec/js_routes/generated_javascript_spec.rb
164
180
  - spec/js_routes/options_spec.rb
165
181
  - spec/js_routes/rails_routes_compatibility_spec.rb