mail2frontmatter 0.0.4 → 0.0.5
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.
- checksums.yaml +4 -4
- data/lib/mail2frontmatter/preprocessor.rb +1 -0
- data/lib/mail2frontmatter/version.rb +1 -1
- data/lib/mail2frontmatter/watcher.rb +1 -1
- data/spec/preprocessor_spec.rb +23 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ace6e95944c171685f6dc61db3145b2f67c440c
|
4
|
+
data.tar.gz: ab0297aebb9758ec50afde90e20bc6be471ac4e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
@@ -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
|
data/spec/preprocessor_spec.rb
CHANGED
@@ -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
|