js_from_routes 2.0.2 → 2.0.3

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
  SHA256:
3
- metadata.gz: e519db2185c78b02fadb95f984de960cea4c8e87e8f931d87d9f8501d4515930
4
- data.tar.gz: 7d8c112e3ed479c1de9c51f3980f8cee3849c13851eaf0a65613c4ff6cef0bac
3
+ metadata.gz: db1718354ae9ce8148221f6cb5331398809cb684450cf1d88d43636f5b2f0c40
4
+ data.tar.gz: d883f5e22c950ed87481ac9d8d1fca08ef669c5fe56b7fd51cc48124d9640077
5
5
  SHA512:
6
- metadata.gz: cbee6bf52472a6265f3c44602f29c7ebdf87deb65900ce7f95d5739eb97a1a139b2ef06b40a96487273af0cfbb7dc6a9ae12da6e4a3bacd85300aae8b1642db6
7
- data.tar.gz: da4f0e39ef8523067a653fd90f6bd2d9c4c38c106db3fd7ee93acdd32b8bd1df6659accfc9e200bb0a565c5be01a3517fdcdc86293852374bddaa1223b9747a2
6
+ metadata.gz: 319b235a6fcc6bf8564517486de5fb9790fc5076fa0b3030b711eb49ea058c5ba877fc7b8a217976f9556cd330c8f78114e5a2361a11367536d25fad233ef013
7
+ data.tar.gz: 8ec656121b7a10bb0123ede54409a5327d215124d6fdd11f38f5aad34d1f56e0e982dc5139cada10a978037d6fe0767ed94ef1abdcdded1d61d104438a12ff9f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [2.0.3](https://github.com/ElMassimo/js_from_routes/compare/js_from_routes@2.0.2...js_from_routes@2.0.3) (2021-03-16)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Ensure changing the client library triggers code generation ([6cf2bdf](https://github.com/ElMassimo/js_from_routes/commit/6cf2bdf4896dafe0d1e80668551665c46bfcadc6))
7
+
8
+
9
+ ### Features
10
+
11
+ * Allow passing JS_FROM_ROUTES_FORCE=true to ignore cache keys ([8a6d2a8](https://github.com/ElMassimo/js_from_routes/commit/8a6d2a807e0a9926c6b24e1fc9127f917ec0ed5d))
12
+
13
+
14
+
1
15
  ## [2.0.2](https://github.com/ElMassimo/js_from_routes/compare/js_from_routes@2.0.1...js_from_routes@2.0.2) (2021-03-14)
2
16
 
3
17
  ### Improvements
@@ -44,7 +44,7 @@ module JsFromRoutes
44
44
  # Public: Used to check whether the file should be generated again, changes
45
45
  # based on the configuration, and route definition.
46
46
  def cache_key
47
- routes.map(&:inspect).join + [File.read(@config.template_path), @config.helper_mappings.inspect].join
47
+ routes.map(&:inspect).join + [File.read(@config.template_path), @config.helper_mappings.inspect, @config.client_library].join
48
48
  end
49
49
 
50
50
  # Public: Exposes the preferred import library to the generator.
@@ -126,6 +126,11 @@ module JsFromRoutes
126
126
  object.instance_eval(@compiled_template)
127
127
  end
128
128
 
129
+ # Internal: Returns true if the cache key has changed since the last codegen.
130
+ def stale?(file, cache_key_comment)
131
+ ENV["JS_FROM_ROUTES_FORCE"] || file.gets != cache_key_comment
132
+ end
133
+
129
134
  # Internal: Writes if the file does not exist or the cache key has changed.
130
135
  # The cache strategy consists of a comment on the first line of the file.
131
136
  #
@@ -134,7 +139,7 @@ module JsFromRoutes
134
139
  FileUtils.mkdir_p(name.dirname)
135
140
  cache_key_comment = "// JsFromRoutes CacheKey #{Digest::MD5.hexdigest(cache_key)}\n"
136
141
  File.open(name, "a+") { |file|
137
- if file.gets != cache_key_comment
142
+ if stale?(file, cache_key_comment)
138
143
  file.truncate(0)
139
144
  file.write(cache_key_comment)
140
145
  file.write(yield)
@@ -4,5 +4,5 @@
4
4
  # Generates one file per controller, and one function per route.
5
5
  module JsFromRoutes
6
6
  # Public: This library adheres to semantic versioning.
7
- VERSION = "2.0.2"
7
+ VERSION = "2.0.3"
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: js_from_routes
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Máximo Mussini
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-14 00:00:00.000000000 Z
11
+ date: 2021-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties