diff options
author | 2017-11-05 23:31:21 +0100 | |
---|---|---|
committer | 2017-11-05 23:31:21 +0100 | |
commit | 84bff14bf649969b3729b2c751b423d33e508f0b (patch) | |
tree | a585b92b88fa10998a7100b78152b2a18f388968 /src/models/Recipe.js | |
parent | Merge pull request #213 from alecive/master (diff) | |
parent | bump version to beta 12 (diff) | |
download | ferdium-app-84bff14bf649969b3729b2c751b423d33e508f0b.tar.gz ferdium-app-84bff14bf649969b3729b2c751b423d33e508f0b.tar.zst ferdium-app-84bff14bf649969b3729b2c751b423d33e508f0b.zip |
Merge pull request #217 from meetfranz/developv5.0.0-beta.125.0.0-beta.12
Beta 12
Diffstat (limited to 'src/models/Recipe.js')
-rw-r--r-- | src/models/Recipe.js | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/models/Recipe.js b/src/models/Recipe.js index 43a3450b1..9971df77c 100644 --- a/src/models/Recipe.js +++ b/src/models/Recipe.js | |||
@@ -1,7 +1,8 @@ | |||
1 | import emailParser from 'address-rfc2822'; | ||
2 | |||
1 | export default class Recipe { | 3 | export default class Recipe { |
2 | id = ''; | 4 | id = ''; |
3 | name = ''; | 5 | name = ''; |
4 | author = ''; | ||
5 | description = ''; | 6 | description = ''; |
6 | version = '1.0'; | 7 | version = '1.0'; |
7 | path = ''; | 8 | path = ''; |
@@ -25,12 +26,13 @@ export default class Recipe { | |||
25 | } | 26 | } |
26 | 27 | ||
27 | if (!data.id) { | 28 | if (!data.id) { |
28 | throw Error('Recipe requires Id'); | 29 | // Franz 4 recipes do not have an Id |
30 | throw Error(`Recipe '${data.name}' requires Id`); | ||
29 | } | 31 | } |
30 | 32 | ||
31 | this.id = data.id || this.id; | 33 | this.id = data.id || this.id; |
32 | this.name = data.name || this.name; | 34 | this.name = data.name || this.name; |
33 | this.author = data.author || this.author; | 35 | this.rawAuthor = data.author || this.author; |
34 | this.description = data.description || this.description; | 36 | this.description = data.description || this.description; |
35 | this.version = data.version || this.version; | 37 | this.version = data.version || this.version; |
36 | this.path = data.path; | 38 | this.path = data.path; |
@@ -49,4 +51,15 @@ export default class Recipe { | |||
49 | 51 | ||
50 | this.message = data.config.message || this.message; | 52 | this.message = data.config.message || this.message; |
51 | } | 53 | } |
54 | |||
55 | get author() { | ||
56 | try { | ||
57 | const addresses = emailParser.parse(this.rawAuthor); | ||
58 | return addresses.map(a => ({ email: a.address, name: a.phrase })); | ||
59 | } catch (err) { | ||
60 | console.warn(`Not a valid author for ${this.name}`); | ||
61 | } | ||
62 | |||
63 | return []; | ||
64 | } | ||
52 | } | 65 | } |