flatten_routes 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +189 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/flatten_routes.gemspec +26 -0
- data/lib/flatten_routes/version.rb +3 -0
- data/lib/flatten_routes.rb +64 -0
- data/lib/tasks/flatten_routes.rake +49 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7e3e904496ba4058af2d181e7336acc9351f7cd4
|
4
|
+
data.tar.gz: e6996d5eb5bed9ee50662b02410ac2fb6821a7c6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6ca17a1184bb4920a82fed08a45c8bd1f8f12d2ee6ce621e1152d47b7ce15a0c573f118faebc5f67ab769b8a192c263233f5c60b83312fc5ef5ed5b5727c1fde
|
7
|
+
data.tar.gz: ba00f51a07651f6fe5b9afe37b6dac42374729f2560be8f44df7244f3e26b1f37c1771711fdbec5ab0cbf378fab0622103d648da032972edf72d767f836fc515
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at nserihiro@gmail.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Kazuhiro Serizawa
|
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,189 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/serihiro/flatten_routes.svg?branch=master)](https://travis-ci.org/serihiro/flatten_routes)
|
2
|
+
|
3
|
+
# FlattenRoutes
|
4
|
+
|
5
|
+
Convert the routes.rb to not using resource style.
|
6
|
+
This gem provides 2 rake tasks.
|
7
|
+
|
8
|
+
```
|
9
|
+
rake flatten_routes:annotate # Annotate routes.rb
|
10
|
+
rake flatten_routes:convert # Convert routes.rb to not using resource style
|
11
|
+
```
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'flatten_routes'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
$ bundle
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
$ gem install flatten_routes
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
### Convert your routes.rb.
|
32
|
+
|
33
|
+
Execute the following command in your Rails.root.
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
$ rake flatten_routes:convert
|
37
|
+
```
|
38
|
+
|
39
|
+
If routes.rb is like this,
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
Rails.application.routes.draw do
|
43
|
+
ActiveAdmin.routes(self)
|
44
|
+
resources :todos, except: [:new, :edit] do
|
45
|
+
member do
|
46
|
+
post :start
|
47
|
+
post :finish
|
48
|
+
post :restart
|
49
|
+
post :giveup
|
50
|
+
put :awesome
|
51
|
+
end
|
52
|
+
collection do
|
53
|
+
get :finished
|
54
|
+
get :not_yet
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
```
|
59
|
+
|
60
|
+
then your routes.rb will become like this.
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
Rails.application.routes.draw do
|
64
|
+
# == generated by flatten_routes from here 2016-02-27 17:53:37 +0900
|
65
|
+
get '/admin' => 'admin/dashboard#index'
|
66
|
+
get '/admin/dashboard' => 'admin/dashboard#index'
|
67
|
+
post '/admin/todos/batch_action' => 'admin/todos#batch_action'
|
68
|
+
get '/admin/todos' => 'admin/todos#index'
|
69
|
+
post '/admin/todos' => 'admin/todos#create'
|
70
|
+
get '/admin/todos/new' => 'admin/todos#new'
|
71
|
+
get '/admin/todos/:id/edit' => 'admin/todos#edit'
|
72
|
+
get '/admin/todos/:id' => 'admin/todos#show'
|
73
|
+
patch '/admin/todos/:id' => 'admin/todos#update'
|
74
|
+
put '/admin/todos/:id' => 'admin/todos#update'
|
75
|
+
delete '/admin/todos/:id' => 'admin/todos#destroy'
|
76
|
+
get '/admin/comments' => 'admin/comments#index'
|
77
|
+
post '/admin/comments' => 'admin/comments#create'
|
78
|
+
get '/admin/comments/:id' => 'admin/comments#show'
|
79
|
+
delete '/admin/comments/:id' => 'admin/comments#destroy'
|
80
|
+
post '/todos/:id/start' => 'todos#start'
|
81
|
+
post '/todos/:id/finish' => 'todos#finish'
|
82
|
+
post '/todos/:id/restart' => 'todos#restart'
|
83
|
+
post '/todos/:id/giveup' => 'todos#giveup'
|
84
|
+
put '/todos/:id/awesome' => 'todos#awesome'
|
85
|
+
get '/todos/finished' => 'todos#finished'
|
86
|
+
get '/todos/not_yet' => 'todos#not_yet'
|
87
|
+
get '/todos' => 'todos#index'
|
88
|
+
post '/todos' => 'todos#create'
|
89
|
+
get '/todos/:id' => 'todos#show'
|
90
|
+
patch '/todos/:id' => 'todos#update'
|
91
|
+
put '/todos/:id' => 'todos#update'
|
92
|
+
delete '/todos/:id' => 'todos#destroy'
|
93
|
+
# == generated by flatten_routes to here
|
94
|
+
# ActiveAdmin.routes(self)
|
95
|
+
# resources :todos, except: [:new, :edit] do
|
96
|
+
# member do
|
97
|
+
# post :start
|
98
|
+
# post :finish
|
99
|
+
# post :restart
|
100
|
+
# post :giveup
|
101
|
+
# put :awesome
|
102
|
+
# end
|
103
|
+
# collection do
|
104
|
+
# get :finished
|
105
|
+
# get :not_yet
|
106
|
+
# end
|
107
|
+
# end
|
108
|
+
```
|
109
|
+
|
110
|
+
### Annotate your routes.rb with simple style routes definitions as comment.
|
111
|
+
|
112
|
+
Execute the following command in your Rails.root.
|
113
|
+
|
114
|
+
```ruby
|
115
|
+
$ rake flatten_routes:annotate
|
116
|
+
```
|
117
|
+
|
118
|
+
```ruby
|
119
|
+
Rails.application.routes.draw do
|
120
|
+
# == generated by flatten_routes from here 2016-02-27 17:56:31 +0900
|
121
|
+
# get '/admin' => 'admin/dashboard#index'
|
122
|
+
# get '/admin/dashboard' => 'admin/dashboard#index'
|
123
|
+
# post '/admin/todos/batch_action' => 'admin/todos#batch_action'
|
124
|
+
# get '/admin/todos' => 'admin/todos#index'
|
125
|
+
# post '/admin/todos' => 'admin/todos#create'
|
126
|
+
# get '/admin/todos/new' => 'admin/todos#new'
|
127
|
+
# get '/admin/todos/:id/edit' => 'admin/todos#edit'
|
128
|
+
# get '/admin/todos/:id' => 'admin/todos#show'
|
129
|
+
# patch '/admin/todos/:id' => 'admin/todos#update'
|
130
|
+
# put '/admin/todos/:id' => 'admin/todos#update'
|
131
|
+
# delete '/admin/todos/:id' => 'admin/todos#destroy'
|
132
|
+
# get '/admin/comments' => 'admin/comments#index'
|
133
|
+
# post '/admin/comments' => 'admin/comments#create'
|
134
|
+
# get '/admin/comments/:id' => 'admin/comments#show'
|
135
|
+
# delete '/admin/comments/:id' => 'admin/comments#destroy'
|
136
|
+
# post '/todos/:id/start' => 'todos#start'
|
137
|
+
# post '/todos/:id/finish' => 'todos#finish'
|
138
|
+
# post '/todos/:id/restart' => 'todos#restart'
|
139
|
+
# post '/todos/:id/giveup' => 'todos#giveup'
|
140
|
+
# put '/todos/:id/awesome' => 'todos#awesome'
|
141
|
+
# get '/todos/finished' => 'todos#finished'
|
142
|
+
# get '/todos/not_yet' => 'todos#not_yet'
|
143
|
+
# get '/todos' => 'todos#index'
|
144
|
+
# post '/todos' => 'todos#create'
|
145
|
+
# get '/todos/:id' => 'todos#show'
|
146
|
+
# patch '/todos/:id' => 'todos#update'
|
147
|
+
# put '/todos/:id' => 'todos#update'
|
148
|
+
# delete '/todos/:id' => 'todos#destroy'
|
149
|
+
# == generated by flatten_routes to here
|
150
|
+
ActiveAdmin.routes(self)
|
151
|
+
resources :todos, except: [:new, :edit] do
|
152
|
+
member do
|
153
|
+
post :start
|
154
|
+
post :finish
|
155
|
+
post :restart
|
156
|
+
post :giveup
|
157
|
+
put :awesome
|
158
|
+
end
|
159
|
+
collection do
|
160
|
+
get :finished
|
161
|
+
get :not_yet
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
```
|
166
|
+
|
167
|
+
## Note
|
168
|
+
* If you update annotated comments, just execute `$ rake flatten_routes:convert` again.
|
169
|
+
|
170
|
+
|
171
|
+
## Dependency
|
172
|
+
* Rails '>= 4.0.0', '< 4.2'
|
173
|
+
* I do not confirm that this gem works in rails5.x yet...
|
174
|
+
|
175
|
+
## Development
|
176
|
+
|
177
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
178
|
+
|
179
|
+
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).
|
180
|
+
|
181
|
+
## Contributing
|
182
|
+
|
183
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/flatten_routes. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
184
|
+
|
185
|
+
|
186
|
+
## License
|
187
|
+
|
188
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
189
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "flatten_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
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'flatten_routes/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'flatten_routes'
|
8
|
+
spec.version = FlattenRoutes::VERSION
|
9
|
+
spec.authors = ['Kazuhiro Serizawa']
|
10
|
+
spec.email = ['nserihiro@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = %q{Convert the routes.rb to not using resource style.}
|
13
|
+
spec.description = %q{Convert the routes.rb to not using resource style.}
|
14
|
+
spec.homepage = 'https://github.com/serihiro/flatten_routes'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.11'
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
25
|
+
spec.add_development_dependency 'actionpack', '~> 4.2.0'
|
26
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'flatten_routes/version'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rake'
|
4
|
+
require 'action_dispatch/routing/inspector'
|
5
|
+
|
6
|
+
module FlattenRoutes
|
7
|
+
Dir[File.join(File.dirname(__FILE__), 'tasks', '**/*.rake')].each { |rake| load rake }
|
8
|
+
|
9
|
+
class Util
|
10
|
+
ROUTES_CONTENT_PATTERN = %r{(routes.draw do\r?\n)(.*?)(\r?\nend)}m
|
11
|
+
MAGIC_COMMENT_START_CONTENT = '# == generated by flatten_routes from here'.freeze
|
12
|
+
MAGIC_COMMENT_END_CONTENT = '# == generated by flatten_routes to here'.freeze
|
13
|
+
MAGIC_COMMENT_QUOTED_PATTERN = %r{(# == generated by flatten_routes from here)(.*?)(# == generated by flatten_routes to here\r?\n)}m
|
14
|
+
|
15
|
+
class << self
|
16
|
+
def routes_from_rails_application
|
17
|
+
all_routes = Rails.application.routes.routes
|
18
|
+
inspector = ActionDispatch::Routing::RoutesInspector.new(all_routes)
|
19
|
+
inspector.send(:collect_routes, all_routes)
|
20
|
+
end
|
21
|
+
|
22
|
+
SEPARATOR = '=>'.freeze
|
23
|
+
|
24
|
+
def format_routes(routes)
|
25
|
+
routes.map! do |route|
|
26
|
+
{
|
27
|
+
verb: route[:verb].downcase,
|
28
|
+
path: route[:path].gsub(%r{\(\.:format\)},'').gsub(%r{[\w\/:]+}, '\'\&\''),
|
29
|
+
reqs: route[:reqs].gsub(%r{[\w\/#]+}, '\'\&\'')
|
30
|
+
}
|
31
|
+
end
|
32
|
+
verb_length, path_length = %i(verb path).map do |key|
|
33
|
+
routes.map { |route| route[key].length }.max || 0
|
34
|
+
end
|
35
|
+
line = []
|
36
|
+
new_routes = []
|
37
|
+
routes.each do |routes|
|
38
|
+
line.clear
|
39
|
+
line << routes[:verb].ljust(verb_length)
|
40
|
+
line << routes[:path].ljust(path_length)
|
41
|
+
line << SEPARATOR
|
42
|
+
line << routes[:reqs]
|
43
|
+
new_routes << (' ' << line.join(' '))
|
44
|
+
end
|
45
|
+
|
46
|
+
new_routes
|
47
|
+
end
|
48
|
+
|
49
|
+
def add_magic_comment(content, time = Time.now)
|
50
|
+
"#{MAGIC_COMMENT_START_CONTENT} #{time}\n#{content}\n#{MAGIC_COMMENT_END_CONTENT}\n"
|
51
|
+
end
|
52
|
+
|
53
|
+
def delete_flatten_routes_definition(content)
|
54
|
+
content.gsub(MAGIC_COMMENT_QUOTED_PATTERN, '')
|
55
|
+
end
|
56
|
+
|
57
|
+
def commentize(contents)
|
58
|
+
return contents if contents.size < 1
|
59
|
+
|
60
|
+
contents.map { |content| "##{content}" }
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'flatten_routes'
|
2
|
+
|
3
|
+
namespace :flatten_routes do
|
4
|
+
desc 'Convert routes.rb to not using resource style. The original routes definitions will remain as comment.'
|
5
|
+
task convert: :environment do
|
6
|
+
routes = FlattenRoutes::Util.routes_from_rails_application
|
7
|
+
new_routes_definition = FlattenRoutes::Util.format_routes(routes)
|
8
|
+
new_routes_definition = FlattenRoutes::Util.add_magic_comment(new_routes_definition.join("\n"))
|
9
|
+
|
10
|
+
file_name = File.join(Rails.root, 'config', 'routes.rb')
|
11
|
+
original_content = File.read(file_name)
|
12
|
+
|
13
|
+
matched = FlattenRoutes::Util::ROUTES_CONTENT_PATTERN.match(original_content)
|
14
|
+
exit unless matched
|
15
|
+
|
16
|
+
original_routes_definition = matched[2]
|
17
|
+
# delete old generated routes definition by flatten_routes
|
18
|
+
original_routes_definition = FlattenRoutes::Util.delete_flatten_routes_definition(original_routes_definition)
|
19
|
+
|
20
|
+
# comment out original definition
|
21
|
+
original_routes_definition = original_routes_definition.split("\n").map do
|
22
|
+
|line| %r{(^#|^\s*?#)}.match(line) ? line : "##{line}"
|
23
|
+
end.join("\n")
|
24
|
+
new_content = original_content.gsub(FlattenRoutes::Util::ROUTES_CONTENT_PATTERN,
|
25
|
+
"\\1#{new_routes_definition + original_routes_definition}\\3")
|
26
|
+
File.open(file_name, 'wb') { |f| f.puts(new_content) }
|
27
|
+
end
|
28
|
+
|
29
|
+
desc 'Annotate routes.rb'
|
30
|
+
task annotate: :environment do
|
31
|
+
routes = FlattenRoutes::Util.routes_from_rails_application
|
32
|
+
new_routes_definition = FlattenRoutes::Util.format_routes(routes)
|
33
|
+
new_routes_definition = FlattenRoutes::Util.commentize(new_routes_definition)
|
34
|
+
new_routes_definition = FlattenRoutes::Util.add_magic_comment(new_routes_definition.join("\n"))
|
35
|
+
|
36
|
+
file_name = File.join(Rails.root, 'config', 'routes.rb')
|
37
|
+
original_content = File.read(file_name)
|
38
|
+
|
39
|
+
matched = FlattenRoutes::Util::ROUTES_CONTENT_PATTERN.match(original_content)
|
40
|
+
exit unless matched
|
41
|
+
|
42
|
+
original_routes_definition = matched[2]
|
43
|
+
# delete old generated routes definition by flatten_routes
|
44
|
+
original_routes_definition = FlattenRoutes::Util.delete_flatten_routes_definition(original_routes_definition)
|
45
|
+
new_content = original_content.gsub(FlattenRoutes::Util::ROUTES_CONTENT_PATTERN,
|
46
|
+
"\\1#{new_routes_definition + original_routes_definition}\\3")
|
47
|
+
File.open(file_name, 'wb') { |f| f.puts(new_content) }
|
48
|
+
end
|
49
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: flatten_routes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kazuhiro Serizawa
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: actionpack
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 4.2.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 4.2.0
|
69
|
+
description: Convert the routes.rb to not using resource style.
|
70
|
+
email:
|
71
|
+
- nserihiro@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- CODE_OF_CONDUCT.md
|
80
|
+
- Gemfile
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- bin/console
|
85
|
+
- bin/setup
|
86
|
+
- flatten_routes.gemspec
|
87
|
+
- lib/flatten_routes.rb
|
88
|
+
- lib/flatten_routes/version.rb
|
89
|
+
- lib/tasks/flatten_routes.rake
|
90
|
+
homepage: https://github.com/serihiro/flatten_routes
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 2.4.5.1
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: Convert the routes.rb to not using resource style.
|
114
|
+
test_files: []
|