hub_client 0.0.1 → 0.0.2

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ODFiNjgyMzhmM2UwMWE0OTNmMGYzZTRlZTM0OGMyYjZlMjhjOWZiYQ==
4
+ YjZkNGYyZjVkYThhMjllMTY3NDA5MWMyNjNjYjU2ZjU5OTUyMzg1OA==
5
5
  data.tar.gz: !binary |-
6
- OTI3NTU0MDEwMTg5ZDg2ZTUyNTU3YTEyYjk1NDVkOGVmOTBjMjJhYQ==
6
+ ZjUwZjUyYTVkZWVhZmRlODI4MjU4Y2Y3NjZiMjUxNzQwZWU0NTRlZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MTc3YTg4NWQ3YmM2MjUzMTk4ZGYxMTJjMzk4YzZhYTU0NTUyZDE1NzE4NmM0
10
- YzRkMDdiMTNmNWI5NmI0ODMwYmU5M2U2N2U2MzljMDZlMjZlNWU2M2ZhMTkx
11
- YzI3YTRhZjJhYWU4Y2Y3YTY5NWUzNGRmNjhmODc1Nzc3YTZjZTA=
9
+ Y2MxOWZiMGMxMGE2NWNmY2Q4NjU1ZjkwN2RmNTliZGRjYTliZDk0YTg2OGNi
10
+ NjUxNjQzN2JlNTdmYmUwMDBmMTM1NjhhZjNkNWI5YzFmNmY2NDk0YTg5ODdk
11
+ YjkyNDFkZDgwZmRiYTQ0MjM3NjFlNDA0NmEwNmY4NmFlMDc2ZjY=
12
12
  data.tar.gz: !binary |-
13
- ZjFhNWE4YjBkNGE2ODkwMGRmNGU2NWJhOGFlMDkwMzkxZmI1ZDYxYWQ3Y2E2
14
- MmJlNGM1MGRiNDA3NjVhZmZhMzBiZjBkODJlZGJiOTJiYmJiMTBiNGQwYjZh
15
- MzQ4ZmE1ZGNiZGJlYmY1MGVhZjMyOGY4OTcyNmY4NzNlNTQ3NzQ=
13
+ ZDE3NThkM2M5OTkzNTk3NWNiZGUwZDE5YzNlNTgwMjdmOGMxMTMyNjdmNjMx
14
+ MWI4OTFjMDhhM2EzMTIwZGI1MDgwYjA4ZjE3YjE4MzNhMWRhOGI4MWRlZDA1
15
+ Y2JiZDk2NmUzZjJlYWFlOGY4ODdlNDY1ZGZjNTgwMDIwNzcyZjk=
data/hub_client.gemspec CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_runtime_dependency "rest-client"
22
+ spec.add_runtime_dependency "activesupport"
22
23
  spec.add_development_dependency "bundler", "~> 1.5"
23
24
  spec.add_development_dependency "rake"
24
25
  spec.add_development_dependency "rspec"
@@ -1,6 +1,6 @@
1
1
  module HubClient
2
2
  class Configuration
3
- attr_accessor :env, :access_token, :endpoint_url
3
+ attr_accessor :env, :access_token, :endpoint_url, :http_auth
4
4
  end
5
5
 
6
6
  def self.configuration
@@ -2,7 +2,7 @@ module HubClient
2
2
  class Logger
3
3
  def method_missing(method_sym, *args, &block)
4
4
  if defined?(Rails)
5
- Rails.logger.send(method_sym, args)
5
+ Rails.logger.send(method_sym, *args)
6
6
  end
7
7
  end
8
8
  end
@@ -1,3 +1,3 @@
1
1
  module HubClient
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/hub_client.rb CHANGED
@@ -8,19 +8,23 @@ module HubClient
8
8
  raise ConfigArgumentMissing, "endpoint_url missing" unless HubClient.configuration.endpoint_url
9
9
  raise ConfigArgumentMissing, "env missing" unless HubClient.configuration.env
10
10
 
11
- payload = { type: type, env: HubClient.configuration.env, content: content }
11
+ if HubClient.configuration.http_auth.present?
12
+ opts = HubClient.configuration.http_auth.slice(:user, :password)
13
+ end
12
14
 
13
- RestClient.post(HubClient.configuration.endpoint_url, payload) do |response, request, result|
14
- handle_response(result, request)
15
+ rest_resource = RestClient::Resource.new(HubClient.configuration.endpoint_url, opts)
16
+ payload = { type: type, env: HubClient.configuration.env, content: content }
17
+ rest_resource.post(payload) do |response, request, result|
18
+ handle_response(response, request, result)
15
19
  end
16
20
  end
17
21
 
18
22
  private
19
23
 
20
- def self.handle_response(result, request)
24
+ def self.handle_response(response, request, result)
21
25
  # When request didn't succeed we log it
22
26
  unless result.code.start_with?("2")
23
- HubClient.logger.info(request.args)
27
+ HubClient.logger.info("Code: #{result.code} Response: #{response} Request: #{request.args}")
24
28
  end
25
29
  end
26
30
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hub_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yarin Goldman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-24 00:00:00.000000000 Z
11
+ date: 2014-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ! '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement