mail2frontmatter 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 26bc82508ba945ff59767e16107e28b4ffe74490
4
- data.tar.gz: a019002f991f36e00baded30dac4a18143344448
3
+ metadata.gz: 7ace6e95944c171685f6dc61db3145b2f67c440c
4
+ data.tar.gz: ab0297aebb9758ec50afde90e20bc6be471ac4e4
5
5
  SHA512:
6
- metadata.gz: c1558fbc122ab98cf27e82568b2d87e9a3b21d8bb8027e98df902230e028bec14b0207e4892085fa87efc193ae3a68935bd8239c312b6d0a982bdd600cbfe64d
7
- data.tar.gz: f72979a52e51bab65842de1480f00ed123ab09b10d64f80058ac70a4d5a6ccbe30a3d91796b51eb37452e9fa3f4f1b72e4babcd8713fe145e390f7934ccf3d22
6
+ metadata.gz: 48a37162365e5015c5a89b39a252a6f2b49e92b14ba14fe4e077467a19b6e8231fbfea3737f66c11f258a2368bc04eb28749f48c94456121117f30d9529c5524
7
+ data.tar.gz: 5f702a7aba5ed48c4b4dfce4c75a1fc90ed1a625497dbc0f4ebfad60abac2c227bac1f3a211f689494ce06941526d892147dc8056275a98767389b1c11e7e15f
@@ -11,6 +11,7 @@ module Mail2FrontMatter
11
11
 
12
12
  def self.register(options = {})
13
13
  raise InvalidProcessor, "run method not defined on #{self}" if !self.respond_to?(:run)
14
+ raise ArgumentError, "options must be a hash" unless options.is_a? Hash
14
15
  @options = options
15
16
 
16
17
  @@processors << self
@@ -1,3 +1,3 @@
1
1
  module Mail2FrontMatter
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -40,7 +40,7 @@ module Mail2FrontMatter
40
40
  raise e
41
41
  end
42
42
 
43
- klass = "Mail2FrontMatter::#{processor[:key].underscore.classify}".constantize.register(processor[:options])
43
+ klass = "Mail2FrontMatter::#{processor[:key].underscore.classify}".constantize.register(processor[:options] || {})
44
44
  end
45
45
 
46
46
  mail_protocol = config.delete(:protocol) || :imap
@@ -26,6 +26,17 @@ describe Mail2FrontMatter::PreProcessor, "registration" do
26
26
  return MyValidProcessor
27
27
  }
28
28
 
29
+ # let(:invalidly_registered_preprocessor) {
30
+ # class MyOtherwiseValidProcessor < Mail2FrontMatter::PreProcessor
31
+ # def self.run(metadata, body)
32
+ # # some modification
33
+ # return metadata, body
34
+ # end
35
+ # end
36
+
37
+ # return MyOtherwiseValidProcessor
38
+ # }
39
+
29
40
  it "should raise errors for invalid processors" do
30
41
  expect {
31
42
  invalidly_defined_preprocessor.register({})
@@ -38,4 +49,16 @@ describe Mail2FrontMatter::PreProcessor, "registration" do
38
49
  }.to_not raise_error
39
50
  end
40
51
 
52
+ it "should raise an error when registered without a hash" do
53
+ expect {
54
+ validly_defined_preprocessor.register(nil)
55
+ }.to raise_error(ArgumentError)
56
+ end
57
+
58
+ it "should not raise an error when registered with a hash" do
59
+ expect {
60
+ validly_defined_preprocessor.register({ foo: 'bar' })
61
+ }.to_not raise_error
62
+ end
63
+
41
64
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mail2frontmatter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kunal Shah