ahub 0.2.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ahub.gemspec +1 -0
- data/lib/ahub/answer.rb +1 -5
- data/lib/ahub/group.rb +0 -6
- data/lib/ahub/modules/class_helpers.rb +8 -2
- data/lib/ahub/question.rb +1 -13
- data/lib/ahub/space.rb +0 -8
- data/lib/ahub/topic.rb +0 -4
- data/lib/ahub/user.rb +11 -15
- data/lib/ahub/version.rb +1 -1
- data/lib/ahub.rb +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e10245bb91d6110fefe1d92aeabef36109eaa5d
|
4
|
+
data.tar.gz: 28bce863640fa59b4dffb44bb977943103509aa8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 284d8a7c56055999ccc9b892a9db14eac70cdc264f5eb8fe189ec255ff1a88c012c1831a3ad257965879356941ca0f7b4ab8ee0a1451853ab95680b56a597ff9
|
7
|
+
data.tar.gz: 76b6d8d895539be53bcdc99124cf0a1bcc251811533772b161b6ff27f9e43ec7f1883de1094d60a84ecfb7e94c4bebb82c280f312f5a2214c4de3dba93784cbb
|
data/ahub.gemspec
CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
spec.add_runtime_dependency "rest-client", "~> 1.8"
|
24
24
|
spec.add_runtime_dependency "dotenv", "~> 2.0"
|
25
|
+
spec.add_runtime_dependency "activesupport", "~> 4.2"
|
25
26
|
|
26
27
|
spec.add_development_dependency "bundler", "~> 1.10"
|
27
28
|
spec.add_development_dependency "rake", "~> 10.0"
|
data/lib/ahub/answer.rb
CHANGED
@@ -9,12 +9,8 @@ module Ahub
|
|
9
9
|
create_resource(url: url, payload: {body: body}, headers: headers(username: username, password: password))
|
10
10
|
end
|
11
11
|
|
12
|
-
attr_reader :body, :body_as_html, :author
|
13
|
-
|
14
12
|
def initialize(attrs)
|
15
|
-
|
16
|
-
@body = attrs[:body]
|
17
|
-
@body_as_html = attrs[:bodyAsHTML]
|
13
|
+
super(attrs)
|
18
14
|
@author = Ahub::User.new(attrs[:author])
|
19
15
|
end
|
20
16
|
|
data/lib/ahub/group.rb
CHANGED
@@ -8,8 +8,14 @@ module Ahub
|
|
8
8
|
raise NotImplementedError
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
12
|
-
|
11
|
+
def initialize(attrs)
|
12
|
+
attrs.each_pair do |k,v|
|
13
|
+
self.instance_variable_set("@#{k.to_s.underscore}", v)
|
14
|
+
|
15
|
+
self.class.send(:define_method, k.to_s.underscore.to_sym) do
|
16
|
+
instance_variable_get("@#{__method__}")
|
17
|
+
end
|
18
|
+
end
|
13
19
|
end
|
14
20
|
end
|
15
21
|
end
|
data/lib/ahub/question.rb
CHANGED
@@ -14,19 +14,7 @@ module Ahub
|
|
14
14
|
create_resource(url: url, payload: payload, headers: user_headers)
|
15
15
|
end
|
16
16
|
|
17
|
-
attr_accessor :title, :body, :body_as_html
|
18
|
-
attr_reader :space_id, :answerCount
|
19
|
-
|
20
|
-
def initialize(attrs)
|
21
|
-
@id = attrs[:id]
|
22
|
-
@answer_ids = attrs[:answers]
|
23
|
-
@answerCount = attrs[:answerCount]
|
24
|
-
@body = attrs[:body]
|
25
|
-
@body_as_html = attrs[:bodyAsHTML]
|
26
|
-
@space_id = attrs[:primaryContainerId]
|
27
|
-
@title = attrs[:title]
|
28
|
-
@topics = attrs[:topics]
|
29
|
-
end
|
17
|
+
attr_accessor :title, :body, :body_as_html
|
30
18
|
|
31
19
|
def move(space_id:)
|
32
20
|
raise Exception("No Question Id") unless id
|
data/lib/ahub/space.rb
CHANGED
@@ -2,13 +2,5 @@ module Ahub
|
|
2
2
|
class Space
|
3
3
|
extend Ahub::APIHelpers
|
4
4
|
include Ahub::ClassHelpers
|
5
|
-
|
6
|
-
attr_accessor :id, :error, :name, :active, :parent_id
|
7
|
-
def initialize(attrs)
|
8
|
-
@id = attrs[:id]
|
9
|
-
@name = attrs[:name]
|
10
|
-
@active = attrs[:active]
|
11
|
-
@parent_id = attrs[:parentId]
|
12
|
-
end
|
13
5
|
end
|
14
6
|
end
|
data/lib/ahub/topic.rb
CHANGED
data/lib/ahub/user.rb
CHANGED
@@ -20,28 +20,24 @@ module Ahub
|
|
20
20
|
matches.find{|user| user.username.downcase.strip == username.downcase.strip}
|
21
21
|
end
|
22
22
|
|
23
|
-
attr_reader :username, :realname, :avatar_url,
|
24
|
-
:post_count, :follow_count, :follower_count,
|
25
|
-
:active, :suspended, :deactivated, :answers
|
26
|
-
|
27
23
|
def initialize(attrs)
|
28
|
-
|
29
|
-
@
|
30
|
-
@realname = attrs[:realname]
|
31
|
-
@avatar_url = attrs[:avatar]
|
32
|
-
@post_count = attrs[:postCount]
|
33
|
-
@follow_count = attrs[:followCount]
|
34
|
-
@follower_count = attrs[:followerCount]
|
35
|
-
@active = attrs[:active]
|
36
|
-
@suspended = attrs[:suspended]
|
37
|
-
@deactivated =attrs[:deactivated]
|
38
|
-
@complete = attrs[:complete]
|
24
|
+
super
|
25
|
+
@groups = attrs[:groups].map{|group| Ahub::Group.new(group)} if attrs[:groups]
|
39
26
|
end
|
40
27
|
|
41
28
|
def is_complete?
|
42
29
|
!!@complete
|
43
30
|
end
|
44
31
|
|
32
|
+
def questions
|
33
|
+
unless @questions
|
34
|
+
response = self.class.get_resource(url: "#{self.class.base_url}/#{id}/question.json", headers: self.class.admin_headers)
|
35
|
+
@questions = response[:list].map{ |question| Ahub::Question.new(question) }
|
36
|
+
end
|
37
|
+
|
38
|
+
@questions
|
39
|
+
end
|
40
|
+
|
45
41
|
def answers
|
46
42
|
unless @answers
|
47
43
|
response = self.class.get_resource(url: "#{self.class.base_url}/#{id}/answer.json", headers: self.class.admin_headers)
|
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.
|
4
|
+
version: 0.3.1
|
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-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4.2'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4.2'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|