activemessaging 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -21,7 +21,7 @@ end
21
21
 
22
22
  gem_spec = Gem::Specification.new do |s|
23
23
  s.name = %q{activemessaging}
24
- s.version = "0.6.0"
24
+ s.version = "0.6.1"
25
25
 
26
26
  s.specification_version = 2 if s.respond_to? :specification_version=
27
27
 
@@ -1,13 +1,15 @@
1
1
  #!/usr/bin/env ruby
2
+
3
+ ENV['APP_ROOT'] ||= File.expand_path(File.join(File.dirname(__FILE__), '..'))
4
+ APP_ROOT = ENV['APP_ROOT']
5
+ script_file = File.join(APP_ROOT, 'lib', 'poller.rb')
6
+ tmp_dir = File.join(APP_ROOT, 'tmp')
7
+
2
8
  require 'rubygems'
3
9
  require 'daemons'
4
10
  require 'activesupport'
5
11
  require 'activemessaging'
6
12
 
7
- APP_ROOT = File.expand_path(File.dirname(__FILE__) + '/..')
8
- script_file = File.join(File.dirname(__FILE__)+'/../lib/poller.rb')
9
- tmp_dir = File.join(File.expand_path(APP_ROOT), 'tmp')
10
-
11
13
  options = {
12
14
  :app_name => "poller",
13
15
  :dir_mode => :normal,
@@ -4,12 +4,13 @@ STDOUT.sync = true; STDOUT.flush
4
4
  STDERR.sync = true; STDERR.flush
5
5
 
6
6
  #Try to Load Merb
7
- begin
7
+ merb_init_file = File.expand_path(File.dirname(__FILE__)+'/../config/merb_init')
8
+ if File.exists? merb_init_file
8
9
  require File.expand_path(File.dirname(__FILE__)+'/../config/boot')
9
10
  #need this because of the CWD
10
11
  Merb.root = MERB_ROOT
11
- require File.expand_path(File.dirname(__FILE__)+'/../config/merb_init')
12
- rescue LoadError
12
+ require merb_init_file
13
+ else
13
14
  # Load Rails
14
15
  RAILS_ROOT=File.expand_path(File.join(File.dirname(__FILE__), '..'))
15
16
  require File.join(RAILS_ROOT, 'config', 'boot')
@@ -20,4 +21,4 @@ end
20
21
  #ActiveMessaging::load_processors
21
22
 
22
23
  # Start it up!
23
- ActiveMessaging::start
24
+ ActiveMessaging::start
@@ -1,5 +1,5 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper'
2
- require File.dirname(__FILE__) + '/../../vendor/plugins/activemessaging/lib/activemessaging/test_helper'
2
+ require 'activemessaging/test_helper'
3
3
  require File.dirname(__FILE__) + '/../../app/processors/application'
4
4
 
5
5
  class <%= class_name %>ProcessorTest < Test::Unit::TestCase
@@ -1,7 +1,8 @@
1
1
  module ActiveMessaging
2
- VERSION = "0.5" #maybe this should be higher, but I'll let others judge :)
2
+ VERSION = "0.6.1"
3
3
  APP_ROOT = ENV['APP_ROOT'] || ENV['RAILS_ROOT'] || ((defined? RAILS_ROOT) && RAILS_ROOT) || File.dirname($0)
4
4
  APP_ENV = ENV['APP_ENV'] || ENV['RAILS_ENV'] || 'development'
5
+ ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
5
6
 
6
7
  # Used to indicate that the processing for a thread shoud complete
7
8
  class StopProcessingException < Interrupt #:nodoc:
@@ -18,9 +19,10 @@ module ActiveMessaging
18
19
  end
19
20
 
20
21
  def ActiveMessaging.logger
21
- @@logger = RAILS_DEFAULT_LOGGER if !defined?(@@logger) && (defined?(RAILS_DEFAULT_LOGGER) && !RAILS_DEFAULT_LOGGER.nil?)
22
- @@logger = ActiveRecord::Base.logger unless defined?(@@logger)
23
- @@logger = Logger.new(STDOUT) unless defined?(@@logger)
22
+ @@logger = nil unless defined? @@logger
23
+ @@logger ||= RAILS_DEFAULT_LOGGER if defined? RAILS_DEFAULT_LOGGER
24
+ @@logger ||= ActiveRecord::Base.logger if defined? ActiveRecord
25
+ @@logger ||= Logger.new(STDOUT)
24
26
  @@logger
25
27
  end
26
28
 
@@ -36,18 +38,20 @@ module ActiveMessaging
36
38
  require 'activemessaging/trace_filter'
37
39
 
38
40
  # load all under the adapters dir
39
- Dir[APP_ROOT + '/vendor/plugins/activemessaging/lib/activemessaging/adapters/*.rb'].each{|a|
41
+ Dir[File.join(ROOT, 'lib', 'activemessaging', 'adapters', '*.rb')].each do |a|
40
42
  begin
41
43
  adapter_name = File.basename(a, ".rb")
42
44
  require 'activemessaging/adapters/' + adapter_name
43
45
  rescue RuntimeError, LoadError => e
44
46
  logger.debug "ActiveMessaging: adapter #{adapter_name} not loaded: #{ e.message }"
45
47
  end
46
- }
48
+ end
47
49
  end
48
50
 
49
51
  def self.load_config
52
+ p APP_ROOT
50
53
  path = File.expand_path("#{APP_ROOT}/config/messaging.rb")
54
+ p path
51
55
  begin
52
56
  load path
53
57
  rescue MissingSourceFile
@@ -115,10 +119,9 @@ end
115
119
  #load these once to start with
116
120
  ActiveMessaging.load_activemessaging
117
121
 
118
-
119
-
120
- # reload these on each request - leveraging Dispatcher semantics for consistency
121
- begin
122
+ # reload these on each Rails request - leveraging Dispatcher semantics for consistency
123
+ if defined? Rails
124
+ ActiveMessaging.logger.info "Rails available: Adding dispatcher prepare callback."
122
125
  require 'dispatcher' unless defined?(::Dispatcher)
123
126
 
124
127
  # add processors and config to on_prepare if supported (rails 1.2+)
@@ -127,7 +130,4 @@ begin
127
130
  ActiveMessaging.reload_activemessaging
128
131
  end
129
132
  end
130
- rescue MissingSourceFile => e
131
- logger.info e.message
132
- logger.info "Rails not available."
133
133
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activemessaging
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - jon.tirsen