pretty_irb 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 +7 -0
- data/00-MANIFEST.md +356 -0
- data/ADVANCED_FEATURES.md +440 -0
- data/AI_HELP.md +408 -0
- data/AI_QUICK_START.md +247 -0
- data/COMPLETE.md +421 -0
- data/EXAMPLES.md +206 -0
- data/FEATURE_SHOWCASE.md +441 -0
- data/FILE_STRUCTURE.md +231 -0
- data/Gemfile +3 -0
- data/IMPLEMENTATION_COMPLETE.md +309 -0
- data/INDEX.md +708 -0
- data/INSTALL.md +250 -0
- data/LICENSE.txt +21 -0
- data/PUBLISH_TO_RUBYGEMS.md +466 -0
- data/QUICKSTART.md +70 -0
- data/QUICK_REFERENCE.md +253 -0
- data/README.md +251 -0
- data/Rakefile +6 -0
- data/SETUP.md +209 -0
- data/START_HERE.md +462 -0
- data/SUMMARY.md +372 -0
- data/WELCOME.md +300 -0
- data/WHAT_IS_NEW.md +324 -0
- data/exe/irb1 +6 -0
- data/exe/pretty_irb +6 -0
- data/lib/pretty_irb/ai_helper.rb +842 -0
- data/lib/pretty_irb/auto_corrector.rb +76 -0
- data/lib/pretty_irb/benchmarker.rb +94 -0
- data/lib/pretty_irb/cheat_sheet.rb +476 -0
- data/lib/pretty_irb/formatter.rb +66 -0
- data/lib/pretty_irb/history_manager.rb +97 -0
- data/lib/pretty_irb/shell.rb +387 -0
- data/lib/pretty_irb/snippet_manager.rb +119 -0
- data/lib/pretty_irb/variable_inspector.rb +146 -0
- data/lib/pretty_irb/version.rb +3 -0
- data/lib/pretty_irb.rb +26 -0
- metadata +200 -0
data/QUICK_REFERENCE.md
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
# Pretty IRB - Quick Feature Reference
|
|
2
|
+
|
|
3
|
+
## ๐ Quick Start Commands
|
|
4
|
+
|
|
5
|
+
### History Management (Search & Replay)
|
|
6
|
+
```ruby
|
|
7
|
+
history # Show all commands
|
|
8
|
+
history search keyword # Find past commands
|
|
9
|
+
history last 5 # View recent 5 commands
|
|
10
|
+
history export file.rb # Save session
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Snippet Manager (Save Code)
|
|
14
|
+
```ruby
|
|
15
|
+
snippet save name "code" # Store code snippet
|
|
16
|
+
snippet list # Show all snippets
|
|
17
|
+
snippet load name # Execute snippet
|
|
18
|
+
snippet search term # Find snippets
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Variable Inspector (Inspect State)
|
|
22
|
+
```ruby
|
|
23
|
+
vars # List all variables
|
|
24
|
+
vars name # Details on variable
|
|
25
|
+
vars type:String # Find String variables
|
|
26
|
+
vars memory # Memory usage report
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Benchmarker (Performance Testing)
|
|
30
|
+
```ruby
|
|
31
|
+
bench "code" # Benchmark code
|
|
32
|
+
bench compare "a" vs "b" # Compare two approaches
|
|
33
|
+
bench memory "code" # Memory profiling
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Ruby Cheat Sheet (Quick Reference)
|
|
37
|
+
```ruby
|
|
38
|
+
cheat # General reference
|
|
39
|
+
cheat array # Array methods
|
|
40
|
+
cheat hash # Hash methods
|
|
41
|
+
cheat string # String methods
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## ๐ก Real-World Examples
|
|
47
|
+
|
|
48
|
+
### Example 1: Finding Performance Issues
|
|
49
|
+
|
|
50
|
+
```ruby
|
|
51
|
+
# 1. Load a function
|
|
52
|
+
snippet save my_func "[1,2,3].each { |x| puts x }"
|
|
53
|
+
|
|
54
|
+
# 2. Benchmark it
|
|
55
|
+
bench "my_func"
|
|
56
|
+
|
|
57
|
+
# 3. Try faster version
|
|
58
|
+
bench compare "[1,2,3].each { |x| puts x }" vs "[1,2,3].map { puts _1 }"
|
|
59
|
+
|
|
60
|
+
# 4. Check memory
|
|
61
|
+
bench memory "[1,2,3].each { |x| puts x }"
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Example 2: Learning New Methods
|
|
65
|
+
|
|
66
|
+
```ruby
|
|
67
|
+
# 1. View cheatsheet
|
|
68
|
+
cheat array
|
|
69
|
+
|
|
70
|
+
# 2. Try different methods
|
|
71
|
+
[1,2,3].map { |x| x * 2 }
|
|
72
|
+
|
|
73
|
+
# 3. Get explanation
|
|
74
|
+
?explain(map)
|
|
75
|
+
|
|
76
|
+
# 4. See best practices
|
|
77
|
+
?practices(performance)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Example 3: Session Management
|
|
81
|
+
|
|
82
|
+
```ruby
|
|
83
|
+
# 1. Work on code
|
|
84
|
+
name = "Ruby"
|
|
85
|
+
scores = [95, 87, 92]
|
|
86
|
+
|
|
87
|
+
# 2. Inspect variables
|
|
88
|
+
vars
|
|
89
|
+
|
|
90
|
+
# 3. Search history
|
|
91
|
+
history search scores
|
|
92
|
+
|
|
93
|
+
# 4. Export everything
|
|
94
|
+
history export my_work.rb
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## ๐ All New Features Matrix
|
|
100
|
+
|
|
101
|
+
| Feature | Command | Purpose |
|
|
102
|
+
|---------|---------|---------|
|
|
103
|
+
| **History** | `history` | Search & replay commands |
|
|
104
|
+
| **History Search** | `history search TERM` | Find past commands |
|
|
105
|
+
| **History Export** | `history export FILE` | Save session to file |
|
|
106
|
+
| **Snippet Save** | `snippet save NAME CODE` | Store code patterns |
|
|
107
|
+
| **Snippet List** | `snippet list` | View all saved snippets |
|
|
108
|
+
| **Snippet Load** | `snippet load NAME` | Execute saved snippet |
|
|
109
|
+
| **Variable List** | `vars` | See all variables |
|
|
110
|
+
| **Variable Detail** | `vars NAME` | Inspect specific var |
|
|
111
|
+
| **Variable Search** | `vars search:TERM` | Find variables by name |
|
|
112
|
+
| **Type Filter** | `vars type:String` | Find by type |
|
|
113
|
+
| **Memory Report** | `vars memory` | Usage breakdown |
|
|
114
|
+
| **Benchmark** | `bench CODE` | Performance test |
|
|
115
|
+
| **Compare** | `bench compare A vs B` | Performance comparison |
|
|
116
|
+
| **Memory Profile** | `bench memory CODE` | Memory allocation |
|
|
117
|
+
| **Cheat Sheet** | `cheat` | General reference |
|
|
118
|
+
| **Topic Reference** | `cheat TOPIC` | Topic-specific help |
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## ๐ฏ Pro Tips & Tricks
|
|
123
|
+
|
|
124
|
+
### 1. Fast Learning Loop
|
|
125
|
+
```ruby
|
|
126
|
+
cheat array # See reference
|
|
127
|
+
[1,2,3].select { |x| x > 1 } # Try it
|
|
128
|
+
?explain(select) # Understand it
|
|
129
|
+
?practices(readability) # Learn best way
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### 2. Performance Optimization
|
|
133
|
+
```ruby
|
|
134
|
+
snippet save original "slow_code"
|
|
135
|
+
bench original
|
|
136
|
+
# Make changes...
|
|
137
|
+
bench compare "slow_code" vs "new_code"
|
|
138
|
+
snippet save optimized "new_code"
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### 3. Session Export
|
|
142
|
+
```ruby
|
|
143
|
+
# Work on something
|
|
144
|
+
x = 5
|
|
145
|
+
y = x * 2
|
|
146
|
+
|
|
147
|
+
# Save everything
|
|
148
|
+
history export work_session.rb
|
|
149
|
+
# Now you have all commands in a file!
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### 4. Code Reuse
|
|
153
|
+
```ruby
|
|
154
|
+
# Save useful patterns
|
|
155
|
+
snippet save sum_array "arr.reduce(:+)"
|
|
156
|
+
snippet save double_array "arr.map { |x| x * 2 }"
|
|
157
|
+
|
|
158
|
+
# Later, just load them
|
|
159
|
+
snippet load sum_array
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### 5. Memory Analysis
|
|
163
|
+
```ruby
|
|
164
|
+
# Create data
|
|
165
|
+
big_array = (1..10000).to_a
|
|
166
|
+
big_hash = big_array.each_with_index.to_h
|
|
167
|
+
|
|
168
|
+
# Analyze
|
|
169
|
+
vars memory
|
|
170
|
+
# See which takes more space
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## ๐ Troubleshooting
|
|
176
|
+
|
|
177
|
+
### Snippets not saving?
|
|
178
|
+
- Check `~/.pretty_irb_snippets/` directory exists
|
|
179
|
+
- Ensure write permissions in home directory
|
|
180
|
+
|
|
181
|
+
### History not showing?
|
|
182
|
+
- History only records during REPL session
|
|
183
|
+
- Export before exiting to save permanently
|
|
184
|
+
|
|
185
|
+
### Benchmark results vary?
|
|
186
|
+
- First run may be slower (optimization)
|
|
187
|
+
- Try multiple benchmarks for average
|
|
188
|
+
- Close other applications for consistent results
|
|
189
|
+
|
|
190
|
+
### Variables disappearing?
|
|
191
|
+
- They only exist during current session
|
|
192
|
+
- Use `history export` to save code
|
|
193
|
+
- Use `snippet save` to preserve code
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## ๐ Feature Comparison
|
|
198
|
+
|
|
199
|
+
### vs Regular IRB
|
|
200
|
+
- โ
Pretty colored output
|
|
201
|
+
- โ
History search & export
|
|
202
|
+
- โ
Snippet management
|
|
203
|
+
- โ
Variable inspection
|
|
204
|
+
- โ
Performance benchmarking
|
|
205
|
+
- โ
AI learning features
|
|
206
|
+
- โ
Ruby cheat sheets
|
|
207
|
+
|
|
208
|
+
### vs Python IPython
|
|
209
|
+
- โ
Ruby-specific features
|
|
210
|
+
- โ
Snippet management
|
|
211
|
+
- โ
AI helper for learning
|
|
212
|
+
- โ
Cheat sheet integration
|
|
213
|
+
- โ
Benchmarking built-in
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## ๐ Getting Started in 5 Minutes
|
|
218
|
+
|
|
219
|
+
1. **Start Pretty IRB**
|
|
220
|
+
```bash
|
|
221
|
+
pretty_irb
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
2. **Try a command**
|
|
225
|
+
```ruby
|
|
226
|
+
[1, 2, 3].map { |x| x * 2 }
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
3. **View history**
|
|
230
|
+
```ruby
|
|
231
|
+
history
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
4. **Learn about methods**
|
|
235
|
+
```ruby
|
|
236
|
+
?explain(map)
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
5. **Save for later**
|
|
240
|
+
```ruby
|
|
241
|
+
snippet save my_snippet "[1, 2, 3].map { |x| x * 2 }"
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
Done! You're now using Pretty IRB's advanced features!
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## ๐ See Also
|
|
249
|
+
|
|
250
|
+
- [README.md](README.md) - Main documentation
|
|
251
|
+
- [ADVANCED_FEATURES.md](ADVANCED_FEATURES.md) - Detailed feature guide
|
|
252
|
+
- [AI_HELP.md](AI_HELP.md) - AI Helper documentation
|
|
253
|
+
- [AI_QUICK_START.md](AI_QUICK_START.md) - AI learning guide
|
data/README.md
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
# Pretty IRB - Enhanced Interactive Ruby Shell
|
|
2
|
+
|
|
3
|
+
A beautiful, feature-rich IRB alternative with:
|
|
4
|
+
|
|
5
|
+
โจ **Pretty Fonts & Colors** - Beautiful syntax highlighting with colorized output
|
|
6
|
+
๐ง **Auto-Correct** - Smart suggestions for common mistakes using `did_you_mean`
|
|
7
|
+
๐ค **AI Helper** - Learn Ruby methods, best practices, and get code analysis
|
|
8
|
+
๐ **History Manager** - Search and replay command history
|
|
9
|
+
๐พ **Snippet Manager** - Save and reuse code snippets
|
|
10
|
+
๐ **Variable Inspector** - Inspect and analyze variables
|
|
11
|
+
โก **Benchmarker** - Performance testing and comparison
|
|
12
|
+
๐ **Ruby Cheat Sheet** - Quick reference for syntax and methods
|
|
13
|
+
โก **Enhanced Readline** - Better line editing with history support
|
|
14
|
+
๐ก **Helpful Hints** - Smart error messages with correction suggestions
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
Add this line to your Gemfile:
|
|
19
|
+
|
|
20
|
+
```ruby
|
|
21
|
+
gem 'pretty_irb'
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Or install it yourself:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
gem install pretty_irb
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
Start the Pretty IRB shell:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pretty_irb
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Then use it like regular IRB:
|
|
39
|
+
|
|
40
|
+
```ruby
|
|
41
|
+
pretty_irb >> 1 + 2
|
|
42
|
+
=> 3
|
|
43
|
+
|
|
44
|
+
pretty_irb >> "hello world".upcase
|
|
45
|
+
=> "HELLO WORLD"
|
|
46
|
+
|
|
47
|
+
pretty_irb >> [1, 2, 3].map { |x| x * 2 }
|
|
48
|
+
=> [2, 4, 6]
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Commands
|
|
52
|
+
|
|
53
|
+
#### Basic Commands
|
|
54
|
+
- `exit` or `quit` - Exit the shell
|
|
55
|
+
- `help` - Show available commands
|
|
56
|
+
- `clear` - Clear the screen
|
|
57
|
+
|
|
58
|
+
#### History Management
|
|
59
|
+
- `history` - Show all command history
|
|
60
|
+
- `history search KEYWORD` - Search history
|
|
61
|
+
- `history last N` - Show last N commands
|
|
62
|
+
- `history export FILE` - Export to file
|
|
63
|
+
- `history clear` - Clear history
|
|
64
|
+
|
|
65
|
+
#### Snippet Manager
|
|
66
|
+
- `snippet list` - List saved snippets
|
|
67
|
+
- `snippet save NAME CODE` - Save code
|
|
68
|
+
- `snippet load NAME` - Load and execute
|
|
69
|
+
- `snippet show NAME` - View snippet details
|
|
70
|
+
- `snippet delete NAME` - Delete snippet
|
|
71
|
+
- `snippet search KEYWORD` - Search snippets
|
|
72
|
+
|
|
73
|
+
#### Variable Inspector
|
|
74
|
+
- `vars` - List all variables
|
|
75
|
+
- `vars VARNAME` - Inspect variable
|
|
76
|
+
- `vars type:TYPE` - Find by type
|
|
77
|
+
- `vars search:KEYWORD` - Search variables
|
|
78
|
+
- `vars memory` - Memory usage
|
|
79
|
+
|
|
80
|
+
#### Benchmarker
|
|
81
|
+
- `bench CODE` - Benchmark code
|
|
82
|
+
- `bench compare CODE1 vs CODE2` - Compare
|
|
83
|
+
- `bench memory CODE` - Profile memory
|
|
84
|
+
|
|
85
|
+
#### Cheat Sheet
|
|
86
|
+
- `cheat` - Show general cheat sheet
|
|
87
|
+
- `cheat TOPIC` - Topic cheat sheet (array, hash, string, enumerable, file, regex, date)
|
|
88
|
+
|
|
89
|
+
#### AI Helper
|
|
90
|
+
- `?explain(method)` - Explain a method
|
|
91
|
+
- `?example(topic)` - Get code examples
|
|
92
|
+
- `?debug(code)` - Analyze code
|
|
93
|
+
- `?practices(topic)` - Learn best practices
|
|
94
|
+
- `?ref(keyword)` - Quick reference
|
|
95
|
+
|
|
96
|
+
## Features
|
|
97
|
+
|
|
98
|
+
### 1. Syntax Highlighting
|
|
99
|
+
Code is automatically syntax-highlighted with beautiful colors using the Rouge gem.
|
|
100
|
+
|
|
101
|
+
### 2. Auto-Correct
|
|
102
|
+
Common Ruby errors are automatically corrected and suggestions are provided:
|
|
103
|
+
- Method name typos (`.lenght` โ `.length`)
|
|
104
|
+
- Variable name suggestions using `did_you_mean`
|
|
105
|
+
- Helpful error messages
|
|
106
|
+
|
|
107
|
+
### 3. Pretty Output
|
|
108
|
+
Different data types are displayed with appropriate colors:
|
|
109
|
+
- Strings in blue
|
|
110
|
+
- Numbers in green
|
|
111
|
+
- Booleans in cyan
|
|
112
|
+
- Nil in gray
|
|
113
|
+
- Arrays and Hashes formatted nicely
|
|
114
|
+
|
|
115
|
+
### 4. AI Helper - Learn Ruby Interactively! ๐ค
|
|
116
|
+
|
|
117
|
+
Get instant help right in your REPL:
|
|
118
|
+
|
|
119
|
+
```ruby
|
|
120
|
+
# Learn how a method works
|
|
121
|
+
pretty_irb >> ?explain(map)
|
|
122
|
+
|
|
123
|
+
# Get code examples
|
|
124
|
+
pretty_irb >> ?example(class)
|
|
125
|
+
|
|
126
|
+
# Learn best practices
|
|
127
|
+
pretty_irb >> ?practices(naming)
|
|
128
|
+
|
|
129
|
+
# Analyze your code for issues
|
|
130
|
+
pretty_irb >> ?debug("[1,2,3][0]")
|
|
131
|
+
|
|
132
|
+
# Quick reference
|
|
133
|
+
pretty_irb >> ?ref(operators)
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
See [AI_HELP.md](AI_HELP.md) for detailed documentation.
|
|
137
|
+
|
|
138
|
+
### 5. History Manager ๐
|
|
139
|
+
|
|
140
|
+
Never lose your commands again:
|
|
141
|
+
|
|
142
|
+
```ruby
|
|
143
|
+
# Search previous commands
|
|
144
|
+
pretty_irb >> history search map
|
|
145
|
+
|
|
146
|
+
# View recent history
|
|
147
|
+
pretty_irb >> history last 10
|
|
148
|
+
|
|
149
|
+
# Export for sharing
|
|
150
|
+
pretty_irb >> history export my_session.rb
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### 6. Snippet Manager ๐พ
|
|
154
|
+
|
|
155
|
+
Save and reuse code patterns:
|
|
156
|
+
|
|
157
|
+
```ruby
|
|
158
|
+
# Save a useful snippet
|
|
159
|
+
pretty_irb >> snippet save double_array "[1,2,3].map { |x| x * 2 }"
|
|
160
|
+
|
|
161
|
+
# Load it later
|
|
162
|
+
pretty_irb >> snippet load double_array
|
|
163
|
+
|
|
164
|
+
# Search your snippets
|
|
165
|
+
pretty_irb >> snippet search array
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### 7. Variable Inspector ๐
|
|
169
|
+
|
|
170
|
+
Understand your current state:
|
|
171
|
+
|
|
172
|
+
```ruby
|
|
173
|
+
# List all variables
|
|
174
|
+
pretty_irb >> vars
|
|
175
|
+
|
|
176
|
+
# Inspect specific variable
|
|
177
|
+
pretty_irb >> vars name
|
|
178
|
+
|
|
179
|
+
# Find by type
|
|
180
|
+
pretty_irb >> vars type:String
|
|
181
|
+
|
|
182
|
+
# Memory usage
|
|
183
|
+
pretty_irb >> vars memory
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### 8. Benchmarker โก
|
|
187
|
+
|
|
188
|
+
Measure and compare code performance:
|
|
189
|
+
|
|
190
|
+
```ruby
|
|
191
|
+
# Benchmark code
|
|
192
|
+
pretty_irb >> bench "[1,2,3] * 100"
|
|
193
|
+
|
|
194
|
+
# Compare implementations
|
|
195
|
+
pretty_irb >> bench compare "(1..100).map { |x| x*2 }" vs "(1..100).collect { |x| x*2 }"
|
|
196
|
+
|
|
197
|
+
# Profile memory
|
|
198
|
+
pretty_irb >> bench memory "[1,2,3] * 1000"
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### 9. Ruby Cheat Sheet ๐
|
|
202
|
+
|
|
203
|
+
Quick reference without leaving REPL:
|
|
204
|
+
|
|
205
|
+
```ruby
|
|
206
|
+
# General overview
|
|
207
|
+
pretty_irb >> cheat
|
|
208
|
+
|
|
209
|
+
# Array methods
|
|
210
|
+
pretty_irb >> cheat array
|
|
211
|
+
|
|
212
|
+
# String methods
|
|
213
|
+
pretty_irb >> cheat string
|
|
214
|
+
|
|
215
|
+
# Available topics: array, hash, string, enumerable, file, regex, date
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### 10. Enhanced Error Messages
|
|
219
|
+
Errors include color-coded messages and helpful hints:
|
|
220
|
+
```
|
|
221
|
+
NameError: undefined local variable or method `foo'
|
|
222
|
+
๐ก Did you mean?: for
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## Documentation
|
|
226
|
+
|
|
227
|
+
- [AI_HELP.md](AI_HELP.md) - AI Helper features and examples
|
|
228
|
+
- [ADVANCED_FEATURES.md](ADVANCED_FEATURES.md) - Advanced features guide with workflows
|
|
229
|
+
|
|
230
|
+
## Development
|
|
231
|
+
|
|
232
|
+
After checking out the repo, run `bundle install` to install dependencies.
|
|
233
|
+
|
|
234
|
+
Then run `rake spec` to run the tests.
|
|
235
|
+
|
|
236
|
+
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
237
|
+
|
|
238
|
+
## Contributing
|
|
239
|
+
|
|
240
|
+
Bug reports and pull requests are welcome on GitHub.
|
|
241
|
+
|
|
242
|
+
## License
|
|
243
|
+
|
|
244
|
+
The gem is available as open source under the terms of the MIT License.
|
|
245
|
+
|
|
246
|
+
## Inspirations
|
|
247
|
+
|
|
248
|
+
This gem is inspired by:
|
|
249
|
+
- Ruby's IRB (Interactive Ruby Shell)
|
|
250
|
+
- Python's IPython
|
|
251
|
+
- Node.js's REPL with autocomplete
|
data/Rakefile
ADDED
data/SETUP.md
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# Pretty IRB - Setup Guide
|
|
2
|
+
|
|
3
|
+
## ๐ฆ Installation
|
|
4
|
+
|
|
5
|
+
### Option 1: Local Development
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
cd c:\Users\Jayesh\Music\ROR\pretty_irb
|
|
9
|
+
bundle install
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
### Option 2: Install as Gem (for production)
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
gem build pretty_irb.gemspec
|
|
16
|
+
gem install pretty_irb-0.1.0.gem
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## ๐ Running Pretty IRB
|
|
20
|
+
|
|
21
|
+
### Development Mode
|
|
22
|
+
```bash
|
|
23
|
+
ruby bin/console
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Installed as Gem
|
|
27
|
+
```bash
|
|
28
|
+
pretty_irb
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## ๐ Project Structure
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
pretty_irb/
|
|
35
|
+
โโโ bin/
|
|
36
|
+
โ โโโ console # Development console
|
|
37
|
+
โ โโโ setup
|
|
38
|
+
โโโ exe/
|
|
39
|
+
โ โโโ pretty_irb # Executable entry point
|
|
40
|
+
โโโ lib/
|
|
41
|
+
โ โโโ pretty_irb.rb # Main gem file
|
|
42
|
+
โ โโโ pretty_irb/
|
|
43
|
+
โ โโโ version.rb # Version info
|
|
44
|
+
โ โโโ formatter.rb # Syntax highlighting & output formatting
|
|
45
|
+
โ โโโ auto_corrector.rb # Auto-correct functionality
|
|
46
|
+
โ โโโ shell.rb # Main REPL shell
|
|
47
|
+
โโโ spec/
|
|
48
|
+
โ โโโ spec_helper.rb
|
|
49
|
+
โ โโโ pretty_irb_spec.rb
|
|
50
|
+
โ โโโ formatter_spec.rb
|
|
51
|
+
โ โโโ auto_corrector_spec.rb
|
|
52
|
+
โโโ Gemfile # Dependencies
|
|
53
|
+
โโโ Rakefile # Build tasks
|
|
54
|
+
โโโ pretty_irb.gemspec # Gem specification
|
|
55
|
+
โโโ README.md # Documentation
|
|
56
|
+
โโโ LICENSE.txt # MIT License
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## โจ Key Features
|
|
60
|
+
|
|
61
|
+
### 1. **Syntax Highlighting**
|
|
62
|
+
- Ruby code is automatically highlighted with beautiful colors
|
|
63
|
+
- Uses Rouge gem for lexing
|
|
64
|
+
|
|
65
|
+
### 2. **Auto-Correct**
|
|
66
|
+
- Common method name typos are fixed automatically
|
|
67
|
+
- `did_you_mean` provides smart suggestions for errors
|
|
68
|
+
- Helpful error messages with fix suggestions
|
|
69
|
+
|
|
70
|
+
### 3. **Pretty Output**
|
|
71
|
+
- Strings: Light Blue
|
|
72
|
+
- Numbers: Light Green
|
|
73
|
+
- Booleans: Light Cyan
|
|
74
|
+
- Nil: Light Black/Gray
|
|
75
|
+
- Arrays & Hashes: Formatted with colors
|
|
76
|
+
|
|
77
|
+
### 4. **Enhanced REPL**
|
|
78
|
+
- Customizable prompt
|
|
79
|
+
- Command history
|
|
80
|
+
- Better line editing with Reline
|
|
81
|
+
- `help` command for available commands
|
|
82
|
+
|
|
83
|
+
## ๐ง Dependencies
|
|
84
|
+
|
|
85
|
+
```ruby
|
|
86
|
+
irb >= 1.0 # Interactive Ruby shell base
|
|
87
|
+
rouge ~> 3.26 # Syntax highlighting
|
|
88
|
+
colorize ~> 0.8 # Colored output
|
|
89
|
+
did_you_mean ~> 1.5 # Auto-correct suggestions
|
|
90
|
+
reline ~> 0.3 # Enhanced readline
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## ๐ก Usage Examples
|
|
94
|
+
|
|
95
|
+
```ruby
|
|
96
|
+
# Start the shell
|
|
97
|
+
$ pretty_irb
|
|
98
|
+
|
|
99
|
+
pretty_irb >> 1 + 2
|
|
100
|
+
=> 3
|
|
101
|
+
|
|
102
|
+
pretty_irb >> "hello".upcase
|
|
103
|
+
=> "HELLO"
|
|
104
|
+
|
|
105
|
+
pretty_irb >> [1, 2, 3].map { |x| x * 2 }
|
|
106
|
+
=> [2, 4, 6]
|
|
107
|
+
|
|
108
|
+
pretty_irb >> { name: "Ruby", version: 2.7 }
|
|
109
|
+
=> {:name=>"Ruby", :version=>2.7}
|
|
110
|
+
|
|
111
|
+
# Commands
|
|
112
|
+
pretty_irb >> help # Show available commands
|
|
113
|
+
pretty_irb >> exit # Exit the shell
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## ๐งช Running Tests
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
cd pretty_irb
|
|
120
|
+
bundle install
|
|
121
|
+
bundle exec rspec
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## ๐ Development Notes
|
|
125
|
+
|
|
126
|
+
### Adding New Auto-Corrections
|
|
127
|
+
|
|
128
|
+
Edit `lib/pretty_irb/auto_corrector.rb`:
|
|
129
|
+
|
|
130
|
+
```ruby
|
|
131
|
+
def fix_method_names(code)
|
|
132
|
+
code.gsub(/\.old_method/, ".new_method")
|
|
133
|
+
end
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Adding New Syntax Colors
|
|
137
|
+
|
|
138
|
+
Edit `lib/pretty_irb/formatter.rb`:
|
|
139
|
+
|
|
140
|
+
```ruby
|
|
141
|
+
def colorize_token(token_type, value)
|
|
142
|
+
case token_type
|
|
143
|
+
when Rouge::Token::YourToken
|
|
144
|
+
value.your_color
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## ๐ Troubleshooting
|
|
150
|
+
|
|
151
|
+
### Issue: Commands not found
|
|
152
|
+
**Solution**: Make sure the gem is properly installed:
|
|
153
|
+
```bash
|
|
154
|
+
gem list | grep pretty_irb
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Issue: Colors not showing
|
|
158
|
+
**Solution**: Try running with:
|
|
159
|
+
```bash
|
|
160
|
+
export TERM=xterm-256color
|
|
161
|
+
pretty_irb
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Issue: Auto-correct not working
|
|
165
|
+
**Solution**: Check that `did_you_mean` is properly installed:
|
|
166
|
+
```bash
|
|
167
|
+
gem list | grep did_you_mean
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## ๐ Next Steps
|
|
171
|
+
|
|
172
|
+
### Future Enhancements
|
|
173
|
+
|
|
174
|
+
1. **More Auto-Corrections**
|
|
175
|
+
- Common Rails methods
|
|
176
|
+
- String method typos
|
|
177
|
+
- Common logic errors
|
|
178
|
+
|
|
179
|
+
2. **Theme Support**
|
|
180
|
+
- Dark mode
|
|
181
|
+
- Light mode
|
|
182
|
+
- Custom themes
|
|
183
|
+
|
|
184
|
+
3. **Enhanced Features**
|
|
185
|
+
- Code search history
|
|
186
|
+
- Snippet support
|
|
187
|
+
- Plugin system
|
|
188
|
+
|
|
189
|
+
4. **Performance**
|
|
190
|
+
- Faster startup time
|
|
191
|
+
- Caching for frequently used methods
|
|
192
|
+
- Lazy loading of modules
|
|
193
|
+
|
|
194
|
+
## ๐ License
|
|
195
|
+
|
|
196
|
+
MIT License - See LICENSE.txt for details
|
|
197
|
+
|
|
198
|
+
## ๐ค Contributing
|
|
199
|
+
|
|
200
|
+
Contributions are welcome! Please:
|
|
201
|
+
1. Fork the repository
|
|
202
|
+
2. Create a feature branch
|
|
203
|
+
3. Make your changes
|
|
204
|
+
4. Write tests
|
|
205
|
+
5. Submit a pull request
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
For more information, see README.md or visit the GitHub repository.
|