split_routes 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f1630f30fea60ed2184cd5e441b26d57adc03fd6
4
+ data.tar.gz: 7081fb58dc340eb38cc9e3237a8ec0c321af7cb1
5
+ SHA512:
6
+ metadata.gz: 3cb7cd649b83c4d10852b259fca613a09e3cc265accf3ffe61b69f61c085be2525e9b3dcb337b494b80604e18058660ffcc3919707f38b546a5b25dae302573e
7
+ data.tar.gz: 3104b99912acc93ee8c19709dfdf94bff57188cc558f9224aab23b3d8c9ec76669aee9b6131e6b661fa43fd6249d3b25a440d456869d5aaf238c760c1146fc38
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2018 mars
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/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # SplitRoutes
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'split_routes', github: 'rails-gems/split_routes'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install split_routes
22
+ ```
23
+
24
+ ### 创建`Split Route File`
25
+
26
+ ```
27
+ $ rails g split_routes admin
28
+ ```
29
+
30
+ ## Contributing
31
+ Contribution directions go here.
32
+
33
+ ## License
34
+ 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,33 @@
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 = 'SplitRoutes'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+
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
+
33
+ task default: :test
@@ -0,0 +1,11 @@
1
+ class ActionDispatch::Routing::Mapper
2
+ # def draw(routes_name)
3
+ # instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
4
+ # end
5
+
6
+ def draw_routes
7
+ Dir.glob("#{Rails.root}/config/routes/**/*.rb").each do |route|
8
+ instance_eval(File.read(route))
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ # rails g split_routes admin
2
+ class SplitRoutesGenerator < Rails::Generators::NamedBase # :nodoc:
3
+ source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
4
+
5
+ desc "Copy route file template to application config/routes directory"
6
+ def copy_initialize_file
7
+ template 'route.rb', "config/routes/#{file_name}.rb"
8
+ end
9
+ end
@@ -0,0 +1,4 @@
1
+ # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
2
+ # defaults format: :json do
3
+ # resources :anyname
4
+ # end
@@ -0,0 +1,6 @@
1
+ require 'action_dipatch/routing/mapper'# if defined? Rails
2
+ require 'split_routes/reloader'
3
+ require 'split_routes/railtie'# if defined? Rails
4
+ module SplitRoutes
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,11 @@
1
+ module SplitRoutes
2
+ class Railtie < Rails::Railtie
3
+ initializer "split_routes.configure_rails_initialization" do |app|
4
+ # some initialization behavior
5
+ app.middleware.use SplitRoutes::Reloader if Rails.env.development?
6
+ app.routes.prepend do
7
+ draw_routes
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,16 @@
1
+ module SplitRoutes
2
+ class Reloader
3
+ def initialize(app)
4
+ @app = app
5
+
6
+ @routes_reloader = ActiveSupport::FileUpdateChecker.new([], 'config/routes' => 'rb') do
7
+ Rails.application.reload_routes!
8
+ end
9
+ end
10
+
11
+ def call(env)
12
+ @routes_reloader.execute_if_updated
13
+ @app.call(env)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,3 @@
1
+ module SplitRoutes
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :split_routes do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: split_routes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - mars
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-09-04 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: '6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "<"
25
+ - !ruby/object:Gem::Version
26
+ version: '6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sqlite3
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Split Routes to More Files
42
+ email:
43
+ - 578595193@qq.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - MIT-LICENSE
49
+ - README.md
50
+ - Rakefile
51
+ - lib/action_dipatch/routing/mapper.rb
52
+ - lib/generators/split_routes_generator.rb
53
+ - lib/generators/templates/route.rb
54
+ - lib/split_routes.rb
55
+ - lib/split_routes/railtie.rb
56
+ - lib/split_routes/reloader.rb
57
+ - lib/split_routes/version.rb
58
+ - lib/tasks/split_routes_tasks.rake
59
+ homepage: https://github.com/wuyuedefeng/SplitRoutes
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.6.13
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: SplitRoutes.
83
+ test_files: []