ahub 0.1.13 → 0.1.14

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: d0e453dddc2acc0a93623f4025dc466f2a654516
4
- data.tar.gz: 70d03b7cef6e65850fbe124434e86c09a90ef4f1
3
+ metadata.gz: b11c85492d4dbe8a0a35913bedbd0923981f80e1
4
+ data.tar.gz: dcae934db479bb0d7b68f909ca0c69cadba49534
5
5
  SHA512:
6
- metadata.gz: e3eed926881b86e039bce3704b52fb16e19e15d171a4f3a4fb00b3073f366f8286eff2d6f7f3d8c66d589a5fb71f4a39a0751c6077508835f4d83fbe257b7025
7
- data.tar.gz: 133bee33d7c56a4011c8b4fee96a22508f93532b4e0ad19548250b5934c14d81beb57e46bb7fff978866923efcf80b55853b8b21d8eb65701ef1fed8b23cf732
6
+ metadata.gz: dac6d749ab6a169a0bb54836aacad9c27fee939b0516c8b919f91b2fe32d8c36e40c255ac2f182cedc88de0c1887306b0a4ed8963a856793f1d4d96dadd72961
7
+ data.tar.gz: 41d75ed0904baa303c3db587b13f1f7a9984eaef9afa82120e1e840be5f6cff5866ff646d1418002cc1ccdc35f35d01419f3e6b0c3d2678bd6843f0b17c2e41e
data/.travis.yml CHANGED
@@ -1,4 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.1.4
4
+ - 2.1.7
5
+ - 2.2.3
4
6
  before_install: gem install bundler -v 1.10.6
data/README.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # Ahub
2
2
  A gem to interact with the [Answer Hub API](docs.answerhubapiv2.apiary.io)
3
3
 
4
+ Master
5
+ [![Build Status](https://travis-ci.org/abelmartin/ahub.svg?branch=master)](https://travis-ci.org/abelmartin/ahub)
6
+
7
+ Gem v0.1.13
8
+ [![Build Status](https://travis-ci.org/abelmartin/ahub.svg?branch=v0.1.13)](https://github.com/abelmartin/ahub/tree/v0.1.13)
9
+
4
10
  ## Installation
5
11
 
6
12
  Add this line to your application's Gemfile:
data/ahub.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["abel.martin@gmail.com"]
11
11
 
12
12
  spec.summary = "A gem to interact with the Answer Hub API"
13
- spec.description = "Answer Hub is a great product. This gem allows you to easily interact with it's API"
13
+ spec.description = "Answer Hub is a great product. This gem allows you to easily interact with its API"
14
14
  spec.homepage = "https://github.com/abelmartin/ahub"
15
15
  spec.license = "MIT"
16
16
 
data/lib/ahub/answer.rb CHANGED
@@ -3,6 +3,14 @@ module Ahub
3
3
  extend Ahub::APIHelpers
4
4
  include Ahub::ClassHelpers
5
5
 
6
+ def self.create(question_id:, body:, username:, password:)
7
+ payload = {body: body}
8
+
9
+ url = "#{Ahub::DOMAIN}/services/v2/question/#{question_id}/answer.json"
10
+
11
+ make_post_call(url, payload.to_json, headers(username: username, password: password))
12
+ end
13
+
6
14
  attr_reader :body, :body_as_html, :author
7
15
 
8
16
  def initialize(attrs)
@@ -15,15 +23,5 @@ module Ahub
15
23
  def user
16
24
  @author
17
25
  end
18
-
19
- def self.create(question_id:, body:, username:, password:)
20
- data = {body: body}
21
-
22
- url = "#{Ahub::DOMAIN}/services/v2/question/#{question_id}/answer.json"
23
-
24
- auth_headers = headers(username: username, password: password)
25
-
26
- new JSON.parse(RestClient.post(url, data.to_json, auth_headers), symbolize_names: true)
27
- end
28
26
  end
29
27
  end
@@ -44,5 +44,12 @@ module Ahub
44
44
  def object_id_from_response(response)
45
45
  response.headers[:location].match(/(?<id>\d*)\.json/)[:id].to_i
46
46
  end
47
+
48
+ private
49
+
50
+ def make_post_call(url:, payload:, headers:)
51
+ response = RestClient.post(url, payload.to_json, admin_headers)
52
+ find(object_id_from_response(response))
53
+ end
47
54
  end
48
55
  end
data/lib/ahub/question.rb CHANGED
@@ -3,8 +3,8 @@ module Ahub
3
3
  extend Ahub::APIHelpers
4
4
  include Ahub::ClassHelpers
5
5
 
6
- attr_accessor :title, :body, :body_as_html, :author, :answerCount
7
- attr_reader :space_id
6
+ attr_accessor :title, :body, :body_as_html, :author
7
+ attr_reader :space_id, :answerCount
8
8
 
9
9
  def self.create(title:, body:, topics:, space_id: nil, username:, password:)
10
10
  url = "#{base_url}.json"
@@ -13,11 +13,7 @@ module Ahub
13
13
 
14
14
  user_headers = headers(username:username, password:password)
15
15
 
16
- response = RestClient.post(url, payload.to_json, user_headers)
17
-
18
- find(object_id_from_response(response))
19
- rescue => e
20
- new({error: e.message})
16
+ make_post_call(url: url, payload: payload.to_json, headers: user_headers)
21
17
  end
22
18
 
23
19
  def initialize(attrs)
@@ -35,8 +31,6 @@ module Ahub
35
31
 
36
32
  move_url = "#{self.class.base_url}/#{id}/move.json?space=#{space_id}"
37
33
  RestClient.put("#{url}", self.class.admin_headers)
38
- rescue => e
39
- @error = e.message
40
34
  end
41
35
 
42
36
  def url
data/lib/ahub/user.rb CHANGED
@@ -14,8 +14,6 @@ module Ahub
14
14
 
15
15
  response = RestClient.post(url, payload.to_json, admin_headers)
16
16
  find(object_id_from_response(response))
17
- rescue => e
18
- new({error: e.message})
19
17
  end
20
18
 
21
19
  def self.find_by_username(username)
data/lib/ahub/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ahub
2
- VERSION = "0.1.13"
2
+ VERSION = "0.1.14"
3
3
  end
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.13
4
+ version: 0.1.14
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-09 00:00:00.000000000 Z
11
+ date: 2015-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -95,7 +95,7 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '3.2'
97
97
  description: Answer Hub is a great product. This gem allows you to easily interact
98
- with it's API
98
+ with its API
99
99
  email:
100
100
  - abel.martin@gmail.com
101
101
  executables: