pry-diff-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 +12 -0
- data/.rspec +3 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +44 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/pry-diff-routes.rb +7 -0
- data/lib/pry_diff_routes/commands.rb +7 -0
- data/lib/pry_diff_routes/commands/diff_routes.rb +91 -0
- data/lib/pry_diff_routes/formatters/modified_routes_formatter.rb +73 -0
- data/lib/pry_diff_routes/formatters/new_routes_formatter.rb +14 -0
- data/lib/pry_diff_routes/formatters/removed_routes_formatter.rb +14 -0
- data/lib/pry_diff_routes/railtie.rb +21 -0
- data/lib/pry_diff_routes/route_wrapper.rb +66 -0
- data/lib/pry_diff_routes/routes_diff_processor.rb +72 -0
- data/lib/pry_diff_routes/util.rb +41 -0
- data/lib/pry_diff_routes/version.rb +3 -0
- data/pry-diff-routes.gemspec +27 -0
- metadata +120 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 157d8b346eea255e119daa75615fdad90a0f84db1c8b230ce818d63c8f475009
|
4
|
+
data.tar.gz: 35bef130d086c757eb1258b172c4967b81caa9077788682c34fa69ecfd3fbad7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: af079cf685ccc01459969a02c4639ac895fb05eecb26e0e1269bfa7ffd53a15544ffaf160f1b3f5d1744757690f45f6f9e56ee2747b17f5a9b0fee60b0305b5f
|
7
|
+
data.tar.gz: c3665a9b0c549b4217c1216685fabb8c71876cc5b7d5f00bab5c028bbae0f5e0f7a0f10cad380b4c753e266a90c4e0fae9117e3a49969e117eb9ef801d19ed00
|
data/.gitignore
ADDED
data/.rspec
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 a.styd@yahoo.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 [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Adrian Setyadi
|
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,44 @@
|
|
1
|
+
# PryDiffRoutes
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/pry/diff/routes`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'pry-diff-routes'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install pry-diff-routes
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
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.
|
30
|
+
|
31
|
+
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).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/styd/pry-diff-routes. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/pry-diff-routes/blob/master/CODE_OF_CONDUCT.md).
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
41
|
+
|
42
|
+
## Code of Conduct
|
43
|
+
|
44
|
+
Everyone interacting in the Pry::Diff::Routes project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/styd/pry-diff-routes/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 "pry/diff/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(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
require_relative '../route_wrapper'
|
2
|
+
|
3
|
+
module PryDiffRoutes
|
4
|
+
class DiffRoutes < Pry::ClassCommand
|
5
|
+
R_MODE = 1; M_MODE = 2; N_MODE = 4; A_MODE = 7
|
6
|
+
|
7
|
+
singleton_class.attr_accessor :_previous_routes
|
8
|
+
|
9
|
+
match 'diff-routes'
|
10
|
+
group 'Rails'
|
11
|
+
description 'Show the difference you made in routes.'
|
12
|
+
banner <<-BANNER
|
13
|
+
Usage: diff-routes [-S|-R|-M|-N]
|
14
|
+
|
15
|
+
`diff-routes' displays changes in routes.
|
16
|
+
|
17
|
+
# Save current routes as the basis for changes
|
18
|
+
diff-routes -S
|
19
|
+
|
20
|
+
# Display routes that have been removed
|
21
|
+
diff-routes -R
|
22
|
+
|
23
|
+
# Display modified routes
|
24
|
+
diff-routes -M
|
25
|
+
|
26
|
+
# Display new routes
|
27
|
+
diff-routes -N
|
28
|
+
BANNER
|
29
|
+
|
30
|
+
def options(opt)
|
31
|
+
opt.on :S, "save", "Save current routes",
|
32
|
+
as: String
|
33
|
+
opt.on :R, "removed", "Show removed routes",
|
34
|
+
as: String
|
35
|
+
opt.on :M, "modified", "Show modified routes",
|
36
|
+
as: String
|
37
|
+
opt.on :N, "new", "Show new routes",
|
38
|
+
as: String
|
39
|
+
end
|
40
|
+
|
41
|
+
def process
|
42
|
+
Rails.application.reload_routes!
|
43
|
+
all_routes = Rails.application.routes.routes
|
44
|
+
|
45
|
+
return save_routes(all_routes) if opts[:S]
|
46
|
+
|
47
|
+
removed_mode = opts[:R] ? R_MODE : 0
|
48
|
+
modified_mode = opts[:M] ? M_MODE : 0
|
49
|
+
new_mode = opts[:N] ? N_MODE : 0
|
50
|
+
display_mode = removed_mode | modified_mode | new_mode
|
51
|
+
|
52
|
+
output.puts process_diff(all_routes, display_mode)
|
53
|
+
end
|
54
|
+
|
55
|
+
# `opts[:S]`.
|
56
|
+
def save_routes(routes)
|
57
|
+
DiffRoutes._previous_routes = wrap_routes(routes)
|
58
|
+
nil
|
59
|
+
end
|
60
|
+
|
61
|
+
def wrap_routes(routes)
|
62
|
+
prev_name = nil
|
63
|
+
routes.reject(&:internal).map do |route|
|
64
|
+
if route.name.nil?
|
65
|
+
route.instance_variable_set(:@name, prev_name)
|
66
|
+
else
|
67
|
+
prev_name = route.name
|
68
|
+
end
|
69
|
+
|
70
|
+
RouteWrapper.new(route)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def process_diff(current_routes, mode)
|
75
|
+
routes =
|
76
|
+
RoutesDiffProcessor.new(
|
77
|
+
DiffRoutes._previous_routes,
|
78
|
+
wrap_routes(current_routes),
|
79
|
+
mode
|
80
|
+
)
|
81
|
+
|
82
|
+
if routes.changed?
|
83
|
+
routes
|
84
|
+
else
|
85
|
+
"No routes changed."
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
Commands.add_command(self)
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module PryDiffRoutes
|
2
|
+
class ModifiedRoutesFormatter
|
3
|
+
include Util
|
4
|
+
|
5
|
+
def initialize(routes_changes)
|
6
|
+
@routes_changes = routes_changes
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_s
|
10
|
+
<<~MODIFIED
|
11
|
+
#{bold_yellow 'Modified:'}
|
12
|
+
#{routes_diff}
|
13
|
+
MODIFIED
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
def routes_diff
|
18
|
+
@routes_changes.map do |before, after|
|
19
|
+
<<~CHANGES
|
20
|
+
#{before.display_verb_and_path}
|
21
|
+
#{prefix_changes(before, after)}
|
22
|
+
#{controller_changes(before, after)}
|
23
|
+
#{action_changes(before, after)}
|
24
|
+
#{constraints_changes(before, after)}
|
25
|
+
CHANGES
|
26
|
+
end.join("\n")
|
27
|
+
end
|
28
|
+
|
29
|
+
def prefix_changes(before, after)
|
30
|
+
if before.prefix != after.prefix
|
31
|
+
pad_lines <<~DIFF.chomp, 2
|
32
|
+
#{arrow_key('Prefix')}-#{highlight_red before.prefix}
|
33
|
+
+#{highlight_green after.prefix}
|
34
|
+
DIFF
|
35
|
+
else
|
36
|
+
pad_lines before.display_prefix, 2
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def controller_changes(before, after)
|
41
|
+
if before.controller != after.controller
|
42
|
+
pad_lines <<~DIFF.chomp, 2
|
43
|
+
#{arrow_key('Controller')}-#{highlight_red(before.controller.camelize + 'Controller')}
|
44
|
+
+#{highlight_green(after.controller.camelize + 'Controller')}
|
45
|
+
DIFF
|
46
|
+
else
|
47
|
+
pad_lines before.display_controller, 2
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def action_changes(before, after)
|
52
|
+
if before.action != after.action
|
53
|
+
pad_lines <<~DIFF.chomp, 2
|
54
|
+
#{arrow_key('Action')}-#{highlight_red('#' + before.action)}
|
55
|
+
+#{highlight_green('#' + after.action)}
|
56
|
+
DIFF
|
57
|
+
else
|
58
|
+
pad_lines before.display_action, 2
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def constraints_changes(before, after)
|
63
|
+
if before.constraints != after.constraints
|
64
|
+
<<-DIFF.chomp
|
65
|
+
#{arrow_key('Constraints')}-#{highlight_red before.constraints}
|
66
|
+
+#{highlight_green after.constraints}
|
67
|
+
DIFF
|
68
|
+
else
|
69
|
+
pad_lines before.display_constraints, 2
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module PryDiffRoutes
|
2
|
+
class Railtie < Rails::Railtie
|
3
|
+
# Cribbed from PryRails::Railtie
|
4
|
+
# Removed Rails versions < 5 checking as they are no longer supported.
|
5
|
+
console do
|
6
|
+
unless defined? PryRails
|
7
|
+
require 'pry'
|
8
|
+
|
9
|
+
Rails.application.config.console = Pry
|
10
|
+
|
11
|
+
require "rails/console/app"
|
12
|
+
require "rails/console/helpers"
|
13
|
+
TOPLEVEL_BINDING.eval('self').extend ::Rails::ConsoleMethods
|
14
|
+
end
|
15
|
+
|
16
|
+
require 'pry_diff_routes/commands'
|
17
|
+
|
18
|
+
DiffRoutes.new.save_routes(Rails.application.routes.routes)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'action_dispatch/routing/inspector'
|
2
|
+
require_relative 'util'
|
3
|
+
|
4
|
+
if RUBY_ENGINE == 'ruby'
|
5
|
+
using Module.new {
|
6
|
+
refine Hash do
|
7
|
+
alias old_to_s to_s
|
8
|
+
def to_s
|
9
|
+
old_to_s.gsub(%r{\:(\w+)\=\>}, "\\1: ")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
module PryDiffRoutes
|
16
|
+
class RouteWrapper < ActionDispatch::Routing::RouteWrapper
|
17
|
+
include Util
|
18
|
+
include Comparable
|
19
|
+
|
20
|
+
alias_method :prefix, :name
|
21
|
+
|
22
|
+
def <=>(other)
|
23
|
+
self.prefix <=> other.prefix &&
|
24
|
+
self.verb <=> other.verb &&
|
25
|
+
self.reqs <=> other.reqs
|
26
|
+
end
|
27
|
+
|
28
|
+
def hash
|
29
|
+
[self.prefix, self.verb, self.reqs].hash
|
30
|
+
end
|
31
|
+
|
32
|
+
def eql?(other)
|
33
|
+
self == other
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_s
|
37
|
+
pad_lines <<~ROUTE, 1
|
38
|
+
#{display_verb_and_path}
|
39
|
+
#{display_prefix}
|
40
|
+
#{display_controller}
|
41
|
+
#{display_action}
|
42
|
+
#{display_constraints}
|
43
|
+
ROUTE
|
44
|
+
end
|
45
|
+
|
46
|
+
def display_verb_and_path
|
47
|
+
"#{bold verb.ljust(6, ' ')} #{dim_format path}"
|
48
|
+
end
|
49
|
+
|
50
|
+
def display_prefix
|
51
|
+
"#{arrow_key('Prefix')} #{prefix}"
|
52
|
+
end
|
53
|
+
|
54
|
+
def display_controller
|
55
|
+
"#{arrow_key('Controller')} #{controller.camelize}Controller"
|
56
|
+
end
|
57
|
+
|
58
|
+
def display_action
|
59
|
+
"#{arrow_key('Action')} ##{action}"
|
60
|
+
end
|
61
|
+
|
62
|
+
def display_constraints
|
63
|
+
"#{arrow_key('Constraints')} #{constraints}"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require_relative 'formatters/removed_routes_formatter'
|
2
|
+
require_relative 'formatters/modified_routes_formatter'
|
3
|
+
require_relative 'formatters/new_routes_formatter'
|
4
|
+
|
5
|
+
module PryDiffRoutes
|
6
|
+
class RoutesDiffProcessor
|
7
|
+
def initialize(previous_routes, current_routes, display_mode)
|
8
|
+
@previous = previous_routes
|
9
|
+
@current = current_routes
|
10
|
+
@mode = display_mode.zero? ? DiffRoutes::A_MODE : display_mode
|
11
|
+
|
12
|
+
@removed, @modified, @new = process_diff if changed?
|
13
|
+
end
|
14
|
+
|
15
|
+
def changed?
|
16
|
+
@previous != @current
|
17
|
+
end
|
18
|
+
|
19
|
+
def process_diff
|
20
|
+
inner_join = @previous & @current
|
21
|
+
removed_routes = @previous - inner_join
|
22
|
+
new_routes = @current - inner_join
|
23
|
+
|
24
|
+
modified_routes = {}
|
25
|
+
|
26
|
+
removed_routes.reject! do |r_route|
|
27
|
+
catch :modified do
|
28
|
+
new_routes.each do |n_route|
|
29
|
+
if n_route.verb == r_route.verb && n_route.path == r_route.path
|
30
|
+
modified_routes[r_route] = n_route
|
31
|
+
new_routes.reject!{|route| route == n_route }
|
32
|
+
|
33
|
+
throw :modified, true
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
false
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
[removed_routes, modified_routes, new_routes]
|
42
|
+
end
|
43
|
+
|
44
|
+
def show_removed?
|
45
|
+
(@mode & DiffRoutes::R_MODE == DiffRoutes::R_MODE) && @removed.any?
|
46
|
+
end
|
47
|
+
|
48
|
+
def display_removed
|
49
|
+
RemovedRoutesFormatter.new(@removed) if show_removed?
|
50
|
+
end
|
51
|
+
|
52
|
+
def show_modified?
|
53
|
+
(@mode & DiffRoutes::M_MODE == DiffRoutes::M_MODE) && @modified.any?
|
54
|
+
end
|
55
|
+
|
56
|
+
def display_modified
|
57
|
+
ModifiedRoutesFormatter.new(@modified) if show_modified?
|
58
|
+
end
|
59
|
+
|
60
|
+
def show_new?
|
61
|
+
(@mode & DiffRoutes::N_MODE == DiffRoutes::N_MODE) && @new.any?
|
62
|
+
end
|
63
|
+
|
64
|
+
def display_new
|
65
|
+
NewRoutesFormatter.new(@new) if show_new?
|
66
|
+
end
|
67
|
+
|
68
|
+
def to_s
|
69
|
+
"#{display_removed}#{display_modified}#{display_new}"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module PryDiffRoutes
|
2
|
+
module Util
|
3
|
+
module_function
|
4
|
+
|
5
|
+
def pad_lines(text="", pad_length=0)
|
6
|
+
text.gsub(/^(.*)$/, ' ' * 2 * pad_length + "\\1")
|
7
|
+
end
|
8
|
+
|
9
|
+
def arrow_key(key)
|
10
|
+
key.ljust(12, ' ') + '->'
|
11
|
+
end
|
12
|
+
|
13
|
+
def dim_format(text)
|
14
|
+
text.sub(/(\(.:format\))$/, "\e[2m\\1\e[0m")
|
15
|
+
end
|
16
|
+
|
17
|
+
def highlight_red(text)
|
18
|
+
"\e[1;30;41m#{text}\e[0m"
|
19
|
+
end
|
20
|
+
|
21
|
+
def highlight_green(text)
|
22
|
+
"\e[1;30;42m#{text}\e[0m"
|
23
|
+
end
|
24
|
+
|
25
|
+
def bold(text)
|
26
|
+
"\e[1m#{text}\e[0m"
|
27
|
+
end
|
28
|
+
|
29
|
+
def bold_red(text)
|
30
|
+
"\e[1;31m#{text}\e[0m"
|
31
|
+
end
|
32
|
+
|
33
|
+
def bold_yellow(text)
|
34
|
+
"\e[1;33m#{text}\e[0m"
|
35
|
+
end
|
36
|
+
|
37
|
+
def bold_green(text)
|
38
|
+
"\e[1;32m#{text}\e[0m"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative 'lib/pry_diff_routes/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "pry-diff-routes"
|
5
|
+
spec.version = PryDiffRoutes::VERSION
|
6
|
+
spec.authors = ["Adrian Setyadi"]
|
7
|
+
spec.email = ["a.styd@yahoo.com"]
|
8
|
+
|
9
|
+
spec.summary = %q{Inspect routes changes in Rails console}
|
10
|
+
spec.description = %q{A Pry plugin to see the difference you made to Rails routes}
|
11
|
+
spec.homepage = "https://github.com/styd/pry-diff-routes"
|
12
|
+
spec.license = "MIT"
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
14
|
+
|
15
|
+
# Specify which files should be added to the gem when it is released.
|
16
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
17
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
18
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
|
19
|
+
end
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "pry", "~> 0.12.0"
|
23
|
+
|
24
|
+
spec.add_development_dependency "rails", ">= 5"
|
25
|
+
spec.add_development_dependency "rake", "~> 12.0"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pry-diff-routes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Adrian Setyadi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-03-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pry
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.12.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.12.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rails
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5'
|
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: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
description: A Pry plugin to see the difference you made to Rails routes
|
70
|
+
email:
|
71
|
+
- a.styd@yahoo.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- CODE_OF_CONDUCT.md
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/console
|
84
|
+
- bin/setup
|
85
|
+
- lib/pry-diff-routes.rb
|
86
|
+
- lib/pry_diff_routes/commands.rb
|
87
|
+
- lib/pry_diff_routes/commands/diff_routes.rb
|
88
|
+
- lib/pry_diff_routes/formatters/modified_routes_formatter.rb
|
89
|
+
- lib/pry_diff_routes/formatters/new_routes_formatter.rb
|
90
|
+
- lib/pry_diff_routes/formatters/removed_routes_formatter.rb
|
91
|
+
- lib/pry_diff_routes/railtie.rb
|
92
|
+
- lib/pry_diff_routes/route_wrapper.rb
|
93
|
+
- lib/pry_diff_routes/routes_diff_processor.rb
|
94
|
+
- lib/pry_diff_routes/util.rb
|
95
|
+
- lib/pry_diff_routes/version.rb
|
96
|
+
- pry-diff-routes.gemspec
|
97
|
+
homepage: https://github.com/styd/pry-diff-routes
|
98
|
+
licenses:
|
99
|
+
- MIT
|
100
|
+
metadata: {}
|
101
|
+
post_install_message:
|
102
|
+
rdoc_options: []
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 2.4.0
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
requirements: []
|
116
|
+
rubygems_version: 3.1.2
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: Inspect routes changes in Rails console
|
120
|
+
test_files: []
|