-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2dad0d1
commit d9112c4
Showing
5 changed files
with
164 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
{ | ||
"profile_sidebar_fill_color": "F8FCF2", | ||
"profile_sidebar_border_color": "547980", | ||
"profile_background_tile": true, | ||
"name": "Ryan Sarver", | ||
"profile_image_url": "http://a0.twimg.com/profile_images/1777569006/image1327396628_normal.png", | ||
"created_at": "Mon Feb 26 18:05:55 +0000 2007", | ||
"location": "San Francisco, CA", | ||
"follow_request_sent": false, | ||
"profile_link_color": "547980", | ||
"is_translator": false, | ||
"id_str": "795649", | ||
"default_profile": false, | ||
"contributors_enabled": true, | ||
"favourites_count": 3162, | ||
"url": null, | ||
"profile_image_url_https": "https://si0.twimg.com/profile_images/1777569006/image1327396628_normal.png", | ||
"utc_offset": -28800, | ||
"id": 795649, | ||
"profile_use_background_image": true, | ||
"listed_count": 1586, | ||
"profile_text_color": "594F4F", | ||
"lang": "en", | ||
"followers_count": 276334, | ||
"protected": false, | ||
"notifications": true, | ||
"profile_background_image_url_https": "https://si0.twimg.com/profile_background_images/113854313/xa60e82408188860c483d73444d53e21.png", | ||
"profile_background_color": "45ADA8", | ||
"verified": false, | ||
"geo_enabled": true, | ||
"time_zone": "Pacific Time (US & Canada)", | ||
"description": "Director, Platform at Twitter. Detroit and Boston export. Foodie and over-the-hill hockey player. @devon's lesser half", | ||
"default_profile_image": false, | ||
"profile_background_image_url": "http://a0.twimg.com/profile_background_images/113854313/xa60e82408188860c483d73444d53e21.png", | ||
"status": { | ||
"coordinates": null, | ||
"favorited": false, | ||
"truncated": false, | ||
"created_at": "Sat Aug 25 19:33:11 +0000 2012", | ||
"retweeted_status": { | ||
"coordinates": null, | ||
"favorited": false, | ||
"truncated": false, | ||
"created_at": "Sat Aug 25 19:20:36 +0000 2012", | ||
"id_str": "239442171466493953", | ||
"entities": { | ||
"urls": [ | ||
{ | ||
"expanded_url": "http://nbcnews.to/NtkRTJ", | ||
"url": "http://t.co/f8ivBrVd", | ||
"indices": [ | ||
102, | ||
122 | ||
], | ||
"display_url": "nbcnews.to/NtkRTJ" | ||
} | ||
], | ||
"hashtags": [ | ||
|
||
], | ||
"user_mentions": [ | ||
|
||
] | ||
}, | ||
"in_reply_to_user_id_str": null, | ||
"contributors": null, | ||
"text": "Neil Armstrong has died at the age of 82 from complications from heart operations he had 3 weeks ago. http://t.co/f8ivBrVd", | ||
"retweet_count": 112, | ||
"in_reply_to_status_id_str": null, | ||
"id": 239442171466493953, | ||
"geo": null, | ||
"retweeted": false, | ||
"possibly_sensitive": false, | ||
"in_reply_to_user_id": null, | ||
"place": null, | ||
"in_reply_to_screen_name": null, | ||
"source": "web", | ||
"in_reply_to_status_id": null | ||
}, | ||
"id_str": "239445335481647105", | ||
"entities": { | ||
"urls": [ | ||
{ | ||
"expanded_url": "http://nbcnews.to/NtkRTJ", | ||
"url": "http://t.co/f8ivBrVd", | ||
"indices": [ | ||
115, | ||
135 | ||
], | ||
"display_url": "nbcnews.to/NtkRTJ" | ||
} | ||
], | ||
"hashtags": [ | ||
|
||
], | ||
"user_mentions": [ | ||
{ | ||
"name": "NBC News", | ||
"id_str": "14173315", | ||
"id": 14173315, | ||
"indices": [ | ||
3, | ||
11 | ||
], | ||
"screen_name": "NBCNews" | ||
} | ||
] | ||
}, | ||
"in_reply_to_user_id_str": null, | ||
"contributors": null, | ||
"text": "RT @NBCNews: Neil Armstrong has died at the age of 82 from complications from heart operations he had 3 weeks ago. http://t.co/f8ivBrVd", | ||
"retweet_count": 112, | ||
"in_reply_to_status_id_str": null, | ||
"id": 239445335481647105, | ||
"geo": null, | ||
"retweeted": false, | ||
"possibly_sensitive": false, | ||
"in_reply_to_user_id": null, | ||
"place": null, | ||
"in_reply_to_screen_name": null, | ||
"source": "<a href=\"http://twitter.com\" rel=\"nofollow\">Twitter for iPhone</a>", | ||
"in_reply_to_status_id": null | ||
}, | ||
"statuses_count": 13728, | ||
"friends_count": 1780, | ||
"following": true, | ||
"show_all_inline_media": true, | ||
"screen_name": "rsarver" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
var fs = require('fs') | ||
, parse = require('../lib/profile').parse; | ||
|
||
|
||
describe('profile.parse', function() { | ||
|
||
describe('example profile', function() { | ||
var profile; | ||
|
||
before(function(done) { | ||
fs.readFile('test/data/example.json', 'utf8', function(err, data) { | ||
if (err) { return done(err); } | ||
profile = parse(data); | ||
console.log(profile); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should parse profile', function() { | ||
expect(profile.id).to.equal('795649'); | ||
expect(profile.username).to.equal('rsarver'); | ||
expect(profile.displayName).to.equal('Ryan Sarver'); | ||
expect(profile.photos[0].value).to.equal('https://si0.twimg.com/profile_images/1777569006/image1327396628_normal.png'); | ||
}); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d9112c4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type of "profile.id" doesn't match the "JSON.parse(data).id". It will be a trouble to find items in MongoDB.
The 'profile.test.js' should have this test.
d9112c4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's normalized to a string to conform to the Portable Contacts schema.
Also, Twitter recommends using "id_str" to avoid potential problems regarding big integers: https://dev.twitter.com/docs/twitter-ids-json-and-snowflake.
If you want an integer, you'll need to parseInt(profile.id), but its more future-proof to use a string type in your DB schema.