wreddit 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +40 -9
- data/lib/wreddit/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7baadbacdc155586c41211dcc1d043832e7ef30c
|
4
|
+
data.tar.gz: 5c4fca23befb9658860583b47c1b4534e71062fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6dc0d37f1ab45cc6db10c272eaf8045d0e9669b046a8b4bb8b8f217c9eac646bd8e864df81f21c4c86872ba69d70d933be5b8b626df5ca4678c747adfd70829
|
7
|
+
data.tar.gz: 22868bab14fa9d22607dd4ae1b88841706f42eaea8874e3a454c28870bc3cd1996996693327f512914a92f0ca31e34ab64037526d879fe3d22c900a544ed1178
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@ WReddit: Reddit API wrapper for Ruby
|
|
5
5
|
A Reddit API Wrapper built in Ruby to play with my own Gem. It really only helps you grab subreddit information and user information.
|
6
6
|
|
7
7
|
##### What makes this special?
|
8
|
-
It's utilizing Reddit's free API resources. You can't make a lot of requests, but if you cache them using Redis, you could probably use this on a small toy app for yourself. It's a good way to quickly grab Reddit subreddits, comments, articles, and user profiles for your application.
|
8
|
+
It's utilizing Reddit's free API resources. That means you don't need any authorization to make requests. You can't make a lot of requests, but if you cache them using Redis, you could probably use this on a small toy app for yourself. It's a good way to quickly grab Reddit subreddits, comments, articles, and user profiles for your application.
|
9
9
|
|
10
10
|
## Install
|
11
11
|
add this to your Gemfile:
|
@@ -16,21 +16,52 @@ gem 'wreddit'
|
|
16
16
|
run ```bundle install``` in your app
|
17
17
|
|
18
18
|
## How to use
|
19
|
-
|
20
|
-
<b>User, Subreddit, Comments, Title, Parser</b>
|
21
|
-
<br>Yes, I realize that this would be inconvenient in a real-world application. This is simply my own project that taught me basic API wrapping skills. In the future, I will likely update everything including the lack of a Class to help OOP
|
19
|
+
As of v.1.0.2 we are using the Wreddit class.
|
22
20
|
###### Example of basic usage
|
23
21
|
```
|
24
|
-
|
22
|
+
wreddit = Wreddit.new #wreddit will be a standard variable for future examples
|
23
|
+
@reddit_user = wreddit.user('username').parse
|
25
24
|
```
|
26
|
-
user
|
27
|
-
|
25
|
+
<b>user</b> -> checks for a username on Reddit.com. If the user doesn't exist, their API handles that.<br>
|
26
|
+
<b>subreddit</b> -> checks for subreddit. If left empty, it'll default to /r/all.<br>
|
27
|
+
<b>parse</b> -> will parse the response in JSON format by default. If you'd like to parse XML or HTTP, you can do that like this:
|
28
28
|
```
|
29
|
-
...
|
29
|
+
...parse('xml') or parse('html') or parse('json')
|
30
30
|
```
|
31
31
|
|
32
32
|
###### Example of advanced usage
|
33
|
+
In this example, we'd be grabbing the subreddit and its comments in a specific thread
|
34
|
+
```
|
35
|
+
@reddit_comments = wreddit.subreddit('learnprogramming').comments('specific_article_id').parse
|
36
|
+
```
|
37
|
+
If you just quickly want to get the links, titles, or descriptions for articles/comments, I made some snappy methods.
|
38
|
+
You don't have to parse them. For now, it assumes that you want an array from the JSON object. Getting top links to articles in subreddit
|
39
|
+
```
|
40
|
+
@reddit_links = wreddit.subreddit('learnprogramming').links
|
41
|
+
```
|
42
|
+
Getting top titles of articles in subreddit
|
43
|
+
```
|
44
|
+
@reddit_titles = wreddit.subreddit('learnprogramming').titles
|
45
|
+
```
|
46
|
+
Getting top descriptions of articles in subreddit
|
47
|
+
```
|
48
|
+
@reddit_descriptions = wreddit.subreddit('learnprogramming').descriptions
|
49
|
+
```
|
50
|
+
|
51
|
+
##### Hazards
|
52
|
+
You cannot assume that any of these methods together will provide some response. Logically, some of these will render nil arrays. However, you'd be surprised by some things you can do. Like:
|
33
53
|
In this example, we'd be grabbing the subreddit, its comments in a specific thread
|
34
54
|
```
|
35
|
-
@
|
55
|
+
@stuff = wreddit.user('myusername').links #provides valid links to user submitted threads
|
56
|
+
|
57
|
+
@stuff = wreddit.user('myusername').descriptions #provides valid descriptions to commments
|
58
|
+
```
|
59
|
+
|
60
|
+
But you would <b>NOT</b> be able to write something like:
|
36
61
|
```
|
62
|
+
@invalid_response = wreddit.user('myusername').subreddit('learnprogramming').parse
|
63
|
+
```
|
64
|
+
|
65
|
+
The API will response with 404.
|
66
|
+
|
67
|
+
Email me with any questions at seanjhulse@gmail.com
|
data/lib/wreddit/version.rb
CHANGED