ahub 0.1.12 → 0.1.13
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 +4 -4
- data/lib/ahub/answer.rb +3 -8
- data/lib/ahub/exception_factory.rb +15 -0
- data/lib/ahub/group.rb +0 -1
- data/lib/ahub/modules/api_helpers.rb +2 -2
- data/lib/ahub/modules/class_helpers.rb +1 -1
- data/lib/ahub/question.rb +0 -3
- data/lib/ahub/space.rb +0 -3
- data/lib/ahub/topic.rb +0 -5
- data/lib/ahub/user.rb +9 -4
- data/lib/ahub/version.rb +1 -1
- data/lib/ahub.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0e453dddc2acc0a93623f4025dc466f2a654516
|
4
|
+
data.tar.gz: 70d03b7cef6e65850fbe124434e86c09a90ef4f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3eed926881b86e039bce3704b52fb16e19e15d171a4f3a4fb00b3073f366f8286eff2d6f7f3d8c66d589a5fb71f4a39a0751c6077508835f4d83fbe257b7025
|
7
|
+
data.tar.gz: 133bee33d7c56a4011c8b4fee96a22508f93532b4e0ad19548250b5934c14d81beb57e46bb7fff978866923efcf80b55853b8b21d8eb65701ef1fed8b23cf732
|
data/lib/ahub/answer.rb
CHANGED
@@ -3,15 +3,13 @@ module Ahub
|
|
3
3
|
extend Ahub::APIHelpers
|
4
4
|
include Ahub::ClassHelpers
|
5
5
|
|
6
|
-
|
6
|
+
attr_reader :body, :body_as_html, :author
|
7
7
|
|
8
8
|
def initialize(attrs)
|
9
9
|
@id = attrs[:id]
|
10
|
-
@error = attrs[:error]
|
11
|
-
|
12
10
|
@body = attrs[:body]
|
13
|
-
@
|
14
|
-
|
11
|
+
@body_as_html = attrs[:bodyAsHTML]
|
12
|
+
@author = Ahub::User.new(attrs[:author])
|
15
13
|
end
|
16
14
|
|
17
15
|
def user
|
@@ -26,9 +24,6 @@ module Ahub
|
|
26
24
|
auth_headers = headers(username: username, password: password)
|
27
25
|
|
28
26
|
new JSON.parse(RestClient.post(url, data.to_json, auth_headers), symbolize_names: true)
|
29
|
-
rescue => e
|
30
|
-
new({error: e.message})
|
31
27
|
end
|
32
|
-
|
33
28
|
end
|
34
29
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Ahub
|
2
|
+
class ExceptionFactory
|
3
|
+
attr_reader :orignal_exception
|
4
|
+
def initialize(exception)
|
5
|
+
new UnknownError(exception)
|
6
|
+
|
7
|
+
@orignal_exception = exception
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class RequestError < Exception ; end
|
12
|
+
class RedirectError < Exception ; end
|
13
|
+
class LicenseError < Exception ; end
|
14
|
+
class UnknownError < Exception ; end
|
15
|
+
end
|
data/lib/ahub/group.rb
CHANGED
@@ -20,8 +20,8 @@ module Ahub
|
|
20
20
|
url = "#{base_url}/#{id}.json"
|
21
21
|
|
22
22
|
new JSON.parse(RestClient.get(url, admin_headers), symbolize_names:true)
|
23
|
-
rescue => e
|
24
|
-
|
23
|
+
rescue RestClient::ResourceNotFound => e
|
24
|
+
nil
|
25
25
|
end
|
26
26
|
|
27
27
|
def find_all(params: nil, page: 1, pageSize: 30)
|
data/lib/ahub/question.rb
CHANGED
data/lib/ahub/space.rb
CHANGED
data/lib/ahub/topic.rb
CHANGED
data/lib/ahub/user.rb
CHANGED
@@ -23,11 +23,11 @@ module Ahub
|
|
23
23
|
matches.find{|user| user.username.downcase.strip == username.downcase.strip}
|
24
24
|
end
|
25
25
|
|
26
|
-
attr_reader :username, :realname, :avatar_url,
|
27
|
-
|
28
|
-
|
29
|
-
@error = attrs[:error]
|
26
|
+
attr_reader :username, :realname, :avatar_url,
|
27
|
+
:post_count, :follow_count, :follower_count,
|
28
|
+
:active, :suspended, :deactivated
|
30
29
|
|
30
|
+
def initialize(attrs)
|
31
31
|
@username = attrs[:username]
|
32
32
|
@realname = attrs[:realname]
|
33
33
|
@avatar_url = attrs[:avatar]
|
@@ -37,6 +37,11 @@ module Ahub
|
|
37
37
|
@active = attrs[:active]
|
38
38
|
@suspended = attrs[:suspended]
|
39
39
|
@deactivated =attrs[:deactivated]
|
40
|
+
@complete = attrs[:complete]
|
41
|
+
end
|
42
|
+
|
43
|
+
def is_complete?
|
44
|
+
!!@complete
|
40
45
|
end
|
41
46
|
end
|
42
47
|
end
|
data/lib/ahub/version.rb
CHANGED
data/lib/ahub.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ahub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Abel Martin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- bin/setup
|
119
119
|
- lib/ahub.rb
|
120
120
|
- lib/ahub/answer.rb
|
121
|
+
- lib/ahub/exception_factory.rb
|
121
122
|
- lib/ahub/group.rb
|
122
123
|
- lib/ahub/modules/api_helpers.rb
|
123
124
|
- lib/ahub/modules/class_helpers.rb
|