ayadn 0.6.4 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +20 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +17 -0
  5. data/Gemfile +14 -0
  6. data/Guardfile +26 -0
  7. data/LICENSE.txt +22 -0
  8. data/MANUAL.md +946 -0
  9. data/README.md +26 -411
  10. data/Rakefile +6 -0
  11. data/ayadn.gemspec +39 -0
  12. data/bin/ayadn +3 -3
  13. data/lib/ayadn.rb +12 -25
  14. data/lib/ayadn/action.rb +1121 -0
  15. data/lib/ayadn/alias.rb +106 -0
  16. data/lib/ayadn/api.rb +312 -301
  17. data/lib/ayadn/app.rb +429 -365
  18. data/lib/ayadn/authorize.rb +127 -28
  19. data/lib/ayadn/blacklist.rb +116 -0
  20. data/lib/ayadn/cnx.rb +105 -0
  21. data/lib/ayadn/databases.rb +110 -0
  22. data/lib/ayadn/descriptions.rb +1043 -0
  23. data/lib/ayadn/endpoints.rb +220 -153
  24. data/lib/ayadn/errors.rb +37 -0
  25. data/lib/ayadn/extend.rb +4 -10
  26. data/lib/ayadn/fileops.rb +48 -0
  27. data/lib/ayadn/logs.rb +32 -0
  28. data/lib/ayadn/pinboard.rb +46 -35
  29. data/lib/ayadn/post.rb +229 -212
  30. data/lib/ayadn/scroll.rb +251 -0
  31. data/lib/ayadn/set.rb +377 -0
  32. data/lib/ayadn/settings.rb +195 -0
  33. data/lib/ayadn/status.rb +226 -165
  34. data/lib/ayadn/switch.rb +72 -0
  35. data/lib/ayadn/version.rb +4 -0
  36. data/lib/ayadn/view.rb +506 -269
  37. data/lib/ayadn/workers.rb +362 -0
  38. data/spec/helpers.rb +19 -0
  39. data/spec/mock/@ericd.json +160 -0
  40. data/spec/mock/@m.json +45 -0
  41. data/spec/mock/checkins.json +1856 -0
  42. data/spec/mock/fwr_@ayadn.json +1077 -0
  43. data/spec/mock/posted.json +1 -0
  44. data/spec/mock/stream.json +1 -0
  45. data/spec/spec_helper.rb +14 -0
  46. data/spec/unit/api_spec.rb +61 -0
  47. data/spec/unit/databases_spec.rb +5 -0
  48. data/spec/unit/descriptions_spec.rb +9 -0
  49. data/spec/unit/endpoints_spec.rb +35 -0
  50. data/spec/unit/post_spec.rb +136 -0
  51. data/spec/unit/status_spec.rb +9 -0
  52. data/spec/unit/view_spec.rb +119 -0
  53. data/spec/unit/workers_spec.rb +147 -0
  54. metadata +216 -40
  55. data/CHANGELOG.md +0 -250
  56. data/CONTRIBUTORS.md +0 -5
  57. data/LICENSE.md +0 -14
  58. data/lib/ayadn/adn_files.rb +0 -84
  59. data/lib/ayadn/client-http.rb +0 -226
  60. data/lib/ayadn/colors.rb +0 -62
  61. data/lib/ayadn/config.yml +0 -35
  62. data/lib/ayadn/debug.rb +0 -36
  63. data/lib/ayadn/files.rb +0 -184
  64. data/lib/ayadn/get-api.rb +0 -43
  65. data/lib/ayadn/help.rb +0 -152
  66. data/lib/ayadn/list.rb +0 -89
  67. data/lib/ayadn/main.rb +0 -542
  68. data/lib/ayadn/requires.rb +0 -12
  69. data/lib/ayadn/skip.rb +0 -27
  70. data/lib/ayadn/tools.rb +0 -208
  71. data/lib/ayadn/user-stream.rb +0 -91
  72. data/lib/ayadn/view-channels.rb +0 -120
  73. data/lib/ayadn/view-interactions.rb +0 -57
  74. data/lib/ayadn/view-object.rb +0 -195
  75. data/lib/experiments.rb +0 -109
@@ -0,0 +1 @@
1
+ {"meta":{"code":200},"data":{"created_at":"2014-03-31T11:35:43Z","num_stars":0,"num_replies":0,"source":{"link":"http://www.ayadn-app.net","name":"Ayadn","client_id":"hFsCGArAjgJkYBHTHbZnUvzTmL4vaLHL"},"text":"TEST","num_reposts":0,"canonical_url":"https://alpha.app.net/aya_tests/post/27170863","entities":{"mentions":[],"hashtags":[],"links":[]},"html":"<span itemscope=\"https://app.net/schemas/Post\">TEST</span>","machine_only":false,"user":{"username":"aya_tests","avatar_image":{"url":"https://d2rfichhc2fb9n.cloudfront.net/image/5/wtcnGHTyeGX988iObjlCFHdHEM17InMiOiJzMyIsImIiOiJhZG4tdXNlci1hc3NldHMiLCJrIjoiYXNzZXRzL3VzZXIvMDcvMDEvODAvMDcwMTgwMDAwMDAwMDAwMC5qcGciLCJvIjoiIn0","width":322,"is_default":false,"height":322},"description":{"text":"Experimental account for running tests.","html":"<span itemscope=\"https://app.net/schemas/Post\">Experimental account for running tests.</span>","entities":{"mentions":[],"hashtags":[],"links":[]}},"locale":"fr_FR","created_at":"2013-11-02T17:06:51Z","id":"185581","canonical_url":"https://alpha.app.net/aya_tests","cover_image":{"url":"https://d2rfichhc2fb9n.cloudfront.net/image/5/kZ-JRmTbmd3WVPswTJ8Nwxzkf917InMiOiJzMyIsImIiOiJ0YXBwLWFzc2V0cyIsImsiOiJpL1UvaS9ZL1VpWW5xRFNvTUtyTEhLNXA0OHN2NkxmTmRVMC5qcGciLCJvIjoiIn0","width":960,"is_default":true,"height":260},"timezone":"Europe/Berlin","counts":{"following":15,"posts":673,"followers":13,"stars":5},"type":"human","annotations":[{"type":"net.chimpli.media","value":{"image":"29487","audio":"29489","video":"29488"}}],"name":"@ericd's tests account"},"you_reposted":false,"id":"27170863","you_starred":false,"thread_id":"27170863","annotations":[{"type":"com.ayadn.user","value":{"username":"aya_tests","avatar_image":{"url":"https://d2rfichhc2fb9n.cloudfront.net/image/5/wtcnGHTyeGX988iObjlCFHdHEM17InMiOiJzMyIsImIiOiJhZG4tdXNlci1hc3NldHMiLCJrIjoiYXNzZXRzL3VzZXIvMDcvMDEvODAvMDcwMTgwMDAwMDAwMDAwMC5qcGciLCJvIjoiIn0","width":322,"is_default":false,"height":322},"id":"185581","name":"@ericd's tests account"}},{"type":"com.ayadn.client","value":{"url":"http://ayadn-app.net","version":"1.0.0-alpha4","author":{"username":"ericd","id":"69904","email":"eric@aya.io","name":"Eric Dejonckheere"}}}]}}
@@ -0,0 +1 @@
1
+ {"meta":{"marker":{"name":"unified","updated_at":"2014-02-14T16:40:11Z","version":"1yx4xvHf5QJ-KYSaSHKhXYhOVV4","last_read_id":"22660948","percentage":0,"id":"22660948"},"min_id":"23184500","code":200,"max_id":"23187443","more":true},"data":[{"annotations":[{"type":"net.app.core.crosspost","value":{"canonical_url":"http://500px.com/photos"}}],"num_stars":0,"num_reposts":0,"num_replies":0,"source":{"link":"http://ifttt.com","name":"IFTTT","client_id":"GzJVygE6vpLbabgBtEKzEKH8ASzS6mF3"},"text":"Jagulsan. by Julia Cory \u2122 http://feed.500px.com/~r/500px-best/~3/c2tMPEJVf6I/61517259 #photography","created_at":"2014-02-19T20:40:56Z","id":"23187443","canonical_url":"https://alpha.app.net/500px/post/23187443","entities":{"mentions":[],"hashtags":[{"name":"photography","len":12,"pos":86}],"links":[{"url":"http://feed.500px.com/~r/500px-best/~3/c2tMPEJVf6I/61517259","text":"http://feed.500px.com/~r/500px-best/~3/c2tMPEJVf6I/61517259","pos":26,"len":59}]},"machine_only":false,"user":{"you_muted":false,"you_can_subscribe":false,"is_following":false,"is_follower":true,"timezone":"America/Los_Angeles","you_follow":true,"counts":{"following":0,"posts":20184,"followers":74,"stars":0},"canonical_url":"https://alpha.app.net/500px","id":"101831","locale":"en_US","type":"feed","annotations":[{"type":"net.app.core.directory.blog","value":{"url":"http://500px.com/"}},{"type":"net.app.core.directory.twitter","value":{"username":"500px"}}],"username":"500px","avatar_image":{"url":"https://d2rfichhc2fb9n.cloudfront.net/image/5/XYripPkMJifmvIc76wF7gvUz8rd7InMiOiJzMyIsImIiOiJhZG4tdXNlci1hc3NldHMiLCJrIjoiYXNzZXRzL3VzZXIvMGEvZWYvMzAvMGFlZjMwMDAwMDAwMDAwMC5wbmciLCJvIjoiIn0","width":500,"is_default":false,"height":500},"description":{"text":"@500px is a premium photo sharing platform for aspiring and professional photographers.\r\nhttp://500px.com\r\n\r\n500px representative? reclaim.adn.username@gmail.com","entities":{"mentions":[{"is_leading":true,"pos":0,"id":"101831","len":6,"name":"500px"}],"hashtags":[],"links":[{"url":"http://500px.com","text":"http://500px.com","pos":89,"len":16}]}},"is_muted":false,"follows_you":false,"you_can_follow":true,"name":"500px Popular Photos","created_at":"2013-05-19T22:33:57Z","cover_image":{"url":"https://d2rfichhc2fb9n.cloudfront.net/image/5/j6fAtk0eWJfQdodVDf7UyqfgCnx7InMiOiJzMyIsImIiOiJhZG4tdXNlci1hc3NldHMiLCJrIjoiYXNzZXRzL3VzZXIvZWEvZWYvMzAvZWFlZjMwMDAwMDAwMDAwMC5wbmciLCJvIjoiIn0","width":1015,"is_default":false,"height":317},"you_blocked":false},"you_reposted":false,"you_starred":false,"thread_id":"23187443","pagination_id":"23187443"},{"annotations":[{"type":"net.app.core.oembed","value":{"provider_url":"https://app.net","thumbnail_large_url_immediate_expires":"2014-02-19T22:00:00Z","embeddable_url":"https://app.net/b/m6bk3","author_name":"@adn","height":206,"thumbnail_large_width":640,"thumbnail_large_url_immediate":"https://d36tc8clsz1tk5.cloudfront.net/adn-uf-01/AL/AY/4H/ALAY4HErDXrloVDqJfRsTipgPRqhZ-qlSirqlMVSczc?response-cache-control=public%2C%20max-age%3D7200%2C%20s-maxage%3D172800&response-content-disposition=inline%3B%20filename%2A%3DUTF-8%27%27Screen%2520Shot%25202014-02-19%2520at%252012.20.11%2520PM_image_thumb_960r.png&Expires=1392847200&Signature=WkL3JN6EbjQf2EumJE0kGftKuDHSf4GNigWl7BVbnXCt5LoiPPxd9KooynO1jbeOczGTEG5pnb-MSmiRAfVjPAPoRXtSHepJCax~wJzm6TH~8JADRsipzaPmrZ2t8HaGQxJQPNaR~WlyzgqzPDeCsormwMkxjMinNEYu4cyycAU_&Key-Pair-Id=APKAIWNGPWT6YVKFBWJA","thumbnail_url":"https://files.app.net/1/787952/aPty7DK2laMI_1Vxtzz-m2k_SptaDCPN200PM3qfNTLk9hOs7r8EDTNVvQ4qNq3yPboJuj-AypBjS9NTVLXkQAT3RFd1YX1g_XGOvhKaGypvWw3t7kWgOdz_BybgbDcgZejkoizZ6acY7coAfNRUq_QOCrYOEHmeeR3KhmUJYs_-gHTlzcw_5MbZogPtVBNOA/image_thumb_200s","thumbnail_width":200,"file_token_read":"aPty7DK2laMI_1Vxtzz-m2k_SptaDCPN200PM3qfNTLk9hOs7r8EDTNVvQ4qNq3yPboJuj-AypBjS9NTVLXkQAT3RFd1YX1g_XGOvhKaGypvWw3t7kWgOdz_BybgbDcgZejkoizZ6acY7coAfNRUq_QOCrYOEHmeeR3KhmUJYs_-gHTlzcw_5MbZogPtVBNOA","thumbnail_height":200,"thumbnail_url_immediate_expires":"2014-02-19T22:00:00Z","thumbnail_large_height":144,"url_immediate":"https://d36tc8clsz1tk5.cloudfront.net/adn-uf-01/mH/ae/xq/mHaexqiWb3ZyJd79aMTDECpgPRqhZ-qlSirqlMVSczc?response-cache-control=public%2C%20max-age%3D7200%2C%20s-maxage%3D172800&response-content-disposition=inline%3B%20filename%2A%3DUTF-8%27%27Screen%2520Shot%25202014-02-19%2520at%252012.20.11%2520PM.png&Expires=1392847200&Signature=n2olkP-2iwdBs~i6nel5oKh9x3NzVdQMoYieZptU35ViNF62YPVidM3UFqyBA-FbfkZ57aWbFZj~YYORKJh8x~es1nOzbsqoT0UYWY9hq0803LISQ0OkFzRa8a09PAhgX7LJvyWliD5BQ1riZdnLPKtZndfaYyfD9f2YHCg92to_&Key-Pair-Id=APKAIWNGPWT6YVKFBWJA","title":"Screen Shot 2014-02-19 at 12.20.11 PM.png","url":"https://files.app.net/1/787952/aPty7DK2laMI_1Vxtzz-m2k_SptaDCPN200PM3qfNTLk9hOs7r8EDTNVvQ4qNq3yPboJuj-AypBjS9NTVLXkQAT3RFd1YX1g_XGOvhKaGypvWw3t7kWgOdz_BybgbDcgZejkoizZ6acY7coAfNRUq_QOCrYOEHmeeR3KhmUJYs_-gHTlzcw_5MbZogPtVBNOA","thumbnail_large_url":"https://files.app.net/1/787952/aPty7DK2laMI_1Vxtzz-m2k_SptaDCPN200PM3qfNTLk9hOs7r8EDTNVvQ4qNq3yPboJuj-AypBjS9NTVLXkQAT3RFd1YX1g_XGOvhKaGypvWw3t7kWgOdz_BybgbDcgZejkoizZ6acY7coAfNRUq_QOCrYOEHmeeR3KhmUJYs_-gHTlzcw_5MbZogPtVBNOA/image_thumb_960r","url_immediate_expires":"2014-02-19T22:00:00Z","width":914,"version":"1.0","author_url":"https://alpha.app.net/adn","provider_name":"App.net","thumbnail_url_immediate":"https://d36tc8clsz1tk5.cloudfront.net/adn-uf-01/uX/j4/do/uXj4doYGR2ZN2KF251YRxSpgPRqhZ-qlSirqlMVSczc?response-cache-control=public%2C%20max-age%3D7200%2C%20s-maxage%3D172800&response-content-disposition=inline%3B%20filename%2A%3DUTF-8%27%27Screen%2520Shot%25202014-02-19%2520at%252012.20.11%2520PM_image_thumb_200s.png&Expires=1392847200&Signature=AKleKUadeQRrmSRk6Pa4JApDx3Rd9~a6sCKxEy2wYPyb-RdLhdTIqmK3UFZmtAYLQ46wy1uY977ttarh1A5yZa4YqeVNOje8vTmI-rsPP88Y530vavi2q1LVRq7H--uhw9~VW4HAkVC~Jc7dfJaL3LvmIZ3Thuhlw8l9Rf4iwTc_&Key-Pair-Id=APKAIWNGPWT6YVKFBWJA","type":"photo","file_id":"787952"}}],"num_stars":0,"num_reposts":0,"num_replies":0,"source":{"link":"https://alpha.app.net","name":"Alpha","client_id":"caYWDBvjwt2e9HWMm6qyKS6KcATHUkzQ"},"text":"Backer of the Day: Should Thinkful teach a class on Angular? https://app.net/b/m6bk3","created_at":"2014-02-19T20:39:34Z","id":"23187363","canonical_url":"https://alpha.app.net/adn/post/23187363","entities":{"mentions":[],"hashtags":[],"links":[{"url":"https://app.net/b/m6bk3","text":"https://app.net/b/m6bk3","pos":61,"len":23}]},"machine_only":false,"user":{"you_muted":false,"you_can_subscribe":true,"is_following":false,"is_follower":true,"timezone":"America/Los_Angeles","you_follow":true,"counts":{"following":15,"posts":815,"followers":132705,"stars":208},"canonical_url":"https://alpha.app.net/adn","id":"136","locale":"en_US","type":"human","annotations":[],"username":"adn","avatar_image":{"url":"https://d2rfichhc2fb9n.cloudfront.net/image/5/dh5rn5n1TSWMqjfd7vdp2gmAF9t7InMiOiJzMyIsImIiOiJhZG4tdXNlci1hc3NldHMiLCJrIjoiYXNzZXRzL3VzZXIvODIvNjAvNTAvODI2MDUwMDAwMDAwMDAwMC5wbmciLCJvIjoiIn0","width":200,"is_default":false,"height":200},"description":{"text":"The official App.net account keeping you updated on all the App.net news.\r\nFor support issues please direct comments at @adnsupport. You can also email support@app.net for help. #ADN","entities":{"mentions":[{"pos":120,"id":"133078","len":11,"name":"adnsupport"}],"hashtags":[{"name":"adn","len":4,"pos":178}],"links":[{"url":"http://App.net","text":"App.net","pos":13,"len":7},{"url":"http://App.net","text":"App.net","pos":60,"len":7}]}},"is_muted":false,"follows_you":false,"you_can_follow":true,"verified_domain":"app.net","name":"App.net Staff","created_at":"2012-08-05T00:13:46Z","cover_image":{"url":"https://d2rfichhc2fb9n.cloudfront.net/image/5/qG9iv3LI5FTxyZZAIvaTWMbvGuR7InMiOiJzMyIsImIiOiJhZG4tdXNlci1hc3NldHMiLCJrIjoiYXNzZXRzL3VzZXIvZjAvNmIvMzAvZjA2YjMwMDAwMDAwMDAwMC5wbmciLCJvIjoiIn0","width":961,"is_default":false,"height":300},"you_blocked":false},"you_reposted":false,"you_starred":false,"thread_id":"23187363","pagination_id":"23187363"},{"annotations":[{"type":"net.app.core.crosspost","value":{"canonical_url":"http://bit.ly/1cr16vM"}},{"type":"net.app.core.language","value":{"language":"en_US"}},{"type":"net.app.pourover.item.author","value":{"author":"Jon Brodkin"}},{"type":"net.app.pourover.item.tags","value":{"tags":["tom wheeler","Ministry of Innovation","Law & Disorder","FCC","municipal broadband"]}}],"num_stars":0,"num_reposts":0,"num_replies":0,"source":{"link":"https://adn-pourover.appspot.com/","name":"PourOver","client_id":"6kmFxf2JrEqmFRQ4WncLfN8WWx7FnUS8"},"text":"FCC thinks it can overturn state laws that restrict public broadband http://bit.ly/1cr16vM","created_at":"2014-02-19T20:27:19Z","id":"23186340","canonical_url":"https://alpha.app.net/arstechnica/post/23186340","entities":{"mentions":[],"hashtags":[],"links":[{"url":"http://bit.ly/1cr16vM","text":"http://bit.ly/1cr16vM","pos":69,"len":21}]},"machine_only":false,"user":{"you_muted":false,"you_can_subscribe":true,"is_following":false,"is_follower":true,"timezone":"America/Los_Angeles","you_follow":true,"counts":{"following":7,"posts":3293,"followers":9989,"stars":11},"canonical_url":"https://alpha.app.net/arstechnica","id":"24677","locale":"en_US","type":"feed","annotations":[],"username":"arstechnica","avatar_image":{"url":"https://d2rfichhc2fb9n.cloudfront.net/image/5/EcCQJiyB0bApLJgutwgRsfLZ_JF7InMiOiJzMyIsImIiOiJhZG4tdXNlci1hc3NldHMiLCJrIjoiYXNzZXRzL3VzZXIvOTMvZGUvMDAvOTNkZTAwMDAwMDAwMDAwMC5wbmciLCJvIjoiIn0","width":200,"is_default":false,"height":200},"description":{"text":"Original news and reviews, analysis of tech trends, and expert advice on the most fundamental aspects of tech and the many ways it's helping us enjoy our world. Account managed by Cesar Torres (@Urraca).","entities":{"mentions":[{"pos":194,"id":"27273","len":7,"name":"urraca"}],"hashtags":[],"links":[]}},"is_muted":false,"follows_you":false,"you_can_follow":true,"verified_domain":"arstechnica.com","name":"Ars Technica","created_at":"2012-10-09T17:45:36Z","cover_image":{"url":"https://d2rfichhc2fb9n.cloudfront.net/image/5/H0q2xCQVtM2ejV5dRg68Ec27Ta97InMiOiJzMyIsImIiOiJhZG4tdXNlci1hc3NldHMiLCJrIjoiYXNzZXRzL3VzZXIvMzAvZDMvNTAvMzBkMzUwMDAwMDAwMDAwMC5wbmciLCJvIjoiIn0","width":960,"is_default":false,"height":100},"you_blocked":false},"you_reposted":false,"you_starred":false,"thread_id":"23186340","pagination_id":"23186340"},{"annotations":[{"type":"net.app.core.crosspost","value":{"canonical_url":"http://500px.com/photos"}}],"num_stars":0,"num_reposts":0,"num_replies":0,"source":{"link":"http://ifttt.com","name":"IFTTT","client_id":"GzJVygE6vpLbabgBtEKzEKH8ASzS6mF3"},"text":"Arizona Wildflowers by Lisa Holloway http://feed.500px.com/~r/500px-best/~3/i4uhLN-4rd4/61484745 #photography","created_at":"2014-02-19T20:25:51Z","id":"23186223","canonical_url":"https://alpha.app.net/500px/post/23186223","entities":{"mentions":[],"hashtags":[{"name":"photography","len":12,"pos":97}],"links":[{"url":"http://feed.500px.com/~r/500px-best/~3/i4uhLN-4rd4/61484745","text":"http://feed.500px.com/~r/500px-best/~3/i4uhLN-4rd4/61484745","pos":37,"len":59}]},"machine_only":false,"user":{"you_muted":false,"you_can_subscribe":false,"is_following":false,"is_follower":true,"timezone":"America/Los_Angeles","you_follow":true,"counts":{"following":0,"posts":20184,"followers":74,"stars":0},"canonical_url":"https://alpha.app.net/500px","id":"101831","locale":"en_US","type":"feed","annotations":[{"type":"net.app.core.directory.blog","value":{"url":"http://500px.com/"}},{"type":"net.app.core.directory.twitter","value":{"username":"500px"}}],"username":"500px","avatar_image":{"url":"https://d2rfichhc2fb9n.cloudfront.net/image/5/XYripPkMJifmvIc76wF7gvUz8rd7InMiOiJzMyIsImIiOiJhZG4tdXNlci1hc3NldHMiLCJrIjoiYXNzZXRzL3VzZXIvMGEvZWYvMzAvMGFlZjMwMDAwMDAwMDAwMC5wbmciLCJvIjoiIn0","width":500,"is_default":false,"height":500},"description":{"text":"@500px is a premium photo sharing platform for aspiring and professional photographers.\r\nhttp://500px.com\r\n\r\n500px representative? reclaim.adn.username@gmail.com","entities":{"mentions":[{"is_leading":true,"pos":0,"id":"101831","len":6,"name":"500px"}],"hashtags":[],"links":[{"url":"http://500px.com","text":"http://500px.com","pos":89,"len":16}]}},"is_muted":false,"follows_you":false,"you_can_follow":true,"name":"500px Popular Photos","created_at":"2013-05-19T22:33:57Z","cover_image":{"url":"https://d2rfichhc2fb9n.cloudfront.net/image/5/j6fAtk0eWJfQdodVDf7UyqfgCnx7InMiOiJzMyIsImIiOiJhZG4tdXNlci1hc3NldHMiLCJrIjoiYXNzZXRzL3VzZXIvZWEvZWYvMzAvZWFlZjMwMDAwMDAwMDAwMC5wbmciLCJvIjoiIn0","width":1015,"is_default":false,"height":317},"you_blocked":false},"you_reposted":false,"you_starred":false,"thread_id":"23186223","pagination_id":"23186223"},{"annotations":[],"num_stars":0,"num_reposts":0,"num_replies":0,"source":{"link":"http://www.jonathonduerig.com/dev-lite","name":"Dev Lite","client_id":"Kk5tuTEZGQe3WnnhzdTX8KXAFgjjjpej"},"text":"Wikipedia-size maths proof too big for humans to check\nhttp://www.newscientist.com/article/dn25068-wikipediasize-maths-proof-too-big-for-humans-to-check.html#.UwTuA3gRq8M\n\u00bb Comments [news.ycombinator.com]","created_at":"2014-02-19T20:20:34Z","id":"23185830","canonical_url":"https://alpha.app.net/hackernews/post/23185830","entities":{"mentions":[],"hashtags":[],"links":[{"url":"http://www.newscientist.com/article/dn25068-wikipediasize-maths-proof-too-big-for-humans-to-check.html#.UwTuA3gRq8M","text":"http://www.newscientist.com/article/dn25068-wikipediasize-maths-proof-too-big-for-humans-to-check.html#.UwTuA3gRq8M","pos":55,"len":115},{"url":"http://news.ycombinator.com/item?id=7264886","text":"Comments","pos":173,"len":8,"amended_len":31}]},"machine_only":false,"user":{"you_muted":false,"you_can_subscribe":true,"is_following":false,"is_follower":true,"timezone":"America/New_York","you_follow":true,"counts":{"following":0,"posts":10357,"followers":132,"stars":0},"canonical_url":"https://alpha.app.net/hackernews","id":"59872","locale":"en_US","type":"feed","annotations":[],"username":"hackernews","avatar_image":{"url":"https://d2rfichhc2fb9n.cloudfront.net/image/5/fNgS7Ev5HXFC2jlTcccBxF63XLh7InMiOiJzMyIsImIiOiJhZG4tdXNlci1hc3NldHMiLCJrIjoiYXNzZXRzL3VzZXIvYTAvZWYvNTAvYTBlZjUwMDAwMDAwMDAwMC5wbmciLCJvIjoiIn0","width":200,"is_default":false,"height":200},"description":{"text":"Automated posting of Hacker News stories as soon as they reach 20 points. Includes duplicate-free, *unshortened* links to the stories AND to the Hacker News comments, which is often just as important or interesting as the link itself. Maintained by @eg.","entities":{"mentions":[{"pos":249,"id":"291","len":3,"name":"eg"}],"hashtags":[],"links":[]}},"is_muted":false,"follows_you":false,"you_can_follow":true,"name":"Hacker News","created_at":"2013-03-25T16:08:06Z","cover_image":{"url":"https://d2rfichhc2fb9n.cloudfront.net/image/5/cXI0IhM9jn_ahEdnKU3AqU-LJ1J7InMiOiJzMyIsImIiOiJhZG4tdXNlci1hc3NldHMiLCJrIjoiYXNzZXRzL3VzZXIvZTAvZWYvNTAvZTBlZjUwMDAwMDAwMDAwMC5wbmciLCJvIjoiIn0","width":960,"is_default":false,"height":223},"you_blocked":false},"you_reposted":false,"you_starred":false,"thread_id":"23185830","pagination_id":"23185830"},{"annotations":[{"type":"net.app.core.crosspost","value":{"canonical_url":"http://appadvice.com"}}],"num_stars":0,"num_reposts":0,"num_replies":0,"source":{"link":"http://ifttt.com","name":"IFTTT","client_id":"GzJVygE6vpLbabgBtEKzEKH8ASzS6mF3"},"text":"Enjoy Ghoulish Multiplayer Brawls In Fright Fight http://ift.tt/1d0TA7I","created_at":"2014-02-19T20:11:35Z","id":"23185112","canonical_url":"https://alpha.app.net/appadvice/post/23185112","entities":{"mentions":[],"hashtags":[],"links":[{"url":"http://ift.tt/1d0TA7I","text":"http://ift.tt/1d0TA7I","pos":50,"len":21}]},"machine_only":false,"user":{"you_muted":false,"you_can_subscribe":true,"is_following":false,"is_follower":true,"timezone":"America/Los_Angeles","you_follow":true,"counts":{"following":5,"posts":8303,"followers":4866,"stars":1},"canonical_url":"https://alpha.app.net/appadvice","id":"77968","locale":"en_US","type":"feed","annotations":[{"type":"net.app.core.directory.blog","value":{"url":"http://appadvice.com/"}},{"type":"net.app.core.directory.twitter","value":{"username":"AppAdvice"}}],"username":"appadvice","avatar_image":{"url":"https://d2rfichhc2fb9n.cloudfront.net/image/5/BhR-b9_YZL4XlvgQAXeDj150sfh7InMiOiJzMyIsImIiOiJhZG4tdXNlci1hc3NldHMiLCJrIjoiYXNzZXRzL3VzZXIvMWMvOTQvMzAvMWM5NDMwMDAwMDAwMDAwMC5qcGciLCJvIjoiIn0","width":100,"is_default":false,"height":100},"description":{"text":"\uf8ff The best source for iOS news, reviews, how-tos, and accessories.","entities":{"mentions":[],"hashtags":[],"links":[]}},"is_muted":false,"follows_you":false,"you_can_follow":true,"verified_domain":"appadvice.com","name":"AppAdvice.com","created_at":"2013-04-22T16:10:40Z","cover_image":{"url":"https://d2rfichhc2fb9n.cloudfront.net/image/5/RP0L6YdO5l-9BdauEpRDssD4mH97InMiOiJzMyIsImIiOiJhZG4tdXNlci1hc3NldHMiLCJrIjoiYXNzZXRzL3VzZXIvNmMvOTQvMzAvNmM5NDMwMDAwMDAwMDAwMC5qcGciLCJvIjoiIn0","width":960,"is_default":false,"height":199},"you_blocked":false},"you_reposted":false,"you_starred":false,"thread_id":"23185112","pagination_id":"23185112"},{"annotations":[{"type":"net.app.core.crosspost","value":{"canonical_url":"http://500px.com/photos"}}],"num_stars":0,"num_reposts":0,"num_replies":0,"source":{"link":"http://ifttt.com","name":"IFTTT","client_id":"GzJVygE6vpLbabgBtEKzEKH8ASzS6mF3"},"text":"Entre ciel et terre by Andre Villeneuve http://feed.500px.com/~r/500px-best/~3/hFi3AUnh_u8/61493427 #photography","created_at":"2014-02-19T20:11:14Z","id":"23185081","canonical_url":"https://alpha.app.net/500px/post/23185081","entities":{"mentions":[],"hashtags":[{"name":"photography","len":12,"pos":100}],"links":[{"url":"http://feed.500px.com/~r/500px-best/~3/hFi3AUnh_u8/61493427","text":"http://feed.500px.com/~r/500px-best/~3/hFi3AUnh_u8/61493427","pos":40,"len":59}]},"machine_only":false,"user":{"you_muted":false,"you_can_subscribe":false,"is_following":false,"is_follower":true,"timezone":"America/Los_Angeles","you_follow":true,"counts":{"following":0,"posts":20184,"followers":74,"stars":0},"canonical_url":"https://alpha.app.net/500px","id":"101831","locale":"en_US","type":"feed","annotations":[{"type":"net.app.core.directory.blog","value":{"url":"http://500px.com/"}},{"type":"net.app.core.directory.twitter","value":{"username":"500px"}}],"username":"500px","avatar_image":{"url":"https://d2rfichhc2fb9n.cloudfront.net/image/5/XYripPkMJifmvIc76wF7gvUz8rd7InMiOiJzMyIsImIiOiJhZG4tdXNlci1hc3NldHMiLCJrIjoiYXNzZXRzL3VzZXIvMGEvZWYvMzAvMGFlZjMwMDAwMDAwMDAwMC5wbmciLCJvIjoiIn0","width":500,"is_default":false,"height":500},"description":{"text":"@500px is a premium photo sharing platform for aspiring and professional photographers.\r\nhttp://500px.com\r\n\r\n500px representative? reclaim.adn.username@gmail.com","entities":{"mentions":[{"is_leading":true,"pos":0,"id":"101831","len":6,"name":"500px"}],"hashtags":[],"links":[{"url":"http://500px.com","text":"http://500px.com","pos":89,"len":16}]}},"is_muted":false,"follows_you":false,"you_can_follow":true,"name":"500px Popular Photos","created_at":"2013-05-19T22:33:57Z","cover_image":{"url":"https://d2rfichhc2fb9n.cloudfront.net/image/5/j6fAtk0eWJfQdodVDf7UyqfgCnx7InMiOiJzMyIsImIiOiJhZG4tdXNlci1hc3NldHMiLCJrIjoiYXNzZXRzL3VzZXIvZWEvZWYvMzAvZWFlZjMwMDAwMDAwMDAwMC5wbmciLCJvIjoiIn0","width":1015,"is_default":false,"height":317},"you_blocked":false},"you_reposted":false,"you_starred":false,"thread_id":"23185081","pagination_id":"23185081"},{"annotations":[],"num_stars":0,"num_reposts":0,"num_replies":0,"source":{"link":"http://www.jonathonduerig.com/dev-lite","name":"Dev Lite","client_id":"Kk5tuTEZGQe3WnnhzdTX8KXAFgjjjpej"},"text":"How Microryza Acquired the Domain Experiment.com\nhttp://priceonomics.com/how-microryza-acquired-the-domain-experimentcom/\n\u00bb Comments [news.ycombinator.com]","created_at":"2014-02-19T20:10:23Z","id":"23185033","canonical_url":"https://alpha.app.net/hackernews/post/23185033","entities":{"mentions":[],"hashtags":[],"links":[{"url":"http://Experiment.com","text":"Experiment.com","pos":34,"len":14},{"url":"http://priceonomics.com/how-microryza-acquired-the-domain-experimentcom/","text":"http://priceonomics.com/how-microryza-acquired-the-domain-experimentcom/","pos":49,"len":72},{"url":"http://news.ycombinator.com/item?id=7265540","text":"Comments","pos":124,"len":8,"amended_len":31}]},"machine_only":false,"user":{"you_muted":false,"you_can_subscribe":true,"is_following":false,"is_follower":true,"timezone":"America/New_York","you_follow":true,"counts":{"following":0,"posts":10357,"followers":132,"stars":0},"canonical_url":"https://alpha.app.net/hackernews","id":"59872","locale":"en_US","type":"feed","annotations":[],"username":"hackernews","avatar_image":{"url":"https://d2rfichhc2fb9n.cloudfront.net/image/5/fNgS7Ev5HXFC2jlTcccBxF63XLh7InMiOiJzMyIsImIiOiJhZG4tdXNlci1hc3NldHMiLCJrIjoiYXNzZXRzL3VzZXIvYTAvZWYvNTAvYTBlZjUwMDAwMDAwMDAwMC5wbmciLCJvIjoiIn0","width":200,"is_default":false,"height":200},"description":{"text":"Automated posting of Hacker News stories as soon as they reach 20 points. Includes duplicate-free, *unshortened* links to the stories AND to the Hacker News comments, which is often just as important or interesting as the link itself. Maintained by @eg.","entities":{"mentions":[{"pos":249,"id":"291","len":3,"name":"eg"}],"hashtags":[],"links":[]}},"is_muted":false,"follows_you":false,"you_can_follow":true,"name":"Hacker News","created_at":"2013-03-25T16:08:06Z","cover_image":{"url":"https://d2rfichhc2fb9n.cloudfront.net/image/5/cXI0IhM9jn_ahEdnKU3AqU-LJ1J7InMiOiJzMyIsImIiOiJhZG4tdXNlci1hc3NldHMiLCJrIjoiYXNzZXRzL3VzZXIvZTAvZWYvNTAvZTBlZjUwMDAwMDAwMDAwMC5wbmciLCJvIjoiIn0","width":960,"is_default":false,"height":223},"you_blocked":false},"you_reposted":false,"you_starred":false,"thread_id":"23185033","pagination_id":"23185033"},{"annotations":[{"type":"net.app.core.crosspost","value":{"canonical_url":"http://feeds.popsci.com/c/34567/f/632419/s/374c6496/sc/38/l/0L0Spopsci0N0Carticle0Cscience0Ccat0Ebites0Eare0Elinked0Edepression/story01.htm?utm_medium=App.net&utm_source=PourOver"}},{"type":"net.app.core.language","value":{"language":"en_US"}},{"type":"net.app.pourover.item.author","value":{"author":"Douglas Main"}}],"num_stars":0,"num_reposts":0,"num_replies":0,"source":{"link":"https://adn-pourover.appspot.com/","name":"PourOver","client_id":"6kmFxf2JrEqmFRQ4WncLfN8WWx7FnUS8"},"text":"Cat Bites Are Linked To Depression [feeds.popsci.com]","created_at":"2014-02-19T20:09:03Z","id":"23184932","canonical_url":"https://alpha.app.net/popsci/post/23184932","entities":{"mentions":[],"hashtags":[],"links":[{"url":"http://feeds.popsci.com/c/34567/f/632419/s/374c6496/sc/38/l/0L0Spopsci0N0Carticle0Cscience0Ccat0Ebites0Eare0Elinked0Edepression/story01.htm?utm_medium=App.net&utm_source=PourOver","text":"Cat Bites Are Linked To Depression","pos":0,"len":34,"amended_len":53}]},"machine_only":false,"user":{"username":"popsci","avatar_image":{"url":"https://d2rfichhc2fb9n.cloudfront.net/image/5/0BEAZbq-71fdcciz3VCsmHinKNt7InMiOiJzMyIsImIiOiJhZG4tdXNlci1hc3NldHMiLCJrIjoiYXNzZXRzL3VzZXIvMDAvNDAvNTAvMDA0MDUwMDAwMDAwMDAwMC5qcGciLCJvIjoiIn0","width":145,"is_default":false,"height":145},"name":"Popular Science","you_muted":false,"follows_you":false,"created_at":"2013-07-22T05:32:04Z","you_can_follow":true,"you_can_subscribe":true,"annotations":[],"canonical_url":"https://alpha.app.net/popsci","locale":"en_US","is_following":false,"is_follower":true,"you_follow":true,"is_muted":false,"timezone":"America/New_York","counts":{"following":2,"posts":1812,"followers":19,"stars":0},"you_blocked":false,"type":"feed","id":"133815","cover_image":{"url":"https://d2rfichhc2fb9n.cloudfront.net/image/5/kZ-JRmTbmd3WVPswTJ8Nwxzkf917InMiOiJzMyIsImIiOiJ0YXBwLWFzc2V0cyIsImsiOiJpL1UvaS9ZL1VpWW5xRFNvTUtyTEhLNXA0OHN2NkxmTmRVMC5qcGciLCJvIjoiIn0","width":960,"is_default":true,"height":260}},"you_reposted":false,"you_starred":false,"thread_id":"23184932","pagination_id":"23184932"},{"annotations":[{"type":"net.app.core.crosspost","value":{"canonical_url":"http://www.wired.com"}}],"num_stars":0,"num_reposts":0,"num_replies":0,"source":{"link":"http://ifttt.com","name":"IFTTT","client_id":"GzJVygE6vpLbabgBtEKzEKH8ASzS6mF3"},"text":"An F1 Run Captured in Insane 360-Degree Interactive Video http://ift.tt/1mtTrU9","created_at":"2014-02-19T20:04:43Z","id":"23184500","canonical_url":"https://alpha.app.net/wired/post/23184500","entities":{"mentions":[],"hashtags":[],"links":[{"url":"http://ift.tt/1mtTrU9","text":"http://ift.tt/1mtTrU9","pos":58,"len":21}]},"machine_only":false,"user":{"you_muted":false,"you_can_subscribe":true,"is_following":false,"is_follower":true,"timezone":"Europe/Berlin","you_follow":true,"counts":{"following":0,"posts":4324,"followers":8860,"stars":0},"canonical_url":"https://alpha.app.net/wired","id":"50718","locale":"en_US","type":"feed","annotations":[],"username":"wired","avatar_image":{"url":"https://d2rfichhc2fb9n.cloudfront.net/image/5/20WVRNYzEkFV5LPbmutpVipILu57InMiOiJzMyIsImIiOiJhZG4tdXNlci1hc3NldHMiLCJrIjoiYXNzZXRzL3VzZXIvNTUvMWEvNDAvNTUxYTQwMDAwMDAwMDAwMC5wbmciLCJvIjoiIn0","width":116,"is_default":false,"height":116},"description":{"text":"The front line in the war on mendacity","entities":{"mentions":[],"hashtags":[],"links":[]}},"is_muted":false,"follows_you":false,"you_can_follow":true,"verified_domain":"wired.com","name":"Wired","created_at":"2013-03-07T20:00:57Z","cover_image":{"url":"https://d2rfichhc2fb9n.cloudfront.net/image/5/1Pfjg_QPxpJsmpz0qm-LyZ2jqq57InMiOiJzMyIsImIiOiJhZG4tdXNlci1hc3NldHMiLCJrIjoiYXNzZXRzL3VzZXIvMDcvMWEvNDAvMDcxYTQwMDAwMDAwMDAwMC5qcGciLCJvIjoiIn0","width":2448,"is_default":false,"height":489},"you_blocked":false},"you_reposted":false,"you_starred":false,"thread_id":"23184500","pagination_id":"23184500"}]}
@@ -0,0 +1,14 @@
1
+ require 'ayadn'
2
+ require 'fakefs/spec_helpers'
3
+
4
+ RSpec.configure do |config|
5
+ config.treat_symbols_as_metadata_keys_with_true_values = true
6
+ config.run_all_when_everything_filtered = true
7
+ config.filter_run :focus
8
+ # Run specs in random order to surface order dependencies. If you find an
9
+ # order dependency and want to debug it, you can fix the order by providing
10
+ # the seed, which is printed after each run.
11
+ # --seed 1234
12
+ config.order = 'random'
13
+ #config.include FakeFS::SpecHelpers, fakefs: true
14
+ end
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ayadn::API do
4
+ before do
5
+ Ayadn::Settings.stub(:options).and_return({
6
+ counts: {
7
+ default: 50
8
+ },
9
+ timeline: {
10
+ directed: 1,
11
+ deleted: 0,
12
+ html: 0,
13
+ annotations: 1
14
+ }
15
+ })
16
+ end
17
+ describe ".build_query" do
18
+ it 'returns a URL with count=12' do
19
+ expect(Ayadn::API.build_query({count: 12})).to match /count=12/
20
+ end
21
+ it 'returns a URL with count=50' do
22
+ expect(Ayadn::API.build_query(Ayadn::Settings.options)).to match /count=50/
23
+ end
24
+ it 'returns a URL with count=50 (default)' do
25
+ expect(Ayadn::API.build_query({count: "I'm drunk"})).to match /count=50/
26
+ end
27
+ it 'returns a URL with directed=0' do
28
+ expect(Ayadn::API.build_query({directed: 0})).to match /directed=0/
29
+ end
30
+ it 'returns a URL with directed=0 (default)' do
31
+ expect(Ayadn::API.build_query({directed: "I'm drunk"})).to match /directed=1/
32
+ end
33
+ it 'returns a URL with directed=1' do
34
+ expect(Ayadn::API.build_query(Ayadn::Settings.options)).to match /directed=1/
35
+ end
36
+ it 'returns a URL with deleted=1' do
37
+ expect(Ayadn::API.build_query({deleted: 1})).to match /deleted=1/
38
+ end
39
+ it 'returns a URL with deleted=0' do
40
+ expect(Ayadn::API.build_query(Ayadn::Settings.options)).to match /deleted=0/
41
+ end
42
+ it 'returns a URL with html=1' do
43
+ expect(Ayadn::API.build_query({html: 1})).to match /html=1/
44
+ end
45
+ it 'returns a URL with html=0' do
46
+ expect(Ayadn::API.build_query(Ayadn::Settings.options)).to match /html=0/
47
+ end
48
+ it 'returns a URL with annotations=0' do
49
+ expect(Ayadn::API.build_query({annotations: 0})).to match /annotations=0/
50
+ end
51
+ it 'returns a URL with annotations=1' do
52
+ expect(Ayadn::API.build_query(Ayadn::Settings.options)).to match /annotations=1/
53
+ end
54
+ end
55
+ describe "#check_response_meta_code" do
56
+ it "returns original response if code is 200" do
57
+ res = {'meta' => { 'code' => 200 }}
58
+ expect(Ayadn::API.new.check_response_meta_code(res)).to eq res
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ayadn::Databases do
4
+
5
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ayadn::Descriptions do
4
+ describe ".unified" do
5
+ it 'returns a string' do
6
+ expect(Ayadn::Descriptions.unified).to include "Show your App.net timeline, aka the Unified Stream"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ayadn::Endpoints do
4
+ before do
5
+ Ayadn::Settings.stub(:user_token).and_return('XXX')
6
+ Ayadn::Settings.stub(:options).and_return({
7
+ counts: {
8
+ unified: 33,
9
+ default: 100
10
+ },
11
+ timeline: {
12
+ directed: 1,
13
+ deleted: 0,
14
+ html: 0,
15
+ annotations: 1
16
+ }
17
+ })
18
+ end
19
+ describe '#token_info' do
20
+ it "returns the Token url" do
21
+ expect(Ayadn::Endpoints.new.token_info).to eq 'https://alpha-api.app.net/stream/0/token/?access_token=XXX'
22
+ end
23
+ end
24
+ describe '#unified' do
25
+ it "returns the Unified url" do
26
+ expect(Ayadn::Endpoints.new.unified({})).to eq 'https://alpha-api.app.net/stream/0/posts/stream/unified?access_token=XXX&count=33&include_html=0&include_directed=1&include_deleted=0&include_annotations=1'
27
+ end
28
+ it "returns the Unified url" do
29
+ expect(Ayadn::Endpoints.new.unified({count: 66, html: 1})).to eq 'https://alpha-api.app.net/stream/0/posts/stream/unified?access_token=XXX&count=66&include_html=1&include_directed=1&include_deleted=0&include_annotations=1'
30
+ end
31
+ it "returns the Unified url" do
32
+ expect(Ayadn::Endpoints.new.unified({since_id: 336699})).to eq 'https://alpha-api.app.net/stream/0/posts/stream/unified?access_token=XXX&count=100&include_html=0&include_directed=1&include_deleted=0&include_annotations=1&since_id=336699'
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,136 @@
1
+ require 'spec_helper'
2
+ require 'helpers'
3
+ require 'json'
4
+ require 'io/console'
5
+
6
+ describe Ayadn::Post do
7
+ before do
8
+ Ayadn::Settings.stub(:options).and_return({
9
+ colors: {
10
+ hashtags: :cyan,
11
+ mentions: :red,
12
+ username: :green,
13
+ id: :blue,
14
+ name: :yellow,
15
+ source: :blue,
16
+ symbols: :green,
17
+ index: :blue,
18
+ date: :cyan,
19
+ link: :magenta
20
+ },
21
+ timeline: {
22
+ show_real_name: true,
23
+ show_date: true,
24
+ show_symbols: true,
25
+ show_source: true
26
+ },
27
+ formats: {table: {width: 75}},
28
+ counts: {
29
+ default: 33
30
+ }
31
+ })
32
+ Ayadn::Settings.stub(:config).and_return({
33
+ identity: {
34
+ username: 'test',
35
+ handle: '@test'
36
+ },
37
+ post_max_length: 256,
38
+ message_max_length: 2048,
39
+ version: Ayadn::VERSION
40
+ })
41
+ Ayadn::Settings.stub(:user_token).and_return('XXX')
42
+ Ayadn::Errors.stub(:warn).and_return("warned")
43
+ Ayadn::Logs.stub(:rec).and_return("logged")
44
+ end
45
+
46
+ let(:post) { Ayadn::Post.new }
47
+
48
+ describe "#post" do
49
+ it "should raise an error if args are empty" do
50
+ printed = capture_stdout do
51
+ post.post([])
52
+ end
53
+ expect(printed).to include "You should provide some text."
54
+ end
55
+ end
56
+
57
+ # let(:rest) {RestClient = double}
58
+ # let(:res) {response = double}
59
+ # let(:db) {Ayadn::Databases = double}
60
+
61
+ # describe "#post" do
62
+ # before do
63
+ # db.stub(:blacklist) {"x"}
64
+ # res.stub(:code) {200}
65
+ # rest.stub(:post) {File.read("spec/mock/posted.json")}
66
+ # end
67
+ # # Those 2 tests return a fake response, but this fake
68
+ # # response wouldn't be returned if the tests failed
69
+ # # I should intercept what goes into the fake RestClient
70
+ # # instead, but have no idea how to do it at the moment ¯\(ツ)/¯
71
+ # #
72
+ # # As their warning messages are pretty annoying, I disabled
73
+ # # them but you can uncomment to run the test
74
+ # it "sends a post" do
75
+ # a = post.post(["TEST"])
76
+ # printed = capture_stdout do
77
+ # Ayadn::View.new.show_posted(a)
78
+ # end
79
+ # expect(printed).to include '@aya_tests'
80
+ # expect(printed).to include 'TEST'
81
+ # end
82
+ # it "sends a message" do
83
+ # a = post.send_message(666, 'TEST')
84
+ # printed = capture_stdout do
85
+ # Ayadn::View.new.show_posted(a)
86
+ # end
87
+ # expect(printed).to include '@aya_tests'
88
+ # expect(printed).to include 'TEST'
89
+ # end
90
+ # end
91
+
92
+ describe "#reply" do
93
+ it "formats a reply" do
94
+ new_post = "Hey guys!"
95
+ replied_to = {1=>{:handle => "@test",:username => "test", :mentions => ["user1", "user2"]}}
96
+ post.reply(new_post, replied_to).should eq "@test Hey guys! @user1 @user2"
97
+ replied_to = {1=>{:handle => "@test",:username => "test", :mentions => ["user1", "test"]}}
98
+ post.reply(new_post, replied_to).should eq "@test Hey guys! @user1"
99
+ replied_to = {1=>{:handle => "@yo",:username => "test", :mentions => ["test", "lol"]}}
100
+ post.reply(new_post, replied_to).should eq "@yo Hey guys! @lol"
101
+ end
102
+ end
103
+
104
+ describe "#text_is_empty?" do
105
+ it "checks if empty" do
106
+ post.text_is_empty?(["allo"]).should be false
107
+ post.text_is_empty?([""]).should be true
108
+ post.text_is_empty?([]).should be true
109
+ end
110
+ end
111
+
112
+ describe "#markdown_extract" do
113
+ it "splits markdown" do
114
+ post.markdown_extract("[ayadn](http://ayadn-app.net)").should eq ["ayadn", "http://ayadn-app.net"]
115
+ end
116
+ end
117
+
118
+ describe "#get_markdown_text" do
119
+ it "extracts markdown text" do
120
+ post.get_markdown_text("[ayadn](http://ayadn-app.net)").should eq "ayadn"
121
+ end
122
+ end
123
+
124
+ describe "#check_post_length" do
125
+ it "checks normal post length" do
126
+ post.check_post_length(["allo", "wtf"]).should be nil #no error
127
+ end
128
+ end
129
+
130
+ describe "#check_message_length" do
131
+ it "checks normal message length" do
132
+ post.check_message_length(["allo", "wtf"]).should be nil #no error
133
+ end
134
+ end
135
+
136
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ayadn::Status do
4
+ describe ".done" do
5
+ it 'returns a green Done string' do
6
+ expect(Ayadn::Status.done).to eq("\e[32m\nDone.\n\e[0m")
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,119 @@
1
+ require 'spec_helper'
2
+ require 'helpers'
3
+ require 'json'
4
+ require 'io/console'
5
+
6
+ describe Ayadn::View do
7
+
8
+ before do
9
+ Ayadn::Settings.stub(:options).and_return({
10
+ colors: {
11
+ hashtags: :cyan,
12
+ mentions: :red,
13
+ username: :green,
14
+ id: :blue,
15
+ name: :yellow,
16
+ source: :blue,
17
+ symbols: :green,
18
+ index: :blue,
19
+ date: :cyan,
20
+ link: :magenta
21
+ },
22
+ timeline: {
23
+ show_real_name: true,
24
+ show_date: true,
25
+ show_symbols: true,
26
+ show_source: true
27
+ },
28
+ formats: {table: {width: 75}},
29
+ counts: {
30
+ default: 33
31
+ }
32
+ })
33
+ Ayadn::Settings.stub(:config).and_return({
34
+ identity: {
35
+ username: 'test'
36
+ }
37
+ })
38
+ Ayadn::Logs.stub(:rec).and_return("logged")
39
+ Ayadn::Databases.stub(:blacklist).and_return("blacklist")
40
+ Ayadn::Databases.stub(:save_indexed_posts).and_return("indexed")
41
+ end
42
+
43
+ describe "#settings" do
44
+ it 'outputs the settings' do
45
+ printed = capture_stdout do
46
+ Ayadn::View.new.show_settings
47
+ end
48
+ expect(printed).to include "Ayadn settings"
49
+ expect(printed).to include "colors"
50
+ end
51
+ end
52
+
53
+ let(:stream) { JSON.parse(File.read("spec/mock/stream.json")) }
54
+
55
+ describe "#show_posts" do
56
+ it 'outputs the stream' do
57
+ printed = capture_stdout do
58
+ Ayadn::View.new.show_posts(stream['data'], {})
59
+ end
60
+ expect(printed).to include "23184500"
61
+ expect(printed).to include "Backer of the Day"
62
+ end
63
+ end
64
+
65
+ describe "#show_simple_post" do
66
+ it 'outputs one post' do
67
+ printed = capture_stdout do
68
+ Ayadn::View.new.show_simple_post([stream['data'][0]], {})
69
+ end
70
+ expect(printed).to include "23187443"
71
+ expect(printed).to include "Julia Cory"
72
+ end
73
+ end
74
+
75
+ describe "#show_posts_with_index" do
76
+ it 'outputs the indexed stream' do
77
+ printed = capture_stdout do
78
+ Ayadn::View.new.show_posts_with_index(stream['data'], {})
79
+ end
80
+ expect(printed).to include "001"
81
+ expect(printed).to include "Backer of the Day"
82
+ end
83
+ end
84
+
85
+ let(:user_e) { JSON.parse(File.read("spec/mock/@ericd.json")) }
86
+
87
+ describe "#show_userinfos" do
88
+ it "outputs user info" do
89
+ printed = capture_stdout do
90
+ Ayadn::View.new.show_userinfos(user_e['data'], "")
91
+ end
92
+ expect(printed).to include "Sound engineer"
93
+ expect(printed).to include "aya.io"
94
+ expect(printed).to include "69904"
95
+ expect(printed).to include "Eric"
96
+ expect(printed).to include "2013"
97
+ expect(printed).to include "fr_FR"
98
+ expect(printed).to include "ritsz"
99
+ expect(printed).to include "1973"
100
+ end
101
+ end
102
+
103
+ let(:followers) { JSON.parse(File.read("spec/mock/fwr_@ayadn.json")) }
104
+
105
+ describe "#show_list_followers" do
106
+ it "outputs the list of followers" do
107
+ list = Ayadn::Workers.extract_users(followers[0])
108
+ printed = capture_stdout do
109
+ Ayadn::View.new.show_list_followers(list, '@ayadn')
110
+ end
111
+ expect(printed).to include "@ericd"
112
+ expect(printed).to include "Nicolas Maumont"
113
+ end
114
+ end
115
+
116
+
117
+
118
+
119
+ end
@@ -0,0 +1,147 @@
1
+ require 'spec_helper'
2
+ require 'helpers'
3
+ require 'json'
4
+ require 'io/console'
5
+
6
+ describe Ayadn::Workers do
7
+
8
+ before do
9
+ Ayadn::Settings.stub(:options).and_return({
10
+ colors: {
11
+ hashtags: :cyan,
12
+ mentions: :red,
13
+ username: :green
14
+ },
15
+ formats: {table: {width: 75}}
16
+ })
17
+ Ayadn::Logs.stub(:rec).and_return("logged")
18
+ Ayadn::Databases.stub(:blacklist).and_return("blacklist")
19
+ Ayadn::Databases.stub(:users).and_return("users")
20
+ end
21
+
22
+ let(:data) { JSON.parse(File.read("spec/mock/stream.json")) }
23
+ let(:checkins) { JSON.parse(File.read("spec/mock/checkins.json")) }
24
+
25
+ describe "#build_posts" do
26
+ it "builds posts hash from stream" do
27
+ posts = Ayadn::Workers.new.build_posts(data['data'])
28
+ expect(posts.length).to eq 10
29
+ expect(posts[23187363][:name]).to eq 'App.net Staff'
30
+ expect(posts[23184500][:username]).to eq 'wired'
31
+ expect(posts[23185033][:handle]).to eq '@hackernews'
32
+ expect(posts[23184500][:links]).to eq ['http://ift.tt/1mtTrU9']
33
+ expect(posts[23187443][:source_name]).to eq 'IFTTT'
34
+ expect(posts[23187443][:thread_id]).to eq '23187443'
35
+ expect(posts[23187443][:text]).to include 'Jagulsan. by Julia Cory'
36
+ expect(posts[23187443][:is_starred]).to be false
37
+ expect(posts[23187443][:is_repost]).to be false
38
+ expect(posts[23187443][:is_reply]).to be false
39
+ expect(posts[23187443][:directed_to]).to be false
40
+ expect(posts[23187443][:has_checkins]).to be false
41
+ expect(posts[23187443][:mentions]).to eq []
42
+ expect(posts[23187443][:checkins]).to be_empty
43
+ expect(posts[23187443].length).to eq 29
44
+ end
45
+ it "gets oembed link from checkins post" do
46
+ posts = Ayadn::Workers.new.build_posts(checkins['data'])
47
+ expect(posts[27101186][:links]).to eq ["https://photos.app.net/27101186/1"]
48
+ expect(posts[27080492][:links]).to eq ["http://sprintr.co/27080492"]
49
+ expect(posts[27073989][:links]).to eq ["http://pic.favd.net/27073989", "https://photos.app.net/27073989/1"]
50
+ end
51
+ end
52
+
53
+ describe "#extract_hashtags" do
54
+ it "extracts hashtags" do
55
+ tags = Ayadn::Workers.new.extract_hashtags(data['data'][0])
56
+ expect(tags).to eq ['photography']
57
+ end
58
+ end
59
+
60
+ describe "#extract_links" do
61
+ it "extracts links" do
62
+ links = Ayadn::Workers.new.extract_links(data['data'][0])
63
+ expect(links).to eq ['http://feed.500px.com/~r/500px-best/~3/c2tMPEJVf6I/61517259']
64
+ end
65
+ end
66
+
67
+ describe "#extract_checkins" do
68
+ it "extracts checkins" do
69
+ posts = Ayadn::Workers.new.build_posts(checkins['data'])
70
+ expect(posts.length).to eq 10
71
+ expect(posts[27101186][:has_checkins]).to be true
72
+ expect(posts[27101186][:checkins][:name]).to eq "Hobbs State Park"
73
+ expect(posts[27101186][:checkins][:address]).to eq "21392 E Highway 12"
74
+ expect(posts[27101186][:checkins][:address_extended]).to be nil
75
+ expect(posts[27101186][:checkins][:locality]).to eq "Rogers"
76
+ expect(posts[26947690][:has_checkins]).to be true
77
+ expect(posts[26947690][:checkins][:categories]).to eq "Landmarks"
78
+ expect(posts[26947690][:checkins][:country_code]).to eq "us"
79
+ expect(posts[26947690][:mentions]).to eq ["tuaw"]
80
+ end
81
+ end
82
+
83
+ let(:list) { {"007"=>["bond", "James Bond", true, true], "666"=>["mrtest", "Mr Test", false, false]} }
84
+
85
+ describe "#build_followers_list" do
86
+ it 'builds the followers table list' do
87
+ printed = capture_stdout do
88
+ puts Ayadn::Workers.new.build_followers_list(list, "@test")
89
+ end
90
+ expect(printed).to include "+----"
91
+ expect(printed).to include "@test"
92
+ expect(printed).to include "@bond"
93
+ expect(printed).to include "Mr Test"
94
+ end
95
+ end
96
+
97
+ describe "#build_followings_list" do
98
+ it 'builds the followings table list' do
99
+ printed = capture_stdout do
100
+ puts Ayadn::Workers.new.build_followings_list(list, "@test")
101
+ end
102
+ expect(printed).to include "+----"
103
+ expect(printed).to include "@test"
104
+ expect(printed).to include "@bond"
105
+ expect(printed).to include "Mr Test"
106
+ end
107
+ end
108
+
109
+ describe "#build_muted_list" do
110
+ it 'builds the muted table list' do
111
+ printed = capture_stdout do
112
+ puts Ayadn::Workers.new.build_muted_list(list)
113
+ end
114
+ expect(printed).to include "+----"
115
+ expect(printed).to include "@bond"
116
+ expect(printed).to include "Mr Test"
117
+ end
118
+ end
119
+
120
+ describe "#build_blocked_list" do
121
+ it 'builds the blocked table list' do
122
+ printed = capture_stdout do
123
+ puts Ayadn::Workers.new.build_blocked_list(list)
124
+ end
125
+ expect(printed).to include "+----"
126
+ expect(printed).to include "@bond"
127
+ expect(printed).to include "Mr Test"
128
+ end
129
+ end
130
+
131
+ describe ".add_arobase_if_missing" do
132
+ it 'adds @ to username' do
133
+ expect(Ayadn::Workers.add_arobase_if_missing(["user"])).to eq "@user"
134
+ end
135
+ it 'does nothing to @username' do
136
+ expect(Ayadn::Workers.add_arobase_if_missing(["@user"])).to eq "@user"
137
+ end
138
+ end
139
+
140
+ describe ".remove_arobase_if_present" do
141
+ it "removes @ from username" do
142
+ expect(Ayadn::Workers.remove_arobase_if_present("@user")).to eq "user"
143
+ expect(Ayadn::Workers.remove_arobase_if_present("user")).to eq "user"
144
+ end
145
+ end
146
+
147
+ end