codementor 2.0.1 → 2.0.2

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.
Files changed (4) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +13 -142
  3. package/lib/index.js +129 -160
  4. package/package.json +1 -2
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016-25 Ionică Bizău <bizauionica@gmail.com> (https://ionicabizau.net)
3
+ Copyright (c) 2016-26 Ionică Bizău <bizauionica@gmail.com> (https://ionicabizau.net)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,55 +1,15 @@
1
1
  <!-- Please do not edit this file. Edit the `blah` field in the `package.json` instead. If in doubt, open an issue. -->
2
2
 
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
3
  # codementor
21
4
 
22
5
  [![Support me on Patreon][badge_patreon]][patreon] [![Buy me a book][badge_amazon]][amazon] [![PayPal][badge_paypal_donate]][paypal-donations] [![Ask me anything](https://img.shields.io/badge/ask%20me-anything-1abc9c.svg)](https://github.com/IonicaBizau/ama) [![Version](https://img.shields.io/npm/v/codementor.svg)](https://www.npmjs.com/package/codementor) [![Downloads](https://img.shields.io/npm/dt/codementor.svg)](https://www.npmjs.com/package/codementor) [![Get help on Codementor](https://cdn.codementor.io/badges/get_help_github.svg)](https://www.codementor.io/@johnnyb?utm_source=github&utm_medium=button&utm_term=johnnyb&utm_campaign=github)
23
6
 
24
7
  <a href="https://www.buymeacoffee.com/H96WwChMy" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/yellow_img.png" alt="Buy Me A Coffee"></a>
25
8
 
26
-
27
-
28
-
29
-
30
-
31
-
32
9
  > A scraper for codementor.io.
33
10
 
34
-
35
-
36
-
37
-
38
-
39
11
  > :bulb: **Hey!** If you need help with JavaScript/CSS/HTML/Git & GitHub, [ping me on CodeMentor](https://www.codementor.io/johnnyb).
40
12
 
41
-
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
13
  ## :cloud: Installation
54
14
 
55
15
  ```sh
@@ -60,22 +20,8 @@ npm install --save codementor
60
20
  yarn add codementor
61
21
  ```
62
22
 
63
-
64
-
65
-
66
-
67
-
68
-
69
-
70
-
71
-
72
-
73
-
74
-
75
23
  ## :clipboard: Example
76
24
 
77
-
78
-
79
25
  ```js
80
26
  const CodeMentor = require("codementor");
81
27
 
@@ -150,41 +96,12 @@ CodeMentor.mentorProfile("johnnyb", (err, { data }) => {
150
96
  });
151
97
  ```
152
98
 
153
-
154
-
155
-
156
-
157
-
158
-
159
-
160
-
161
-
162
-
163
-
164
- ## :question: Get Help
165
-
166
- There are few ways to get help:
167
-
168
-
169
-
170
- 1. Please [post questions on Stack Overflow](https://stackoverflow.com/questions/ask). You can open issues with questions, as long you add a link to your Stack Overflow question.
171
- 2. For bug reports and feature requests, open issues. :bug:
172
- 3. For direct and quick help, you can [use Codementor](https://www.codementor.io/johnnyb). :rocket:
173
-
174
-
175
-
176
-
177
-
178
-
179
-
180
99
  ## :memo: Documentation
181
100
 
182
-
183
101
  ### `userUrl(user)`
184
102
  Returns the user profile url.
185
103
 
186
104
  #### Params
187
-
188
105
  - **String** `user`: The CodeMentor username.
189
106
 
190
107
  #### Return
@@ -194,7 +111,6 @@ Returns the user profile url.
194
111
  Scrapes the mentor profile.
195
112
 
196
113
  #### Params
197
-
198
114
  - **String** `user`: The CodeMentor username.
199
115
  - **Function** `cb`: The callback function.
200
116
 
@@ -205,89 +121,44 @@ Scrapes the mentor profile.
205
121
  Gets the mentor reviews.
206
122
 
207
123
  #### Params
208
-
209
124
  - **String** `user`: The CodeMentor username.
210
125
  - **Function** `cb`: The callback function.
211
126
 
212
127
  #### Return
213
128
  - **Promise** A promise object.
214
129
 
130
+ ## :question: Get Help
215
131
 
132
+ There are a few ways to get help:
216
133
 
134
+ 1. Please [post questions on Stack Overflow](https://stackoverflow.com/questions/ask). You can open issues with questions, as long as you add a link to your Stack Overflow question.
135
+ 2. For bug reports and feature requests, open issues. :bug:
136
+ 3. For direct and quick help, you can [use Codementor](https://www.codementor.io/johnnyb). :rocket:
217
137
 
138
+ ## :yum: How to Contribute
218
139
 
219
-
220
-
221
-
222
-
223
-
224
-
225
-
226
-
227
-
228
- ## :yum: How to contribute
229
140
  Have an idea? Found a bug? See [how to contribute][contributing].
230
141
 
142
+ ## :sparkling_heart: Support My Projects
231
143
 
232
- ## :sparkling_heart: Support my projects
233
- I open-source almost everything I can, and I try to reply to everyone needing help using these projects. Obviously,
234
- this takes time. You can integrate and use these projects in your applications *for free*! You can even change the source code and redistribute (even resell it).
235
-
236
- However, if you get some profit from this or just want to encourage me to continue creating stuff, there are few ways you can do it:
144
+ I open-source almost everything I can, and I try to reply to everyone needing help using these projects. Obviously, this takes time. You can integrate and use these projects in your applications *for free*! You can even change the source code and redistribute it (even resell it).
237
145
 
146
+ However, if you get some profit from this or just want to encourage me to continue creating stuff, there are a few ways you can do it:
238
147
 
239
148
  - Starring and sharing the projects you like :rocket:
240
- - [![Buy me a book][badge_amazon]][amazon]—I love books! I will remember you after years if you buy me one. :grin: :book:
149
+ - [![Buy me a book][badge_amazon]][amazon]—I love books! I will remember you for years if you buy me one. :grin: :book:
241
150
  - [![PayPal][badge_paypal]][paypal-donations]—You can make one-time donations via PayPal. I'll probably buy a ~~coffee~~ tea. :tea:
242
151
  - [![Support me on Patreon][badge_patreon]][patreon]—Set up a recurring monthly donation and you will get interesting news about what I'm doing (things that I don't share with everyone).
243
- - **Bitcoin**—You can send me bitcoins at this address (or scanning the code below): `1P9BRsmazNQcuyTxEqveUsnf5CERdq35V6`
244
-
245
- ![](https://i.imgur.com/z6OQI95.png)
152
+ - **Bitcoin**—You can send me bitcoins at this address (or by scanning the code below): `1P9BRsmazNQcuyTxEqveUsnf5CERdq35V6`
246
153
 
154
+ ![Bitcoin QR code](https://i.imgur.com/z6OQI95.png)
247
155
 
248
156
  Thanks! :heart:
249
157
 
250
-
251
-
252
-
253
-
254
-
255
-
256
-
257
-
258
-
259
-
260
-
261
-
262
-
263
-
264
-
265
- ## :dizzy: Where is this library used?
266
- If you are using this library in one of your projects, add it in this list. :sparkles:
267
-
268
- - `codescriptwiz`
269
- - `devprogrammer`
270
- - `scriptcodesavvy`
271
-
272
-
273
-
274
-
275
-
276
-
277
-
278
-
279
-
280
-
281
-
282
158
  ## :scroll: License
283
159
 
284
160
  [MIT][license] © [Ionică Bizău][website]
285
161
 
286
-
287
-
288
-
289
-
290
-
291
162
  [license]: /LICENSE
292
163
  [website]: https://ionicabizau.net
293
164
  [contributing]: /CONTRIBUTING.md
@@ -297,5 +168,5 @@ If you are using this library in one of your projects, add it in this list. :spa
297
168
  [badge_paypal]: https://ionicabizau.github.io/badges/paypal.svg
298
169
  [badge_paypal_donate]: https://ionicabizau.github.io/badges/paypal_donate.svg
299
170
  [patreon]: https://www.patreon.com/ionicabizau
300
- [amazon]: http://amzn.eu/hRo9sIZ
171
+ [amazon]: https://amzn.eu/hRo9sIZ
301
172
  [paypal-donations]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RVXDDLKKLQRJW
package/lib/index.js CHANGED
@@ -1,175 +1,144 @@
1
1
  "use strict";
2
2
 
3
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
3
+ const scrape = require("scrape-it")
4
+ , match = require("match-it")
5
+ , splitByComma = require("split-by-comma")
6
+ ;
4
7
 
5
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
+ const CODEMENTOR_HOST = "https://www.codementor.io/"
6
9
 
7
- var scrape = require("scrape-it"),
8
- match = require("match-it"),
9
- splitByComma = require("split-by-comma");
10
-
11
- var CODEMENTOR_HOST = "https://www.codementor.io/";
12
-
13
- module.exports = function () {
14
- function CodeMentor() {
15
- _classCallCheck(this, CodeMentor);
10
+ module.exports = class CodeMentor {
11
+ /**
12
+ * userUrl
13
+ * Returns the user profile url.
14
+ *
15
+ * @name userUrl
16
+ * @function
17
+ * @param {String} user The CodeMentor username.
18
+ * @returns {String} The user profile url.
19
+ */
20
+ static userUrl (user) {
21
+ return CODEMENTOR_HOST + "@" +user;
16
22
  }
17
23
 
18
- _createClass(CodeMentor, null, [{
19
- key: "userUrl",
20
-
21
- /**
22
- * userUrl
23
- * Returns the user profile url.
24
- *
25
- * @name userUrl
26
- * @function
27
- * @param {String} user The CodeMentor username.
28
- * @returns {String} The user profile url.
29
- */
30
- value: function userUrl(user) {
31
- return CODEMENTOR_HOST + "@" + user;
32
- }
33
-
34
- /**
35
- * mentorProfile
36
- * Scrapes the mentor profile.
37
- *
38
- * @name mentorProfile
39
- * @function
40
- * @param {String} user The CodeMentor username.
41
- * @param {Function} cb The callback function.
42
- * @returns {Promise} A promise object.
43
- */
44
-
45
- }, {
46
- key: "mentorProfile",
47
- value: function mentorProfile(user, cb) {
48
- debugger;
49
- return scrape(CodeMentor.userUrl(user), {
50
- reviews: {
51
- listItem: "[class^='Review__StyledReview']",
52
- data: {
53
- avatar: {
54
- selector: ".cui-avatar-image > img",
55
- attr: "src"
56
- },
57
- content: ".content",
58
- name: {
59
- selector: ".name",
60
- eq: 0
61
- },
62
- date: ".time"
24
+ /**
25
+ * mentorProfile
26
+ * Scrapes the mentor profile.
27
+ *
28
+ * @name mentorProfile
29
+ * @function
30
+ * @param {String} user The CodeMentor username.
31
+ * @param {Function} cb The callback function.
32
+ * @returns {Promise} A promise object.
33
+ */
34
+ static mentorProfile (user, cb) {
35
+ debugger
36
+ return scrape(CodeMentor.userUrl(user), {
37
+ reviews: {
38
+ listItem: "[class^='Review__StyledReview']"
39
+ , data: {
40
+ avatar: {
41
+ selector: ".cui-avatar-image > img"
42
+ , attr: "src"
43
+ }
44
+ , content: ".content"
45
+ , name: {
46
+ selector: ".name"
47
+ , eq: 0
48
+ }
49
+ , date: ".time"
50
+ }
51
+ }
52
+ , description: ".headline"
53
+ , timezone: {
54
+ selector: ".timezone"
55
+ , how: "text"
56
+ }
57
+ , languages: {
58
+ selector: ".additional-info .languages > span:nth-child(2n)"
59
+ , convert: splitByComma
60
+ }
61
+ , skills: {
62
+ listItem: ".badge.customizeBadge"
63
+ }
64
+ , ratings: {
65
+ selector: ".review-stats .span8 .distribution-row .span3.muted"
66
+ , data: {
67
+ five: {
68
+ eq: 0
69
+ , convert: Number
63
70
  }
64
- },
65
- description: ".headline",
66
- timezone: {
67
- selector: ".timezone",
68
- how: "text"
69
- },
70
- languages: {
71
- selector: ".additional-info .languages > span:nth-child(2n)",
72
- convert: splitByComma
73
- },
74
- skills: {
75
- listItem: ".badge.customizeBadge"
76
- },
77
- ratings: {
78
- selector: ".review-stats .span8 .distribution-row .span3.muted",
79
- data: {
80
- five: {
81
- eq: 0,
82
- convert: Number
83
- },
84
- four: {
85
- eq: 1,
86
- convert: Number
87
- },
88
- three: {
89
- eq: 2,
90
- convert: Number
91
- },
92
- two: {
93
- eq: 3,
94
- convert: Number
95
- },
96
- one: {
97
- eq: 4,
98
- convert: Number
99
- }
71
+ , four: {
72
+ eq: 1
73
+ , convert: Number
100
74
  }
101
- },
102
- name: ".pageTitle",
103
- about: ".about",
104
- rate: {
105
- selector: ".topCard > .price > strong",
106
- convert: function convert(x) {
107
- return parseFloat(x.substring(1));
75
+ , three: {
76
+ eq: 2
77
+ , convert: Number
108
78
  }
109
- },
110
- hourRate: {
111
- selector: ".topCard > .price > strong",
112
- convert: function convert(x) {
113
- return parseFloat(x.substring(1)) * 4;
79
+ , two: {
80
+ eq: 3
81
+ , convert: Number
114
82
  }
115
- },
116
- averateRating: {
117
- selector: ".topCard > strong",
118
- convert: Number
119
- },
120
- sessionCount: {
121
- selector: ".sessionGiven",
122
- convert: function convert(x) {
123
- return +match(x, /([0-9]+) sessions given/)[1];
83
+ , one: {
84
+ eq: 4
85
+ , convert: Number
124
86
  }
125
- },
126
- signUpDate: {
127
- selector: ".sessionGiven",
128
- convert: function convert(x) {
129
- return new Date(match(x, /since (.*)/)[1]);
87
+ }
88
+ }
89
+ , name: ".pageTitle"
90
+ , about: ".about"
91
+ , rate: {
92
+ selector: ".topCard > .price > strong"
93
+ , convert: x => parseFloat(x.substring(1))
94
+ }
95
+ , hourRate: {
96
+ selector: ".topCard > .price > strong"
97
+ , convert: x => parseFloat(x.substring(1)) * 4
98
+ }
99
+ , averateRating: {
100
+ selector: ".topCard > strong"
101
+ , convert: Number
102
+ }
103
+ , sessionCount: {
104
+ selector: ".sessionGiven"
105
+ , convert: x => +match(x, /([0-9]+) sessions given/)[1]
106
+ }
107
+ , signUpDate: {
108
+ selector: ".sessionGiven"
109
+ , convert: x => new Date(match(x, /since (.*)/)[1])
110
+ }
111
+ , responseTime: ".mentor-response .avg-time .good.num"
112
+ , likehoodOfReply: ".mentor-response .rate .good.num"
113
+ , expertise: {
114
+ listItem: ".skillModule"
115
+ , data: {
116
+ name: ".skillName"
117
+ , years_experience: {
118
+ selector: ".skillYear"
119
+ , convert: x => +match(x, /(\d+)/)[1]
130
120
  }
131
- },
132
- responseTime: ".mentor-response .avg-time .good.num",
133
- likehoodOfReply: ".mentor-response .rate .good.num",
134
- expertise: {
135
- listItem: ".skillModule",
136
- data: {
137
- name: ".skillName",
138
- years_experience: {
139
- selector: ".skillYear",
140
- convert: function convert(x) {
141
- return +match(x, /(\d+)/)[1];
142
- }
143
- },
144
- description: ".description",
145
- tags: {
146
- listItem: ".tags",
147
- how: "text"
148
- }
121
+ , description: ".description"
122
+ , tags: {
123
+ listItem: ".tags"
124
+ , how: "text"
149
125
  }
150
126
  }
151
- }, cb);
152
- }
153
-
154
- /**
155
- * mentorReviews
156
- * Gets the mentor reviews.
157
- *
158
- * @name mentorReviews
159
- * @function
160
- * @param {String} user The CodeMentor username.
161
- * @param {Function} cb The callback function.
162
- * @returns {Promise} A promise object.
163
- */
164
-
165
- }, {
166
- key: "mentorReviews",
167
- value: function mentorReviews(user, cb) {
168
- return CodeMentor.mentorProfile(user, function (err, data) {
169
- return cb(err, data && data.reviews);
170
- });
171
- }
172
- }]);
127
+ }
128
+ }, cb);
129
+ }
173
130
 
174
- return CodeMentor;
175
- }();
131
+ /**
132
+ * mentorReviews
133
+ * Gets the mentor reviews.
134
+ *
135
+ * @name mentorReviews
136
+ * @function
137
+ * @param {String} user The CodeMentor username.
138
+ * @param {Function} cb The callback function.
139
+ * @returns {Promise} A promise object.
140
+ */
141
+ static mentorReviews (user, cb) {
142
+ return CodeMentor.mentorProfile(user, (err, data) => cb(err, data && data.reviews));
143
+ }
144
+ };
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "io"
10
10
  ],
11
11
  "license": "MIT",
12
- "version": "2.0.1",
12
+ "version": "2.0.2",
13
13
  "main": "lib/index.js",
14
14
  "scripts": {
15
15
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -40,7 +40,6 @@
40
40
  "cli.js",
41
41
  "index.js",
42
42
  "index.d.ts",
43
- "package-lock.json",
44
43
  "bloggify.js",
45
44
  "bloggify.json",
46
45
  "bloggify/"