ruby_jard 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.
Files changed (42) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +13 -0
  5. data/.travis.yml +6 -0
  6. data/CHANGELOG.md +0 -0
  7. data/CODE_OF_CONDUCT.md +74 -0
  8. data/Gemfile +12 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +16 -0
  11. data/Rakefile +8 -0
  12. data/bin/console +15 -0
  13. data/lib/ruby_jard.rb +77 -0
  14. data/lib/ruby_jard/commands/continue_command.rb +33 -0
  15. data/lib/ruby_jard/commands/down_command.rb +31 -0
  16. data/lib/ruby_jard/commands/finish_command.rb +31 -0
  17. data/lib/ruby_jard/commands/frame_command.rb +36 -0
  18. data/lib/ruby_jard/commands/next_command.rb +31 -0
  19. data/lib/ruby_jard/commands/step_command.rb +31 -0
  20. data/lib/ruby_jard/commands/up_command.rb +31 -0
  21. data/lib/ruby_jard/decorators/loc_decorator.rb +200 -0
  22. data/lib/ruby_jard/decorators/path_decorator.rb +88 -0
  23. data/lib/ruby_jard/decorators/source_decorator.rb +43 -0
  24. data/lib/ruby_jard/decorators/text_decorator.rb +61 -0
  25. data/lib/ruby_jard/layout.rb +99 -0
  26. data/lib/ruby_jard/layout_template.rb +101 -0
  27. data/lib/ruby_jard/repl_processor.rb +143 -0
  28. data/lib/ruby_jard/screen.rb +61 -0
  29. data/lib/ruby_jard/screen_manager.rb +121 -0
  30. data/lib/ruby_jard/screens.rb +26 -0
  31. data/lib/ruby_jard/screens/backtrace_screen.rb +150 -0
  32. data/lib/ruby_jard/screens/breakpoints_screen.rb +23 -0
  33. data/lib/ruby_jard/screens/empty_screen.rb +13 -0
  34. data/lib/ruby_jard/screens/expressions_sreen.rb +22 -0
  35. data/lib/ruby_jard/screens/menu_screen.rb +62 -0
  36. data/lib/ruby_jard/screens/source_screen.rb +133 -0
  37. data/lib/ruby_jard/screens/threads_screen.rb +116 -0
  38. data/lib/ruby_jard/screens/variables_screen.rb +234 -0
  39. data/lib/ruby_jard/session.rb +54 -0
  40. data/lib/ruby_jard/version.rb +6 -0
  41. data/ruby_jard.gemspec +39 -0
  42. metadata +160 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4eaeb2003b2133100d1723d4fc5b3de3ea0ce6c1fd9f5e754a69ac7a489198d4
4
+ data.tar.gz: a1389c55f973eacda0e4fa6fdbf4b4f6f23feb6cf1ab38050f7fd3f8a1d689ed
5
+ SHA512:
6
+ metadata.gz: 04f8ca93a51eef68e3139fa58a5d7acb5ece7f79023dcff53bde4796628518f7fdc86a40903df1d680f4e13c86542a9b48fdc228a899c15674bb9a18e33d8419
7
+ data.tar.gz: 73608c00fe978926adaf05361e7d1467a6c9da325e6cdeba71ed25ddb00e8d027b788ca9154c2c74c13f4b36dbe4502b2e9f12fb9c82ba815b0967c7fa84765e
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,13 @@
1
+ Style/SymbolArray:
2
+ Enabled: false
3
+ Metrics/MethodLength:
4
+ Max: 20
5
+ Metrics/PerceivedComplexity:
6
+ Max: 15
7
+ Metrics/ParameterLists:
8
+ Enabled: false
9
+ Metrics/ClassLength:
10
+ Enabled: false
11
+ AllCops:
12
+ TargetRubyVersion: 2.5
13
+
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.0
6
+ before_install: gem install bundler -v 2.1.2
File without changes
@@ -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 nguyenquangminh0711@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 [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
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
6
+
7
+ gem 'aruba', '~> 1.0.2'
8
+ gem 'byebug', '~> 11.1.0'
9
+ gem 'pry', '~> 0.13.0'
10
+ gem 'rake', '~> 12.0'
11
+ gem 'rspec', '~> 3.0'
12
+ gem 'rubocop', '~> 0.86'
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Minh Nguyen
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.
@@ -0,0 +1,16 @@
1
+ # RubyJard
2
+
3
+ Just another ruby debugger. Jard provides an unified experience debugging Ruby source code in different platforms and editors. Jard is heavily under development. So, nothing to see here :smile:. When everything is ready, I'll update this file.
4
+
5
+ ## Contributing
6
+
7
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ruby_jard. 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]/ruby_jard/blob/master/CODE_OF_CONDUCT.md).
8
+
9
+
10
+ ## License
11
+
12
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
13
+
14
+ ## Code of Conduct
15
+
16
+ Everyone interacting in the RubyJard project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/ruby_jard/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'ruby_jard'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'pry'
15
+ Pry.start(__FILE__)
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pry'
4
+ require 'coderay'
5
+ require 'byebug/core'
6
+ require 'byebug/attacher'
7
+ require 'tty-cursor'
8
+ require 'tty-box'
9
+ require 'tty-screen'
10
+
11
+ require 'ruby_jard/commands/continue_command'
12
+ require 'ruby_jard/commands/up_command'
13
+ require 'ruby_jard/commands/down_command'
14
+ require 'ruby_jard/commands/next_command'
15
+ require 'ruby_jard/commands/step_command'
16
+ require 'ruby_jard/commands/finish_command'
17
+ require 'ruby_jard/commands/frame_command'
18
+
19
+ require 'ruby_jard/repl_processor'
20
+ require 'ruby_jard/screen_manager'
21
+
22
+ require 'ruby_jard/session'
23
+ require 'ruby_jard/version'
24
+
25
+ ##
26
+ # Jard stands for Just Another Ruby Debugger. It implements a layer of UI
27
+ # wrapping around byebug, aims to provide a unified experience when debug
28
+ # Ruby source code. Ruby Jard supports the following major features:
29
+ #
30
+ # * Default Terminal UI, in which the layout and display are responsive to
31
+ # support different screen size.
32
+ # * Highlighted source code screen.
33
+ # * Stacktrace visulization and navigation.
34
+ # * Auto explore and display variables in the current context.
35
+ # * Multi-thread exploration and debugging.
36
+ # * Minimal layout configuration.
37
+ # * Fully layout configuration with Tmux (coming soon).
38
+ # * Integrate with Vim (coming soon).
39
+ # * Integrate with Visual Studio Code (coming soon).
40
+ # * Encrypted remote debugging (coming soon).
41
+ # * Some handful debug tools and data visulization (coming soom).
42
+ #
43
+ # Ruby Jard's core is Byebug, an awesome de factor debugger for Ruby.
44
+ # Therefore, Ruby Jard supports most of Byebug's functionalities.
45
+ #
46
+ module RubyJard
47
+ class Error < StandardError; end
48
+
49
+ def self.current_session
50
+ @current_session ||= RubyJard::Session.new
51
+ end
52
+ end
53
+
54
+ ##
55
+ # Monkey-patch Kernel module to allow putting jard command anywhere.
56
+ module Kernel
57
+ def jard
58
+ RubyJard.current_session.attach
59
+ end
60
+ end
61
+
62
+ ##
63
+ # Globally configure Byebug. Byebug doesn't allow configuration by instance.
64
+ # So, I have no choice.
65
+ # TODO: Byebug autoloaded configuration may override those values.
66
+ Byebug::Setting[:autolist] = false
67
+ Byebug::Setting[:autoirb] = false
68
+ Byebug::Setting[:autopry] = false
69
+ Byebug::Context.processor = RubyJard::ReplProcessor
70
+ # Exclude all files in Ruby Jard source code from the stacktrace.
71
+ Byebug::Context.ignored_files = Byebug::Context.all_files + Dir.glob(
72
+ File.join(
73
+ File.expand_path(__dir__, '../lib'),
74
+ '**',
75
+ '*.rb'
76
+ )
77
+ )
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyJard
4
+ module Commands
5
+ # Command used to continue program execution.
6
+ # Data attached in the throw:
7
+ # * command: constant symbol (:continue)
8
+ # * pry: current context pry instance
9
+ class ContinueCommand < Pry::ClassCommand
10
+ group 'RubyJard'
11
+ description 'Continue program execution.'
12
+
13
+ match 'continue'
14
+
15
+ banner <<-BANNER
16
+ Usage: continue
17
+
18
+ Continue program execution. The program will stop at the next breakpoint, or run until it finishes.
19
+
20
+ Examples:
21
+ continue
22
+ BANNER
23
+
24
+ def process
25
+ throw :control_flow, command: :continue, pry: pry_instance
26
+ ensure
27
+ Byebug.stop if Byebug.stoppable?
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ Pry::Commands.add_command(RubyJard::Commands::ContinueCommand)
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyJard
4
+ module Commands
5
+ # Command used to explore stacktrace.
6
+ # Data attached in the throw:
7
+ # * command: constant symbol (:down)
8
+ # * pry: current context pry instance
9
+ class DownCommand < Pry::ClassCommand
10
+ group 'RubyJard'
11
+ description 'Explore the frames bellow the current stopped line in the backtrace'
12
+
13
+ match 'down'
14
+
15
+ banner <<-BANNER
16
+ Usage: down
17
+
18
+ Explore the frames bellow the current stopped line in the backtrace.
19
+
20
+ Examples:
21
+ down
22
+ BANNER
23
+
24
+ def process
25
+ throw :control_flow, command: :down, pry: pry_instance
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+ Pry::Commands.add_command(RubyJard::Commands::DownCommand)
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyJard
4
+ module Commands
5
+ # Command used to finish up the current frame.
6
+ # Data attached in the throw:
7
+ # * command: constant symbol (:finish)
8
+ # * pry: current context pry instance
9
+ class FinishCommand < Pry::ClassCommand
10
+ group 'RubyJard'
11
+ description 'Finish the execution of the current frame.'
12
+
13
+ match 'finish'
14
+
15
+ banner <<-BANNER
16
+ Usage: finish
17
+
18
+ Finish the execution of the current frame.
19
+
20
+ Examples:
21
+ finish
22
+ BANNER
23
+
24
+ def process
25
+ throw :control_flow, command: :finish, pry: pry_instance
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+ Pry::Commands.add_command(RubyJard::Commands::FinishCommand)
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyJard
4
+ module Commands
5
+ # Command used to explore stacktrace.
6
+ # Data attached in the throw:
7
+ # * command: constant symbol (:frame)
8
+ # * pry: current context pry instance
9
+ # * frame (optional): frame id of the destination frame
10
+ class FrameCommand < Pry::ClassCommand
11
+ group 'RubyJard'
12
+ description 'Explore to any frame of current stacktrace.'
13
+
14
+ match 'frame'
15
+
16
+ banner <<-BANNER
17
+ Usage: frame
18
+
19
+ Explore to any frame of current stacktrace.
20
+
21
+ Examples:
22
+ frame [FRAME_ID]
23
+ BANNER
24
+
25
+ def process
26
+ throw :control_flow,
27
+ command: :frame,
28
+ pry: pry_instance,
29
+ # TODO: Remove redundant options
30
+ options: { frame: args.first }
31
+ end
32
+ end
33
+ end
34
+ end
35
+
36
+ Pry::Commands.add_command(RubyJard::Commands::FrameCommand)
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyJard
4
+ module Commands
5
+ # Command used to continue program execution to the next line.
6
+ # Data attached in the throw:
7
+ # * command: constant symbol (:next)
8
+ # * pry: current context pry instance
9
+ class NextCommand < Pry::ClassCommand
10
+ group 'RubyJard'
11
+ description 'Next into the execution of the current line'
12
+
13
+ match 'next'
14
+
15
+ banner <<-BANNER
16
+ Usage: next
17
+
18
+ Continue program execution to the next line. If the current frame reaches the end, it continue the next line of upper frame.
19
+
20
+ Examples:
21
+ next
22
+ BANNER
23
+
24
+ def process
25
+ throw :control_flow, command: :next, pry: pry_instance
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+ Pry::Commands.add_command(RubyJard::Commands::NextCommand)