read_it 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +44 -0
- data/Rakefile +1 -0
- data/lib/read_it/configurable.rb +16 -0
- data/lib/read_it/http.rb +14 -0
- data/lib/read_it/post.rb +35 -0
- data/lib/read_it/sub.rb +18 -0
- data/lib/read_it/version.rb +3 -0
- data/lib/read_it.rb +21 -0
- data/read_it.gemspec +27 -0
- data/spec/fixtures/sub_latest.json +1 -0
- data/spec/read_it/post_spec.rb +66 -0
- data/spec/read_it/sub_spec.rb +30 -0
- data/spec/read_it_spec.rb +10 -0
- data/spec/spec_helper.rb +1 -0
- metadata +136 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 86a6b05c434cb40b2bd726fd285f65f908a53e54
|
4
|
+
data.tar.gz: c1c6a5468bf89663f317874a36b9b14fdfc4436f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d6942c447a15b90c7dd12ef328b51e0696e123764b0556deb90715d4e198145b29aff430684994a0de2bc4f682e83b1eaff6450a8741a636b246a08da9f4fffd
|
7
|
+
data.tar.gz: d60eb2aeef7f6f8cecc55436576998d679e5dba7f6b2ad0c590993749f2e5b3cb4b09725291f3ab89247ce884973fcb094010b26c41973250f340f021b5dcc66
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Adam Zaninovich
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# ReadIt
|
2
|
+
|
3
|
+
A very simple, read-only wrapper for the reddit api
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'read_it'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install read_it
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
gifs = ReadIt::Sub.new 'gifs' # => #<ReadIt::Sub:0x007f837c168530 @name="/r/gifs">
|
23
|
+
random_post = gifs.sample # => #<ReadIt::Post:0x007f837c08b770...>
|
24
|
+
random_post.title # => "It was the best gif I'd seen all day"
|
25
|
+
random_post.image? # => true
|
26
|
+
random_post.nsfw? # => false
|
27
|
+
random_post.url # => "http://i.imgur.com/D4LcGLt.gif"
|
28
|
+
```
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
ReadIt.sub('babyelephantgifs').recent.first.url # => "http://i.imgur.com/fogh8W4.gif"
|
32
|
+
```
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
ReadIt.sub('avocadosgonewild').sample.nsfw? # => true
|
36
|
+
```
|
37
|
+
|
38
|
+
## Contributing
|
39
|
+
|
40
|
+
1. Fork it ( http://github.com/adamzaninovich/read_it/fork )
|
41
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
42
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
43
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
44
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/read_it/http.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'faraday'
|
3
|
+
|
4
|
+
module ReadIt
|
5
|
+
module HTTP
|
6
|
+
def http
|
7
|
+
@http ||= Faraday::Connection.new 'http://www.reddit.com' do |faraday|
|
8
|
+
faraday.request :url_encoded
|
9
|
+
faraday.adapter ReadIt.adapter
|
10
|
+
faraday.headers["User-Agent"] = "ReadIt v#{ReadIt::VERSION}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/read_it/post.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
module ReadIt
|
2
|
+
class Post
|
3
|
+
def self.parse response
|
4
|
+
response = JSON.parse response.body
|
5
|
+
posts = response.fetch("data", {}).fetch "children", []
|
6
|
+
posts.map { |post| new post["data"] }
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize data
|
10
|
+
@data = data
|
11
|
+
end
|
12
|
+
|
13
|
+
def image?
|
14
|
+
image_types.include? url.split('.').last.downcase
|
15
|
+
end
|
16
|
+
|
17
|
+
def image
|
18
|
+
url if image?
|
19
|
+
end
|
20
|
+
|
21
|
+
def nsfw?
|
22
|
+
over_18
|
23
|
+
end
|
24
|
+
|
25
|
+
def method_missing name, *args, &block
|
26
|
+
@data[name.to_s]
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def image_types
|
32
|
+
%w(png jpg jpeg gif)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/read_it/sub.rb
ADDED
data/lib/read_it.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "read_it/version"
|
2
|
+
require "read_it/configurable"
|
3
|
+
require "read_it/http"
|
4
|
+
require "read_it/sub"
|
5
|
+
require "read_it/post"
|
6
|
+
|
7
|
+
module ReadIt
|
8
|
+
extend ReadIt::Configurable
|
9
|
+
extend ReadIt::HTTP
|
10
|
+
self.adapter = Faraday.default_adapter
|
11
|
+
|
12
|
+
def self.sub name
|
13
|
+
Sub.new name
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# Configuration Example
|
18
|
+
#
|
19
|
+
# ReadIt.configure do |config|
|
20
|
+
# config.adapter = <faraday adapter>
|
21
|
+
# end
|
data/read_it.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'read_it/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "read_it"
|
8
|
+
spec.version = ReadIt::VERSION
|
9
|
+
spec.authors = ["Adam Zaninovich"]
|
10
|
+
spec.email = ["adam.zaninovich@gmail.com"]
|
11
|
+
spec.summary = %q{A very simple wrapper for the reddit api}
|
12
|
+
spec.description = %q{A very simple wrapper for the reddit api}
|
13
|
+
spec.homepage = "https://github.com/adamzaninovich/read_it"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "faraday", ">= 0.8.7"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
spec.add_development_dependency "pry"
|
27
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
{"kind": "Listing", "data": {"modhash": "", "children": [{"kind": "t3", "data": {"domain": "i.imgur.com", "banned_by": null, "media_embed": {}, "subreddit": "pics", "selftext_html": null, "selftext": "", "likes": null, "secure_media": null, "link_flair_text": null, "id": "2eeab3", "gilded": 0, "secure_media_embed": {}, "clicked": false, "stickied": false, "author": "ddshroom", "media": null, "score": 1, "approved_by": null, "over_18": false, "hidden": false, "thumbnail": "http://b.thumbs.redditmedia.com/dOFc5_L4DDXiO7V_LrfpzxT5nWbyYMlwFBfGu9LgTHM.jpg", "subreddit_id": "t5_2qh0u", "edited": false, "link_flair_css_class": null, "author_flair_css_class": null, "downs": 0, "saved": false, "is_self": false, "permalink": "/r/pics/comments/2eeab3/leaves/", "name": "t3_2eeab3", "created": 1408859176.0, "url": "http://i.imgur.com/sQ7zH9R.jpg", "author_flair_text": null, "title": "Leaves", "created_utc": 1408830376.0, "ups": 1, "num_comments": 0, "visited": false, "num_reports": null, "distinguished": null}}, {"kind": "t3", "data": {"domain": "i.imgur.com", "banned_by": null, "media_embed": {}, "subreddit": "pics", "selftext_html": null, "selftext": "", "likes": null, "secure_media": null, "link_flair_text": null, "id": "2eea32", "gilded": 0, "secure_media_embed": {}, "clicked": false, "stickied": false, "author": "someguyfromcanada", "media": null, "score": 1, "approved_by": null, "over_18": false, "hidden": false, "thumbnail": "http://a.thumbs.redditmedia.com/s8bb6l0vy6WhECmoKH9Q2ExXEMzar9kl1WO0-25zKH4.jpg", "subreddit_id": "t5_2qh0u", "edited": false, "link_flair_css_class": null, "author_flair_css_class": null, "downs": 0, "saved": false, "is_self": false, "permalink": "/r/pics/comments/2eea32/hoverflies_mating_in_midair/", "name": "t3_2eea32", "created": 1408859012.0, "url": "http://i.imgur.com/PA5quc5.jpg", "author_flair_text": null, "title": "Hoverflies mating in midair.", "created_utc": 1408830212.0, "ups": 1, "num_comments": 0, "visited": false, "num_reports": null, "distinguished": null}}, {"kind": "t3", "data": {"domain": "i.imgur.com", "banned_by": null, "media_embed": {}, "subreddit": "pics", "selftext_html": null, "selftext": "", "likes": null, "secure_media": null, "link_flair_text": null, "id": "2eea1s", "gilded": 0, "secure_media_embed": {}, "clicked": false, "stickied": false, "author": "Pouringwaffles", "media": null, "score": 3, "approved_by": null, "over_18": false, "hidden": false, "thumbnail": "http://b.thumbs.redditmedia.com/Etc4yqMCiApH0acxYAD4P0tIKrQ2_5BKuXf8r3l_1uk.jpg", "subreddit_id": "t5_2qh0u", "edited": false, "link_flair_css_class": null, "author_flair_css_class": null, "downs": 0, "saved": false, "is_self": false, "permalink": "/r/pics/comments/2eea1s/popsicle_painted_lion/", "name": "t3_2eea1s", "created": 1408858983.0, "url": "http://i.imgur.com/D11bSfo.jpg", "author_flair_text": null, "title": "Popsicle painted lion.", "created_utc": 1408830183.0, "ups": 3, "num_comments": 1, "visited": false, "num_reports": null, "distinguished": null}}, {"kind": "t3", "data": {"domain": "i.imgur.com", "banned_by": null, "media_embed": {}, "subreddit": "pics", "selftext_html": null, "selftext": "", "likes": null, "secure_media": null, "link_flair_text": null, "id": "2eea0f", "gilded": 0, "secure_media_embed": {}, "clicked": false, "stickied": false, "author": "donttrustthename", "media": null, "score": 0, "approved_by": null, "over_18": false, "hidden": false, "thumbnail": "http://b.thumbs.redditmedia.com/PIDGUDb55fTmmbiL4EYVDNKipg_WLfzwAkg4Tw5hpEA.jpg", "subreddit_id": "t5_2qh0u", "edited": false, "link_flair_css_class": null, "author_flair_css_class": null, "downs": 0, "saved": false, "is_self": false, "permalink": "/r/pics/comments/2eea0f/murica/", "name": "t3_2eea0f", "created": 1408858961.0, "url": "http://i.imgur.com/naGynfA.jpg", "author_flair_text": null, "title": "'Murica", "created_utc": 1408830161.0, "ups": 0, "num_comments": 0, "visited": false, "num_reports": null, "distinguished": null}}, {"kind": "t3", "data": {"domain": "i.imgur.com", "banned_by": null, "media_embed": {}, "subreddit": "pics", "selftext_html": null, "selftext": "", "likes": null, "secure_media": null, "link_flair_text": null, "id": "2ee9y9", "gilded": 0, "secure_media_embed": {}, "clicked": false, "stickied": false, "author": "Eneity", "media": null, "score": 1, "approved_by": null, "over_18": false, "hidden": false, "thumbnail": "http://a.thumbs.redditmedia.com/1jmTTc5nTi6q0mXgipVbxlNhzJGqZMqbQ4S90npv8I0.jpg", "subreddit_id": "t5_2qh0u", "edited": false, "link_flair_css_class": null, "author_flair_css_class": null, "downs": 0, "saved": false, "is_self": false, "permalink": "/r/pics/comments/2ee9y9/i_tried_to_please_my_photo_teacher/", "name": "t3_2ee9y9", "created": 1408858913.0, "url": "http://i.imgur.com/K8WMCF9.jpg?1", "author_flair_text": null, "title": "I tried to please my photo teacher", "created_utc": 1408830113.0, "ups": 1, "num_comments": 0, "visited": false, "num_reports": null, "distinguished": null}}, {"kind": "t3", "data": {"domain": "voyager.jpl.nasa.gov", "banned_by": null, "media_embed": {}, "subreddit": "pics", "selftext_html": null, "selftext": "", "likes": null, "secure_media": null, "link_flair_text": null, "id": "2ee9ww", "gilded": 0, "secure_media_embed": {}, "clicked": false, "stickied": false, "author": "ArtsNCrass", "media": null, "score": 2, "approved_by": null, "over_18": false, "hidden": false, "thumbnail": "http://b.thumbs.redditmedia.com/TIS7PV9T9b31uJT0c4JaF1JiCPYQmRYemAf8d6mHkik.jpg", "subreddit_id": "t5_2qh0u", "edited": false, "link_flair_css_class": null, "author_flair_css_class": null, "downs": 0, "saved": false, "is_self": false, "permalink": "/r/pics/comments/2ee9ww/this_pic_was_sent_out_with_the_voyager_probes_as/", "name": "t3_2ee9ww", "created": 1408858885.0, "url": "http://voyager.jpl.nasa.gov/spacecraft/images/image082.gif", "author_flair_text": null, "title": "This pic was sent out with the Voyager probes as an example of how human beings eat and drink. If found, this is how aliens will think we drink.", "created_utc": 1408830085.0, "ups": 2, "num_comments": 2, "visited": false, "num_reports": null, "distinguished": null}}, {"kind": "t3", "data": {"domain": "i.imgur.com", "banned_by": null, "media_embed": {}, "subreddit": "pics", "selftext_html": null, "selftext": "", "likes": null, "secure_media": null, "link_flair_text": null, "id": "2ee9ug", "gilded": 0, "secure_media_embed": {}, "clicked": false, "stickied": false, "author": "penis113", "media": null, "score": 1, "approved_by": null, "over_18": false, "hidden": false, "thumbnail": "http://b.thumbs.redditmedia.com/P-PnLcWguBtnV8WyiSRNUzPmJpGEv46w3d81dSqyZ0g.jpg", "subreddit_id": "t5_2qh0u", "edited": false, "link_flair_css_class": null, "author_flair_css_class": null, "downs": 0, "saved": false, "is_self": false, "permalink": "/r/pics/comments/2ee9ug/nicely_done_sketch/", "name": "t3_2ee9ug", "created": 1408858840.0, "url": "http://i.imgur.com/jAcccTI.jpg", "author_flair_text": null, "title": "nicely done sketch", "created_utc": 1408830040.0, "ups": 1, "num_comments": 2, "visited": false, "num_reports": null, "distinguished": null}}, {"kind": "t3", "data": {"domain": "imgur.com", "banned_by": null, "media_embed": {"content": "<iframe class=\"embedly-embed\" src=\"//cdn.embedly.com/widgets/media.html?src=http%3A%2F%2Fimgur.com%2Fa%2FSHEVK%2Fembed&url=http%3A%2F%2Fimgur.com%2Fa%2FSHEVK&image=http%3A%2F%2Fi.imgur.com%2F8mPBWJU.jpg&key=2aa3c4d5f3de4f5b9120b660ad850dc9&type=text%2Fhtml&schema=imgur\" width=\"550\" height=\"550\" scrolling=\"no\" frameborder=\"0\" allowfullscreen></iframe>", "width": 550, "scrolling": false, "height": 550}, "subreddit": "pics", "selftext_html": null, "selftext": "", "likes": null, "secure_media": null, "link_flair_text": null, "id": "2ee9tb", "gilded": 0, "secure_media_embed": {}, "clicked": false, "stickied": false, "author": "sputnikv", "media": {"oembed": {"provider_url": "http://imgur.com", "description": "The most viral images on the internet, curated in real time by a dedicated community through commenting, voting and sharing.", "title": "imgur: the simple image sharer", "type": "rich", "thumbnail_width": 500, "height": 550, "width": 550, "html": "<iframe class=\"embedly-embed\" src=\"//cdn.embedly.com/widgets/media.html?src=http%3A%2F%2Fimgur.com%2Fa%2FSHEVK%2Fembed&url=http%3A%2F%2Fimgur.com%2Fa%2FSHEVK&image=http%3A%2F%2Fi.imgur.com%2F8mPBWJU.jpg&key=2aa3c4d5f3de4f5b9120b660ad850dc9&type=text%2Fhtml&schema=imgur\" width=\"550\" height=\"550\" scrolling=\"no\" frameborder=\"0\" allowfullscreen></iframe>", "version": "1.0", "provider_name": "Imgur", "thumbnail_url": "http://i.imgur.com/8mPBWJU.jpg", "thumbnail_height": 375}, "type": "imgur.com"}, "score": 0, "approved_by": null, "over_18": false, "hidden": false, "thumbnail": "http://b.thumbs.redditmedia.com/1NjjwfraE-Wq8IXo5tCPmT-l_82vtHwTcCHSIU-Nn9Q.jpg", "subreddit_id": "t5_2qh0u", "edited": false, "link_flair_css_class": null, "author_flair_css_class": null, "downs": 0, "saved": false, "is_self": false, "permalink": "/r/pics/comments/2ee9tb/it_didnt_take_long/", "name": "t3_2ee9tb", "created": 1408858820.0, "url": "http://imgur.com/a/SHEVK", "author_flair_text": null, "title": "It didn't take long", "created_utc": 1408830020.0, "ups": 0, "num_comments": 0, "visited": false, "num_reports": null, "distinguished": null}}, {"kind": "t3", "data": {"domain": "imgur.com", "banned_by": null, "media_embed": {"content": "<iframe class=\"embedly-embed\" src=\"//cdn.embedly.com/widgets/media.html?src=http%3A%2F%2Fimgur.com%2Fa%2FwWsg3%2Fembed&url=http%3A%2F%2Fimgur.com%2Fa%2FwWsg3&image=http%3A%2F%2Fi.imgur.com%2F7lY450q.jpg&key=2aa3c4d5f3de4f5b9120b660ad850dc9&type=text%2Fhtml&schema=imgur\" width=\"550\" height=\"550\" scrolling=\"no\" frameborder=\"0\" allowfullscreen></iframe>", "width": 550, "scrolling": false, "height": 550}, "subreddit": "pics", "selftext_html": null, "selftext": "", "likes": null, "secure_media": null, "link_flair_text": null, "id": "2ee9t6", "gilded": 0, "secure_media_embed": {}, "clicked": false, "stickied": false, "author": "holagatita", "media": {"type": "imgur.com", "oembed": {"provider_url": "http://imgur.com", "description": "The most viral images on the internet, curated in real time by a dedicated community through commenting, voting and sharing.", "title": "Baby Groot by Fred Berger - Imgur", "thumbnail_width": 475, "height": 550, "width": 550, "html": "<iframe class=\"embedly-embed\" src=\"//cdn.embedly.com/widgets/media.html?src=http%3A%2F%2Fimgur.com%2Fa%2FwWsg3%2Fembed&url=http%3A%2F%2Fimgur.com%2Fa%2FwWsg3&image=http%3A%2F%2Fi.imgur.com%2F7lY450q.jpg&key=2aa3c4d5f3de4f5b9120b660ad850dc9&type=text%2Fhtml&schema=imgur\" width=\"550\" height=\"550\" scrolling=\"no\" frameborder=\"0\" allowfullscreen></iframe>", "version": "1.0", "provider_name": "Imgur", "thumbnail_url": "http://i.imgur.com/7lY450q.jpg", "type": "rich", "thumbnail_height": 840}}, "score": 2, "approved_by": null, "over_18": false, "hidden": false, "thumbnail": "http://b.thumbs.redditmedia.com/wEKmeWL7MGjxGZQPhfgS3HCZFdKji_7xT1HbuUpyL8c.jpg", "subreddit_id": "t5_2qh0u", "edited": false, "link_flair_css_class": null, "author_flair_css_class": null, "downs": 0, "saved": false, "is_self": false, "permalink": "/r/pics/comments/2ee9t6/my_boyfriend_made_me_a_baby_groot_for_my_birthday/", "name": "t3_2ee9t6", "created": 1408858818.0, "url": "http://imgur.com/a/wWsg3", "author_flair_text": null, "title": "My boyfriend made me a baby Groot for my birthday!!", "created_utc": 1408830018.0, "ups": 2, "num_comments": 0, "visited": false, "num_reports": null, "distinguished": null}}, {"kind": "t3", "data": {"domain": "i.imgur.com", "banned_by": null, "media_embed": {}, "subreddit": "pics", "selftext_html": null, "selftext": "", "likes": null, "secure_media": null, "link_flair_text": null, "id": "2ee9ri", "gilded": 0, "secure_media_embed": {}, "clicked": false, "stickied": false, "author": "CalvinHobb3s", "media": null, "score": 1, "approved_by": null, "over_18": false, "hidden": false, "thumbnail": "http://b.thumbs.redditmedia.com/vSeki03g66fEOSrkmurTSLfuA19uV9UBeRtU8ENFkGQ.jpg", "subreddit_id": "t5_2qh0u", "edited": false, "link_flair_css_class": null, "author_flair_css_class": null, "downs": 0, "saved": false, "is_self": false, "permalink": "/r/pics/comments/2ee9ri/oh_my_god/", "name": "t3_2ee9ri", "created": 1408858783.0, "url": "http://i.imgur.com/BRomU7u.jpg", "author_flair_text": null, "title": "Oh my god...", "created_utc": 1408829983.0, "ups": 1, "num_comments": 0, "visited": false, "num_reports": null, "distinguished": null}}, {"kind": "t3", "data": {"domain": "i.imgur.com", "banned_by": null, "media_embed": {}, "subreddit": "pics", "selftext_html": null, "selftext": "", "likes": null, "secure_media": null, "link_flair_text": null, "id": "2ee9r4", "gilded": 0, "secure_media_embed": {}, "clicked": false, "stickied": false, "author": "A_Wooden_Spoon", "media": null, "score": 2, "approved_by": null, "over_18": false, "hidden": false, "thumbnail": "http://a.thumbs.redditmedia.com/6N2AzFUMSfzYBNcKpa6HKdmM_reCqSvQ_YxubL1Pa00.jpg", "subreddit_id": "t5_2qh0u", "edited": false, "link_flair_css_class": null, "author_flair_css_class": null, "downs": 0, "saved": false, "is_self": false, "permalink": "/r/pics/comments/2ee9r4/this_leaf_was_excited_to_see_me_today/", "name": "t3_2ee9r4", "created": 1408858777.0, "url": "http://i.imgur.com/ZcGxhf5.jpg", "author_flair_text": null, "title": "This leaf was excited to see me today.", "created_utc": 1408829977.0, "ups": 2, "num_comments": 0, "visited": false, "num_reports": null, "distinguished": null}}, {"kind": "t3", "data": {"domain": "imgur.com", "banned_by": null, "media_embed": {"content": "<iframe class=\"embedly-embed\" src=\"//cdn.embedly.com/widgets/media.html?src=http%3A%2F%2Fimgur.com%2Fa%2FxlRqo%2Fembed&url=http%3A%2F%2Fimgur.com%2Fa%2FxlRqo&image=http%3A%2F%2Fi.imgur.com%2FfnZjtJJ.jpg&key=2aa3c4d5f3de4f5b9120b660ad850dc9&type=text%2Fhtml&schema=imgur\" width=\"550\" height=\"550\" scrolling=\"no\" frameborder=\"0\" allowfullscreen></iframe>", "width": 550, "scrolling": false, "height": 550}, "subreddit": "pics", "selftext_html": null, "selftext": "", "likes": null, "secure_media": null, "link_flair_text": null, "id": "2ee9o7", "gilded": 0, "secure_media_embed": {}, "clicked": false, "stickied": false, "author": "eajmes", "media": {"type": "imgur.com", "oembed": {"provider_url": "http://imgur.com", "description": "The most viral images on the internet, curated in real time by a dedicated community through commenting, voting and sharing.", "title": "Jerame - Imgur", "thumbnail_width": 2448, "height": 550, "width": 550, "html": "<iframe class=\"embedly-embed\" src=\"//cdn.embedly.com/widgets/media.html?src=http%3A%2F%2Fimgur.com%2Fa%2FxlRqo%2Fembed&url=http%3A%2F%2Fimgur.com%2Fa%2FxlRqo&image=http%3A%2F%2Fi.imgur.com%2FfnZjtJJ.jpg&key=2aa3c4d5f3de4f5b9120b660ad850dc9&type=text%2Fhtml&schema=imgur\" width=\"550\" height=\"550\" scrolling=\"no\" frameborder=\"0\" allowfullscreen></iframe>", "version": "1.0", "provider_name": "Imgur", "thumbnail_url": "http://i.imgur.com/fnZjtJJ.jpg", "type": "rich", "thumbnail_height": 3264}}, "score": 1, "approved_by": null, "over_18": false, "hidden": false, "thumbnail": "http://b.thumbs.redditmedia.com/c9L8ZnPqii_5qOjocFCTq-U0rIphvVW-B9p_uU61E_U.jpg", "subreddit_id": "t5_2qh0u", "edited": false, "link_flair_css_class": null, "author_flair_css_class": null, "downs": 0, "saved": false, "is_self": false, "permalink": "/r/pics/comments/2ee9o7/can_anyone_take_in_a_cat_im_in_southeast_iowa_and/", "name": "t3_2ee9o7", "created": 1408858722.0, "url": "http://imgur.com/a/xlRqo", "author_flair_text": null, "title": "Can anyone take in a cat? I'm in southeast Iowa, and I just can't let her in the house.", "created_utc": 1408829922.0, "ups": 1, "num_comments": 0, "visited": false, "num_reports": null, "distinguished": null}}, {"kind": "t3", "data": {"domain": "i.imgur.com", "banned_by": null, "media_embed": {}, "subreddit": "pics", "selftext_html": null, "selftext": "", "likes": null, "secure_media": null, "link_flair_text": null, "id": "2ee9o5", "gilded": 0, "secure_media_embed": {}, "clicked": false, "stickied": false, "author": "willhaney", "media": null, "score": 0, "approved_by": null, "over_18": false, "hidden": false, "thumbnail": "http://b.thumbs.redditmedia.com/f1ob9MAaiSq0X4Bi7ULzwscXx-uTfSDzJ2UWecy3ulE.jpg", "subreddit_id": "t5_2qh0u", "edited": false, "link_flair_css_class": null, "author_flair_css_class": null, "downs": 0, "saved": false, "is_self": false, "permalink": "/r/pics/comments/2ee9o5/best_tiltshiftselective_focus_ive_seen_launch_of/", "name": "t3_2ee9o5", "created": 1408858721.0, "url": "http://i.imgur.com/1cZUwZT.jpg", "author_flair_text": null, "title": "Best tilt-shift(selective focus) I've seen. Launch of STS-2 Columbia from Launch Complex 39A at the Kennedy Space Center in Florida.", "created_utc": 1408829921.0, "ups": 0, "num_comments": 0, "visited": false, "num_reports": null, "distinguished": null}}, {"kind": "t3", "data": {"domain": "i.imgur.com", "banned_by": null, "media_embed": {}, "subreddit": "pics", "selftext_html": null, "selftext": "", "likes": null, "secure_media": null, "link_flair_text": null, "id": "2ee9jf", "gilded": 0, "secure_media_embed": {}, "clicked": false, "stickied": false, "author": "1337Scott", "media": null, "score": 1, "approved_by": null, "over_18": false, "hidden": false, "thumbnail": "http://a.thumbs.redditmedia.com/XiLHxemFkferzQfyB0M-jvPxHKaxDBEHtEVrREpyAQ8.jpg", "subreddit_id": "t5_2qh0u", "edited": false, "link_flair_css_class": null, "author_flair_css_class": null, "downs": 0, "saved": false, "is_self": false, "permalink": "/r/pics/comments/2ee9jf/help_me_out_guys_my_grandmother_bought_this_at_a/", "name": "t3_2ee9jf", "created": 1408858649.0, "url": "http://i.imgur.com/MTS7ss0.jpg", "author_flair_text": null, "title": "help me out guys! My grandmother bought this at a yard sale \"because he is handsome and looks important.\" I told her I'd find out who he is for her. anyone have any idea?", "created_utc": 1408829849.0, "ups": 1, "num_comments": 1, "visited": false, "num_reports": null, "distinguished": null}}, {"kind": "t3", "data": {"domain": "i.imgur.com", "banned_by": null, "media_embed": {}, "subreddit": "pics", "selftext_html": null, "selftext": "", "likes": null, "secure_media": null, "link_flair_text": null, "id": "2ee9e3", "gilded": 0, "secure_media_embed": {}, "clicked": false, "stickied": false, "author": "BaconBytecodeBarbell", "media": null, "score": 1, "approved_by": null, "over_18": false, "hidden": false, "thumbnail": "http://b.thumbs.redditmedia.com/hlQ-GNAI9KMk4gwxfaIw73PCmRy-aheG36aF7fivrjg.jpg", "subreddit_id": "t5_2qh0u", "edited": false, "link_flair_css_class": null, "author_flair_css_class": null, "downs": 0, "saved": false, "is_self": false, "permalink": "/r/pics/comments/2ee9e3/when_shooting_children_focus_and_shoot/", "name": "t3_2ee9e3", "created": 1408858548.0, "url": "http://i.imgur.com/TYdFrbF.jpg", "author_flair_text": null, "title": "When shooting children: focus, and shoot continuously.", "created_utc": 1408829748.0, "ups": 1, "num_comments": 0, "visited": false, "num_reports": null, "distinguished": null}}, {"kind": "t3", "data": {"domain": "i.imgur.com", "banned_by": null, "media_embed": {}, "subreddit": "pics", "selftext_html": null, "selftext": "", "likes": null, "secure_media": null, "link_flair_text": null, "id": "2ee96w", "gilded": 0, "secure_media_embed": {}, "clicked": false, "stickied": false, "author": "woohhaa", "media": null, "score": 1, "approved_by": null, "over_18": false, "hidden": false, "thumbnail": "http://b.thumbs.redditmedia.com/LJXsUQdjgO7SiVdy5hd4nldGu6P4MMGAHEwPOWv33mI.jpg", "subreddit_id": "t5_2qh0u", "edited": false, "link_flair_css_class": null, "author_flair_css_class": null, "downs": 0, "saved": false, "is_self": false, "permalink": "/r/pics/comments/2ee96w/cat_lady_alert/", "name": "t3_2ee96w", "created": 1408858398.0, "url": "http://i.imgur.com/nuxyzRB.png", "author_flair_text": null, "title": "Cat lady alert!", "created_utc": 1408829598.0, "ups": 1, "num_comments": 0, "visited": false, "num_reports": null, "distinguished": null}}, {"kind": "t3", "data": {"domain": "i.imgur.com", "banned_by": null, "media_embed": {}, "subreddit": "pics", "selftext_html": null, "selftext": "", "likes": null, "secure_media": null, "link_flair_text": null, "id": "2ee925", "gilded": 0, "secure_media_embed": {}, "clicked": false, "stickied": false, "author": "carrerascott", "media": null, "score": 2, "approved_by": null, "over_18": false, "hidden": false, "thumbnail": "http://b.thumbs.redditmedia.com/g3-4UyXmimGqyNIiS_k4HNHoLv0tVQZdd-36qEdQpMY.jpg", "subreddit_id": "t5_2qh0u", "edited": false, "link_flair_css_class": null, "author_flair_css_class": null, "downs": 0, "saved": false, "is_self": false, "permalink": "/r/pics/comments/2ee925/did_we_find_the_car_of_a_past_present_or_future/", "name": "t3_2ee925", "created": 1408858295.0, "url": "http://i.imgur.com/XPuaDBU.png", "author_flair_text": null, "title": "Did we find the car of a past, present or future serial killer??", "created_utc": 1408829495.0, "ups": 2, "num_comments": 1, "visited": false, "num_reports": null, "distinguished": null}}, {"kind": "t3", "data": {"domain": "i.imgur.com", "banned_by": null, "media_embed": {}, "subreddit": "pics", "selftext_html": null, "selftext": "", "likes": null, "secure_media": null, "link_flair_text": null, "id": "2ee8zo", "gilded": 0, "secure_media_embed": {}, "clicked": false, "stickied": false, "author": "Tcampanis", "media": null, "score": 0, "approved_by": null, "over_18": false, "hidden": false, "thumbnail": "http://b.thumbs.redditmedia.com/EwydlrjprNQ-IgSKnEIeSucjDZ9361mrd_nOICpkwso.jpg", "subreddit_id": "t5_2qh0u", "edited": false, "link_flair_css_class": null, "author_flair_css_class": null, "downs": 0, "saved": false, "is_self": false, "permalink": "/r/pics/comments/2ee8zo/cloud_rainbow_storm_thing/", "name": "t3_2ee8zo", "created": 1408858248.0, "url": "http://i.imgur.com/SpBUucv.jpg", "author_flair_text": null, "title": "cloud rainbow storm thing", "created_utc": 1408829448.0, "ups": 0, "num_comments": 1, "visited": false, "num_reports": null, "distinguished": null}}, {"kind": "t3", "data": {"domain": "lh4.googleusercontent.com", "banned_by": null, "media_embed": {}, "subreddit": "pics", "selftext_html": null, "selftext": "", "likes": null, "secure_media": null, "link_flair_text": null, "id": "2ee8wp", "gilded": 0, "secure_media_embed": {}, "clicked": false, "stickied": false, "author": "evol0monky6666", "media": null, "score": 1, "approved_by": null, "over_18": false, "hidden": false, "thumbnail": "http://b.thumbs.redditmedia.com/rVrkZnZ8vyf_9nuXi-EpvxBgv45yAlT6YC_pL9ZzP4g.jpg", "subreddit_id": "t5_2qh0u", "edited": false, "link_flair_css_class": null, "author_flair_css_class": null, "downs": 0, "saved": false, "is_self": false, "permalink": "/r/pics/comments/2ee8wp/advertise/", "name": "t3_2ee8wp", "created": 1408858204.0, "url": "https://lh4.googleusercontent.com/-GhPMy_0RmtQ/U_kGpkVpaUI/AAAAAAAAAk0/rcN5wb2ujpE/w557-h788-no/Poster.jpg", "author_flair_text": null, "title": "Advertise", "created_utc": 1408829404.0, "ups": 1, "num_comments": 0, "visited": false, "num_reports": null, "distinguished": null}}, {"kind": "t3", "data": {"domain": "i.imgur.com", "banned_by": null, "media_embed": {}, "subreddit": "pics", "selftext_html": null, "selftext": "", "likes": null, "secure_media": null, "link_flair_text": null, "id": "2ee8vs", "gilded": 0, "secure_media_embed": {}, "clicked": false, "stickied": false, "author": "carrerascott", "media": null, "score": 1, "approved_by": null, "over_18": false, "hidden": false, "thumbnail": "http://b.thumbs.redditmedia.com/eybearpMI_NUp1Wb_gKrZn8QUeaSEjGYg9-oRh9wNeU.jpg", "subreddit_id": "t5_2qh0u", "edited": false, "link_flair_css_class": null, "author_flair_css_class": null, "downs": 0, "saved": false, "is_self": false, "permalink": "/r/pics/comments/2ee8vs/we_got_bored_our_great_dane_got_colored/", "name": "t3_2ee8vs", "created": 1408858183.0, "url": "http://i.imgur.com/nmuDZiw.png", "author_flair_text": null, "title": "We got bored. Our Great Dane got colored.", "created_utc": 1408829383.0, "ups": 1, "num_comments": 3, "visited": false, "num_reports": null, "distinguished": null}}, {"kind": "t3", "data": {"domain": "i.imgur.com", "banned_by": null, "media_embed": {}, "subreddit": "pics", "selftext_html": null, "selftext": "", "likes": null, "secure_media": null, "link_flair_text": null, "id": "2ee8tj", "gilded": 0, "secure_media_embed": {}, "clicked": false, "stickied": false, "author": "youthminister", "media": null, "score": 5, "approved_by": null, "over_18": false, "hidden": false, "thumbnail": "http://b.thumbs.redditmedia.com/gVJiWoMH283s8W8Qh9vLYvJ-mTQfAvA045fsJqYg-xc.jpg", "subreddit_id": "t5_2qh0u", "edited": false, "link_flair_css_class": null, "author_flair_css_class": null, "downs": 0, "saved": false, "is_self": false, "permalink": "/r/pics/comments/2ee8tj/i_blame_you_reddit/", "name": "t3_2ee8tj", "created": 1408858141.0, "url": "http://i.imgur.com/JCbpHgw.jpg", "author_flair_text": null, "title": "I blame you Reddit", "created_utc": 1408829341.0, "ups": 5, "num_comments": 0, "visited": false, "num_reports": null, "distinguished": null}}, {"kind": "t3", "data": {"domain": "imgur.com", "banned_by": null, "media_embed": {}, "subreddit": "pics", "selftext_html": null, "selftext": "", "likes": null, "secure_media": null, "link_flair_text": null, "id": "2ee8pu", "gilded": 0, "secure_media_embed": {}, "clicked": false, "stickied": false, "author": "johnjensen0904", "media": null, "score": 3, "approved_by": null, "over_18": false, "hidden": false, "thumbnail": "http://a.thumbs.redditmedia.com/rbkWoXazcu7Y4v0I5-ORrF5nq78shtcUqte0TArmvK8.jpg", "subreddit_id": "t5_2qh0u", "edited": false, "link_flair_css_class": null, "author_flair_css_class": null, "downs": 0, "saved": false, "is_self": false, "permalink": "/r/pics/comments/2ee8pu/clever_advertising_at_my_local_grocery_store/", "name": "t3_2ee8pu", "created": 1408858076.0, "url": "http://imgur.com/3ZitEWM.jpg", "author_flair_text": null, "title": "Clever advertising at my local grocery store.", "created_utc": 1408829276.0, "ups": 3, "num_comments": 0, "visited": false, "num_reports": null, "distinguished": null}}, {"kind": "t3", "data": {"domain": "i.imgur.com", "banned_by": null, "media_embed": {}, "subreddit": "pics", "selftext_html": null, "selftext": "", "likes": null, "secure_media": null, "link_flair_text": null, "id": "2ee8p9", "gilded": 0, "secure_media_embed": {}, "clicked": false, "stickied": false, "author": "Bobcat_El_Borracho", "media": null, "score": 2, "approved_by": null, "over_18": false, "hidden": false, "thumbnail": "http://b.thumbs.redditmedia.com/aDari2K3AT9a0v_SNtRRH9qPEy2nZ34KRamUU4FzCec.jpg", "subreddit_id": "t5_2qh0u", "edited": false, "link_flair_css_class": null, "author_flair_css_class": null, "downs": 0, "saved": false, "is_self": false, "permalink": "/r/pics/comments/2ee8p9/close_together_but_miles_apart_scottish/", "name": "t3_2ee8p9", "created": 1408858062.0, "url": "http://i.imgur.com/edgVD0u.jpg", "author_flair_text": null, "title": "Close together but miles apart (Scottish Independence Referendum)", "created_utc": 1408829262.0, "ups": 2, "num_comments": 0, "visited": false, "num_reports": null, "distinguished": null}}, {"kind": "t3", "data": {"domain": "i.imgur.com", "banned_by": null, "media_embed": {}, "subreddit": "pics", "selftext_html": null, "selftext": "", "likes": null, "secure_media": null, "link_flair_text": null, "id": "2ee8oa", "gilded": 0, "secure_media_embed": {}, "clicked": false, "stickied": false, "author": "LoogaBeluga", "media": null, "score": 2, "approved_by": null, "over_18": false, "hidden": false, "thumbnail": "http://b.thumbs.redditmedia.com/GEHTczTJFRexdkxUQZJkTS7qvMBx94svcTJxzjM9Mws.jpg", "subreddit_id": "t5_2qh0u", "edited": false, "link_flair_css_class": null, "author_flair_css_class": null, "downs": 0, "saved": false, "is_self": false, "permalink": "/r/pics/comments/2ee8oa/how_to_upsell_your_garage_sale/", "name": "t3_2ee8oa", "created": 1408858047.0, "url": "http://i.imgur.com/YMM0l6X.jpg", "author_flair_text": null, "title": "How to upsell your garage sale", "created_utc": 1408829247.0, "ups": 2, "num_comments": 2, "visited": false, "num_reports": null, "distinguished": null}}, {"kind": "t3", "data": {"domain": "imgur.com", "banned_by": null, "media_embed": {}, "subreddit": "pics", "selftext_html": null, "selftext": "", "likes": null, "secure_media": null, "link_flair_text": null, "id": "2ee8ms", "gilded": 0, "secure_media_embed": {}, "clicked": false, "stickied": false, "author": "aerotech86", "media": null, "score": 0, "approved_by": null, "over_18": false, "hidden": false, "thumbnail": "http://b.thumbs.redditmedia.com/abq9z6rWD4gNKJB12oB9oekJYX0Vdf4Gl62ld1-K-ro.jpg", "subreddit_id": "t5_2qh0u", "edited": false, "link_flair_css_class": null, "author_flair_css_class": null, "downs": 0, "saved": false, "is_self": false, "permalink": "/r/pics/comments/2ee8ms/low_cloud_during_a_morning_storm/", "name": "t3_2ee8ms", "created": 1408858022.0, "url": "http://imgur.com/MwSBgxT.jpg", "author_flair_text": null, "title": "Low cloud during a morning storm", "created_utc": 1408829222.0, "ups": 0, "num_comments": 0, "visited": false, "num_reports": null, "distinguished": null}}], "after": "t3_2ee8ms", "before": null}}
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'pry'
|
3
|
+
|
4
|
+
module ReadIt
|
5
|
+
describe Post do
|
6
|
+
subject(:post) { Post.new({}) }
|
7
|
+
let(:json) { File.read 'spec/fixtures/sub_latest.json' }
|
8
|
+
let(:response) { double body: json }
|
9
|
+
describe '.parse' do
|
10
|
+
it 'parses the json response' do
|
11
|
+
expect(JSON).to receive(:parse).with(json).and_return({})
|
12
|
+
described_class.parse response
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'pulls the posts out of the data' do
|
16
|
+
posts = described_class.parse(response)
|
17
|
+
expect(posts.first).to be_a Post
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#image?' do
|
22
|
+
context 'when the url ends in an image extension' do
|
23
|
+
before { allow(post).to receive(:url).and_return 'url.png' }
|
24
|
+
it { is_expected.to be_image }
|
25
|
+
end
|
26
|
+
context 'when the url does not end in an image extension' do
|
27
|
+
before { allow(post).to receive(:url).and_return 'url.txt' }
|
28
|
+
it { is_expected.to_not be_image }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#image' do
|
33
|
+
context 'when the url ends in an image extension' do
|
34
|
+
before { allow(post).to receive(:url).and_return 'url.png' }
|
35
|
+
it 'has an image' do
|
36
|
+
expect(post.image).to_not be_nil
|
37
|
+
end
|
38
|
+
end
|
39
|
+
context 'when the url does not end in an image extension' do
|
40
|
+
before { allow(post).to receive(:url).and_return 'url.txt' }
|
41
|
+
it 'does not have an image' do
|
42
|
+
expect(post.image).to be_nil
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#nsfw?' do
|
48
|
+
context 'when the post is marked over_18' do
|
49
|
+
before { allow(post).to receive(:over_18).and_return true }
|
50
|
+
it { is_expected.to be_nsfw }
|
51
|
+
end
|
52
|
+
context 'when the post is not marked over_18' do
|
53
|
+
before { allow(post).to receive(:over_18).and_return false }
|
54
|
+
it { is_expected.to_not be_nsfw }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '#method_missing' do
|
59
|
+
it 'access the data hash' do
|
60
|
+
post = Post.new 'some_key' => 'some_value'
|
61
|
+
expect(post.some_key).to eq 'some_value'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module ReadIt
|
4
|
+
describe Sub do
|
5
|
+
let(:response) { double body: '{}' }
|
6
|
+
let(:name) { 'subname' }
|
7
|
+
subject(:sub) { described_class.new name }
|
8
|
+
describe '#initialize' do
|
9
|
+
it 'saves the sub name' do
|
10
|
+
expect(sub.name).to eq "/r/#{name}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#recent' do
|
15
|
+
it 'hits the recent endpoint on the reddit API' do
|
16
|
+
expect(ReadIt.http).to receive(:get).with("/r/#{name}/new.json").and_return response
|
17
|
+
sub.recent
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#sample' do
|
22
|
+
it 'calls sample on recent' do
|
23
|
+
recent = []
|
24
|
+
allow(sub).to receive(:recent).and_return recent
|
25
|
+
expect(recent).to receive(:sample)
|
26
|
+
sub.sample
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'read_it'
|
metadata
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: read_it
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Adam Zaninovich
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.8.7
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.8.7
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.5'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: A very simple wrapper for the reddit api
|
84
|
+
email:
|
85
|
+
- adam.zaninovich@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- Gemfile
|
92
|
+
- LICENSE.txt
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- lib/read_it.rb
|
96
|
+
- lib/read_it/configurable.rb
|
97
|
+
- lib/read_it/http.rb
|
98
|
+
- lib/read_it/post.rb
|
99
|
+
- lib/read_it/sub.rb
|
100
|
+
- lib/read_it/version.rb
|
101
|
+
- read_it.gemspec
|
102
|
+
- spec/fixtures/sub_latest.json
|
103
|
+
- spec/read_it/post_spec.rb
|
104
|
+
- spec/read_it/sub_spec.rb
|
105
|
+
- spec/read_it_spec.rb
|
106
|
+
- spec/spec_helper.rb
|
107
|
+
homepage: https://github.com/adamzaninovich/read_it
|
108
|
+
licenses:
|
109
|
+
- MIT
|
110
|
+
metadata: {}
|
111
|
+
post_install_message:
|
112
|
+
rdoc_options: []
|
113
|
+
require_paths:
|
114
|
+
- lib
|
115
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
requirements: []
|
126
|
+
rubyforge_project:
|
127
|
+
rubygems_version: 2.2.2
|
128
|
+
signing_key:
|
129
|
+
specification_version: 4
|
130
|
+
summary: A very simple wrapper for the reddit api
|
131
|
+
test_files:
|
132
|
+
- spec/fixtures/sub_latest.json
|
133
|
+
- spec/read_it/post_spec.rb
|
134
|
+
- spec/read_it/sub_spec.rb
|
135
|
+
- spec/read_it_spec.rb
|
136
|
+
- spec/spec_helper.rb
|