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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 371152a9dddd73396e1608c4f51fd1271bff7f6d
4
- data.tar.gz: 2000a920adcc97a0db540dd4402d97fc730ad359
3
+ metadata.gz: d0e453dddc2acc0a93623f4025dc466f2a654516
4
+ data.tar.gz: 70d03b7cef6e65850fbe124434e86c09a90ef4f1
5
5
  SHA512:
6
- metadata.gz: b203c7a7f54e6a9614f14c543fe7fb21e28e638f0e22a7eab81ae3de4e15bd3fd3e21e39678b8b2db6a86758768bce96bd4bd4cd8a5ac227cddab1264ff2ebc2
7
- data.tar.gz: 9eb00d0e34711c4bcfcd2cd86e6df9a7a318bf45bac02e912d69859b5040ca526d1994b9c4e664d96e895e48caef7cb70b869a65773bb1780ab624f816ae43c1
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
- attr_accessor :body, :author
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
- @body = attrs[:bodyAsHTML]
14
- # @author = Ahub::User.new(attrs[:author]) # this is an incomplete user object.
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
@@ -5,7 +5,6 @@ module Ahub
5
5
 
6
6
  attr_reader :name
7
7
  def initialize(attrs)
8
- @id = attrs[:id]
9
8
  @name = attrs[:name]
10
9
  end
11
10
 
@@ -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
- new({error: e.message})
23
+ rescue RestClient::ResourceNotFound => e
24
+ nil
25
25
  end
26
26
 
27
27
  def find_all(params: nil, page: 1, pageSize: 30)
@@ -9,7 +9,7 @@ module Ahub
9
9
  end
10
10
 
11
11
  def self.included(klass)
12
- attr_reader :id, :error
12
+ attr_reader :id
13
13
  end
14
14
  end
15
15
  end
data/lib/ahub/question.rb CHANGED
@@ -21,9 +21,6 @@ module Ahub
21
21
  end
22
22
 
23
23
  def initialize(attrs)
24
- @id = attrs[:id]
25
- @error = attrs[:error]
26
-
27
24
  @answer_ids = attrs[:answers]
28
25
  @answerCount = attrs[:answerCount]
29
26
  @body = attrs[:body]
data/lib/ahub/space.rb CHANGED
@@ -5,9 +5,6 @@ module Ahub
5
5
 
6
6
  attr_accessor :id, :error, :name, :active, :parent_id
7
7
  def initialize(attrs)
8
- @id = attrs[:id]
9
- @error = attrs[:error]
10
-
11
8
  @name = attrs[:name]
12
9
  @active = attrs[:active]
13
10
  @parent_id = attrs[:parentId]
data/lib/ahub/topic.rb CHANGED
@@ -2,10 +2,5 @@ module Ahub
2
2
  class Topic
3
3
  extend Ahub::APIHelpers
4
4
  include Ahub::ClassHelpers
5
-
6
- def initialize(attrs)
7
- @id = attrs[:id]
8
- @error = attrs[:error]
9
- end
10
5
  end
11
6
  end
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, :post_count, :follow_count, :follower_count, :active, :suspended, :deactivated
27
- def initialize(attrs)
28
- @id = attrs[:id]
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
@@ -1,3 +1,3 @@
1
1
  module Ahub
2
- VERSION = "0.1.12"
2
+ VERSION = "0.1.13"
3
3
  end
data/lib/ahub.rb CHANGED
@@ -3,6 +3,7 @@ require 'rest_client'
3
3
  require 'ahub/modules/api_helpers'
4
4
  require 'ahub/modules/class_helpers'
5
5
  require 'ahub/version'
6
+ require 'ahub/exception_factory'
6
7
  require 'ahub/user'
7
8
  require 'ahub/question'
8
9
  require 'ahub/answer'
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.12
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-05 00:00:00.000000000 Z
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