tconsole 1.0.1pre1 → 1.0.1pre2
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.
- data/README.md +2 -2
- data/lib/tconsole/version.rb +1 -1
- data/lib/tconsole.rb +31 -9
- metadata +3 -3
data/README.md
CHANGED
@@ -32,9 +32,9 @@ Installing tconsole
|
|
32
32
|
|
33
33
|
How to use tconsole
|
34
34
|
------
|
35
|
-
In your shell of choice, cd into your Rails project's directory and then run
|
35
|
+
In your shell of choice, cd into your Rails project's directory and then run `bundle exec tconsole` to fire up the console. You should see something like this:
|
36
36
|
|
37
|
-
tconsole
|
37
|
+
bundle exec tconsole
|
38
38
|
|
39
39
|
Loading your Rails environment...
|
40
40
|
Environment loaded in 7.160264s.
|
data/lib/tconsole/version.rb
CHANGED
data/lib/tconsole.rb
CHANGED
@@ -5,10 +5,27 @@ require "readline"
|
|
5
5
|
require "benchmark"
|
6
6
|
require "drb/drb"
|
7
7
|
|
8
|
+
Readline.completion_append_character = ""
|
9
|
+
|
10
|
+
# Proc for helping us figure out autocompletes
|
11
|
+
Readline.completion_proc = Proc.new do |str|
|
12
|
+
known_commands = TConsole::Console::KNOWN_COMMANDS.grep(/^#{Regexp.escape(str)}/)
|
13
|
+
|
14
|
+
files = Dir[str+'*'].grep(/^#{Regexp.escape(str)}/)
|
15
|
+
formatted_files = files.collect do |filename|
|
16
|
+
if File.directory?(filename)
|
17
|
+
filename + File::SEPARATOR
|
18
|
+
else
|
19
|
+
filename
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
known_commands.concat(formatted_files)
|
24
|
+
end
|
25
|
+
|
8
26
|
module TConsole
|
9
27
|
class Runner
|
10
28
|
|
11
|
-
SERVER_URI = "druby://localhost:8788"
|
12
29
|
# Spawns a new environment. Looks at the results of the environment to determine whether to stop or
|
13
30
|
# keep running
|
14
31
|
def self.run(argv)
|
@@ -32,12 +49,11 @@ module TConsole
|
|
32
49
|
while running
|
33
50
|
# ignore ctrl-c during load, since things can get kind of messy if we don't
|
34
51
|
|
35
|
-
fork do
|
52
|
+
server_pid = fork do
|
36
53
|
begin
|
37
54
|
server = Server.new(config)
|
38
55
|
|
39
|
-
DRb.start_service(
|
40
|
-
|
56
|
+
drb_server = DRb.start_service("drbunix://tmp/tconsole.#{Process.pid}", server)
|
41
57
|
DRb.thread.join
|
42
58
|
rescue Interrupt
|
43
59
|
# do nothing here since the outer process will shut things down for us
|
@@ -45,7 +61,7 @@ module TConsole
|
|
45
61
|
end
|
46
62
|
|
47
63
|
# Set up our client connection to the server
|
48
|
-
server = DRbObject.new_with_uri(
|
64
|
+
server = DRbObject.new_with_uri("drbunix://tmp/tconsole.#{server_pid}")
|
49
65
|
|
50
66
|
loaded = false
|
51
67
|
wait_until = Time.now + 10
|
@@ -82,6 +98,7 @@ module TConsole
|
|
82
98
|
end
|
83
99
|
|
84
100
|
class Console
|
101
|
+
KNOWN_COMMANDS = ["exit", "reload", "help", "units", "functionals", "integration", "recent", "uncommitted", "all", "info", "!failed"]
|
85
102
|
|
86
103
|
def initialize
|
87
104
|
read_history
|
@@ -89,7 +106,10 @@ module TConsole
|
|
89
106
|
|
90
107
|
# Returns true if the app should keep running, false otherwise
|
91
108
|
def read_and_execute(server)
|
92
|
-
while line = Readline.readline("tconsole> ",
|
109
|
+
while line = Readline.readline("tconsole> ", false)
|
110
|
+
# TODO: Avoid pushing duplicate commands onto the history
|
111
|
+
Readline::HISTORY << line
|
112
|
+
|
93
113
|
line.strip!
|
94
114
|
args = line.split(/\s/)
|
95
115
|
|
@@ -156,7 +176,7 @@ module TConsole
|
|
156
176
|
def store_history
|
157
177
|
if ENV['HOME']
|
158
178
|
File.open(history_file, "w") do |f|
|
159
|
-
Readline::HISTORY.to_a[0..49].each do |item|
|
179
|
+
Readline::HISTORY.to_a.reverse[0..49].each do |item|
|
160
180
|
f.puts(item)
|
161
181
|
end
|
162
182
|
end
|
@@ -166,10 +186,12 @@ module TConsole
|
|
166
186
|
# Loads history from past sessions
|
167
187
|
def read_history
|
168
188
|
if ENV['HOME'] && File.exist?(history_file)
|
169
|
-
File.readlines(history_file).each do |line|
|
170
|
-
Readline::HISTORY
|
189
|
+
File.readlines(history_file).reverse.each do |line|
|
190
|
+
Readline::HISTORY << line
|
171
191
|
end
|
172
192
|
end
|
173
193
|
end
|
174
194
|
end
|
175
195
|
end
|
196
|
+
|
197
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tconsole
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1pre2
|
5
5
|
prerelease: 5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-
|
12
|
+
date: 2012-01-25 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: ! " tconsole allows Rails developers to easily and quickly run their
|
15
15
|
tests as a whole or in subsets. It forks the testing processes from\n a preloaded
|
@@ -47,7 +47,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
47
47
|
version: '0'
|
48
48
|
segments:
|
49
49
|
- 0
|
50
|
-
hash:
|
50
|
+
hash: 185882967550172537
|
51
51
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
52
|
none: false
|
53
53
|
requirements:
|