ruby_jard 0.1.0 → 0.2.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 (53) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +10 -0
  3. data/CHANGELOG.md +40 -0
  4. data/Gemfile +1 -1
  5. data/README.md +65 -2
  6. data/docs/guide-ui.png +0 -0
  7. data/lib/ruby_jard.rb +49 -12
  8. data/lib/ruby_jard/box_drawer.rb +126 -0
  9. data/lib/ruby_jard/column.rb +18 -0
  10. data/lib/ruby_jard/commands/continue_command.rb +1 -6
  11. data/lib/ruby_jard/commands/down_command.rb +1 -4
  12. data/lib/ruby_jard/commands/frame_command.rb +12 -11
  13. data/lib/ruby_jard/commands/next_command.rb +1 -4
  14. data/lib/ruby_jard/commands/step_command.rb +1 -4
  15. data/lib/ruby_jard/commands/step_out_command.rb +28 -0
  16. data/lib/ruby_jard/commands/up_command.rb +1 -4
  17. data/lib/ruby_jard/console.rb +86 -0
  18. data/lib/ruby_jard/control_flow.rb +71 -0
  19. data/lib/ruby_jard/decorators/color_decorator.rb +78 -0
  20. data/lib/ruby_jard/decorators/loc_decorator.rb +41 -28
  21. data/lib/ruby_jard/decorators/source_decorator.rb +1 -1
  22. data/lib/ruby_jard/key_binding.rb +14 -0
  23. data/lib/ruby_jard/key_bindings.rb +96 -0
  24. data/lib/ruby_jard/keys.rb +49 -0
  25. data/lib/ruby_jard/layout.rb +67 -55
  26. data/lib/ruby_jard/layouts/wide_layout.rb +138 -0
  27. data/lib/ruby_jard/repl_processor.rb +80 -90
  28. data/lib/ruby_jard/repl_proxy.rb +232 -0
  29. data/lib/ruby_jard/row.rb +16 -0
  30. data/lib/ruby_jard/screen.rb +114 -36
  31. data/lib/ruby_jard/screen_drawer.rb +89 -0
  32. data/lib/ruby_jard/screen_manager.rb +157 -56
  33. data/lib/ruby_jard/screens/backtrace_screen.rb +88 -97
  34. data/lib/ruby_jard/screens/menu_screen.rb +23 -31
  35. data/lib/ruby_jard/screens/source_screen.rb +42 -90
  36. data/lib/ruby_jard/screens/threads_screen.rb +50 -64
  37. data/lib/ruby_jard/screens/variables_screen.rb +96 -99
  38. data/lib/ruby_jard/session.rb +13 -7
  39. data/lib/ruby_jard/span.rb +18 -0
  40. data/lib/ruby_jard/templates/column_template.rb +17 -0
  41. data/lib/ruby_jard/templates/layout_template.rb +35 -0
  42. data/lib/ruby_jard/templates/row_template.rb +22 -0
  43. data/lib/ruby_jard/templates/screen_template.rb +35 -0
  44. data/lib/ruby_jard/templates/space_template.rb +15 -0
  45. data/lib/ruby_jard/templates/span_template.rb +25 -0
  46. data/lib/ruby_jard/version.rb +1 -1
  47. data/ruby_jard.gemspec +1 -4
  48. metadata +29 -41
  49. data/lib/ruby_jard/commands/finish_command.rb +0 -31
  50. data/lib/ruby_jard/decorators/text_decorator.rb +0 -61
  51. data/lib/ruby_jard/layout_template.rb +0 -101
  52. data/lib/ruby_jard/screens/breakpoints_screen.rb +0 -23
  53. data/lib/ruby_jard/screens/expressions_sreen.rb +0 -22
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyJard
4
+ module Templates
5
+ ##
6
+ # Template of a layout. Templates are hierarchy. Each template includes the
7
+ # sizing configuration, including absolute values, min, max, or ratio
8
+ # relative to its parant.
9
+ class LayoutTemplate
10
+ attr_reader :height_ratio, :width_ratio,
11
+ :min_width, :min_height,
12
+ :height, :width,
13
+ :children,
14
+ :fill_width, :fill_height
15
+
16
+ def initialize(
17
+ height_ratio: nil, width_ratio: nil,
18
+ min_width: nil, min_height: nil,
19
+ height: nil, width: nil,
20
+ children: [],
21
+ fill_width: nil, fill_height: nil
22
+ )
23
+ @height_ratio = height_ratio
24
+ @width_ratio = width_ratio
25
+ @min_width = min_width
26
+ @min_height = min_height
27
+ @height = height
28
+ @width = width
29
+ @children = children
30
+ @fill_width = fill_width
31
+ @fill_height = fill_height
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyJard
4
+ module Templates
5
+ ##
6
+ # Template for a row. Each screen has only 1 template for row. Each row includes multiple columns.
7
+ class RowTemplate
8
+ attr_reader :columns, :line_limit
9
+
10
+ def initialize(columns: [], line_limit: nil)
11
+ @columns = columns
12
+ @line_limit = line_limit
13
+ end
14
+
15
+ def priorities
16
+ columns.flat_map do |column|
17
+ column.spans.flat_map(&:priority)
18
+ end.uniq.compact.sort.reverse
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyJard
4
+ module Templates
5
+ ##
6
+ # Template of a screen. A screen doesn't have children. Each screen includes screen name, sizes androw template for
7
+ # rendering.
8
+ class ScreenTemplate
9
+ attr_reader :screen, :row_template, :height_ratio, :width_ratio,
10
+ :min_width, :min_height,
11
+ :height, :width,
12
+ :fill_width, :fill_height
13
+
14
+ def initialize(
15
+ screen: nil,
16
+ row_template: nil,
17
+ height_ratio: nil, width_ratio: nil,
18
+ min_width: nil, min_height: nil,
19
+ height: nil, width: nil,
20
+ fill_width: nil, fill_height: nil
21
+ )
22
+ @screen = screen
23
+ @row_template = row_template
24
+ @height_ratio = height_ratio
25
+ @width_ratio = width_ratio
26
+ @min_width = min_width
27
+ @min_height = min_height
28
+ @height = height
29
+ @width = width
30
+ @fill_width = fill_width
31
+ @fill_height = fill_height
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyJard
4
+ module Templates
5
+ ##
6
+ # A series of spaces. Used to align or push items in a row.
7
+ class SpaceTemplate
8
+ attr_reader :priority
9
+
10
+ def initialize
11
+ @priority = 0
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyJard
4
+ module Templates
5
+ ##
6
+ # Template for a span. Span is the most basic unit of display. It is just a sequence of characters, styles, and
7
+ # other layout properties.
8
+ class SpanTemplate
9
+ attr_reader :name, :margin_right, :margin_left, :word_wrap, :priority, :ellipsis
10
+
11
+ def initialize(
12
+ name,
13
+ margin_left: 0, margin_right: 0,
14
+ ellipsis: false, word_wrap: false, priority: 0
15
+ )
16
+ @name = name
17
+ @margin_left = margin_left
18
+ @margin_right = margin_right
19
+ @priority = priority
20
+ @word_wrap = word_wrap
21
+ @ellipsis = ellipsis
22
+ end
23
+ end
24
+ end
25
+ end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Semantic versionn
4
4
  module RubyJard
5
- VERSION = '0.1.0'
5
+ VERSION = '0.2.0'
6
6
  end
@@ -30,10 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
31
31
  spec.require_paths = ['lib']
32
32
 
33
- spec.add_runtime_dependency 'tty-box', '>= 0.5.0'
34
- spec.add_runtime_dependency 'tty-cursor', '>= 0.7.1'
35
- spec.add_runtime_dependency 'tty-screen', '>= 0.8.0'
36
-
37
33
  spec.add_runtime_dependency 'byebug', '>= 11.1.0'
34
+ spec.add_runtime_dependency 'pastel', '>= 0.7.4'
38
35
  spec.add_runtime_dependency 'pry', '>= 0.13.0'
39
36
  end
metadata CHANGED
@@ -1,71 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_jard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Minh Nguyen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-01 00:00:00.000000000 Z
11
+ date: 2020-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: tty-box
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 0.5.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.5.0
27
- - !ruby/object:Gem::Dependency
28
- name: tty-cursor
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 0.7.1
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: 0.7.1
41
- - !ruby/object:Gem::Dependency
42
- name: tty-screen
14
+ name: byebug
43
15
  requirement: !ruby/object:Gem::Requirement
44
16
  requirements:
45
17
  - - ">="
46
18
  - !ruby/object:Gem::Version
47
- version: 0.8.0
19
+ version: 11.1.0
48
20
  type: :runtime
49
21
  prerelease: false
50
22
  version_requirements: !ruby/object:Gem::Requirement
51
23
  requirements:
52
24
  - - ">="
53
25
  - !ruby/object:Gem::Version
54
- version: 0.8.0
26
+ version: 11.1.0
55
27
  - !ruby/object:Gem::Dependency
56
- name: byebug
28
+ name: pastel
57
29
  requirement: !ruby/object:Gem::Requirement
58
30
  requirements:
59
31
  - - ">="
60
32
  - !ruby/object:Gem::Version
61
- version: 11.1.0
33
+ version: 0.7.4
62
34
  type: :runtime
63
35
  prerelease: false
64
36
  version_requirements: !ruby/object:Gem::Requirement
65
37
  requirements:
66
38
  - - ">="
67
39
  - !ruby/object:Gem::Version
68
- version: 11.1.0
40
+ version: 0.7.4
69
41
  - !ruby/object:Gem::Dependency
70
42
  name: pry
71
43
  requirement: !ruby/object:Gem::Requirement
@@ -101,33 +73,49 @@ files:
101
73
  - README.md
102
74
  - Rakefile
103
75
  - bin/console
76
+ - docs/guide-ui.png
104
77
  - lib/ruby_jard.rb
78
+ - lib/ruby_jard/box_drawer.rb
79
+ - lib/ruby_jard/column.rb
105
80
  - lib/ruby_jard/commands/continue_command.rb
106
81
  - lib/ruby_jard/commands/down_command.rb
107
- - lib/ruby_jard/commands/finish_command.rb
108
82
  - lib/ruby_jard/commands/frame_command.rb
109
83
  - lib/ruby_jard/commands/next_command.rb
110
84
  - lib/ruby_jard/commands/step_command.rb
85
+ - lib/ruby_jard/commands/step_out_command.rb
111
86
  - lib/ruby_jard/commands/up_command.rb
87
+ - lib/ruby_jard/console.rb
88
+ - lib/ruby_jard/control_flow.rb
89
+ - lib/ruby_jard/decorators/color_decorator.rb
112
90
  - lib/ruby_jard/decorators/loc_decorator.rb
113
91
  - lib/ruby_jard/decorators/path_decorator.rb
114
92
  - lib/ruby_jard/decorators/source_decorator.rb
115
- - lib/ruby_jard/decorators/text_decorator.rb
93
+ - lib/ruby_jard/key_binding.rb
94
+ - lib/ruby_jard/key_bindings.rb
95
+ - lib/ruby_jard/keys.rb
116
96
  - lib/ruby_jard/layout.rb
117
- - lib/ruby_jard/layout_template.rb
97
+ - lib/ruby_jard/layouts/wide_layout.rb
118
98
  - lib/ruby_jard/repl_processor.rb
99
+ - lib/ruby_jard/repl_proxy.rb
100
+ - lib/ruby_jard/row.rb
119
101
  - lib/ruby_jard/screen.rb
102
+ - lib/ruby_jard/screen_drawer.rb
120
103
  - lib/ruby_jard/screen_manager.rb
121
104
  - lib/ruby_jard/screens.rb
122
105
  - lib/ruby_jard/screens/backtrace_screen.rb
123
- - lib/ruby_jard/screens/breakpoints_screen.rb
124
106
  - lib/ruby_jard/screens/empty_screen.rb
125
- - lib/ruby_jard/screens/expressions_sreen.rb
126
107
  - lib/ruby_jard/screens/menu_screen.rb
127
108
  - lib/ruby_jard/screens/source_screen.rb
128
109
  - lib/ruby_jard/screens/threads_screen.rb
129
110
  - lib/ruby_jard/screens/variables_screen.rb
130
111
  - lib/ruby_jard/session.rb
112
+ - lib/ruby_jard/span.rb
113
+ - lib/ruby_jard/templates/column_template.rb
114
+ - lib/ruby_jard/templates/layout_template.rb
115
+ - lib/ruby_jard/templates/row_template.rb
116
+ - lib/ruby_jard/templates/screen_template.rb
117
+ - lib/ruby_jard/templates/space_template.rb
118
+ - lib/ruby_jard/templates/span_template.rb
131
119
  - lib/ruby_jard/version.rb
132
120
  - ruby_jard.gemspec
133
121
  homepage: https://github.com/nguyenquangminh0711/ruby_jard
@@ -1,31 +0,0 @@
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)
@@ -1,61 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RubyJard
4
- module Decorators
5
- ##
6
- # Decorate text colos and styles. It acts as a wrapper for Pastel gem
7
- # TODO: the current color handling sucks. This should be migrated to a
8
- # color scheme system instead.
9
- class TextDecorator
10
- attr_reader :length, :content
11
-
12
- def initialize(color, highlighted = false)
13
- @length = 0
14
- @content = ''
15
- @color = color
16
- @highlighted = highlighted
17
- end
18
-
19
- def text(sentence, *styles)
20
- return self + sentence if sentence.is_a?(TextDecorator)
21
-
22
- sentence = sentence.to_s
23
- @length += sentence.length
24
-
25
- @content +=
26
- if styles.empty?
27
- sentence
28
- else
29
- @color.decorate(sentence, *compose_styles(styles))
30
- end
31
-
32
- self
33
- end
34
-
35
- def with_highlight(highlighted)
36
- @highlighted = highlighted
37
-
38
- self
39
- end
40
-
41
- def +(other)
42
- if other.is_a?(RubyJard::Decorators::TextDecorator)
43
- @length = other.length
44
- @content += other.content
45
- else
46
- text(other.to_s)
47
- end
48
-
49
- self
50
- end
51
-
52
- private
53
-
54
- def compose_styles(styles)
55
- styles.delete(:clear)
56
- styles.delete(:dim)
57
- styles.prepend(@highlighted ? :clear : :dim)
58
- end
59
- end
60
- end
61
- end
@@ -1,101 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RubyJard
4
- ##
5
- # Template of a layout. Templates are hierarchy. Each template includes the
6
- # sizing configuration, including absolute values, min, max, or ratio
7
- # relative to its parant.
8
- class LayoutTemplate
9
- attr_reader :screen, :height_ratio, :width_ratio,
10
- :min_width, :min_height,
11
- :height, :width,
12
- :children,
13
- :fill_width, :fill_height
14
-
15
- def initialize(
16
- screen: nil, height_ratio: nil, width_ratio: nil,
17
- min_width: nil, min_height: nil,
18
- height: nil, width: nil,
19
- children: [],
20
- fill_width: nil, fill_height: nil
21
- )
22
- @screen = screen
23
- @height_ratio = height_ratio
24
- @width_ratio = width_ratio
25
- @min_width = min_width
26
- @min_height = min_height
27
- @height = height
28
- @width = width
29
- @children = children
30
- @fill_width = fill_width
31
- @fill_height = fill_height
32
- end
33
- end
34
-
35
- WideLayoutTemplate = LayoutTemplate.new(
36
- min_width: 120,
37
- min_height: 10,
38
- fill_width: true,
39
- fill_height: false,
40
- children: [
41
- LayoutTemplate.new(
42
- height_ratio: 50,
43
- min_height: 7,
44
- fill_width: true,
45
- children: [
46
- LayoutTemplate.new(
47
- screen: :source,
48
- width_ratio: 60
49
- ),
50
- LayoutTemplate.new(
51
- width_ratio: 40,
52
- fill_height: true,
53
- children: [
54
- LayoutTemplate.new(
55
- screen: :variables,
56
- width_ratio: 100,
57
- height_ratio: 100,
58
- min_height: 3
59
- )
60
- # LayoutTemplate.new(
61
- # screen: :breakpoints,
62
- # width_ratio: 100,
63
- # height_ratio: 25,
64
- # min_height: 3
65
- # ),
66
- # LayoutTemplate.new(
67
- # screen: :expressions,
68
- # width_ratio: 100,
69
- # height_ratio: 25,
70
- # min_height: 3
71
- # )
72
- ]
73
- )
74
- ]
75
- ),
76
- LayoutTemplate.new(
77
- height_ratio: 20,
78
- min_height: 3,
79
- fill_width: true,
80
- children: [
81
- LayoutTemplate.new(
82
- screen: :backtrace,
83
- width_ratio: 60
84
- ),
85
- LayoutTemplate.new(
86
- screen: :threads,
87
- width_ratio: 40
88
- )
89
- ]
90
- ),
91
- LayoutTemplate.new(
92
- height: 2,
93
- screen: :menu
94
- )
95
- ]
96
- )
97
-
98
- DEFAULT_LAYOUT_TEMPLATES = [
99
- WideLayoutTemplate
100
- ].freeze
101
- end