active_wrapper 0.3.3 → 0.3.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/README.md CHANGED
@@ -6,13 +6,13 @@ Wraps ActiveRecord and Logger for use in non-Rails environments.
6
6
  Compatibility
7
7
  -------------
8
8
 
9
- Tested with Ruby 1.8.6, 1.8.7, and 1.9.1.
9
+ Maintained under Ruby 1.9.2.
10
10
 
11
11
  Setup
12
12
  -----
13
13
 
14
14
  <pre>
15
- sudo gem install active_wrapper --source http://gemcutter.org
15
+ gem install active_wrapper
16
16
  </pre>
17
17
 
18
18
  Usage
@@ -2,17 +2,17 @@ require File.dirname(__FILE__) + '/active_wrapper/gems'
2
2
 
3
3
  ActiveWrapper::Gems.require(:lib)
4
4
 
5
- require 'action_mailer'
6
5
  require 'active_record'
7
6
  require 'fileutils'
8
7
  require 'logger'
8
+ require 'pony'
9
9
  require 'yaml'
10
10
 
11
11
  $:.unshift File.dirname(__FILE__) + '/active_wrapper'
12
12
 
13
13
  require 'db'
14
+ require 'email'
14
15
  require 'log'
15
- require 'mail'
16
16
  require 'version'
17
17
 
18
18
  module ActiveWrapper
@@ -28,13 +28,9 @@ module ActiveWrapper
28
28
  }.merge(options.reject { |k, v| v.nil? })
29
29
 
30
30
  db = Db.new(options)
31
+ mail = Email.new(options)
31
32
  log = Log.new(options)
32
- mail = Mail.new(options)
33
33
 
34
- ActionMailer::Base.logger = log
35
-
36
- ActiveWrapper::Gems.lockfile
37
-
38
34
  [ db, log, mail ]
39
35
  end
40
36
  end
@@ -95,12 +95,12 @@ module ActiveWrapper
95
95
 
96
96
  def redirect_stdout(&block)
97
97
  if env == 'test'
98
- stdout = $stdout
99
- $stdout = File.new('/dev/null', 'w')
98
+ stdout = $stdout.dup
99
+ $stdout = $stdout.reopen(RUBY_PLATFORM =~ /mswin/ ? "NUL" : "/dev/null")
100
100
  end
101
101
  yield
102
102
  if env == 'test'
103
- $stdout = stdout
103
+ $stdout.reopen(stdout)
104
104
  end
105
105
  end
106
106
  end
@@ -0,0 +1,41 @@
1
+ module ActiveWrapper
2
+ class Email
3
+
4
+ attr_reader :base, :env, :config
5
+
6
+ def initialize(options)
7
+ @base = options[:base]
8
+ @config = {
9
+ :smtp => options[:smtp],
10
+ :sendmail => options[:sendmail]
11
+ }
12
+ @env = options[:env].to_s
13
+
14
+ path = "#{base}/config/mail.yml"
15
+ via = nil
16
+
17
+ if File.exists?(path)
18
+ yaml = YAML::load(File.open(path))
19
+ if yaml && yaml[@env]
20
+ yaml = yaml[@env].to_options
21
+ [ :sendmail, :smtp ].each do |type|
22
+ if yaml[type]
23
+ via = type
24
+ if yaml[type].respond_to?(:to_options)
25
+ @config[type] = yaml[type].to_options
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ if via
33
+ ::Pony.options = { :via => via, :via_options => config[via] }
34
+ end
35
+ end
36
+
37
+ def deliver(options)
38
+ ::Pony.mail options
39
+ end
40
+ end
41
+ end
@@ -6,16 +6,17 @@ unless defined?(ActiveWrapper::Gems)
6
6
  class Gems
7
7
 
8
8
  VERSIONS = {
9
- :actionmailer => '=2.3.5',
10
- :activerecord => '=2.3.5',
9
+ :activerecord => '=3.0.3',
10
+ :mysql2 => '=0.2.6',
11
+ :pony => '=1.1',
11
12
  :rake => '=0.8.7',
12
- :rspec => '=1.3.0'
13
+ :rspec => '=1.3.1'
13
14
  }
14
15
 
15
16
  TYPES = {
16
- :gemspec => [ :activerecord, :actionmailer, :mysql ],
17
+ :gemspec => [ :activerecord, :mysql2 ],
17
18
  :gemspec_dev => [ :rspec ],
18
- :lib => [ :activerecord, :actionmailer, :mysql ],
19
+ :lib => [ :activerecord, :mysql2 ],
19
20
  :rake => [ :rake, :rspec ],
20
21
  :spec => [ :rspec ]
21
22
  }
@@ -1,3 +1,3 @@
1
1
  module ActiveWrapper
2
- VERSION = "0.3.3" unless defined?(::ActiveWrapper::VERSION)
2
+ VERSION = "0.3.4" unless defined?(::ActiveWrapper::VERSION)
3
3
  end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_wrapper
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 3
9
- - 3
10
- version: 0.3.3
8
+ - 4
9
+ version: 0.3.4
11
10
  platform: ruby
12
11
  authors:
13
12
  - Winton Welsh
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-10-27 00:00:00 -07:00
17
+ date: 2010-11-24 00:00:00 -08:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
@@ -26,60 +25,43 @@ dependencies:
26
25
  requirements:
27
26
  - - "="
28
27
  - !ruby/object:Gem::Version
29
- hash: 9
30
28
  segments:
31
- - 2
32
29
  - 3
33
- - 5
34
- version: 2.3.5
30
+ - 0
31
+ - 3
32
+ version: 3.0.3
35
33
  type: :runtime
36
34
  version_requirements: *id001
37
35
  - !ruby/object:Gem::Dependency
38
- name: actionmailer
36
+ name: mysql2
39
37
  prerelease: false
40
38
  requirement: &id002 !ruby/object:Gem::Requirement
41
39
  none: false
42
40
  requirements:
43
41
  - - "="
44
42
  - !ruby/object:Gem::Version
45
- hash: 9
46
43
  segments:
44
+ - 0
47
45
  - 2
48
- - 3
49
- - 5
50
- version: 2.3.5
46
+ - 6
47
+ version: 0.2.6
51
48
  type: :runtime
52
49
  version_requirements: *id002
53
- - !ruby/object:Gem::Dependency
54
- name: mysql
55
- prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- hash: 3
62
- segments:
63
- - 0
64
- version: "0"
65
- type: :runtime
66
- version_requirements: *id003
67
50
  - !ruby/object:Gem::Dependency
68
51
  name: rspec
69
52
  prerelease: false
70
- requirement: &id004 !ruby/object:Gem::Requirement
53
+ requirement: &id003 !ruby/object:Gem::Requirement
71
54
  none: false
72
55
  requirements:
73
56
  - - "="
74
57
  - !ruby/object:Gem::Version
75
- hash: 27
76
58
  segments:
77
59
  - 1
78
60
  - 3
79
- - 0
80
- version: 1.3.0
61
+ - 1
62
+ version: 1.3.1
81
63
  type: :development
82
- version_requirements: *id004
64
+ version_requirements: *id003
83
65
  description: Wraps ActiveRecord and Logger for use in non-Rails environments
84
66
  email:
85
67
  - mail@wintoni.us
@@ -91,9 +73,9 @@ extra_rdoc_files: []
91
73
 
92
74
  files:
93
75
  - lib/active_wrapper/db.rb
76
+ - lib/active_wrapper/email.rb
94
77
  - lib/active_wrapper/gems.rb
95
78
  - lib/active_wrapper/log.rb
96
- - lib/active_wrapper/mail.rb
97
79
  - lib/active_wrapper/tasks.rb
98
80
  - lib/active_wrapper/version.rb
99
81
  - lib/active_wrapper.rb
@@ -114,7 +96,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
114
96
  requirements:
115
97
  - - ">="
116
98
  - !ruby/object:Gem::Version
117
- hash: 3
118
99
  segments:
119
100
  - 0
120
101
  version: "0"
@@ -123,7 +104,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
104
  requirements:
124
105
  - - ">="
125
106
  - !ruby/object:Gem::Version
126
- hash: 3
127
107
  segments:
128
108
  - 0
129
109
  version: "0"
@@ -1,49 +0,0 @@
1
- module ActiveWrapper
2
- class Mail
3
-
4
- attr_reader :base, :env, :config
5
-
6
- def initialize(options)
7
- @base = options[:base]
8
- @config = {
9
- :smtp => options[:smtp] || {},
10
- :sendmail => options[:sendmail] || nil,
11
- :imap => options[:imap] || {}
12
- }
13
- @env = options[:env].to_s
14
-
15
- path = "#{base}/config/mail.yml"
16
-
17
- if File.exists?(path)
18
- yaml = YAML::load(File.open(path))
19
- if yaml && yaml[@env]
20
- yaml = yaml[@env].to_options
21
- @config[:imap] = yaml[:imap].to_options if yaml[:imap]
22
- @config[:sendmail] = yaml[:sendmail] if !yaml[:sendmail].nil?
23
- @config[:smtp] = yaml[:smtp].to_options if yaml[:smtp]
24
- end
25
- end
26
- if @env == 'test'
27
- ActionMailer::Base.delivery_method = :test
28
- elsif @config[:sendmail]
29
- ActionMailer::Base.delivery_method = :sendmail
30
- elsif @config[:smtp]
31
- ActionMailer::Base.delivery_method = :smtp
32
- ActionMailer::Base.smtp_settings = @config[:smtp]
33
- end
34
- end
35
-
36
- def deliver(options)
37
- Mailer.deliver_email(options)
38
- end
39
-
40
- class Mailer < ::ActionMailer::Base
41
- def email(options)
42
- from options[:from]
43
- recipients options[:to]
44
- subject options[:subject]
45
- body options[:body]
46
- end
47
- end
48
- end
49
- end