|
| 1 | +/** |
| 2 | +FRESH to JSON Resume conversion routiens. |
| 3 | +@license MIT. Copyright (c) 2015 James M. Devlin / FluentDesk |
| 4 | +*/ |
| 5 | + |
| 6 | +(function(){ |
| 7 | + |
| 8 | + /** |
| 9 | + Convert between FRESH and JRS resume/CV formats. |
| 10 | + @class FRESHConverter |
| 11 | + */ |
| 12 | + var FRESHConverter = module.exports = { |
| 13 | + |
| 14 | + |
| 15 | + /** |
| 16 | + Convert from JSON Resume format to FRESH. |
| 17 | + */ |
| 18 | + toFRESH: function( jrs ) { |
| 19 | + |
| 20 | + return { |
| 21 | + |
| 22 | + name: jrs.basics.name, |
| 23 | + |
| 24 | + info: { |
| 25 | + label: jrs.basics.label, |
| 26 | + class: jrs.basics.label, |
| 27 | + picture: jrs.basics.picture, |
| 28 | + summary: jrs.basics.summary |
| 29 | + }, |
| 30 | + |
| 31 | + contact: { |
| 32 | + email: jrs.basics.email, |
| 33 | + phone: jrs.basics.phone, |
| 34 | + website: jrs.basics.website |
| 35 | + }, |
| 36 | + |
| 37 | + location: { |
| 38 | + city: jrs.basics.location.city, |
| 39 | + region: jrs.basics.location.region, |
| 40 | + country: jrs.basics.location.countryCode, |
| 41 | + code: jrs.basics.location.postalCode, |
| 42 | + address: [ |
| 43 | + jrs.basics.location.address, |
| 44 | + ] |
| 45 | + }, |
| 46 | + |
| 47 | + employment: { |
| 48 | + history: jrs.work.map( function( job ) { |
| 49 | + return { |
| 50 | + position: job.position, |
| 51 | + employer: job.company, |
| 52 | + summary: job.summary, |
| 53 | + current: !job.endDate || !job.endDate.trim() || job.endDate.trim().toLowerCase() === 'current', |
| 54 | + start: job.startDate, |
| 55 | + end: job.endDate, |
| 56 | + url: job.website, |
| 57 | + keywords: "", |
| 58 | + highlights: job.highlights |
| 59 | + }; |
| 60 | + }) |
| 61 | + }, |
| 62 | + |
| 63 | + education: { |
| 64 | + history: jrs.education.map(function(edu){ |
| 65 | + return { |
| 66 | + institution: edu.institution, |
| 67 | + start: edu.startDate, |
| 68 | + end: edu.endDate, |
| 69 | + grade: edu.gpa, |
| 70 | + curriculum: edu.courses, |
| 71 | + url: edu.website || edu.url || null, |
| 72 | + summary: null, |
| 73 | + // ???: edu.area, TODO |
| 74 | + // ???: edu.studyType TODO |
| 75 | + }; |
| 76 | + }) |
| 77 | + }, |
| 78 | + |
| 79 | + service: { |
| 80 | + history: jrs.volunteer.map(function(vol) { |
| 81 | + return { |
| 82 | + type: 'volunteer', |
| 83 | + position: vol.position, |
| 84 | + organization: vol.organization, |
| 85 | + start: vol.startDate, |
| 86 | + end: vol.endDate, |
| 87 | + url: vol.website, |
| 88 | + summary: vol.summary, |
| 89 | + highlights: vol.highlights |
| 90 | + }; |
| 91 | + }) |
| 92 | + }, |
| 93 | + |
| 94 | + skills: jrs.skills.map(function(sk){ |
| 95 | + return { |
| 96 | + name: sk.name, |
| 97 | + summary: "", |
| 98 | + level: sk.level, |
| 99 | + summary: sk.keywords.join(', '), |
| 100 | + years: null, |
| 101 | + proof: null |
| 102 | + }; |
| 103 | + }), |
| 104 | + |
| 105 | + publications: jrs.publications.map(function(pub){ |
| 106 | + return { |
| 107 | + title: pub.name, |
| 108 | + publisher: pub.publisher, |
| 109 | + link: [ |
| 110 | + { 'url': pub.website } |
| 111 | + ], |
| 112 | + year: pub.releaseDate |
| 113 | + }; |
| 114 | + }), |
| 115 | + |
| 116 | + recognition: jrs.awards.map(function(awd){ |
| 117 | + return { |
| 118 | + title: awd.title, |
| 119 | + date: awd.date, |
| 120 | + summary: awd.summary, |
| 121 | + from: awd.awarder, |
| 122 | + url: null |
| 123 | + }; |
| 124 | + }), |
| 125 | + |
| 126 | + social: jrs.basics.profiles.map(function(pro){ |
| 127 | + return { |
| 128 | + label: pro.network, |
| 129 | + network: pro.network, |
| 130 | + url: pro.url, |
| 131 | + user: pro.username |
| 132 | + }; |
| 133 | + }), |
| 134 | + |
| 135 | + interests: jrs.interests |
| 136 | + }; |
| 137 | + }, |
| 138 | + |
| 139 | + /** |
| 140 | + Convert from FRESH format to JSON Resume. |
| 141 | + */ |
| 142 | + toJRS: function( fresh ) { |
| 143 | + |
| 144 | + return { |
| 145 | + |
| 146 | + basics: { |
| 147 | + name: fresh.name, |
| 148 | + summary: fresh.info.summary, |
| 149 | + website: fresh.info.website, |
| 150 | + phone: fresh.info.phone, |
| 151 | + email: fresh.info.email, |
| 152 | + picture: fresh.info.picture, |
| 153 | + location: { |
| 154 | + address: fresh.location.address.join('\n'), |
| 155 | + postalCode: fresh.location.code, |
| 156 | + city: fresh.location.city, |
| 157 | + countryCode: fresh.location.country, |
| 158 | + region: fresh.location.region |
| 159 | + }, |
| 160 | + profiles: fresh.social.map(function(soc){ |
| 161 | + return { |
| 162 | + network: soc.network, |
| 163 | + username: soc.user, |
| 164 | + url: soc.url |
| 165 | + }; |
| 166 | + }) |
| 167 | + }, |
| 168 | + |
| 169 | + work: fresh.employment.history.map(function(emp){ |
| 170 | + return { |
| 171 | + company: emp.employer, |
| 172 | + position: emp.position, |
| 173 | + startDate: emp.start, |
| 174 | + endDate: emp.end, |
| 175 | + summary: emp.summary, |
| 176 | + highlights: emp.highlights |
| 177 | + }; |
| 178 | + }), |
| 179 | + |
| 180 | + education: fresh.education.history.map(function(edu){ |
| 181 | + return { |
| 182 | + institution: edu.institution, |
| 183 | + gpa: edu.grade, |
| 184 | + courses: edu.curriculum, |
| 185 | + startDate: edu.start, |
| 186 | + endDate: edu.end, |
| 187 | + area: "", // TODO |
| 188 | + studyType: "" |
| 189 | + }; |
| 190 | + }), |
| 191 | + |
| 192 | + skills: fresh.skills.map( function(sk){ |
| 193 | + return { |
| 194 | + name: sk.name, |
| 195 | + level: sk.level, |
| 196 | + keywords: [], // TODO |
| 197 | + //???: sk.years, |
| 198 | + //???: sk.summary |
| 199 | + }; |
| 200 | + }), |
| 201 | + |
| 202 | + volunteer: fresh.service.history.map(function(srv){ |
| 203 | + return { |
| 204 | + //???: srv.type, |
| 205 | + organization: srv.organization, |
| 206 | + position: srv.position, |
| 207 | + startDate: srv.start, |
| 208 | + endDate: srv.end, |
| 209 | + website: srv.url, |
| 210 | + summary: srv.summary, |
| 211 | + highlights: srv.highlights |
| 212 | + }; |
| 213 | + }), |
| 214 | + |
| 215 | + awards: fresh.recognition.map(function(awd){ |
| 216 | + return { |
| 217 | + //???: awd.type, // TODO |
| 218 | + //???: awd.url, |
| 219 | + title: awd.title, |
| 220 | + date: awd.date, |
| 221 | + awarder: awd.from, |
| 222 | + summary: awd.summary |
| 223 | + }; |
| 224 | + }), |
| 225 | + |
| 226 | + publications: fresh.publications.map(function(pub){ |
| 227 | + return { |
| 228 | + name: pub.title, |
| 229 | + publisher: "", // TODO |
| 230 | + releaseDate: pub.date, |
| 231 | + website: pub.link[0].url, |
| 232 | + summary: pub.summary |
| 233 | + }; |
| 234 | + }), |
| 235 | + |
| 236 | + interests: fresh.interests |
| 237 | + |
| 238 | + }; |
| 239 | + |
| 240 | + } |
| 241 | + |
| 242 | + }; |
| 243 | + |
| 244 | +}()); |
0 commit comments