Skip to content

Commit 9f658cf

Browse files
committed
Add timestamp to routes file banner
1 parent 5b0ca77 commit 9f658cf

File tree

9 files changed

+20
-28
lines changed

9 files changed

+20
-28
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v2.3.1
4+
5+
* Add timestamp on when routes where generated into banner
6+
37
## v2.3.0
48

59
* Drop support of Rails 4.x

lib/js_routes/instance.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,14 @@ def remove!
7676

7777
sig { returns(T::Hash[String, String]) }
7878
def js_variables
79-
version = Rails.version
8079
prefix = @configuration.prefix
8180
prefix = prefix.call if prefix.is_a?(Proc)
8281
{
8382
'GEM_VERSION' => JsRoutes::VERSION,
83+
'TIMESTAMP' => Time.now.to_s,
8484
'ROUTES_OBJECT' => routes_object,
8585
'RAILS_VERSION' => ::Rails.version,
86-
'DEPRECATED_GLOBBING_BEHAVIOR' => version >= '4.0.0' && version < '4.1.0',
87-
'DEPRECATED_FALSE_PARAMETER_BEHAVIOR' => version < '7.0.0',
86+
'DEPRECATED_FALSE_PARAMETER_BEHAVIOR' => Rails.version < '7.0.0',
8887
'APP_CLASS' => application.class.to_s,
8988
'DEFAULT_URL_OPTIONS' => json(@configuration.default_url_options),
9089
'PREFIX' => json(prefix),

lib/routes.d.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* File generated by js-routes RubyVariables.GEM_VERSION
2+
* File generated by js-routes RubyVariables.GEM_VERSION on RubyVariables.TIMESTAMP
33
* Based on Rails RubyVariables.RAILS_VERSION routes of RubyVariables.APP_CLASS
44
*/
55
declare type Optional<T> = {
@@ -64,7 +64,6 @@ declare type PartsTable = Collection<{
6464
declare type ModuleType = "CJS" | "AMD" | "UMD" | "ESM" | "DTS" | "NIL";
6565
declare const RubyVariables: {
6666
PREFIX: string;
67-
DEPRECATED_GLOBBING_BEHAVIOR: boolean;
6867
DEPRECATED_FALSE_PARAMETER_BEHAVIOR: boolean;
6968
SPECIAL_OPTIONS_KEY: string;
7069
DEFAULT_URL_OPTIONS: RouteParameters;

lib/routes.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* File generated by js-routes RubyVariables.GEM_VERSION
2+
* File generated by js-routes RubyVariables.GEM_VERSION on RubyVariables.TIMESTAMP
33
* Based on Rails RubyVariables.RAILS_VERSION routes of RubyVariables.APP_CLASS
44
*/
55
// eslint-disable-next-line
@@ -415,9 +415,7 @@ RubyVariables.WRAPPER(
415415
value = value.join("/");
416416
}
417417
const result = this.path_identifier(value);
418-
return RubyVariables.DEPRECATED_GLOBBING_BEHAVIOR
419-
? result
420-
: encodeURI(result);
418+
return encodeURI(result);
421419
}
422420
get_prefix() {
423421
const prefix = this.configuration.prefix;

lib/routes.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* File generated by js-routes RubyVariables.GEM_VERSION
2+
* File generated by js-routes RubyVariables.GEM_VERSION on RubyVariables.TIMESTAMP
33
* Based on Rails RubyVariables.RAILS_VERSION routes of RubyVariables.APP_CLASS
44
*/
55

@@ -82,7 +82,6 @@ type ModuleType = "CJS" | "AMD" | "UMD" | "ESM" | "DTS" | "NIL";
8282

8383
declare const RubyVariables: {
8484
PREFIX: string;
85-
DEPRECATED_GLOBBING_BEHAVIOR: boolean;
8685
DEPRECATED_FALSE_PARAMETER_BEHAVIOR: boolean;
8786
SPECIAL_OPTIONS_KEY: string;
8887
DEFAULT_URL_OPTIONS: RouteParameters;
@@ -606,9 +605,7 @@ RubyVariables.WRAPPER(
606605
value = value.join("/");
607606
}
608607
const result = this.path_identifier(value as any);
609-
return RubyVariables.DEPRECATED_GLOBBING_BEHAVIOR
610-
? result
611-
: encodeURI(result);
608+
return encodeURI(result);
612609
}
613610

614611
get_prefix(): string {

spec/js_routes/module_types/dts/routes.spec.d.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* File generated by js-routes RubyVariables.GEM_VERSION
2+
* File generated by js-routes RubyVariables.GEM_VERSION on RubyVariables.TIMESTAMP
33
* Based on Rails RubyVariables.RAILS_VERSION routes of RubyVariables.APP_CLASS
44
*/
55
declare type Optional<T> = {
@@ -64,7 +64,6 @@ declare type PartsTable = Collection<{
6464
declare type ModuleType = "CJS" | "AMD" | "UMD" | "ESM" | "DTS" | "NIL";
6565
declare const RubyVariables: {
6666
PREFIX: string;
67-
DEPRECATED_GLOBBING_BEHAVIOR: boolean;
6867
DEPRECATED_FALSE_PARAMETER_BEHAVIOR: boolean;
6968
SPECIAL_OPTIONS_KEY: string;
7069
DEFAULT_URL_OPTIONS: RouteParameters;

spec/js_routes/module_types/umd_spec.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313

1414
it "should include a comment in the header" do
1515
app_class = "App"
16+
fixed_time = Time.new(2023, 11, 18, 10, 15, 20)
17+
allow(Time).to receive(:now).and_return(fixed_time)
1618

17-
is_expected.to include("File generated by js-routes #{JsRoutes::VERSION}")
19+
is_expected.to include("File generated by js-routes #{JsRoutes::VERSION} on #{fixed_time}")
1820
is_expected.to include("Based on Rails #{Rails.version} routes of #{app_class}")
1921
end
2022

spec/js_routes/options_spec.rb

+5-7
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,12 @@
160160
let(:_options) { {:default_url_options => {format: "json"}} }
161161
let(:_warnings) { nil }
162162

163-
if Rails.version >= "5"
164-
it "should render routing with default_format" do
165-
expectjs("Routes.inbox_path(1)").to eq(test_routes.inbox_path(1))
166-
end
163+
it "should render routing with default_format" do
164+
expectjs("Routes.inbox_path(1)").to eq(test_routes.inbox_path(1))
165+
end
167166

168-
it "should render routing with default_format and zero object" do
169-
expectjs("Routes.inbox_path(0)").to eq(test_routes.inbox_path(0))
170-
end
167+
it "should render routing with default_format and zero object" do
168+
expectjs("Routes.inbox_path(0)").to eq(test_routes.inbox_path(0))
171169
end
172170

173171
it "should override default_format when spefified implicitly" do

spec/support/routes.rb

-4
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ def draw_routes
3939
get "(/sep1/:first_optional)/sep2/:second_required/sep3/:third_required(/:forth_optional)",
4040
as: :thing_deep, controller: :things, action: :show
4141

42-
if Rails.version < "5.0.0"
43-
get "/:controller(/:action(/:id))" => "classic#classic", :as => :classic
44-
end
45-
4642
get "/other_optional/(:optional_id)" => "foo#foo", :as => :foo
4743
get '/other_optional(/*optional_id)' => 'foo#foo', :as => :foo_all
4844

0 commit comments

Comments
 (0)