vegas 0.1.3 → 0.1.4

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.
@@ -1,3 +1,10 @@
1
+ == 0.1.4 2010-02-09
2
+
3
+ * Fixed: Logging on Ruby 1.9 (greatseth)
4
+ * Fixed: Dont chdir when daemonizing (messes up filesystem paths in apps)
5
+ * Fixed: Test cases and dev installation (greatseth)
6
+ * New: You can set the app_dir, pid file, log file and others via command line
7
+
1
8
  == 0.1.3 2010-01-08
2
9
 
3
10
  * Fixed: Runner escapes :app_name to make it a valid string for using in paths (thanks greatseth!)
data/Rakefile CHANGED
@@ -3,33 +3,45 @@ require File.dirname(__FILE__) + '/lib/vegas'
3
3
 
4
4
  begin
5
5
  require 'jeweler'
6
- Jeweler::Tasks.new do |s|
7
- s.name = %q{vegas}
8
- s.version = Vegas::VERSION
9
- s.authors = ["Aaron Quint"]
10
- s.date = %q{2009-08-30}
11
- s.summary = "Vegas aims to solve the simple problem of creating executable versions of Sinatra/Rack apps."
12
- s.description = %{Vegas aims to solve the simple problem of creating executable versions of Sinatra/Rack apps. It includes a class Vegas::Runner that wraps Rack/Sinatra applications and provides a simple command line interface and launching mechanism.}
13
- s.email = ["aaron@quirkey.com"]
14
- s.homepage = %q{http://code.quirkey.com/vegas}
15
- s.rubyforge_project = %q{quirkey}
16
-
17
- s.add_runtime_dependency(%q<rack>, [">= 1.0.0"])
18
-
19
- s.add_development_dependency(%q<mocha>, ["~> 0.9.8"])
20
- s.add_development_dependency(%q<bacon>, ["~> 1.1.0"])
21
- s.add_development_dependency(%q<sinatra>, ["~> 0.9.4"])
22
-
23
- end
24
- Jeweler::GemcutterTasks.new
25
6
  rescue LoadError
26
7
  puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
27
8
  end
28
9
 
10
+ VEGAS_VERSION = if ENV["DEV"]
11
+ "#{Vegas::VERSION}.#{Time.new.to_i}"
12
+ else
13
+ Vegas::VERSION
14
+ end
15
+
16
+ Jeweler::Tasks.new do |s|
17
+ s.name = %q{vegas}
18
+ s.version = VEGAS_VERSION
19
+ s.authors = ["Aaron Quint"]
20
+ s.date = %q{2009-08-30}
21
+ s.summary = "Vegas aims to solve the simple problem of creating executable versions of Sinatra/Rack apps."
22
+ s.description = %{Vegas aims to solve the simple problem of creating executable versions of Sinatra/Rack apps. It includes a class Vegas::Runner that wraps Rack/Sinatra applications and provides a simple command line interface and launching mechanism.}
23
+ s.email = ["aaron@quirkey.com"]
24
+ s.homepage = %q{http://code.quirkey.com/vegas}
25
+ s.rubyforge_project = %q{quirkey}
26
+
27
+ s.add_runtime_dependency(%q<rack>, [">= 1.0.0"])
28
+
29
+ s.add_development_dependency(%q<mocha>, ["~> 0.9.8"])
30
+ s.add_development_dependency(%q<bacon>, ["~> 1.1.0"])
31
+ s.add_development_dependency(%q<sinatra>, ["~> 0.9.4"])
32
+ end
33
+
34
+ Jeweler::GemcutterTasks.new
35
+
29
36
  Rake::TestTask.new do |t|
30
37
  t.libs << "test"
31
38
  t.test_files = FileList['test/test*.rb']
32
39
  t.verbose = true
33
40
  end
34
41
 
42
+ task :package => :build
35
43
  task :default => :test
44
+
45
+ task "install:dev" => :build do
46
+ system "gem install pkg/vegas-#{VEGAS_VERSION}.gem"
47
+ end
@@ -8,7 +8,7 @@ end
8
8
  $LOAD_PATH.unshift File.dirname(__FILE__)
9
9
 
10
10
  module Vegas
11
- VERSION = "0.1.3"
11
+ VERSION = "0.1.4"
12
12
  WINDOWS = !!(RUBY_PLATFORM =~ /(mingw|bccwin|wince|mswin32)/i)
13
13
 
14
14
  autoload :Runner, 'vegas/runner'
@@ -6,7 +6,7 @@ if Vegas::WINDOWS
6
6
  begin
7
7
  require 'win32/process'
8
8
  rescue
9
- puts "Sorry, in order to use Vegas on Windows you need the win32-process gem:\n " +
9
+ puts "Sorry, in order to use Vegas on Windows you need the win32-process gem:",
10
10
  "gem install win32-process"
11
11
  end
12
12
  end
@@ -25,8 +25,8 @@ module Vegas
25
25
 
26
26
  self.class.logger.level = options[:debug] ? Logger::DEBUG : Logger::INFO
27
27
 
28
- @app = app
29
- @app_name = app_name
28
+ @app = app
29
+ @app_name = app_name
30
30
 
31
31
  @filesystem_friendly_app_name = @app_name.gsub(/\W+/, "_")
32
32
  @quoted_app_name = "'#{app_name}'"
@@ -72,28 +72,28 @@ module Vegas
72
72
  end
73
73
 
74
74
  def app_dir
75
- File.join(ROOT_DIR, filesystem_friendly_app_name)
75
+ options[:app_dir] || File.join(ROOT_DIR, filesystem_friendly_app_name)
76
76
  end
77
77
 
78
78
  def pid_file
79
- File.join(app_dir, "#{filesystem_friendly_app_name}.pid")
79
+ options[:pid_file] || File.join(app_dir, "#{filesystem_friendly_app_name}.pid")
80
80
  end
81
81
 
82
82
  def url_file
83
- File.join(app_dir, "#{filesystem_friendly_app_name}.url")
83
+ options[:url_file] || File.join(app_dir, "#{filesystem_friendly_app_name}.url")
84
84
  end
85
85
 
86
+ def log_file
87
+ options[:log_file] || File.join(app_dir, "#{filesystem_friendly_app_name}.log")
88
+ end
89
+
86
90
  def url
87
91
  "http://#{host}:#{port}"
88
92
  end
89
93
 
90
- def log_file
91
- File.join(app_dir, "#{filesystem_friendly_app_name}.log")
92
- end
93
-
94
94
  def start(path = nil)
95
95
  logger.info "Running with Windows Settings" if WINDOWS
96
- logger.info "Starting #{quoted_app_name}"
96
+ logger.info "Starting #{quoted_app_name}..."
97
97
  begin
98
98
  check_for_running(path)
99
99
  find_port
@@ -112,7 +112,8 @@ module Vegas
112
112
  announce_port_attempted
113
113
 
114
114
  unless port_open?
115
- logger.warn "Port #{port} is already in use. Please try another or don't use -P, for auto-port"
115
+ logger.warn "Port #{port} is already in use. Please try another. " +
116
+ "You can also omit the port flag, and we'll find one for you."
116
117
  end
117
118
  else
118
119
  @port = PORT
@@ -126,7 +127,7 @@ module Vegas
126
127
  end
127
128
 
128
129
  def announce_port_attempted
129
- logger.info "Trying to start #{quoted_app_name} on port #{port}"
130
+ logger.info "trying port #{port}..."
130
131
  end
131
132
 
132
133
  def port_open?(check_url = nil)
@@ -172,15 +173,16 @@ module Vegas
172
173
  logger.debug "Parent Process: #{Process.pid}"
173
174
  exit! if fork
174
175
  logger.debug "Child Process: #{Process.pid}"
175
- Dir.chdir "/"
176
- File.umask 0000
177
- FileUtils.touch(log_file)
178
- STDIN.reopen log_file
179
- STDOUT.reopen log_file, "a"
180
- STDERR.reopen log_file, "a"
181
176
  else
182
- Process.daemon
177
+ Process.daemon(true, true)
183
178
  end
179
+
180
+ File.umask 0000
181
+ FileUtils.touch log_file
182
+ STDIN.reopen log_file
183
+ STDOUT.reopen log_file, "a"
184
+ STDERR.reopen log_file, "a"
185
+
184
186
  logger.debug "Child Process: #{Process.pid}"
185
187
 
186
188
  File.open(pid_file, 'w') {|f| f.write("#{Process.pid}") }
@@ -275,11 +277,21 @@ module Vegas
275
277
  OptionParser.new("", 24, ' ') do |opts|
276
278
  # TODO instead of app_name, we should determine the name of the script
277
279
  # used to invoke Vegas and use that here
278
- opts.banner = "Usage: your_executable_name [options]"
280
+ opts.banner = "Usage: #{$0 || app_name} [options]"
279
281
 
280
282
  opts.separator ""
281
283
  opts.separator "Vegas options:"
282
284
 
285
+ opts.on('-K', "--kill", "kill the running process and exit") {|k|
286
+ kill!
287
+ exit
288
+ }
289
+
290
+ opts.on('-S', "--status", "display the current running PID and URL then quit") {|s|
291
+ status
292
+ exit!
293
+ }
294
+
283
295
  opts.on("-s", "--server SERVER", "serve using SERVER (thin/mongrel/webrick)") { |s|
284
296
  @rack_handler = Rack::Handler.get(s)
285
297
  }
@@ -303,21 +315,27 @@ module Vegas
303
315
  opts.on("-L", "--no-launch", "don't launch the browser") { |f|
304
316
  @options[:skip_launch] = true
305
317
  }
306
-
307
- opts.on('-K', "--kill", "kill the running process and exit") {|k|
308
- kill!
309
- exit
310
- }
311
-
312
- opts.on('-S', "--status", "display the current running PID and URL then quit") {|s|
313
- status
314
- exit!
315
- }
316
-
318
+
317
319
  opts.on('-d', "--debug", "raise the log level to :debug (default: :info)") {|s|
318
320
  @options[:debug] = true
319
321
  }
320
-
322
+
323
+ opts.on("--app-dir APP_DIR", "set the app dir where files are stored (default: ~/.vegas/#{filesystem_friendly_app_name})/)") {|app_dir|
324
+ @options[:app_dir] = app_dir
325
+ }
326
+
327
+ opts.on("-P", "--pid-file PID_FILE", "set the path to the pid file (default: app_dir/#{filesystem_friendly_app_name}.pid)") {|pid_file|
328
+ @options[:pid_file] = pid_file
329
+ }
330
+
331
+ opts.on("--log-file LOG_FILE", "set the path to the log file (default: app_dir/#{filesystem_friendly_app_name}.log)") {|log_file|
332
+ @options[:log_file] = log_file
333
+ }
334
+
335
+ opts.on("--url-file URL_FILE", "set the path to the URL file (default: app_dir/#{filesystem_friendly_app_name}.url)") {|url_file|
336
+ @options[:url_file] = url_file
337
+ }
338
+
321
339
  yield opts if block_given?
322
340
 
323
341
  opts.separator ""
@@ -112,20 +112,7 @@ describe 'Vegas::Runner' do
112
112
  end
113
113
  end
114
114
 
115
- describe 'with a sinatra app using mongrel for the server' do
116
- before do
117
- TestApp1.set :server, "mongrel"
118
- Vegas::Runner.any_instance.expects(:system).once
119
- Rack::Handler::Mongrel.stubs(:run)
120
- vegas(TestApp1, 'vegas_test_app_1', {:skip_launch => true, :sessions => true}, ["route","--debug"])
121
- end
122
-
123
- it 'sets the rack handler automaticaly' do
124
- @vegas.rack_handler.should == Rack::Handler::Mongrel
125
- end
126
- end
127
-
128
- describe 'with a sinatra app using webrick for the server' do
115
+ describe 'with a sinatra app using an explicit server setting' do
129
116
  before do
130
117
  TestApp1.set :server, "webrick"
131
118
  Vegas::Runner.any_instance.expects(:system).once
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{vegas}
8
- s.version = "0.1.3"
8
+ s.version = "0.1.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Aaron Quint"]
12
- s.date = %q{2010-01-08}
12
+ s.date = %q{2010-02-10}
13
13
  s.description = %q{Vegas aims to solve the simple problem of creating executable versions of Sinatra/Rack apps. It includes a class Vegas::Runner that wraps Rack/Sinatra applications and provides a simple command line interface and launching mechanism.}
14
14
  s.email = ["aaron@quirkey.com"]
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vegas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Quint
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-08 00:00:00 -05:00
12
+ date: 2010-02-10 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency