ts_routes 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ab317b18c9a7ffbcb0e1f3324fb6555174e6e8d1
4
+ data.tar.gz: c13f90230602915440fd2f2614c8d2fce67332ee
5
+ SHA512:
6
+ metadata.gz: 4c871c035d98d4c73a7da1657a310c0fb72fa9674eefc12b840c6053e2e6c3a8b3258ed65fb9ab2e43b2dccc6cb91688409f20cd924b6a3fe82764be5f7deb4f
7
+ data.tar.gz: 21c8012208d4d2452f0e2a9415fc349cf489a20e4a451067f22bcdf10aab88c1ee35fbb14cc1ee35593c1a8b3efe49b205a3dd693d507a3934a4f4e92f6d0426
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .idea/
11
+ node_modules/
12
+ *.js
data/.rubocop.yml ADDED
@@ -0,0 +1,20 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.3
3
+ DisplayCopNames: true
4
+ Exclude:
5
+ - tasks/**/*.*
6
+
7
+ Style:
8
+ Enabled: false
9
+
10
+ Layout:
11
+ Enabled: false
12
+
13
+ Metrics:
14
+ Enabled: false
15
+
16
+ Bundler:
17
+ Enabled: false
18
+
19
+ Performance/RedundantBlockCall:
20
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,17 @@
1
+ dist: trusty
2
+ sudo: false
3
+ language: ruby
4
+ rvm:
5
+ - "2.3"
6
+ - "2.4"
7
+
8
+ language: node_js
9
+ node_js:
10
+ - "6"
11
+
12
+ install:
13
+ - bin/setup
14
+
15
+ script:
16
+ - bundle exec rake
17
+ - bundle exec rubocop
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in ts_routes.gemspec
4
+ gemspec
5
+
6
+ gem 'rubocop'
7
+ gem 'pry'
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 FUJI Goro (gfx)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # TsRoutes for Rails [![Build Status](https://travis-ci.org/bitjourney/ts_routes-rails.svg?branch=master)](https://travis-ci.org/bitjourney/ts_routes-rails)
2
+
3
+ This gem generates Rails URL helpers in TypeScript, inspired by [js-routes](https://github.com/railsware/js-routes).
4
+
5
+
6
+ ## SYNOPSIS
7
+
8
+ In your `lib/tasks/ts_routes.rake`:
9
+
10
+ ```ruby:ts_routes.rake
11
+
12
+ namespace :ts do
13
+ TS_ROUTES_FILENAME = "javascripts/generated/RailsRoutes.ts"
14
+
15
+ desc "Generate #{TS_ROUTES_FILENAME}"
16
+ task routes: :environment do
17
+ Rails.logger.info("Generating #{TS_ROUTES_FILENAME}")
18
+ source = TsRoutes.generate(
19
+ exclude: [/admin/, /debug/],
20
+ )
21
+ File.write(TS_ROUTES_FILENAME, source)
22
+ end
23
+ end
24
+ ```
25
+
26
+ Then, execute `rake ts:routes` to generate `RailsRoutes.ts` in your favorite path.
27
+
28
+ And you can import it in TypeScript code:
29
+
30
+
31
+ ```foo.ts
32
+ import * as Routes from './generated/RailsRoutes.ts';
33
+
34
+ console.log(Routes.entriesPath({ page: 1, per: 20 })); // => /entries?page=1&per=20
35
+ console.log(Routes.entryPath(1)); // => /entries/1
36
+ ```
37
+
38
+
39
+ ## Installation
40
+
41
+ Add this line to your application's Gemfile:
42
+
43
+ ```ruby
44
+ gem 'ts_routes'
45
+ ```
46
+
47
+ And then execute:
48
+
49
+ $ bundle
50
+
51
+ Or install it yourself as:
52
+
53
+ $ gem install ts_routes
54
+
55
+ ## Usage
56
+
57
+ Generated URL helpers are almost compatible with Rails:
58
+
59
+ * You must pass required parameters to the helpers as non-named (i.e. normal) arguments
60
+ * i.e. `Routes.entryPath(1)` for `/entries/:id`
61
+ * `Routes.entryPath({ id })` is refused
62
+ * You must pass optional parameters as the last argument
63
+ * i.e. `Routes.entriesPath({ page: 1, per: 2 })`
64
+
65
+ ## Development
66
+
67
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
68
+
69
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
70
+
71
+ ## Contributing
72
+
73
+ Bug reports and pull requests are welcome on GitHub at https://github.com/bitjourney/ts_routes-rails.
74
+
75
+ ## License
76
+
77
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,25 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Bundler.setup
5
+ load "rails/tasks/routes.rake"
6
+
7
+ Rake::TestTask.new(:test) do |t|
8
+ t.libs << "test"
9
+ t.libs << "lib"
10
+ t.test_files = FileList["test/**/*_test.rb"]
11
+ end
12
+
13
+ namespace :test do
14
+ desc 'Show routes for tests'
15
+ task :routes do
16
+ Dir["#{__dir__}/test/support/**/*.rb"].sort.each { |f| require f }
17
+ require 'action_dispatch/routing/inspector'
18
+
19
+ all_routes = Rails.application.routes.routes
20
+ inspector = ActionDispatch::Routing::RoutesInspector.new(all_routes)
21
+ puts inspector.format(ActionDispatch::Routing::ConsoleFormatter.new, ENV['CONTROLLER'])
22
+ end
23
+ end
24
+
25
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ts_routes"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ require "pry"
11
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle check || bundle install
7
+ npm install
data/lib/ts_routes.rb ADDED
@@ -0,0 +1,8 @@
1
+ require_relative "./ts_routes/version"
2
+ require_relative "./ts_routes/generator"
3
+
4
+ module TsRoutes
5
+ def self.generate(**opts)
6
+ Generator.new(**opts).generate
7
+ end
8
+ end
@@ -0,0 +1,166 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails/application'
4
+
5
+ module TsRoutes
6
+ class Generator
7
+
8
+ FILTERED_DEFAULT_PARTS = [:controller, :action, :subdomain]
9
+ URL_OPTIONS = [:protocol, :domain, :host, :port, :subdomain]
10
+
11
+ DEFAULT_FILE_HEADER = "/* tslint:disable:max-line-length variable-name whitespace */"
12
+
13
+ # @return [Rails::Application]
14
+ attr_reader :application
15
+
16
+ # @return [Boolean] default to true
17
+ attr_reader :camel_case
18
+
19
+ # @return [String] default to 'path'
20
+ attr_reader :route_suffix
21
+
22
+ # @return [Array<Regexp>,nil] default to nil
23
+ attr_reader :include
24
+
25
+ # @return [Array<Regexp>,nil] default to nil
26
+ attr_reader :exclude
27
+
28
+ # @return [String]
29
+ attr_reader :header
30
+
31
+ def initialize(application: Rails.application,
32
+ camel_case: true,
33
+ route_suffix: 'path',
34
+ include: nil,
35
+ exclude: nil,
36
+ header: DEFAULT_FILE_HEADER
37
+ )
38
+ @application = application
39
+ @camel_case = camel_case
40
+ @route_suffix = route_suffix
41
+ @include = include
42
+ @exclude = exclude
43
+ @header = header
44
+ end
45
+
46
+ # @return [ActionDispatch::Routing::RouteSet]
47
+ def routes
48
+ application.routes
49
+ end
50
+
51
+ # @return [ActionDispatch::Routing::RouteSet::NamedRouteCollection]
52
+ def named_routes
53
+ routes.named_routes
54
+ end
55
+
56
+ # @return [String] TypeScript source code that represents routes.ts
57
+ def generate
58
+ functions = named_routes.flat_map do |_name, route|
59
+ build_routes_if_match(route) + mounted_app_routes(route)
60
+ end
61
+
62
+ header + "\n" + runtime_ts + "\n" + functions.join("\n")
63
+ end
64
+
65
+ # @param [ActionDispatch::Journey::Route] route
66
+ def mounted_app_routes(route)
67
+ app = route.app.respond_to?(:app) && route.app.respond_to?(:constraints) ? route.app.app : route.app
68
+
69
+ if app.respond_to?(:superclass) && app.superclass >= Rails::Engine && !route.path.anchored
70
+ app.routes.named_routes.flat_map do |_, engine_route|
71
+ build_routes_if_match(engine_route, route)
72
+ end
73
+ else
74
+ []
75
+ end
76
+ end
77
+
78
+ # @param [ActionDispatch::Journey::Route] route
79
+ # @param [ActionDispatch::Journey::Route] parent_route
80
+ # @return [Array<String>]
81
+ def build_routes_if_match(route, parent_route = nil)
82
+ return [] if exclude && any_match?(route, parent_route, exclude)
83
+ return [] if include && !any_match?(route, parent_route, include)
84
+
85
+ [build_route_function(route, parent_route)]
86
+ end
87
+
88
+ def any_match?(route, parent_route, matchers)
89
+ full_route = [parent_route&.name, route.name].compact.join('_')
90
+ matchers.any? { |pattern| full_route =~ pattern }
91
+ end
92
+
93
+ # @param [ActionDispatch::Journey::Route] route
94
+ # @param [ActionDispatch::Journey::Route] parent_route
95
+ def build_route_function(route, parent_route = nil)
96
+ name_parts = [parent_route&.name, route.name].compact
97
+ route_name = build_route_name(*name_parts, route_suffix)
98
+
99
+ required_param_declarations = route.required_parts.map do |name|
100
+ symbol = find_spec(route.path.spec, name)
101
+ "#{name}: #{symbol.left.start_with?('*') ? "ScalarType[]" : "ScalarType"}, "
102
+ end.join()
103
+ path_expr = serialize(route, route.path.spec, parent_route)
104
+
105
+ <<~TS
106
+ /** #{parent_route&.path&.spec}#{route.path.spec} */
107
+ export function #{route_name}(#{required_param_declarations}options?: object): string {
108
+ return #{path_expr} + $buildOptions(options, #{route.path.names.to_json});
109
+ }
110
+ TS
111
+ end
112
+
113
+ # @param [Array<String>] name_parts
114
+ def build_route_name(*name_parts)
115
+ route_name = name_parts.compact.join('_')
116
+ camel_case ? route_name.camelize(:lower) : route_name
117
+ end
118
+
119
+ # @return [String]
120
+ def serialize(route, spec, parent_route)
121
+ return nil unless spec
122
+ return spec.tr(':', '').to_json if spec.is_a?(String)
123
+
124
+ expr = serialize_spec(route, spec)
125
+ if parent_route
126
+ "#{serialize_spec(parent_route, parent_route.path.spec, nil)} + #{expr}"
127
+ else
128
+ expr
129
+ end
130
+ end
131
+
132
+ # @return [String]
133
+ def serialize_spec(route, spec, parent_route = nil)
134
+ case spec.type
135
+ when :CAT
136
+ "#{serialize(route, spec.left, parent_route)} + #{serialize(route, spec.right, parent_route)}"
137
+ when :GROUP
138
+ name = spec.left.find(&:symbol?).name
139
+ name_expr = serialize(route, spec.left, parent_route)
140
+ %{((options && options.hasOwnProperty(#{name.to_json})) ? #{name_expr} : "")}
141
+ when :SYMBOL
142
+ name = spec.name
143
+ route.required_parts.include?(name.to_sym) ? name : "(options as any).#{name}"
144
+ when :STAR
145
+ name = spec.left.left.sub(/^\*/, '')
146
+ %{#{name}.map((part) => encodeURIComponent("" + part)).join("/")}
147
+ when :LITERAL, :SLASH, :DOT
148
+ serialize(route, spec.left, parent_route)
149
+ else
150
+ raise "Node type #{spec.type} is not supported yet"
151
+ end
152
+ end
153
+
154
+ # @param [ActionDispatch::Journey::Nodes::Node] node
155
+ # @param [Symbol] name
156
+ def find_spec(node, name)
157
+ node.find do |n|
158
+ n.symbol? && n.name == name.to_s
159
+ end
160
+ end
161
+
162
+ def runtime_ts
163
+ File.read(File.expand_path("runtime.ts", __dir__))
164
+ end
165
+ end
166
+ end
@@ -0,0 +1,31 @@
1
+ /* This is generated by ts_routes-rails */
2
+
3
+ type ScalarType = string | number | boolean;
4
+
5
+ function $buildOptions(options: any, names: string[]): string {
6
+ if (options) {
7
+ let anchor = "";
8
+ const q = [];
9
+ for (const key of Object.keys(options)) {
10
+ if (names.indexOf(key) !== -1) {
11
+ // the key is already consumed
12
+ continue;
13
+ }
14
+
15
+ const value: ScalarType = options[ key ];
16
+
17
+ if (key === "anchor") {
18
+ anchor = "#" + encodeURIComponent("" + value);
19
+ } else if (Array.isArray(value)) {
20
+ for (const v of value as ScalarType[]) {
21
+ q.push(encodeURIComponent(key + "[]") + "=" + encodeURIComponent("" + v));
22
+ }
23
+ } else {
24
+ q.push(encodeURIComponent(key) + "=" + encodeURIComponent("" + value));
25
+ }
26
+ }
27
+ return (q.length > 0 ? "?" + q.join("&") : "") + anchor;
28
+ } else {
29
+ return "";
30
+ }
31
+ }
@@ -0,0 +1,3 @@
1
+ module TsRoutes
2
+ VERSION = "0.1.0"
3
+ end
data/package-lock.json ADDED
@@ -0,0 +1,198 @@
1
+ {
2
+ "name": "ts_routes",
3
+ "version": "1.0.0",
4
+ "lockfileVersion": 1,
5
+ "dependencies": {
6
+ "ansi-regex": {
7
+ "version": "2.1.1",
8
+ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
9
+ "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
10
+ "dev": true
11
+ },
12
+ "ansi-styles": {
13
+ "version": "2.2.1",
14
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz",
15
+ "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=",
16
+ "dev": true
17
+ },
18
+ "babel-code-frame": {
19
+ "version": "6.22.0",
20
+ "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.22.0.tgz",
21
+ "integrity": "sha1-AnYgvuVnqIwyVhV05/0IAdMxGOQ=",
22
+ "dev": true
23
+ },
24
+ "balanced-match": {
25
+ "version": "1.0.0",
26
+ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
27
+ "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
28
+ "dev": true
29
+ },
30
+ "brace-expansion": {
31
+ "version": "1.1.8",
32
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz",
33
+ "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=",
34
+ "dev": true
35
+ },
36
+ "chalk": {
37
+ "version": "1.1.3",
38
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
39
+ "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
40
+ "dev": true
41
+ },
42
+ "colors": {
43
+ "version": "1.1.2",
44
+ "resolved": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz",
45
+ "integrity": "sha1-FopHAXVran9RoSzgyXv6KMCE7WM=",
46
+ "dev": true
47
+ },
48
+ "commander": {
49
+ "version": "2.9.0",
50
+ "resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz",
51
+ "integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=",
52
+ "dev": true
53
+ },
54
+ "concat-map": {
55
+ "version": "0.0.1",
56
+ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
57
+ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
58
+ "dev": true
59
+ },
60
+ "diff": {
61
+ "version": "3.2.0",
62
+ "resolved": "https://registry.npmjs.org/diff/-/diff-3.2.0.tgz",
63
+ "integrity": "sha1-yc45Okt8vQsFinJck98pkCeGj/k=",
64
+ "dev": true
65
+ },
66
+ "escape-string-regexp": {
67
+ "version": "1.0.5",
68
+ "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
69
+ "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=",
70
+ "dev": true
71
+ },
72
+ "esutils": {
73
+ "version": "2.0.2",
74
+ "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz",
75
+ "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=",
76
+ "dev": true
77
+ },
78
+ "fs.realpath": {
79
+ "version": "1.0.0",
80
+ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
81
+ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
82
+ "dev": true
83
+ },
84
+ "glob": {
85
+ "version": "7.1.2",
86
+ "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
87
+ "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
88
+ "dev": true
89
+ },
90
+ "graceful-readlink": {
91
+ "version": "1.0.1",
92
+ "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz",
93
+ "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=",
94
+ "dev": true
95
+ },
96
+ "has-ansi": {
97
+ "version": "2.0.0",
98
+ "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz",
99
+ "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=",
100
+ "dev": true
101
+ },
102
+ "inflight": {
103
+ "version": "1.0.6",
104
+ "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
105
+ "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
106
+ "dev": true
107
+ },
108
+ "inherits": {
109
+ "version": "2.0.3",
110
+ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
111
+ "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
112
+ "dev": true
113
+ },
114
+ "js-tokens": {
115
+ "version": "3.0.1",
116
+ "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.1.tgz",
117
+ "integrity": "sha1-COnxMkhKLEWjCQfp3E1VZ7fxFNc=",
118
+ "dev": true
119
+ },
120
+ "minimatch": {
121
+ "version": "3.0.4",
122
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
123
+ "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
124
+ "dev": true
125
+ },
126
+ "once": {
127
+ "version": "1.4.0",
128
+ "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
129
+ "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
130
+ "dev": true
131
+ },
132
+ "path-is-absolute": {
133
+ "version": "1.0.1",
134
+ "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
135
+ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
136
+ "dev": true
137
+ },
138
+ "path-parse": {
139
+ "version": "1.0.5",
140
+ "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz",
141
+ "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=",
142
+ "dev": true
143
+ },
144
+ "resolve": {
145
+ "version": "1.3.3",
146
+ "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.3.3.tgz",
147
+ "integrity": "sha1-ZVkHw0aahoDcLeOidaj91paR8OU=",
148
+ "dev": true
149
+ },
150
+ "semver": {
151
+ "version": "5.3.0",
152
+ "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz",
153
+ "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=",
154
+ "dev": true
155
+ },
156
+ "strip-ansi": {
157
+ "version": "3.0.1",
158
+ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
159
+ "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
160
+ "dev": true
161
+ },
162
+ "supports-color": {
163
+ "version": "2.0.0",
164
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz",
165
+ "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=",
166
+ "dev": true
167
+ },
168
+ "tslib": {
169
+ "version": "1.7.1",
170
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.7.1.tgz",
171
+ "integrity": "sha1-vIAEFkaRkjp5/oN4u+s9ogF1OOw=",
172
+ "dev": true
173
+ },
174
+ "tslint": {
175
+ "version": "5.4.3",
176
+ "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.4.3.tgz",
177
+ "integrity": "sha1-dhyEArgONHt3M6BDkKdXslNYBGc=",
178
+ "dev": true
179
+ },
180
+ "tsutils": {
181
+ "version": "2.4.0",
182
+ "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.4.0.tgz",
183
+ "integrity": "sha1-rUzm26Dlo+2934Ymt8oEB4IYn+o=",
184
+ "dev": true
185
+ },
186
+ "typescript": {
187
+ "version": "2.4.0",
188
+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.4.0.tgz",
189
+ "integrity": "sha1-rvWo1AS+ujatM5q/B53d3/+6ht0="
190
+ },
191
+ "wrappy": {
192
+ "version": "1.0.2",
193
+ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
194
+ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
195
+ "dev": true
196
+ }
197
+ }
198
+ }
data/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "ts_routes",
3
+ "version": "1.0.0",
4
+ "description": "ts_routes-rails JavaScript runtime",
5
+ "main": "index.js",
6
+ "directories": {
7
+ "lib": "lib",
8
+ "test": "test"
9
+ },
10
+ "dependencies": {
11
+ "typescript": "^2.4.0"
12
+ },
13
+ "devDependencies": {
14
+ "tslint": "*"
15
+ },
16
+ "scripts": {
17
+ "test": "echo \"Error: no test specified\" && exit 1"
18
+ },
19
+ "repository": "https://github.com/bitjourney/ts_routes-rails",
20
+ "author": "FUJI Goro",
21
+ "license": "MIT"
22
+ }
data/ts_routes.gemspec ADDED
@@ -0,0 +1,34 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "ts_routes/version"
5
+
6
+ Gem::Specification.new do
7
+ # @type [Gem::Specification] spec
8
+ |spec|
9
+
10
+ spec.name = "ts_routes"
11
+ spec.version = TsRoutes::VERSION
12
+ spec.authors = ["FUJI Goro (gfx)"]
13
+ spec.email = ["gfuji@cpan.org"]
14
+
15
+ spec.summary = %q{Rails routing helpers for TypeScript}
16
+ spec.description = %q{Rails routing helpers for TypeScript, inspired by js-routes (https://github.com/railsware/js-routes)}
17
+ spec.homepage = "https://github.com/bitjourney/ts_routes-rails"
18
+ spec.license = "MIT"
19
+
20
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
21
+ f.match(%r{^(test|spec|features)/})
22
+ end
23
+ spec.bindir = "exe"
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ["lib"]
26
+
27
+ spec.required_ruby_version = ">= 2.3.0"
28
+
29
+ spec.add_runtime_dependency "railties", "~> 5.0"
30
+
31
+ spec.add_development_dependency "bundler", "~> 1.15"
32
+ spec.add_development_dependency "rake", "~> 12.0"
33
+ spec.add_development_dependency "minitest", "~> 5.0"
34
+ end
data/tslint.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": [
3
+ "tslint:recommended"
4
+ ],
5
+ "defaultSeverity": "error"
6
+ }
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ts_routes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - FUJI Goro (gfx)
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-06-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '5.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '5.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.15'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.15'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '12.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '12.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '5.0'
69
+ description: Rails routing helpers for TypeScript, inspired by js-routes (https://github.com/railsware/js-routes)
70
+ email:
71
+ - gfuji@cpan.org
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rubocop.yml"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - bin/console
84
+ - bin/setup
85
+ - lib/ts_routes.rb
86
+ - lib/ts_routes/generator.rb
87
+ - lib/ts_routes/runtime.ts
88
+ - lib/ts_routes/version.rb
89
+ - package-lock.json
90
+ - package.json
91
+ - ts_routes.gemspec
92
+ - tslint.json
93
+ homepage: https://github.com/bitjourney/ts_routes-rails
94
+ licenses:
95
+ - MIT
96
+ metadata: {}
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: 2.3.0
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubyforge_project:
113
+ rubygems_version: 2.6.10
114
+ signing_key:
115
+ specification_version: 4
116
+ summary: Rails routing helpers for TypeScript
117
+ test_files: []