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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d5f307354e4239342014fc3d91d325b869504e702e2e506e7e40d7fd6f56725
4
- data.tar.gz: 7722fc672c577326429f6c766518c35ca6850fef3f57201b00351f35510c3e2b
3
+ metadata.gz: 6e2d73a565e441bcdf7d5aa4d761ead90e0b4350271fc8932055f7d30a623c41
4
+ data.tar.gz: 624d470d9459fa9685ef373b60f44525501368cd245583709d267a7b7e576057
5
5
  SHA512:
6
- metadata.gz: e0339d828c055a1dba2c4d3e236bb3cf9f8d5644a1d80feb8696c8b89ea9012545626337597876023170815f271b35b65d406f519c01c702818dbe39e8454c64
7
- data.tar.gz: b4d696a61887d7226e79b89dea2017cffa8ea2ce6014ec41a80f9385f36cabc155c3401bac65f9146ae93e1278246f0d18d084f8009d79a2e746a957a45bc01a
6
+ metadata.gz: 2d063f2ff8f22b79f8ffd60e81dcc1e47a096e325c0c9b4f8816c3814f2442f36ea55d8b52d14580800acdf3299e427b97e67c5e5e4dea55d0ceac122bb00d51
7
+ data.tar.gz: 49bab2cb4e144f61f75c1099bf2435fe8e07ae95e1cef59d49e0cf0e2da965024d000a679859dc0514f0616cd264195df2632794d3e6d4200159b22157953de4
@@ -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
@@ -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!(hash)
49
- self
48
+ self.class.new(client, @params.merge(hash))
50
49
  end
51
50
 
52
51
  def find_by(kvp)
@@ -7,7 +7,7 @@ module GhostRb
7
7
  class PostsController < BaseController
8
8
  attr_reader :endpoint, :resource_klass
9
9
 
10
- def initialize(client)
10
+ def initialize(client, params = nil)
11
11
  super
12
12
  @endpoint = 'posts'
13
13
  @resource_klass = Resources::Post
@@ -7,7 +7,7 @@ module GhostRb
7
7
  class TagsController < BaseController
8
8
  attr_reader :endpoint, :resource_klass
9
9
 
10
- def initialize(client)
10
+ def initialize(client, params = nil)
11
11
  super
12
12
  @endpoint = 'tags'
13
13
  @resource_klass = Resources::Tag
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GhostRb
4
- VERSION = '0.2.8'
4
+ VERSION = '0.3.0'
5
5
  end
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.2.8
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-06 00:00:00.000000000 Z
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.1
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