js_routes_watcher 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Guardfile +20 -0
- data/MIT-LICENSE +20 -0
- data/Procfile +5 -0
- data/README.md +54 -0
- data/Rakefile +32 -0
- data/lib/js_routes_watcher/engine.rb +5 -0
- data/lib/js_routes_watcher/version.rb +3 -0
- data/lib/js_routes_watcher.rb +5 -0
- data/lib/tasks/js_routes_watcher_tasks.rake +8 -0
- metadata +124 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4d5640a23ab6258d66842baf221d11ea9e4f618af4bd36697d15bd0c306895db
|
4
|
+
data.tar.gz: 818a72e79e16ff165bf70caf31259dd982dcd726fe4e61f808948e2590595d15
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 19262d7208e113d6b296fbc07fb01ec5097229c1f3d7265aa254ddd9f45d4503352a280ceb058c96162a8448fdddc7860dbb5247f0505808ebb544c8036d694d
|
7
|
+
data.tar.gz: f6ad50439df37fa4efaab8bd4d5c6f7af9f0b616778cfab43353775fd10902ce674a62c4bcfdbf19b316e55d7ecf25cb946a1d91c915467eca309c1a657b9328
|
data/Guardfile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(app lib config test spec features) \
|
6
|
+
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
7
|
+
|
8
|
+
## Note: if you are using the `directories` clause above and you are not
|
9
|
+
## watching the project directory ('.'), then you will want to move
|
10
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
11
|
+
#
|
12
|
+
# $ mkdir config
|
13
|
+
# $ mv Guardfile config/
|
14
|
+
# $ ln -s config/Guardfile .
|
15
|
+
#
|
16
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
17
|
+
|
18
|
+
guard 'rake', :task => 'js_routes_watcher:generate' do
|
19
|
+
watch(%r{^config/routes.rb})
|
20
|
+
end
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2018 Dmitriy Beliaev
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Procfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# JsRoutesWatcher
|
2
|
+
Plugin for *Ruby on Rails* which utilise [js-routes](https://github.com/railsware/js-routes) gem to work with **webpacker**.
|
3
|
+
|
4
|
+
Using modern JS-frameworks such as **Vue** or **React**, you have to move all rails-generated routes to javascript.
|
5
|
+
Then you'll be able to do this:
|
6
|
+
```javascript
|
7
|
+
const login_path = Routes.api_login_path()
|
8
|
+
```
|
9
|
+
|
10
|
+
[js-routes](https://github.com/railsware/js-routes) gem gives you the ability to export rails routes to standalone js-file.
|
11
|
+
|
12
|
+
But how to do this automatically? There's gem you're watching on comes to play.
|
13
|
+
|
14
|
+
Every time when `config/routes.rb` is updated `Guard` task will regenerate `app/javascript/packs/routes.js` file. And all you have to do – is to import it in your project js-packs.
|
15
|
+
```javascript
|
16
|
+
import './routes.js'
|
17
|
+
// Then
|
18
|
+
Routes.api_login_path()
|
19
|
+
```
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
## Installation
|
24
|
+
All you need to start using plugin is to:
|
25
|
+
|
26
|
+
1. Install gem.
|
27
|
+
Add this line to your application's Gemfile:
|
28
|
+
```ruby
|
29
|
+
gem 'js_routes_watcher', github: "codemotion/js_routes_watcher"
|
30
|
+
```
|
31
|
+
And then execute:
|
32
|
+
```bash
|
33
|
+
$ bundle
|
34
|
+
```
|
35
|
+
2. Create `Guardfile` in the root of the project and fill it with:
|
36
|
+
```ruby
|
37
|
+
guard 'rake', :task => 'js_routes_watcher:generate' do
|
38
|
+
watch(%r{^config/routes.rb})
|
39
|
+
end
|
40
|
+
```
|
41
|
+
And then save file.
|
42
|
+
|
43
|
+
3. Be shure what you're using **webpacker** gem and starting it with [Foreman](https://github.com/ddollar/foreman) or [Overmind](https://github.com/DarthSim/overmind).
|
44
|
+
|
45
|
+
4. `Procfile` must have the following line to start `Guard` task in background:
|
46
|
+
```
|
47
|
+
guard: bundle exec guard
|
48
|
+
```
|
49
|
+
|
50
|
+
## Contributing
|
51
|
+
You're free to contribute via pull requests.
|
52
|
+
|
53
|
+
## License
|
54
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'JsRoutesWatcher'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
load 'rails/tasks/statistics.rake'
|
21
|
+
|
22
|
+
require 'bundler/gem_tasks'
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'test'
|
28
|
+
t.pattern = 'test/**/*_test.rb'
|
29
|
+
t.verbose = false
|
30
|
+
end
|
31
|
+
|
32
|
+
task default: :test
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: js_routes_watcher
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dmitriy Beliaev
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-06-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 5.2.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.2.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: js-routes
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: guard
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: webpacker
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard-rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Creating a Guard task to auto-regenerate app/javascript/packs/routes.js
|
84
|
+
file when config/routes.rb is updated.
|
85
|
+
email:
|
86
|
+
- admin@cogear.ru
|
87
|
+
executables: []
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- Guardfile
|
92
|
+
- MIT-LICENSE
|
93
|
+
- Procfile
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- lib/js_routes_watcher.rb
|
97
|
+
- lib/js_routes_watcher/engine.rb
|
98
|
+
- lib/js_routes_watcher/version.rb
|
99
|
+
- lib/tasks/js_routes_watcher_tasks.rake
|
100
|
+
homepage: https://github.com/codemotion/js_routes_watcher
|
101
|
+
licenses:
|
102
|
+
- MIT
|
103
|
+
metadata: {}
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options: []
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
requirements: []
|
119
|
+
rubyforge_project:
|
120
|
+
rubygems_version: 2.7.6
|
121
|
+
signing_key:
|
122
|
+
specification_version: 4
|
123
|
+
summary: Plugin for Ruby on Rails which utilise js-routes gem to work with webpacker.
|
124
|
+
test_files: []
|