remailer 0.4.0 → 0.4.1

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.4.1
@@ -150,9 +150,14 @@ class Remailer::Interpreter
150
150
  # include:
151
151
  # * :delegate => Which object to use as a delegate, if applicable.
152
152
  # * :state => What the initial state should be. The default is :initalized
153
+ # If a block is supplied, the interpreter object is supplied as an argument
154
+ # to give the caller an opportunity to perform any initial configuration
155
+ # before the first state is entered.
153
156
  def initialize(options = nil)
154
157
  @delegate = (options and options[:delegate])
155
158
 
159
+ yield(self) if (block_given?)
160
+
156
161
  enter_state(options && options[:state] || self.class.initial_state)
157
162
  end
158
163
 
data/remailer.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{remailer}
8
- s.version = "0.4.0"
8
+ s.version = "0.4.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Scott Tadman"]
data/test/helper.rb CHANGED
@@ -23,7 +23,7 @@ class Proc
23
23
  end
24
24
  end
25
25
 
26
- unless (Hash.respond_to?(:slice))
26
+ unless (Hash.new.respond_to?(:slice))
27
27
  class Hash
28
28
  def slice(*keys)
29
29
  keys.inject({ }) do |h, k|
@@ -101,6 +101,10 @@ class ExampleInterpreter < Remailer::Interpreter
101
101
  end
102
102
  end
103
103
 
104
+ class InterpreterWithAccessor < Remailer::Interpreter
105
+ attr_accessor :example
106
+ end
107
+
104
108
  class RemailerInterpreterTest < Test::Unit::TestCase
105
109
  def test_default_state
106
110
  assert_equal [ :initialized, :terminated ], Remailer::Interpreter.states_defined.collect { |s| s.to_s }.sort.collect { |s| s.to_sym }
@@ -283,4 +287,16 @@ class RemailerInterpreterTest < Test::Unit::TestCase
283
287
  assert interpreter.error.index(':initialized')
284
288
  assert interpreter.error.index(':invalid')
285
289
  end
290
+
291
+ def test_new_with_block
292
+ interpreter = InterpreterWithAccessor.new
293
+
294
+ assert_equal nil, interpreter.example
295
+
296
+ interpreter = InterpreterWithAccessor.new do |interpreter|
297
+ interpreter.example = 'example'
298
+ end
299
+
300
+ assert_equal 'example', interpreter.example
301
+ end
286
302
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- - 0
9
- version: 0.4.0
8
+ - 1
9
+ version: 0.4.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Scott Tadman