tconsole 0.0.4.pre → 1.0.0.pre

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.
@@ -126,5 +126,12 @@ module TConsole
126
126
  message = "Running #{files.length} #{files.length == 1 ? "test file" : "test files"} based on uncommitted changes..."
127
127
  run_tests(files, test_pattern, message)
128
128
  end
129
+
130
+ def run_info
131
+ puts "Defined Constants:"
132
+ puts Module.constants.sort.join("\n")
133
+ puts
134
+ puts
135
+ end
129
136
  end
130
137
  end
@@ -1,3 +1,3 @@
1
1
  module TConsole
2
- VERSION = "0.0.4.pre"
2
+ VERSION = "1.0.0.pre"
3
3
  end
data/lib/tconsole.rb CHANGED
@@ -21,6 +21,9 @@ module TConsole
21
21
  puts
22
22
  puts "Welcome to tconsole. Type 'help' for help or 'exit' to quit."
23
23
 
24
+ # Set up our console input handling and history
25
+ console = Console.new
26
+
24
27
  # Start the server
25
28
  while running
26
29
  # ignore ctrl-c during load, since things can get kind of messy if we don't
@@ -60,18 +63,28 @@ module TConsole
60
63
  exit(1)
61
64
  end
62
65
 
63
- running = command_loop(server) if running
66
+ running = console.read_and_execute(server) if running
64
67
 
65
68
  server.stop
66
69
  Process.waitall
67
70
  end
68
71
 
72
+ console.store_history
73
+
69
74
  puts
70
75
  puts "Exiting. Bye!"
71
76
  system("stty", stty_save);
72
77
  end
78
+ end
73
79
 
74
- def self.command_loop(server)
80
+ class Console
81
+
82
+ def initialize
83
+ read_history
84
+ end
85
+
86
+ # Returns true if the app should keep running, false otherwise
87
+ def read_and_execute(server)
75
88
  while line = Readline.readline("tconsole> ", true)
76
89
  line.strip!
77
90
  args = line.split(/\s/)
@@ -83,7 +96,7 @@ module TConsole
83
96
  elsif args[0] == "reload"
84
97
  return true
85
98
  elsif args[0] == "help"
86
- help
99
+ print_help
87
100
  elsif args[0] == "units"
88
101
  server.run_tests(["test/unit/**/*_test.rb"], args[1])
89
102
  elsif args[0] == "functionals"
@@ -96,16 +109,18 @@ module TConsole
96
109
  server.run_uncommitted(args[1])
97
110
  elsif args[0] == "all"
98
111
  server.run_tests(["test/unit/**/*_test.rb", "test/functional/**/*_test.rb", "test/integration/**/*_test.rb"], args[1])
112
+ elsif args[0] == "info"
113
+ server.run_info
99
114
  else
100
115
  server.run_tests([args[0]], args[1])
101
116
  end
102
117
  end
103
118
 
104
- return true
119
+ true
105
120
  end
106
121
 
107
122
  # Prints a list of available commands
108
- def self.help
123
+ def print_help
109
124
  puts
110
125
  puts "Available commands:"
111
126
  puts
@@ -128,5 +143,29 @@ module TConsole
128
143
  puts "test."
129
144
  puts
130
145
  end
146
+
147
+ def history_file
148
+ File.join(ENV['HOME'], ".tconsole_history")
149
+ end
150
+
151
+ # Stores last 50 items in history to $HOME/.tconsole_history
152
+ def store_history
153
+ if ENV['HOME']
154
+ File.open(history_file, "w") do |f|
155
+ Readline::HISTORY.to_a[0..49].each do |item|
156
+ f.puts(item)
157
+ end
158
+ end
159
+ end
160
+ end
161
+
162
+ # Loads history from past sessions
163
+ def read_history
164
+ if ENV['HOME'] && File.exist?(history_file)
165
+ File.readlines(history_file).each do |line|
166
+ Readline::HISTORY.push(line)
167
+ end
168
+ end
169
+ end
131
170
  end
132
171
  end
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: 0.0.4.pre
4
+ version: 1.0.0.pre
5
5
  prerelease: 6
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: 2011-12-17 00:00:00.000000000 Z
12
+ date: 2011-12-30 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: tconsole gives you a helpful console for running Rails tests
15
15
  email: