mongrel_console 0.2

Sign up to get free protection for your applications and to get access to all the features.
data/COPYING ADDED
@@ -0,0 +1 @@
1
+ No copying restrictions/license given.
data/LICENSE ADDED
@@ -0,0 +1 @@
1
+ No license given.
data/README ADDED
@@ -0,0 +1,5 @@
1
+ == Mongrel_console GemPlugin
2
+
3
+ You should document your project here.
4
+
5
+
data/Rakefile ADDED
@@ -0,0 +1,38 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/clean'
4
+ require 'rake/gempackagetask'
5
+ require 'rake/rdoctask'
6
+ require 'tools/rakehelp'
7
+ require 'fileutils'
8
+ include FileUtils
9
+
10
+ setup_tests
11
+ setup_clean ["pkg", "lib/*.bundle", "*.gem", ".config"]
12
+
13
+ setup_rdoc ['README', 'LICENSE', 'COPYING', 'lib/**/*.rb', 'doc/**/*.rdoc']
14
+
15
+ desc "Does a full compile, test run"
16
+ task :default => [:test, :package]
17
+
18
+ version="0.2"
19
+ name="mongrel_console"
20
+
21
+ setup_gem(name, version) do |spec|
22
+ spec.summary = "Provides a combined Mongrel and Rails IRB console."
23
+ spec.description = spec.summary
24
+ spec.author="Zed A. Shaw"
25
+ spec.add_dependency('gem_plugin', '>= 0.2.1')
26
+ spec.add_dependency('mongrel', '>= 0.3.11')
27
+ spec.files += Dir.glob("resources/**/*")
28
+ end
29
+
30
+
31
+ task :install => [:test, :package] do
32
+ sh %{gem install pkg/#{name}-#{version}.gem}
33
+ end
34
+
35
+ task :uninstall => [:clean] do
36
+ sh %{gem uninstall #{name}}
37
+ end
38
+
@@ -0,0 +1,83 @@
1
+ require "irb"
2
+ begin
3
+ require "irb/completion"
4
+ rescue
5
+ STDERR.puts "Problem lading irb/completion: #$!"
6
+ end
7
+ require 'rubygems'
8
+ require 'yaml'
9
+ require 'mongrel/rails'
10
+ require 'config/environment'
11
+ require 'dispatcher'
12
+ require 'mongrel/debug'
13
+ require 'net/http'
14
+
15
+ class MongrelConsoleRunner
16
+
17
+ def initialize
18
+ @port = 3000
19
+ @env = "development"
20
+ end
21
+
22
+ def tail(file="log/#{@env}.log")
23
+ STDERR.puts "Tailing #{file}. CTRL-C to stop it."
24
+
25
+ cursor = File.size(file)
26
+ last_checked = Time.now
27
+ tail_thread = Thread.new do
28
+ File.open(file, 'r') do |f|
29
+ loop do
30
+ if f.mtime > last_checked
31
+ f.seek cursor
32
+ last_checked = f.mtime
33
+ contents = f.read
34
+ cursor += contents.length
35
+ print contents
36
+ end
37
+ sleep 1
38
+ end
39
+ end
40
+ end
41
+
42
+ trap("INT") { tail_thread.kill }
43
+ tail_thread.join
44
+ nil
45
+ end
46
+
47
+ def start(port=@port, env=@env)
48
+ `mongrel_rails start #{port} #{env} -d`
49
+ end
50
+
51
+ def stop
52
+ `mongrel_rails stop`
53
+ end
54
+
55
+ def restart(port=@port, env=@env)
56
+ stop
57
+ start(port, env)
58
+ end
59
+
60
+ def status
61
+ if File.exist? "log/mongrel.pid"
62
+ pid = open("log/mongrel.pid") {|f| f.read.to_i }
63
+ puts "Running on port #@port in env #@env with PID #{pid}"
64
+ else
65
+ puts "Mongrel not running."
66
+ end
67
+ end
68
+
69
+ def get(url="/")
70
+ Net::HTTP.get("localhost", url, @port)
71
+ end
72
+ end
73
+
74
+
75
+ $mongrel = MongrelConsoleRunner.new
76
+ puts "Starting console. mongrel.[start | stop | restart | status | tail | get]"
77
+ $mongrel.status
78
+
79
+ def self.mongrel
80
+ $mongrel
81
+ end
82
+
83
+ IRB.start(__FILE__)
@@ -0,0 +1,27 @@
1
+ require 'rubygems'
2
+ require 'gem_plugin'
3
+ require 'mongrel'
4
+
5
+ class Console < GemPlugin::Plugin "/commands"
6
+ include Mongrel::Command::Base
7
+
8
+ def configure
9
+ options [
10
+ ['-c', '--chdir DIR', "Change to directory before running", :@dir, "."]
11
+ ]
12
+ end
13
+
14
+ def validate
15
+ valid_dir? @dir, "Directory is not valid"
16
+ return @valid
17
+ end
18
+
19
+ def run
20
+ begin
21
+ Dir.chdir @dir
22
+ load File.join(File.dirname(__FILE__), "console.rb")
23
+ rescue Object
24
+ STDERR.puts "Cannot run the console script: #$!"
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,2 @@
1
+ ---
2
+ :debug: false
data/tools/rakehelp.rb ADDED
@@ -0,0 +1,105 @@
1
+
2
+ def make(makedir)
3
+ Dir.chdir(makedir) do
4
+ sh(PLATFORM =~ /win32/ ? 'nmake' : 'make')
5
+ end
6
+ end
7
+
8
+
9
+ def extconf(dir)
10
+ Dir.chdir(dir) do ruby "extconf.rb" end
11
+ end
12
+
13
+
14
+ def setup_tests
15
+ Rake::TestTask.new do |t|
16
+ t.libs << "test"
17
+ t.test_files = FileList['test/test*.rb']
18
+ t.verbose = true
19
+ end
20
+ end
21
+
22
+
23
+ def setup_clean otherfiles
24
+ files = ['build/*', '**/*.o', '**/*.so', '**/*.a', 'lib/*-*', '**/*.log'] + otherfiles
25
+ CLEAN.include(files)
26
+ end
27
+
28
+
29
+ def setup_rdoc files
30
+ Rake::RDocTask.new do |rdoc|
31
+ rdoc.rdoc_dir = 'doc/rdoc'
32
+ rdoc.options << '--line-numbers'
33
+ rdoc.rdoc_files.add(files)
34
+ end
35
+ end
36
+
37
+
38
+ def setup_extension(dir, extension)
39
+ ext = "ext/#{dir}"
40
+ ext_so = "#{ext}/#{extension}.#{Config::CONFIG['DLEXT']}"
41
+ ext_files = FileList[
42
+ "#{ext}/*.c",
43
+ "#{ext}/*.h",
44
+ "#{ext}/extconf.rb",
45
+ "#{ext}/Makefile",
46
+ "lib"
47
+ ]
48
+
49
+ task "lib" do
50
+ directory "lib"
51
+ end
52
+
53
+ desc "Builds just the #{extension} extension"
54
+ task extension.to_sym => ["#{ext}/Makefile", ext_so ]
55
+
56
+ file "#{ext}/Makefile" => ["#{ext}/extconf.rb"] do
57
+ extconf "#{ext}"
58
+ end
59
+
60
+ file ext_so => ext_files do
61
+ make "#{ext}"
62
+ cp ext_so, "lib"
63
+ end
64
+ end
65
+
66
+
67
+ def base_gem_spec(pkg_name, pkg_version)
68
+ pkg_version = pkg_version
69
+ pkg_name = pkg_name
70
+ pkg_file_name = "#{pkg_name}-#{pkg_version}"
71
+ Gem::Specification.new do |s|
72
+ s.name = pkg_name
73
+ s.version = pkg_version
74
+ s.platform = Gem::Platform::RUBY
75
+ s.has_rdoc = true
76
+ s.extra_rdoc_files = [ "README" ]
77
+
78
+ s.files = %w(COPYING LICENSE README Rakefile) +
79
+ Dir.glob("{bin,doc/rdoc,test,lib}/**/*") +
80
+ Dir.glob("ext/**/*.{h,c,rb}") +
81
+ Dir.glob("examples/**/*.rb") +
82
+ Dir.glob("tools/*.rb")
83
+
84
+ s.require_path = "lib"
85
+ s.extensions = FileList["ext/**/extconf.rb"].to_a
86
+ s.bindir = "bin"
87
+ end
88
+ end
89
+
90
+ def setup_gem(pkg_name, pkg_version)
91
+ spec = base_gem_spec(pkg_name, pkg_version)
92
+ yield spec if block_given?
93
+
94
+ Rake::GemPackageTask.new(spec) do |p|
95
+ p.gem_spec = spec
96
+ p.need_tar = true
97
+ end
98
+ end
99
+
100
+ def setup_win32_gem(pkg_name, pkg_version)
101
+ spec = base_gem_spec(pkg_name, pkg_version)
102
+ yield spec if block_given?
103
+
104
+ Gem::Builder.new(spec).build
105
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.0
3
+ specification_version: 1
4
+ name: mongrel_console
5
+ version: !ruby/object:Gem::Version
6
+ version: "0.2"
7
+ date: 2007-01-19 00:00:00 -08:00
8
+ summary: Provides a combined Mongrel and Rails IRB console.
9
+ require_paths:
10
+ - lib
11
+ email:
12
+ homepage:
13
+ rubyforge_project:
14
+ description: Provides a combined Mongrel and Rails IRB console.
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Zed A. Shaw
31
+ files:
32
+ - COPYING
33
+ - LICENSE
34
+ - README
35
+ - Rakefile
36
+ - lib/mongrel_console
37
+ - lib/mongrel_console/console.rb
38
+ - lib/mongrel_console/init.rb
39
+ - tools/rakehelp.rb
40
+ - resources/defaults.yaml
41
+ test_files: []
42
+
43
+ rdoc_options: []
44
+
45
+ extra_rdoc_files:
46
+ - README
47
+ executables: []
48
+
49
+ extensions: []
50
+
51
+ requirements: []
52
+
53
+ dependencies:
54
+ - !ruby/object:Gem::Dependency
55
+ name: gem_plugin
56
+ version_requirement:
57
+ version_requirements: !ruby/object:Gem::Version::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 0.2.1
62
+ version:
63
+ - !ruby/object:Gem::Dependency
64
+ name: mongrel
65
+ version_requirement:
66
+ version_requirements: !ruby/object:Gem::Version::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 0.3.11
71
+ version: