Class: StashNotifier::HTTPClient

Inherits:
Object
  • Object
show all
Defined in:
lib/stash_notifier/http_client.rb

Constant Summary collapse

STASH_BUILD_STATUS_PATH =
'rest/build-status/1.0/commits'
DEFAULTS =
{
  http_client: Faraday.new
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ HTTPClient

Returns a new instance of HTTPClient.



31
32
33
34
35
36
37
38
39
40
# File 'lib/stash_notifier/http_client.rb', line 31

def initialize(args)
  args = DEFAULTS.merge(args)

  @stash_url    = args[:stash_url]
  @stash_user   = args[:stash_user]
  @stash_pwd    = args[:stash_pwd]
  @git_commit   = args[:git_commit]
  @build_result = args[:build_result]
  @http_client  = args[:http_client]
end

Instance Attribute Details

#build_resultObject

Returns the value of attribute build_result.



28
29
30
# File 'lib/stash_notifier/http_client.rb', line 28

def build_result
  @build_result
end

#git_commitObject

Returns the value of attribute git_commit.



28
29
30
# File 'lib/stash_notifier/http_client.rb', line 28

def git_commit
  @git_commit
end

#http_clientObject

Returns the value of attribute http_client.



28
29
30
# File 'lib/stash_notifier/http_client.rb', line 28

def http_client
  @http_client
end

#stash_pwdObject

Returns the value of attribute stash_pwd.



28
29
30
# File 'lib/stash_notifier/http_client.rb', line 28

def stash_pwd
  @stash_pwd
end

#stash_urlObject

Returns the value of attribute stash_url.



28
29
30
# File 'lib/stash_notifier/http_client.rb', line 28

def stash_url
  @stash_url
end

#stash_userObject

Returns the value of attribute stash_user.



28
29
30
# File 'lib/stash_notifier/http_client.rb', line 28

def stash_user
  @stash_user
end

Instance Method Details

#post_to_stashObject



51
52
53
54
55
56
# File 'lib/stash_notifier/http_client.rb', line 51

def post_to_stash
  setup_http_client
  response = post_results
  check_errors(response)
  response
end

#to_sObject



42
43
44
45
46
47
48
49
# File 'lib/stash_notifier/http_client.rb', line 42

def to_s
  "StashNotifier connection:
  url: #{stash_url},
  git_commit: #{git_commit},
  user: #{stash_user},
  pwd: ***********,
  build_result: #{build_result}"
end