tconsole 0.0.1.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.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in tconsole.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/TODO ADDED
@@ -0,0 +1,3 @@
1
+ * Add help command
2
+ * Add ability to profile tests
3
+ * Figure out why ^c isn't working
data/bin/tconsole ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "tconsole"
4
+
5
+ TConsole::Runner.run
@@ -0,0 +1,3 @@
1
+ module TConsole
2
+ VERSION = "0.0.1.pre"
3
+ end
data/lib/tconsole.rb ADDED
@@ -0,0 +1,99 @@
1
+ require "tconsole/version"
2
+
3
+ require 'readline'
4
+ require 'benchmark'
5
+
6
+ module TConsole
7
+ class Runner
8
+ # Spawns a new environment. Looks at the results of the environment to determine whether to stop or
9
+ # keep running
10
+ def self.run
11
+ running = true
12
+
13
+ while running
14
+ read, write = IO.pipe
15
+ pid = fork do
16
+ response = run_environment(write)
17
+ write.puts [Marshal.dump(response)].pack("m")
18
+ end
19
+ write.close
20
+
21
+ response = read.read
22
+ Process.wait2(pid)
23
+ running = Marshal.load(response.unpack("m")[0])
24
+ read.close
25
+ end
26
+
27
+ puts
28
+ puts "Exiting. Bye!"
29
+ end
30
+
31
+ # Starts our Rails environment and listens for console commands
32
+ # Returns true if we should keep running or false if we need to exit
33
+ def self.run_environment(write)
34
+
35
+ puts
36
+ puts "Loading Rails environment..."
37
+ time = Benchmark.realtime do
38
+ # Ruby environment loading is shamelessly borrowed from spork
39
+ ENV["RAILS_ENV"] ||= "test"
40
+ $:.unshift("./test")
41
+
42
+ require "./config/application"
43
+ ::Rails.application
44
+ end
45
+
46
+ puts "Environment loaded in #{time}s."
47
+ puts
48
+
49
+ # Store the state of the terminal
50
+ stty_save = `stty -g`.chomp
51
+ #trap('INT') { system('stty', stty_save); exit }
52
+
53
+
54
+ while line = Readline.readline('> ', true)
55
+ if line == "exit"
56
+ return false
57
+ elsif line == "reload"
58
+ return true
59
+ elsif line == "units"
60
+ run_tests(["test/unit/**/*_test.rb"])
61
+ elsif line == "functionals"
62
+ run_tests(["test/functional/**/*_test.rb"])
63
+ elsif line == "integration"
64
+ run_tests(["test/integration/**/*_test.rb"])
65
+ elsif line == "all"
66
+ run_tests(["test/unit/**/*_test.rb", "test/functional/**/*_test.rb", "test/integration/**/*_test.rb"])
67
+ else
68
+ run_tests([line])
69
+ end
70
+ end
71
+ end
72
+
73
+ # Taks an array of globs and loads all of the files in the globs
74
+ # and then runs the tests in those files
75
+ def self.run_tests(globs)
76
+ time = Benchmark.realtime do
77
+ pid = fork do
78
+ puts "Running tests..."
79
+ puts
80
+
81
+ paths = []
82
+ globs.each do |glob|
83
+ paths.concat(Dir.glob(glob))
84
+ end
85
+
86
+ paths.each do |path|
87
+ require File.realpath(path)
88
+ end
89
+ end
90
+
91
+ Process.wait2(pid)
92
+ end
93
+
94
+ puts
95
+ puts "Test time (including load): #{time}s"
96
+ puts
97
+ end
98
+ end
99
+ end
data/tconsole.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "tconsole/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "tconsole"
7
+ s.version = TConsole::VERSION
8
+ s.authors = ["Alan Johnson"]
9
+ s.email = ["alan@commondream.net"]
10
+ s.homepage = ""
11
+ s.summary = %q{tconsole gives you a helpful console for running Rails tests}
12
+ s.description = %q{tconsole gives you a helpful console for running Rails tests}
13
+
14
+ s.rubyforge_project = "tconsole"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ # s.add_runtime_dependency "rest-client"
24
+ end
metadata ADDED
@@ -0,0 +1,54 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tconsole
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.pre
5
+ prerelease: 6
6
+ platform: ruby
7
+ authors:
8
+ - Alan Johnson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-12-09 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: tconsole gives you a helpful console for running Rails tests
15
+ email:
16
+ - alan@commondream.net
17
+ executables:
18
+ - tconsole
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - Gemfile
24
+ - Rakefile
25
+ - TODO
26
+ - bin/tconsole
27
+ - lib/tconsole.rb
28
+ - lib/tconsole/version.rb
29
+ - tconsole.gemspec
30
+ homepage: ''
31
+ licenses: []
32
+ post_install_message:
33
+ rdoc_options: []
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ! '>'
46
+ - !ruby/object:Gem::Version
47
+ version: 1.3.1
48
+ requirements: []
49
+ rubyforge_project: tconsole
50
+ rubygems_version: 1.8.11
51
+ signing_key:
52
+ specification_version: 3
53
+ summary: tconsole gives you a helpful console for running Rails tests
54
+ test_files: []