ghost_rb 0.2.8 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ghost_rb.rb +1 -0
- data/lib/ghost_rb/client.rb +4 -0
- data/lib/ghost_rb/controllers/base_controller.rb +3 -4
- data/lib/ghost_rb/controllers/posts_controller.rb +1 -1
- data/lib/ghost_rb/controllers/tags_controller.rb +1 -1
- data/lib/ghost_rb/controllers/users_controller.rb +35 -0
- data/lib/ghost_rb/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e2d73a565e441bcdf7d5aa4d761ead90e0b4350271fc8932055f7d30a623c41
|
4
|
+
data.tar.gz: 624d470d9459fa9685ef373b60f44525501368cd245583709d267a7b7e576057
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d063f2ff8f22b79f8ffd60e81dcc1e47a096e325c0c9b4f8816c3814f2442f36ea55d8b52d14580800acdf3299e427b97e67c5e5e4dea55d0ceac122bb00d51
|
7
|
+
data.tar.gz: 49bab2cb4e144f61f75c1099bf2435fe8e07ae95e1cef59d49e0cf0e2da965024d000a679859dc0514f0616cd264195df2632794d3e6d4200159b22157953de4
|
data/lib/ghost_rb.rb
CHANGED
@@ -12,6 +12,7 @@ require 'ghost_rb/resources/tag'
|
|
12
12
|
require 'ghost_rb/controllers/base_controller'
|
13
13
|
require 'ghost_rb/controllers/posts_controller'
|
14
14
|
require 'ghost_rb/controllers/tags_controller'
|
15
|
+
require 'ghost_rb/controllers/users_controller'
|
15
16
|
|
16
17
|
# @author Rene Hernandez
|
17
18
|
# @since 0.1
|
data/lib/ghost_rb/client.rb
CHANGED
@@ -29,6 +29,10 @@ module GhostRb
|
|
29
29
|
Controllers::TagsController.new(self)
|
30
30
|
end
|
31
31
|
|
32
|
+
def users
|
33
|
+
Controllers::UsersController.new(self)
|
34
|
+
end
|
35
|
+
|
32
36
|
def get(endpoint, query)
|
33
37
|
response = @http.get(endpoint, query, {}, follow_redirect: true)
|
34
38
|
content = Support::HashWithIndifferentAccess.new(
|
@@ -11,9 +11,9 @@ module GhostRb
|
|
11
11
|
class BaseController
|
12
12
|
attr_reader :client, :params
|
13
13
|
|
14
|
-
def initialize(client)
|
14
|
+
def initialize(client, params = nil)
|
15
15
|
@client = client
|
16
|
-
@params = Support::HashWithIndifferentAccess.new
|
16
|
+
@params = Support::HashWithIndifferentAccess.new(params)
|
17
17
|
end
|
18
18
|
|
19
19
|
def all
|
@@ -45,8 +45,7 @@ module GhostRb
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def where(hash)
|
48
|
-
@params.merge
|
49
|
-
self
|
48
|
+
self.class.new(client, @params.merge(hash))
|
50
49
|
end
|
51
50
|
|
52
51
|
def find_by(kvp)
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GhostRb
|
4
|
+
module Controllers
|
5
|
+
|
6
|
+
# @author Rene Hernandez
|
7
|
+
# @since 0.3
|
8
|
+
class UsersController < BaseController
|
9
|
+
attr_reader :endpoint, :resource_klass
|
10
|
+
|
11
|
+
def initialize(client, params = nil)
|
12
|
+
super
|
13
|
+
@endpoint = 'users'
|
14
|
+
@resource_klass = Resources::User
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def raise_fetch_single_error(kvp, status, errors)
|
20
|
+
key = kvp.key?(:id) ? :id : :slug
|
21
|
+
message = "Unable to fetch user with #{key} = #{kvp[key]}"
|
22
|
+
raise Errors::RequestError.new(message,
|
23
|
+
status,
|
24
|
+
errors)
|
25
|
+
end
|
26
|
+
|
27
|
+
def raise_fetch_list_error(status, errors)
|
28
|
+
raise Errors::RequestError.new('Unable to fetch users',
|
29
|
+
status,
|
30
|
+
errors)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/ghost_rb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ghost_rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rene Hernandez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -145,6 +145,7 @@ files:
|
|
145
145
|
- lib/ghost_rb/controllers/base_controller.rb
|
146
146
|
- lib/ghost_rb/controllers/posts_controller.rb
|
147
147
|
- lib/ghost_rb/controllers/tags_controller.rb
|
148
|
+
- lib/ghost_rb/controllers/users_controller.rb
|
148
149
|
- lib/ghost_rb/errors.rb
|
149
150
|
- lib/ghost_rb/resources/base_resource.rb
|
150
151
|
- lib/ghost_rb/resources/post.rb
|
@@ -173,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
173
174
|
version: '0'
|
174
175
|
requirements: []
|
175
176
|
rubyforge_project:
|
176
|
-
rubygems_version: 2.7.
|
177
|
+
rubygems_version: 2.7.2
|
177
178
|
signing_key:
|
178
179
|
specification_version: 4
|
179
180
|
summary: GhostRb is a REST API client to interact with a given Ghost blog
|