redis_cache_mailer_delivery 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,2 +1,7 @@
1
- - 0.0.4
1
+ v0.0.6
2
+ * BUG fix: One has to set the whole settings in the client or CacheDelivery will
3
+ not work properly since some settings could be missing
4
+ v0.0.5
5
+ * Generalize how the marshallable converters are working. Make it a setting that can be configured by the clients
6
+ v0.0.4
2
7
  * Add the ability to marshal a unmarshalable object, given the object provides marshallable method that make the object to be marshallable.
@@ -1,5 +1,6 @@
1
1
  require 'action_mailer'
2
2
  require 'redis_cache_mailer_delivery/version'
3
+ require 'redis_cache_mailer_delivery/settings'
3
4
  require 'redis_cache_mailer_delivery/marshallable_converter_setting'
4
5
  require 'redis_cache_mailer_delivery/cache_delivery'
5
6
  require 'redis_cache_mailer_delivery/converters/sequel_marshallable_mail_message'
@@ -9,10 +10,8 @@ module RedisCacheMailerDelivery
9
10
  class << self
10
11
  def install
11
12
  ActionMailer::Base.add_delivery_method :redis_cache, RedisCacheMailerDelivery::CacheDelivery,
12
- :redis_key_name => "redis_cache_mailer_delivery:mail_messages",
13
- :marshallable_converters => []
13
+ Settings.default_values
14
14
  end
15
-
16
15
  end # << self
17
16
  end # RedisCacheMailerDelivery
18
17
  require 'redis_cache_mailer_delivery/railtie'
@@ -6,18 +6,18 @@ module RedisCacheMailerDelivery
6
6
  #
7
7
  class CacheDelivery
8
8
 
9
- # @attr [Hash] settings Settings for CacheDelivery
10
- attr_accessor :settings
9
+ attr_reader :settings
10
+ private :settings
11
11
 
12
12
  # @api private
13
13
  def initialize(settings)
14
- @settings = settings
14
+ @settings = Settings.new(settings)
15
15
  end
16
16
 
17
17
  # @api private
18
18
  def deliver!(mail)
19
- list = Redis::List.new settings[:redis_key_name], :marshal => true
20
- settings[:marshallable_converters].each do |setting|
19
+ list = Redis::List.new settings.redis_key_name, :marshal => true
20
+ settings.marshallable_converters.each do |setting|
21
21
  mail = MarshallableConverterSetting.new(setting).marshallable_class.marshallable(mail)
22
22
  end
23
23
  list << mail
@@ -11,7 +11,8 @@ module RedisCacheMailerDelivery
11
11
  # @return [Array] array of mails (each mail is an instance of Mail.)
12
12
  #
13
13
  def all
14
- list = Redis::List.new ActionMailer::Base.redis_cache_settings[:redis_key_name], :marshal => true
14
+ settings = Settings.new ActionMailer::Base.redis_cache_settings
15
+ list = Redis::List.new settings.redis_key_name, :marshal => true
15
16
  list.values
16
17
  end
17
18
  end
@@ -0,0 +1,15 @@
1
+ module RedisCacheMailerDelivery
2
+ class Settings
3
+ class << self
4
+ def default_values
5
+ {:redis_key_name => "redis_cache_mailer_delivery:mail_messages",
6
+ :marshallable_converters => []}
7
+ end
8
+ end
9
+ def initialize(settings)
10
+ self.class.default_values.merge(settings).each do |key, value|
11
+ self.class.send(:define_method, key) {value}
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,3 +1,3 @@
1
1
  module RedisCacheMailerDelivery
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -2,8 +2,8 @@ require File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_helper"))
2
2
 
3
3
  module RedisCacheMailerDelivery
4
4
  describe CacheDelivery do
5
- subject {described_class.new :redis_key_name => "a-name", :marshallable_converters => []}
6
5
  describe "#deliver!" do
6
+ subject {described_class.new :redis_key_name => "a-name", :marshallable_converters => []}
7
7
  let(:object) {Mail::Message.new}
8
8
 
9
9
  after(:each) do
@@ -0,0 +1,37 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_helper"))
2
+
3
+ module RedisCacheMailerDelivery
4
+ describe Settings do
5
+ describe ".default_values" do
6
+ {:redis_key_name => "redis_cache_mailer_delivery:mail_messages",
7
+ :marshallable_converters => []}.each do |key, value|
8
+ it "includes #{key} and its default value to #{value}" do
9
+ described_class.default_values.should include(key => value)
10
+ end
11
+ end
12
+ end
13
+
14
+ describe ".new" do
15
+ context "when a value that is a key in default_values hash being passed in" do
16
+ subject {described_class.new :redis_key_name => "a-new-name"}
17
+ it "generates a method and return the value being passed in" do
18
+ subject.redis_key_name.should eq("a-new-name")
19
+ end
20
+ end
21
+ context "when a value that is not a key in default_values hash being passed in" do
22
+ subject {described_class.new :something_else => "a-new-name"}
23
+ it "generates a method and return the value being passed in" do
24
+ subject.something_else.should eq("a-new-name")
25
+ end
26
+ end
27
+ Settings.default_values.each do |key, value|
28
+ context "when #{key} is not passed in" do
29
+ subject {described_class.new({})}
30
+ it "generates a method #{key} and return the value defined in the default_values array" do
31
+ subject.send(key).should eq(value)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis_cache_mailer_delivery
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Yi Wen
@@ -155,12 +155,14 @@ files:
155
155
  - lib/redis_cache_mailer_delivery/deliveries.rb
156
156
  - lib/redis_cache_mailer_delivery/marshallable_converter_setting.rb
157
157
  - lib/redis_cache_mailer_delivery/railtie.rb
158
+ - lib/redis_cache_mailer_delivery/settings.rb
158
159
  - lib/redis_cache_mailer_delivery/version.rb
159
160
  - redis_cache_mailer_delivery.gemspec
160
161
  - spec/redis_cache_mailer_delivery/cache_delivery_spec.rb
161
162
  - spec/redis_cache_mailer_delivery/converters/sequel_marshallable_mail_message_spec.rb
162
163
  - spec/redis_cache_mailer_delivery/deliveries_spec.rb
163
164
  - spec/redis_cache_mailer_delivery/marshallable_converter_setting_spec.rb
165
+ - spec/redis_cache_mailer_delivery/settings_spec.rb
164
166
  - spec/redis_cache_mailer_delivery_spec.rb
165
167
  - spec/spec_helper.rb
166
168
  - spec/support/faked_rails.rb
@@ -203,6 +205,7 @@ test_files:
203
205
  - spec/redis_cache_mailer_delivery/converters/sequel_marshallable_mail_message_spec.rb
204
206
  - spec/redis_cache_mailer_delivery/deliveries_spec.rb
205
207
  - spec/redis_cache_mailer_delivery/marshallable_converter_setting_spec.rb
208
+ - spec/redis_cache_mailer_delivery/settings_spec.rb
206
209
  - spec/redis_cache_mailer_delivery_spec.rb
207
210
  - spec/spec_helper.rb
208
211
  - spec/support/faked_rails.rb