haikulearning_mongrel_upload_progress 0.2.3 → 0.2.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.
- data/CHANGELOG +3 -0
- data/README.rdoc +101 -0
- data/haikulearning_mongrel_upload_progress.gemspec +2 -2
- data/lib/haikulearning_mongrel_upload_progress/init.rb +18 -8
- metadata +4 -4
data/CHANGELOG
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
v0.2.4. Changed the way UploadProgressConfig behaves. It now looks for a single mongrel_upload_progress.yml file with multiple environment configs set inside (much like database.yml in Rails). It also raises a NoConfigSpecified error if config there's a
|
2
|
+
problem loading the relevant configuration.
|
3
|
+
|
1
4
|
v0.2.3. Haiku Learning Systems modifications. The path_info Array now matches using === allowing for Regexp and other creative path matchers. Adding UploadProgressConfig to support different configurations for different environments.
|
2
5
|
|
3
6
|
v0.2.2. Signed gem.
|
data/README.rdoc
CHANGED
@@ -5,3 +5,104 @@ A mongrel plugin that makes it possible to check the progress of in-transit uplo
|
|
5
5
|
== Haiku Learning Systems Modifications
|
6
6
|
|
7
7
|
This fork of the {original mongrel_upload_progress gem}[http://rubygems.org/gems/mongrel_upload_progress] has been modified by {Haiku Learning Systems}[http://www.haikulearning.com] to add a few features. Please read the CHANGELOG for more details about these changes.
|
8
|
+
|
9
|
+
This plugin works as a *drop in replacement* for mongrel_upload_progress, though we *strongly suggest* you only have one or the other installed. We haven't tested the interaction between the two & make no guarantees that they will play well together.
|
10
|
+
|
11
|
+
= Mongrel Configuration
|
12
|
+
|
13
|
+
Place the following code somewhere in your code (e.g. <tt>config/mongrel_upload_progress.conf</tt>).
|
14
|
+
|
15
|
+
uri("/",
|
16
|
+
:handler => plugin(
|
17
|
+
"/handlers/upload",
|
18
|
+
Mongrel::UploadProgressConfig.options(File.join(RAILS_ROOT, 'config'))
|
19
|
+
),
|
20
|
+
:in_front => true
|
21
|
+
)
|
22
|
+
|
23
|
+
Because, we're using Mongrel::UploadProgressConfig above, create a <tt>mongrel_upload_progress.yml</tt> file within the appropriate dir (within <tt>File.join(RAILS_ROOT, 'config')</tt> in the above example). The following
|
24
|
+
is one example. Note: You'll need to specify a configuration for each environment
|
25
|
+
you plan to use in your Application.
|
26
|
+
|
27
|
+
development: &_defaults
|
28
|
+
:path_info :
|
29
|
+
- /upload/file # Handles UploadController#file
|
30
|
+
- !ruby/regexp /^\/file\/upload.*/ # Handles any upload* action in FileController
|
31
|
+
:debug : true
|
32
|
+
# Use the development settings, but override the :debug option.
|
33
|
+
production:
|
34
|
+
<<: *_defaults
|
35
|
+
:debug : false
|
36
|
+
|
37
|
+
Then reference the conf file when you start your mongrel(s)
|
38
|
+
|
39
|
+
mongrel_rails start -e development -S config/mongrel_upload_progress.conf
|
40
|
+
|
41
|
+
= Using DRb
|
42
|
+
|
43
|
+
A very useful feature if you're running more than one mongrel process, even across multiple servers.
|
44
|
+
|
45
|
+
== DRb Configuration
|
46
|
+
|
47
|
+
Update your <tt>mongrel_upload_progress.yml</tt> setting by adding DRb information.
|
48
|
+
|
49
|
+
production:
|
50
|
+
<<: *_defaults
|
51
|
+
:drb : druby://127.0.0.1:7999 # A single-server setup. Specify an IP or hostname other than loopback for multiple server setups.
|
52
|
+
|
53
|
+
== DRb Server
|
54
|
+
|
55
|
+
Now, start up a DRb server. Here's an example ruby script.
|
56
|
+
|
57
|
+
require 'rubygems'
|
58
|
+
require 'drb'
|
59
|
+
require 'gem_plugin'
|
60
|
+
|
61
|
+
RAILS_ENV = ENV['RAILS_ENV'] || 'development'
|
62
|
+
config_dir = File.join(File.dirname(__FILE__), '../config')
|
63
|
+
|
64
|
+
GemPlugin::Manager.instance.load 'mongrel' => GemPlugin::INCLUDE
|
65
|
+
DRb.start_service(
|
66
|
+
Mongrel::UploadProgressConfig.options(config_dir)[:drb],
|
67
|
+
Mongrel::UploadProgress.new
|
68
|
+
)
|
69
|
+
DRb.thread.join
|
70
|
+
|
71
|
+
Start the above server with this command:
|
72
|
+
|
73
|
+
RAILS_ENV=production ruby path/to/above_script.rb &
|
74
|
+
|
75
|
+
== DRb in IRB
|
76
|
+
|
77
|
+
For debugging purposes, you can interact with your DRb server using the following IRB script
|
78
|
+
|
79
|
+
require 'rubygems'
|
80
|
+
require 'drb'
|
81
|
+
require 'gem_plugin'
|
82
|
+
|
83
|
+
RAILS_ENV = ENV['RAILS_ENV'] || 'development'
|
84
|
+
|
85
|
+
GemPlugin::Manager.instance.load 'mongrel' => GemPlugin::INCLUDE
|
86
|
+
DRb.start_service
|
87
|
+
|
88
|
+
def list
|
89
|
+
updrb.list
|
90
|
+
end
|
91
|
+
def updrb
|
92
|
+
@updrb ||= DRbObject.new(nil,
|
93
|
+
Mongrel::UploadProgressConfig.options(File.join(File.dirname(__FILE__), '../config'))[:drb]
|
94
|
+
)
|
95
|
+
end
|
96
|
+
def reload_updrb
|
97
|
+
@updrb = nil
|
98
|
+
updrb
|
99
|
+
end
|
100
|
+
|
101
|
+
Then interact with IRB as follows:
|
102
|
+
|
103
|
+
$ RAILS_ENV=production irb -r path/to/above_script.rb
|
104
|
+
> list #=> []
|
105
|
+
# After an upload starts...
|
106
|
+
> list #=> ['1299607166']
|
107
|
+
# You can call any Mongrel::UploadProgress method as well
|
108
|
+
> updrb.check('1299607166') #=> {:received=>1024, :size=>56332114}
|
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{haikulearning_mongrel_upload_progress}
|
5
|
-
s.version = "0.2.
|
5
|
+
s.version = "0.2.4"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["The Mongrel team, with modifications by Marcos Wright Kuhns"]
|
9
|
-
s.date = %q{2011-03-
|
9
|
+
s.date = %q{2011-03-08}
|
10
10
|
s.description = %q{The haikulearning fork of the mongrel_upload_progress gemplugin}
|
11
11
|
s.email = %q{}
|
12
12
|
s.extra_rdoc_files = ["CHANGELOG", "COPYING", "LICENSE", "README.rdoc", "lib/haikulearning_mongrel_upload_progress/init.rb"]
|
@@ -90,15 +90,25 @@ class Mongrel::UploadProgress
|
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
-
|
94
|
-
class<<self
|
93
|
+
module Mongrel::UploadProgressConfig
|
94
|
+
class << self
|
95
95
|
def options(root_dir)
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
96
|
+
opts = YAML.load_file(File.join(root_dir, 'mongrel_upload_progress.yml')) rescue nil
|
97
|
+
raise NoConfigSpecified.new("No config file exists at #{File.join(root_dir, 'config/mongrel_upload_progress.yml').inspect}") if opts.nil? || opts.empty?
|
98
|
+
|
99
|
+
begin
|
100
|
+
::RAILS_ENV
|
101
|
+
rescue
|
102
|
+
raise NoConfigSpecified.new("The ::RAILS_ENV constant must be set (Sorry, no Rails 3 support yet.)")
|
101
103
|
end
|
104
|
+
|
105
|
+
opts = opts[::RAILS_ENV] rescue nil
|
106
|
+
raise NoConfigSpecified.new("No config information exists for the #{::RAILS_ENV} environment.") if opts.nil? || opts.empty?
|
107
|
+
|
108
|
+
opts
|
102
109
|
end
|
103
110
|
end
|
104
|
-
|
111
|
+
|
112
|
+
class NoConfigSpecified < ::RuntimeError
|
113
|
+
end
|
114
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haikulearning_mongrel_upload_progress
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 4
|
10
|
+
version: 0.2.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- The Mongrel team, with modifications by Marcos Wright Kuhns
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-03-
|
18
|
+
date: 2011-03-08 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|