devrant 0.0.3 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b09d803f04ef0c5eafeb8fd121a8d2576f869828
4
- data.tar.gz: c9714660e2855e4f5a88db7b04268a5589450874
3
+ metadata.gz: 1ac9fa760f49b06fed3e7b66392b4d534f198ca3
4
+ data.tar.gz: 0f470c1484c7667ab01130a5e19d387acee4a530
5
5
  SHA512:
6
- metadata.gz: 22bcbbff65d5075d683ccf82a0cb606c38940a3c946dce3e59755f00aa4538f08bc5f81d77340bf1c3f7487c9da70966199d22ede57d085f9bf900e1b8c2b3bc
7
- data.tar.gz: 596be6cad8543e251f2cb4273ecf458badd7f2c9f4ae25745242936fe143f0cab9c1ba3e7c519d7177e960f3383b3144f4c47c9c2d751166e18173f5a669cb90
6
+ metadata.gz: aee605184737fe636fb77f0f7b05a99149dc4474cfd0b322d8825079233fc2487e05593ef00594600a336a21d23c6e930503bd0a0ef882bbbe8b4b877c544963
7
+ data.tar.gz: 75b098d6dcaf114b60c1b5371d712223a4f088626330d1a187f400f79734e3b2ce80abe6b61afd4bb50f42b78409983b6225a33620d3ab57618c2be00b75ff00
data/.gitignore CHANGED
@@ -10,4 +10,5 @@
10
10
 
11
11
  # rspec failure tracking
12
12
  .rspec_status
13
- .gem
13
+ *.gem
14
+ *.swp
data/README.md CHANGED
@@ -85,6 +85,66 @@ devRant = Devrant::Api.new
85
85
  devRant.rants.get_rants({limit: 10, sort: 'algo', skip: 5})
86
86
  ```
87
87
 
88
+ **Getting the Weekly Rants**
89
+
90
+ Find all rants that are featured weekly
91
+
92
+ ```ruby
93
+ require 'devrant'
94
+
95
+ devRant = Devrant::Api.new
96
+
97
+ devRant.rants.weekly
98
+ ```
99
+
100
+ **Getting Story Rants**
101
+
102
+ Get rants that are categorized as a 'story'
103
+
104
+ ```ruby
105
+ require 'devrant'
106
+
107
+ devRant = Devrant::Api.new
108
+
109
+ devRant.rants.stories
110
+ ```
111
+
112
+ **Getting Collabs**
113
+
114
+ Fetches all collabs
115
+
116
+ ```ruby
117
+ require 'devrant'
118
+
119
+ devRant = Devrant::Api.new
120
+
121
+ devRant.rants.collabs
122
+ ```
123
+
124
+ **Searching Rants**
125
+
126
+ Search rants by a specific search term
127
+
128
+ ```ruby
129
+ require 'devrant'
130
+
131
+ devRant = Devrant::Api.new
132
+
133
+ devRant.rants.search('your search term here')
134
+ ```
135
+
136
+ **Getting a Random Rant**
137
+
138
+ Returns a random rant with at least 15++
139
+
140
+ ```ruby
141
+ require 'devrant'
142
+
143
+ devRant = Devrant::Api.new
144
+
145
+ devRant.rants.random
146
+ ```
147
+
88
148
  ### Users
89
149
 
90
150
  **Getting User by ID:**
@@ -97,6 +157,16 @@ devRant = Devrant::Api.new
97
157
  devRant.users.get_user(1234)
98
158
  ```
99
159
 
160
+ **Getting User ID from Username**
161
+
162
+ ```ruby
163
+ require 'devrant'
164
+
165
+ devRant = Devrant::Api.new
166
+
167
+ devRant.users.get_user_id('RuntimeError')
168
+ ```
169
+
100
170
  ## Development
101
171
 
102
172
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -114,3 +184,18 @@ The gem is available as open source under the terms of the [MIT License](http://
114
184
  ## Code of Conduct
115
185
 
116
186
  Everyone interacting in the Devrant project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/alexdovzhanyn/devrant/blob/master/CODE_OF_CONDUCT.md).
187
+
188
+ # Endpoints to Implement
189
+
190
+ - ~~/devrant/rants~~
191
+ - ~~/devrant/rants/:id~~
192
+ - ~~/users/get-user-id~~
193
+ - ~~/users/:id~~
194
+ - /comments
195
+ - /vote
196
+ - ~~/devrant/search~~
197
+ - ~~/devrant/weekly-rants~~
198
+ - ~~/devrant/story-rants~~
199
+ - ~~/devrant/collabs~~
200
+ - ~~/devrant/rants/surprise~~
201
+ - /users/auth-token
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
-
3
+ require "pry"
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
6
  task :default => :spec
@@ -10,9 +10,9 @@ task :console do
10
10
  end
11
11
 
12
12
  task :export do
13
- # exec 'rake'
14
- # exec 'gem build devrant.gemspec'
15
-
16
- new_gem = Dir.glob("/pkg/*").max_by {|f| File.mtime(f)}
17
- puts new_gem
13
+ system 'rake'
14
+ system 'gem build devrant.gemspec'
15
+ new_gem = Dir.glob("*").max_by {|f| File.mtime(f)}
16
+
17
+ system "gem push #{new_gem}"
18
18
  end
@@ -12,4 +12,8 @@ module Devrant
12
12
  JSON.parse(json.body, object_class: OpenStruct)
13
13
  end
14
14
 
15
+ def extend_request_query(options)
16
+ { query: self.class.default_options[:query].merge(options) }
17
+ end
18
+
15
19
  end
@@ -7,6 +7,22 @@ module Devrant
7
7
  structuralize(self.class.get('/devrant/rants')).rants
8
8
  end
9
9
 
10
+ def weekly
11
+ structuralize(self.class.get('/devrant/weekly-rants')).rants
12
+ end
13
+
14
+ def random
15
+ structuralize(self.class.get('/devrant/rants/surprise')).rant
16
+ end
17
+
18
+ def stories
19
+ structuralize(self.class.get('/devrant/story-rants')).rants
20
+ end
21
+
22
+ def collabs
23
+ structuralize(self.class.get('/devrant/collabs')).rants
24
+ end
25
+
10
26
  def get_rant(id)
11
27
  rant = structuralize(self.class.get("/devrant/rants/#{id}")).rant
12
28
 
@@ -16,11 +32,11 @@ module Devrant
16
32
  end
17
33
 
18
34
  def get_rants(params={})
19
- options = {
20
- query: self.class.default_options[:query].merge(params)
21
- }
35
+ structuralize(self.class.get('/devrant/rants', extend_request_query(params))).rants
36
+ end
22
37
 
23
- rants = structuralize(self.class.get("/devrant/rants", options)).rants
38
+ def search(term)
39
+ structuralize(self.class.get('/devrant/search', extend_request_query({term: term}))).results
24
40
  end
25
41
 
26
42
  end
@@ -3,12 +3,20 @@ module Devrant
3
3
  include HTTParty
4
4
  include Devrant
5
5
 
6
- def get_user(id)
6
+ def get_user_by_id(id)
7
7
  user = structuralize(self.class.get("/users/#{id}")).profile
8
8
 
9
9
  return user unless user.nil?
10
10
 
11
11
  raise ArgumentError.new("No user found for id #{id}")
12
12
  end
13
+
14
+ def get_user_id(username)
15
+ id = structuralize(self.class.get('/get-user-id', extend_request_query({username: username}))).user_id
16
+
17
+ return id unless id.nil?
18
+
19
+ raise ArgumentError.new("No user called #{username} found.")
20
+ end
13
21
  end
14
22
  end
@@ -1,3 +1,3 @@
1
1
  module Devrant
2
- VERSION = "0.0.3"
2
+ VERSION = "0.9.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devrant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Dovzhanyn
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-07 00:00:00.000000000 Z
11
+ date: 2017-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -112,7 +112,6 @@ files:
112
112
  - Rakefile
113
113
  - bin/console
114
114
  - bin/setup
115
- - devrant-0.0.2.gem
116
115
  - devrant.gemspec
117
116
  - lib/devrant.rb
118
117
  - lib/devrant/api.rb
Binary file