rack_direct 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/rack_direct/service.rb +15 -3
  2. metadata +3 -3
@@ -14,10 +14,13 @@ module RackDirect
14
14
  end
15
15
 
16
16
  @@services = {}
17
- def self.start name, path
17
+ def self.start path, options = {}
18
+
19
+ name = options[:name] || File.split(path).last
20
+
18
21
  unless @@services[name]
19
22
 
20
- tmppath = generate_rackup_file
23
+ tmppath = generate_rackup_file options[:env]
21
24
 
22
25
  # TODO: check path to make sure a Rails app exists there
23
26
  print "Starting service rack-direct://#{name}..."
@@ -77,12 +80,21 @@ module RackDirect
77
80
 
78
81
  private
79
82
 
80
- def self.generate_rackup_file
83
+ def self.generate_rackup_file environment
81
84
  rackup_file_contents = <<-EOF
82
85
  require 'rack_direct/direct_handler'
83
86
  Rack::Handler.register('#{RACK_DIRECT_ALIAS}', 'RackDirect::DirectHandler')
84
87
  # puts "RackDirect::DirectHandler registered"
88
+ EOF
89
+
90
+ if environment && environment.is_a?(Hash)
91
+ rackup_file_contents += "# Passed in environment:\n"
92
+ environment.each_pair do |k,v|
93
+ rackup_file_contents += "ENV[#{k}] = #{v}\n"
94
+ end
95
+ end
85
96
 
97
+ rackup_file_contents += <<-EOF
86
98
  require "config/environment"
87
99
  use Rails::Rack::LogTailer
88
100
  use Rails::Rack::Static
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack_direct
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 5
10
- version: 0.1.5
9
+ - 6
10
+ version: 0.1.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brian Sharon