yap-shell 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +9 -24
  3. data/Gemfile +1 -5
  4. data/LICENSE.txt +17 -18
  5. data/README.md +28 -14
  6. data/Rakefile +4 -1
  7. data/bin/yap +1 -3
  8. data/lib/.gitkeep +0 -0
  9. data/yap-shell.gemspec +12 -11
  10. metadata +19 -184
  11. data/.rspec +0 -2
  12. data/.travis.yml +0 -11
  13. data/DESIGN.md +0 -87
  14. data/Gemfile.travis +0 -8
  15. data/Gemfile.travis.lock +0 -104
  16. data/WISHLIST.md +0 -54
  17. data/bin/yap-dev +0 -45
  18. data/lib/tasks/gem.rake +0 -62
  19. data/lib/yap.rb +0 -52
  20. data/lib/yap/addon.rb +0 -24
  21. data/lib/yap/addon/base.rb +0 -52
  22. data/lib/yap/addon/export_as.rb +0 -12
  23. data/lib/yap/addon/loader.rb +0 -84
  24. data/lib/yap/addon/path.rb +0 -56
  25. data/lib/yap/addon/rc_file.rb +0 -21
  26. data/lib/yap/addon/reference.rb +0 -22
  27. data/lib/yap/cli.rb +0 -4
  28. data/lib/yap/cli/commands.rb +0 -6
  29. data/lib/yap/cli/commands/addon.rb +0 -14
  30. data/lib/yap/cli/commands/addon/disable.rb +0 -35
  31. data/lib/yap/cli/commands/addon/enable.rb +0 -35
  32. data/lib/yap/cli/commands/addon/list.rb +0 -37
  33. data/lib/yap/cli/commands/addon/search.rb +0 -99
  34. data/lib/yap/cli/commands/generate.rb +0 -13
  35. data/lib/yap/cli/commands/generate/addon.rb +0 -258
  36. data/lib/yap/cli/commands/generate/addonrb.template +0 -22
  37. data/lib/yap/cli/commands/generate/gemspec.template +0 -25
  38. data/lib/yap/cli/commands/generate/license.template +0 -21
  39. data/lib/yap/cli/commands/generate/rakefile.template +0 -6
  40. data/lib/yap/cli/commands/generate/readme.template +0 -40
  41. data/lib/yap/cli/options.rb +0 -162
  42. data/lib/yap/cli/options/addon.rb +0 -64
  43. data/lib/yap/cli/options/addon/disable.rb +0 -62
  44. data/lib/yap/cli/options/addon/enable.rb +0 -63
  45. data/lib/yap/cli/options/addon/list.rb +0 -65
  46. data/lib/yap/cli/options/addon/search.rb +0 -76
  47. data/lib/yap/cli/options/generate.rb +0 -59
  48. data/lib/yap/cli/options/generate/addon.rb +0 -63
  49. data/lib/yap/configuration.rb +0 -74
  50. data/lib/yap/gem_helper.rb +0 -195
  51. data/lib/yap/gem_tasks.rb +0 -6
  52. data/lib/yap/shell.rb +0 -116
  53. data/lib/yap/shell/aliases.rb +0 -58
  54. data/lib/yap/shell/builtins.rb +0 -18
  55. data/lib/yap/shell/builtins/alias.rb +0 -42
  56. data/lib/yap/shell/builtins/cd.rb +0 -57
  57. data/lib/yap/shell/builtins/env.rb +0 -11
  58. data/lib/yap/shell/commands.rb +0 -163
  59. data/lib/yap/shell/evaluation.rb +0 -439
  60. data/lib/yap/shell/evaluation/shell_expansions.rb +0 -99
  61. data/lib/yap/shell/event_emitter.rb +0 -18
  62. data/lib/yap/shell/execution.rb +0 -16
  63. data/lib/yap/shell/execution/builtin_command_execution.rb +0 -20
  64. data/lib/yap/shell/execution/command_execution.rb +0 -30
  65. data/lib/yap/shell/execution/context.rb +0 -128
  66. data/lib/yap/shell/execution/file_system_command_execution.rb +0 -137
  67. data/lib/yap/shell/execution/result.rb +0 -18
  68. data/lib/yap/shell/execution/ruby_command_execution.rb +0 -80
  69. data/lib/yap/shell/execution/shell_command_execution.rb +0 -30
  70. data/lib/yap/shell/prompt.rb +0 -21
  71. data/lib/yap/shell/repl.rb +0 -237
  72. data/lib/yap/shell/version.rb +0 -5
  73. data/lib/yap/world.rb +0 -286
  74. data/rcfiles/yaprc +0 -390
  75. data/scripts/4 +0 -8
  76. data/scripts/bg-vim +0 -4
  77. data/scripts/fail +0 -3
  78. data/scripts/letters +0 -8
  79. data/scripts/lots-of-output +0 -6
  80. data/scripts/pass +0 -3
  81. data/scripts/simulate-long-running +0 -4
  82. data/scripts/write-to-stderr.rb +0 -3
  83. data/scripts/write-to-stdout.rb +0 -3
  84. data/spec/features/addons/generating_an_addon_spec.rb +0 -55
  85. data/spec/features/addons/using_an_addon_spec.rb +0 -182
  86. data/spec/features/aliases_spec.rb +0 -78
  87. data/spec/features/environment_variables_spec.rb +0 -69
  88. data/spec/features/filesystem_commands_spec.rb +0 -61
  89. data/spec/features/first_time_spec.rb +0 -45
  90. data/spec/features/grouping_spec.rb +0 -81
  91. data/spec/features/line_editing_spec.rb +0 -174
  92. data/spec/features/range_spec.rb +0 -35
  93. data/spec/features/redirection_spec.rb +0 -234
  94. data/spec/features/repetition_spec.rb +0 -118
  95. data/spec/features/shell_expansions_spec.rb +0 -127
  96. data/spec/spec_helper.rb +0 -172
  97. data/spec/support/matchers/have_not_printed.rb +0 -30
  98. data/spec/support/matchers/have_printed.rb +0 -68
  99. data/spec/support/very_soon.rb +0 -9
  100. data/spec/support/yap_spec_dsl.rb +0 -258
  101. data/test.rb +0 -206
  102. data/update-rawline.sh +0 -6
data/test.rb DELETED
@@ -1,206 +0,0 @@
1
- require 'terminfo'
2
- require 'io/console'
3
- require 'term/ansicolor'
4
-
5
- $z = File.open("/tmp/z.log", "w+")
6
- $z.sync = true
7
-
8
- module EventEmitter
9
- def _callbacks
10
- @_callbacks ||= Hash.new { |h, k| h[k] = [] }
11
- end
12
-
13
- def on(type, *args, &blk)
14
- _callbacks[type] << blk
15
- self
16
- end
17
-
18
- def emit(type, *args)
19
- _callbacks[type].each do |blk|
20
- blk.call(*args)
21
- end
22
- end
23
- end
24
-
25
- class TerminalRenderer
26
- def initialize(layout_manager)
27
- @output = $stdout
28
- @terminfo = TermInfo.new ENV["TERM"], @output
29
- @layout_manager = layout_manager
30
- @layout_manager.on(:laid_out_content) do |content|
31
- display(content)
32
- end
33
- end
34
-
35
- def display(content)
36
- @output.print(
37
- @terminfo.control_string("clear"), # clear screen
38
- @terminfo.control_string("hpa", 0), # go to column 0 (assuming we're on row 0)
39
- @terminfo.control_string("sc"), # save cursor
40
- content,
41
- @terminfo.control_string("rc") # restore cursor
42
- )
43
- end
44
- end
45
-
46
- class LayoutManager
47
- include EventEmitter
48
-
49
- def initialize
50
- @renderers = []
51
- @mutex = Mutex.new
52
- end
53
-
54
- def add(renderer)
55
- @renderers << renderer
56
- renderer.on(:content_changed) do
57
- layout
58
- end
59
- end
60
-
61
- def layout(width:nil, height:nil)
62
- @mutex.synchronize { _layout(width, height) }
63
- end
64
-
65
- def _layout(width, height)
66
- width ||= $stdout.winsize.last
67
- height ||= $stdout.winsize.first
68
- results_arr = []
69
- column = 0
70
- row = 0
71
- @renderers.each do |renderer|
72
- $z.puts "", "rendering #{renderer.id}"
73
- $z.puts "Column: #{column} at row: #{row}"
74
- $z.puts "Term width: #{width} height: #{height}"
75
- $z.flush
76
- text = renderer.render(width)
77
-
78
- if renderer.anchor == :right
79
- start_column = width - text.length
80
- if start_column <= column || row > 0 # don't render the right prompt anywhere but the first line
81
- next # we've already rendered content here, so skip
82
- else
83
- column = start_column
84
- end
85
- end
86
-
87
- text.each_char do |ch|
88
- queued_text = results_arr.fetch(row){ " " * width }
89
- queued_text[column] = ch
90
- column += 1
91
-
92
- results_arr[row] = queued_text
93
-
94
- if queued_text.length > width
95
- row += 1
96
- column = 0
97
- end
98
- end
99
-
100
- end
101
-
102
- # puts "-"*40
103
- # puts results_arr.length
104
- # puts results_arr.inspect
105
- # puts results_arr#.join("\n")
106
- emit :laid_out_content, results_arr.join("\n")
107
- results_arr#.join("\n")
108
- end
109
- end
110
-
111
- class ContentRenderer
112
- include EventEmitter
113
-
114
- attr_reader :display, :anchor
115
-
116
- def id
117
- @content.id
118
- end
119
-
120
- def initialize(content, display:nil, anchor:nil)
121
- @display = display
122
- @anchor = anchor
123
- @last_width_rendered = nil
124
- @content = content
125
- @content.on(:content_changed) do |content, from:, to:|
126
- @dirty = true
127
- emit :content_changed
128
- end
129
- end
130
-
131
- def render(width)
132
- @content.text
133
- # @content.text.split(//).each_slice(width).map do |chars|
134
- # chars.join
135
- # end
136
- end
137
- end
138
-
139
- class Content
140
- include EventEmitter
141
-
142
- attr_accessor :id, :text
143
-
144
- def initialize(id:, text:"")
145
- @id = id
146
- @text = text
147
- end
148
-
149
- def text=(str)
150
- old_str = @text
151
- @text = str
152
- emit :content_changed, self, from:old_str, to:@text
153
- end
154
- end
155
-
156
- anchor_left = Content.new id:"anchor-left", text:""
157
- prompt = Content.new id:"prompt", text:"> "
158
- input = Content.new id:"input"
159
- right_prompt = Content.new id:"right-prompt"
160
-
161
- anchor_left_renderer = ContentRenderer.new anchor_left
162
- prompt_renderer = ContentRenderer.new(prompt, display: :inline)
163
- input_renderer = ContentRenderer.new(input)
164
- right_prompt_renderer = ContentRenderer.new(right_prompt, anchor: :right)
165
-
166
- layout_manager = LayoutManager.new
167
- layout_manager.add anchor_left_renderer
168
- layout_manager.add prompt_renderer
169
- layout_manager.add input_renderer
170
- layout_manager.add right_prompt_renderer
171
-
172
- terminal = TerminalRenderer.new(layout_manager)
173
-
174
- prompt.text = "> "
175
- sleep 1
176
- input.text = "ls a b c d e f g h i j k l m"
177
- # sleep 1
178
- # prompt.text = "abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz1234567890> "
179
- # sleep 1
180
- anchor_left.text = "£ "
181
- sleep 1
182
- prompt.text = "#{Dir.pwd}> "
183
- sleep 1
184
-
185
- Thread.new do
186
- loop do
187
- ["ls a b c", "echo hello world, goodbye world", "cat foo"].each do |str|
188
- input.text = str
189
- sleep 0.75
190
- end
191
- end
192
- end
193
-
194
- Thread.new do
195
- loop do
196
- %w(apples oranges bananas grapefruits pears cherries).each do |fruit|
197
- anchor_left.text = "(#{fruit}) "
198
- sleep 0.5
199
- end
200
- end
201
- end
202
-
203
- loop do
204
- right_prompt.text = "#{Time.now.to_s}"
205
- sleep 1
206
- end
@@ -1,6 +0,0 @@
1
- #!/bin/sh
2
-
3
- pushd ../../opensource_projects/rawline/
4
- gem build *.gemspec
5
- popd
6
- gem install ../../opensource_projects/rawline/*.gem