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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1ea4fc5534f83930d5fc06d6555c4d7e71be49e4
4
- data.tar.gz: f194dee02fedc6a3d1ffaf296b4b7871820713cd
3
+ metadata.gz: 0e10245bb91d6110fefe1d92aeabef36109eaa5d
4
+ data.tar.gz: 28bce863640fa59b4dffb44bb977943103509aa8
5
5
  SHA512:
6
- metadata.gz: df35600d963fcc5e9fcc0863539d4e3a922cea0d83bf1e9e3d94ceacaad79b15e19b6dd8a63504697fe387e04ac1ccaed8d6df8fcabe868201d606e7b7896ea2
7
- data.tar.gz: 123d634b044ad2395cd31fda2ac884065a015f072a35037d970c4f03c06e832aaf87ae19a9dbd21175ec90474105ac542a609fb2677862ff566ca42893b4822f
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
- @id = attrs[:id]
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
@@ -3,12 +3,6 @@ module Ahub
3
3
  extend Ahub::APIHelpers
4
4
  include Ahub::ClassHelpers
5
5
 
6
- attr_reader :name
7
- def initialize(attrs)
8
- @id = attrs[:id]
9
- @name = attrs[:name]
10
- end
11
-
12
6
  def add(user_id)
13
7
  add_user(user_id)
14
8
  end
@@ -8,8 +8,14 @@ module Ahub
8
8
  raise NotImplementedError
9
9
  end
10
10
 
11
- def self.included(klass)
12
- attr_reader :id
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, :author
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
@@ -2,9 +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
- end
9
5
  end
10
6
  end
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
- @id = attrs[:id]
29
- @username = attrs[:username]
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
@@ -1,3 +1,3 @@
1
1
  module Ahub
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.1"
3
3
  end
data/lib/ahub.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'dotenv'
2
2
  require 'rest_client'
3
+ require 'active_support/inflector'
3
4
  require 'ahub/modules/api_helpers'
4
5
  require 'ahub/modules/class_helpers'
5
6
  require 'ahub/version'
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.2.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 00:00:00.000000000 Z
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