middleware-cli 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 +8 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +28 -0
- data/LICENSE.txt +21 -0
- data/README.md +121 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/middleware-cli +5 -0
- data/lib/.DS_Store +0 -0
- data/lib/middleware-cli/.DS_Store +0 -0
- data/lib/middleware-cli/app.rb +49 -0
- data/lib/middleware-cli/extract_middleware.rb +93 -0
- data/lib/middleware-cli/formatter.rb +57 -0
- data/lib/middleware-cli/list.rb +24 -0
- data/lib/middleware-cli/version.rb +3 -0
- data/lib/middleware-cli.rb +30 -0
- data/middleware-cli.gemspec +40 -0
- metadata +136 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 94ffbe4464797b2bf80bc6abf6e33a8ce58e31e5
|
4
|
+
data.tar.gz: c33ce47f2a5105212166e44b328fc662ba5367eb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e36e845c65158e77de8a83046ff7c7159c20e76ec5f6176ffe760cacc3f3a1d6a39410ffbf71bae1cc01c71f542e7d99920455fbe4fb627d33cb87518c70bc5e
|
7
|
+
data.tar.gz: bc4154abe4c13e633940f5f14c65129741adb847bada4b7c278ede1b77559689e51c22b1b79ac75fbbc1d871dbde8e3138cc259c2b1fda905142764df8f22c0b
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at vikasvr23@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
middleware-cli (0.1.0)
|
5
|
+
terminal-table
|
6
|
+
thor (~> 0.20)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
minitest (5.11.3)
|
12
|
+
rake (10.5.0)
|
13
|
+
terminal-table (1.8.0)
|
14
|
+
unicode-display_width (~> 1.1, >= 1.1.1)
|
15
|
+
thor (0.20.3)
|
16
|
+
unicode-display_width (1.4.0)
|
17
|
+
|
18
|
+
PLATFORMS
|
19
|
+
ruby
|
20
|
+
|
21
|
+
DEPENDENCIES
|
22
|
+
bundler (~> 1.16)
|
23
|
+
middleware-cli!
|
24
|
+
minitest (~> 5.0)
|
25
|
+
rake (~> 10.0)
|
26
|
+
|
27
|
+
BUNDLED WITH
|
28
|
+
1.16.6
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Vikas Verma
|
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,121 @@
|
|
1
|
+
# Middleware CLI
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'middleware-cli', group: :development
|
9
|
+
```
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install middleware-cli
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
To get all the options type:
|
22
|
+
```ruby
|
23
|
+
$ bundle exec middleware-cli
|
24
|
+
```
|
25
|
+
|
26
|
+
To list all your middlewares type:
|
27
|
+
```ruby
|
28
|
+
$ bundle exec middleware-cli list
|
29
|
+
```
|
30
|
+
which will list all your middlewares:
|
31
|
+
```
|
32
|
+
+-------+--------------------------------------------------------+
|
33
|
+
| S/n | Middleware Name |
|
34
|
+
+-------+--------------------------------------------------------+
|
35
|
+
| 1 | Rack::Sendfile |
|
36
|
+
| 2 | ActionDispatch::Static |
|
37
|
+
| 3 | ActionDispatch::Executor |
|
38
|
+
| 4 | ActiveSupport::Cache::Strategy::LocalCache::Middleware |
|
39
|
+
| 5 | Rack::Runtime |
|
40
|
+
| 6 | Rack::MethodOverride |
|
41
|
+
| 7 | ActionDispatch::RequestId |
|
42
|
+
| 8 | ActionDispatch::RemoteIp |
|
43
|
+
| 9 | Sprockets::Rails::QuietAssets |
|
44
|
+
| 10 | Rails::Rack::Logger |
|
45
|
+
| 11 | ActionDispatch::ShowExceptions |
|
46
|
+
| 12 | WebConsole::Middleware |
|
47
|
+
| 13 | ActionDispatch::DebugExceptions |
|
48
|
+
| 14 | Airbrake::Rack::Middleware |
|
49
|
+
| 15 | ActionDispatch::Reloader |
|
50
|
+
| 16 | ActionDispatch::Callbacks |
|
51
|
+
| 17 | ActiveRecord::Migration::CheckPending |
|
52
|
+
| 18 | ActionDispatch::Cookies |
|
53
|
+
| 19 | ActionDispatch::Session::CookieStore |
|
54
|
+
| 20 | ActionDispatch::Flash |
|
55
|
+
| 21 | ActionDispatch::ContentSecurityPolicy::Middleware |
|
56
|
+
| 22 | Rack::Head |
|
57
|
+
| 23 | Rack::ConditionalGet |
|
58
|
+
| 24 | Rack::ETag |
|
59
|
+
| 25 | Rack::TempfileReaper |
|
60
|
+
| 26 | MyRailsApp::Application.routes |
|
61
|
+
+-------+--------------------------------------------------------+
|
62
|
+
| Total | 26 Middlewares |
|
63
|
+
+-------+--------------------------------------------------------+
|
64
|
+
```
|
65
|
+
|
66
|
+
To create new middleware type:
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
$ bundle exec middleware-cli create MyMiddleware
|
70
|
+
```
|
71
|
+
which will create your middleware at 'app/middlewares' which is the default.
|
72
|
+
```
|
73
|
+
class MyMiddleware
|
74
|
+
def initialize(app)
|
75
|
+
# app here is our rails app
|
76
|
+
@app = app
|
77
|
+
end
|
78
|
+
|
79
|
+
def call(env)
|
80
|
+
# env variable is a hash comprising of request parameters such as
|
81
|
+
# headers, request url, request parameters etc.
|
82
|
+
@app.call(env)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
```
|
86
|
+
You can set your path by passing your path as second parameter:
|
87
|
+
```ruby
|
88
|
+
$ bundle exec middleware-cli create MyMiddleware app/services
|
89
|
+
```
|
90
|
+
|
91
|
+
To view all your middleware, you can simple use:
|
92
|
+
```ruby
|
93
|
+
$ bundle exec middleware-cli view
|
94
|
+
```
|
95
|
+
This will generate the code for all your middlewares of the application at middleware folder, which is the default.
|
96
|
+
You can set the folder for all your generated middleware code by:
|
97
|
+
```ruby
|
98
|
+
$ bundle exec middleware-cli view app/middlewares
|
99
|
+
```
|
100
|
+
|
101
|
+
For generating code for any particular middleware, use the name option:
|
102
|
+
```ruby
|
103
|
+
$ bundle exec middleware-cli view app/middlewares --name Rack::Sendfile
|
104
|
+
```
|
105
|
+
|
106
|
+
To view the middleware code in terminal itself use terminal option:
|
107
|
+
```ruby
|
108
|
+
$ bundle exec middleware-cli view app/middlewares --name Rack::Sendfile --terminal
|
109
|
+
```
|
110
|
+
|
111
|
+
## Contributing
|
112
|
+
|
113
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/vikasvr/middleware-cli. 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.
|
114
|
+
|
115
|
+
## License
|
116
|
+
|
117
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
118
|
+
|
119
|
+
## Code of Conduct
|
120
|
+
|
121
|
+
Everyone interacting in the Middleware::Cli project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/vikasvr/middleware-cli/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "middleware/cli"
|
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(__FILE__)
|
data/bin/setup
ADDED
data/exe/middleware-cli
ADDED
data/lib/.DS_Store
ADDED
Binary file
|
Binary file
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MiddlewareCli
|
4
|
+
module App
|
5
|
+
APPLICATION_ROUTE = "::Application.routes"
|
6
|
+
def app_path
|
7
|
+
path_array = Dir.getwd.split("/")
|
8
|
+
while not path_array.empty?
|
9
|
+
guess_path = path_array.join("/")
|
10
|
+
unless Dir[guess_path + "/Gemfile"].empty?
|
11
|
+
return guess_path
|
12
|
+
end
|
13
|
+
path_array.pop
|
14
|
+
end
|
15
|
+
Dir.getwd
|
16
|
+
end
|
17
|
+
|
18
|
+
def middleware_list
|
19
|
+
filtered_list.each_with_index do |middleware, index|
|
20
|
+
yield(middleware, index + 1)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def filtered_list
|
25
|
+
`rake middleware`.each_line.map do |middleware|
|
26
|
+
if middleware.start_with?("use") || middleware.start_with?("run")
|
27
|
+
middleware.split(" ").last
|
28
|
+
end
|
29
|
+
end.compact
|
30
|
+
end
|
31
|
+
|
32
|
+
def load_application
|
33
|
+
require "#{app_path}/config/environment"
|
34
|
+
end
|
35
|
+
|
36
|
+
def copy_file(path, directory_path)
|
37
|
+
FileUtils.mkdir_p directory_path unless Dir.exists?(directory_path)
|
38
|
+
FileUtils.cp path, directory_path
|
39
|
+
end
|
40
|
+
|
41
|
+
def is_route_middleware?(middleware)
|
42
|
+
middleware.include?(APPLICATION_ROUTE)
|
43
|
+
end
|
44
|
+
|
45
|
+
def relative_app_path(*paths)
|
46
|
+
[app_path, paths].join('/')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'middleware-cli/app'
|
4
|
+
|
5
|
+
module MiddlewareCli
|
6
|
+
class ExtractMiddleware
|
7
|
+
class InvalidMiddlewarePath < StandardError; end
|
8
|
+
extend App
|
9
|
+
ACTION_DISPATCH_FLASH = "ActionDispatch::Flash"
|
10
|
+
|
11
|
+
class << self
|
12
|
+
def execute(requested_path, options)
|
13
|
+
begin
|
14
|
+
load_application
|
15
|
+
rescue LoadError
|
16
|
+
puts "Fail to load your application"
|
17
|
+
return
|
18
|
+
end
|
19
|
+
if options["name"].blank?
|
20
|
+
extract_all(requested_path)
|
21
|
+
else
|
22
|
+
extract_one(requested_path, options["name"], options["terminal"])
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def find(middleware)
|
27
|
+
file_path, _ = begin
|
28
|
+
find_source(middleware)
|
29
|
+
rescue StandardError => error
|
30
|
+
[error.backtrace_locations.first.to_s.match(/:\d*:in/).pre_match, nil]
|
31
|
+
end
|
32
|
+
raise InvalidMiddlewarePath if file_path.include?("lib/middleware/helper/extract_middleware")
|
33
|
+
[file_path, namespace_to_path(middleware)]
|
34
|
+
end
|
35
|
+
|
36
|
+
def find_source(middleware_name)
|
37
|
+
middleware = if is_route_middleware?(middleware_name)
|
38
|
+
constantize(middleware_name.match('.routes').pre_match).routes
|
39
|
+
else
|
40
|
+
constantize(middleware_name).send(*init_with(middleware_name))
|
41
|
+
end
|
42
|
+
middleware.method(:call).source_location
|
43
|
+
end
|
44
|
+
|
45
|
+
def constantize(middleware)
|
46
|
+
Object.const_get(middleware)
|
47
|
+
end
|
48
|
+
|
49
|
+
def init_with(middleware)
|
50
|
+
middleware == ACTION_DISPATCH_FLASH ? ['new'] : ['new', OpenStruct.new]
|
51
|
+
end
|
52
|
+
|
53
|
+
def namespace_to_path(middleware)
|
54
|
+
middleware.split(/\W+/).map(&:underscore).join("/")
|
55
|
+
end
|
56
|
+
|
57
|
+
def render_disclaimer(path)
|
58
|
+
puts "Find your middlewares at '\\#{path}' :)"
|
59
|
+
end
|
60
|
+
|
61
|
+
def extract_all(path)
|
62
|
+
middleware_list do | middleware, _|
|
63
|
+
perform(middleware, path)
|
64
|
+
end
|
65
|
+
render_disclaimer(path)
|
66
|
+
end
|
67
|
+
|
68
|
+
def extract_one(path, middleware_name, terminal_output)
|
69
|
+
if middleware_name.blank?
|
70
|
+
puts "Please enter any middleware name"
|
71
|
+
elsif filtered_list.find { |name| name == middleware_name}
|
72
|
+
perform(middleware_name, path, terminal_output)
|
73
|
+
render_disclaimer(path) unless terminal_output
|
74
|
+
else
|
75
|
+
puts "Middleware not found :("
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def perform(middleware, requested_path, terminal_output = false)
|
80
|
+
begin
|
81
|
+
path, folder = find(middleware)
|
82
|
+
if terminal_output
|
83
|
+
puts `cat #{path}`
|
84
|
+
else
|
85
|
+
copy_file(path, relative_app_path(requested_path, folder))
|
86
|
+
end
|
87
|
+
rescue StandardError => e
|
88
|
+
return
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'middleware-cli/app'
|
2
|
+
|
3
|
+
module MiddlewareCli
|
4
|
+
class Formatter
|
5
|
+
DEFAULT_TEMPLATE_NAME = "MiddlewareTemplate".freeze
|
6
|
+
extend App
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def create_template(name, path)
|
10
|
+
begin
|
11
|
+
load_application
|
12
|
+
rescue LoadError
|
13
|
+
puts "Fail to load your application"
|
14
|
+
return
|
15
|
+
end
|
16
|
+
FileUtils.mkdir_p namespaced_path(path) unless Dir.exists?(namespaced_path(path))
|
17
|
+
File.open("#{namespaced_path(path, name.underscore)}.rb", 'w') do |file|
|
18
|
+
file.write formatted_template(name.camelize)
|
19
|
+
end
|
20
|
+
puts disclaimer(name.camelize, path)
|
21
|
+
end
|
22
|
+
|
23
|
+
def namespaced_path(*paths)
|
24
|
+
[app_path, paths].join('/')
|
25
|
+
end
|
26
|
+
|
27
|
+
def formatted_template(temp_name)
|
28
|
+
template.sub!(DEFAULT_TEMPLATE_NAME, temp_name).gsub(' ' * 10, '')
|
29
|
+
end
|
30
|
+
|
31
|
+
def template
|
32
|
+
%q(class MiddlewareTemplate
|
33
|
+
def initialize(app)
|
34
|
+
# app here is our rails app
|
35
|
+
@app = app
|
36
|
+
end
|
37
|
+
|
38
|
+
def call(env)
|
39
|
+
# env variable is a hash comprising of request parameters such as
|
40
|
+
# headers, request url, request parameters etc.
|
41
|
+
@app.call(env)
|
42
|
+
end
|
43
|
+
end)
|
44
|
+
end
|
45
|
+
|
46
|
+
def disclaimer(name, path)
|
47
|
+
%Q(
|
48
|
+
Find your Middleware #{name} at #{path}
|
49
|
+
|
50
|
+
Now configure your middleware by adding:
|
51
|
+
config.middleware.insert_before "Rails::Logger", #{name}
|
52
|
+
in config/application.rb
|
53
|
+
)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'terminal-table'
|
4
|
+
require 'middleware-cli/app'
|
5
|
+
|
6
|
+
module MiddlewareCli
|
7
|
+
class List
|
8
|
+
extend App
|
9
|
+
class << self
|
10
|
+
def display
|
11
|
+
table = Terminal::Table.new do |t|
|
12
|
+
t << ['S/n', 'Middleware Name']
|
13
|
+
t << :separator
|
14
|
+
middleware_list do |middleware, index|
|
15
|
+
t.add_row [index , middleware]
|
16
|
+
end
|
17
|
+
t << :separator
|
18
|
+
t << ['Total', "#{filtered_list.count} Middlewares"]
|
19
|
+
end
|
20
|
+
puts table
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "middleware-cli/version"
|
2
|
+
require "middleware-cli/list"
|
3
|
+
require "middleware-cli/formatter"
|
4
|
+
require "middleware-cli/extract_middleware"
|
5
|
+
require 'thor'
|
6
|
+
|
7
|
+
module MiddlewareCli
|
8
|
+
class Interface < Thor
|
9
|
+
|
10
|
+
desc "list", "List your project's middleware"
|
11
|
+
|
12
|
+
def list
|
13
|
+
List.display
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "view [middleware path]", "Generate view for your middlewares"
|
17
|
+
|
18
|
+
option :name
|
19
|
+
option :terminal, type: :boolean
|
20
|
+
def view(middlware_path = 'middlewares')
|
21
|
+
ExtractMiddleware.execute(middlware_path, options)
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "create [Name] [Path]", "Generate Middleware"
|
25
|
+
|
26
|
+
def create(name, path = 'app/middlewares')
|
27
|
+
Formatter.create_template(name, path)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "middleware-cli/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "middleware-cli"
|
8
|
+
spec.version = MiddlewareCli::VERSION
|
9
|
+
spec.authors = ["Vikas Verma"]
|
10
|
+
spec.email = ["vikasvr23@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{CLI for Rails middlewares}
|
13
|
+
spec.description = %q{You can list, view and create middlewares for your rails app}
|
14
|
+
spec.homepage = ""
|
15
|
+
spec.license = "MIT"
|
16
|
+
spec.metadata = { "source_code_uri" => "https://github.com/vikasvr/middleware-cli" }
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
# if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata["allowed_push_host"] = "Set to 'http://mygemserver.com'"
|
21
|
+
# else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
# "public gem pushes."
|
24
|
+
# end
|
25
|
+
|
26
|
+
# Specify which files should be added to the gem when it is released.
|
27
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
28
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
29
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
30
|
+
end
|
31
|
+
spec.bindir = "exe"
|
32
|
+
spec.required_ruby_version = '>= 2.0.0'
|
33
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
34
|
+
spec.require_paths = ["lib"]
|
35
|
+
spec.add_dependency "thor", "~> 0.20"
|
36
|
+
spec.add_dependency "terminal-table"
|
37
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
38
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
39
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: middleware-cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Vikas Verma
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-06-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.20'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.20'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: terminal-table
|
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: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.16'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.16'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '5.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '5.0'
|
83
|
+
description: You can list, view and create middlewares for your rails app
|
84
|
+
email:
|
85
|
+
- vikasvr23@gmail.com
|
86
|
+
executables:
|
87
|
+
- middleware-cli
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".travis.yml"
|
93
|
+
- CODE_OF_CONDUCT.md
|
94
|
+
- Gemfile
|
95
|
+
- Gemfile.lock
|
96
|
+
- LICENSE.txt
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- bin/console
|
100
|
+
- bin/setup
|
101
|
+
- exe/middleware-cli
|
102
|
+
- lib/.DS_Store
|
103
|
+
- lib/middleware-cli.rb
|
104
|
+
- lib/middleware-cli/.DS_Store
|
105
|
+
- lib/middleware-cli/app.rb
|
106
|
+
- lib/middleware-cli/extract_middleware.rb
|
107
|
+
- lib/middleware-cli/formatter.rb
|
108
|
+
- lib/middleware-cli/list.rb
|
109
|
+
- lib/middleware-cli/version.rb
|
110
|
+
- middleware-cli.gemspec
|
111
|
+
homepage: ''
|
112
|
+
licenses:
|
113
|
+
- MIT
|
114
|
+
metadata:
|
115
|
+
source_code_uri: https://github.com/vikasvr/middleware-cli
|
116
|
+
post_install_message:
|
117
|
+
rdoc_options: []
|
118
|
+
require_paths:
|
119
|
+
- lib
|
120
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 2.0.0
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
requirements: []
|
131
|
+
rubyforge_project:
|
132
|
+
rubygems_version: 2.6.14
|
133
|
+
signing_key:
|
134
|
+
specification_version: 4
|
135
|
+
summary: CLI for Rails middlewares
|
136
|
+
test_files: []
|