scc_ruby 0.1.1 → 0.1.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,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 570e6cb391d145f030ef91663cdadd8abfe95ebda32083b7f8e81e64c2a62bf4
4
- data.tar.gz: 07a9f0c5b62ff652858228f8ed8e87eebab382aa99d5e2989d8a91d87847e5bd
3
+ metadata.gz: fe6f4fdb28dc28fd2129a787ecab34ea099fe78408e4b1b32bf2ce2e7170ba58
4
+ data.tar.gz: 9f1d8e235999de686f36476c98a1cb7e4a62f1bd9dfb0db397ee973c38334669
5
5
  SHA512:
6
- metadata.gz: db651289519d4c22ac9566fbc665f976a82d72eba08e3554d6f42d292ce4e1b7e6aaf92075ee3123261a29b521e701a3a6d4408659a27365f5763c76d68cbde8
7
- data.tar.gz: b2f911a57b61975dbb54dcd6ce9d1fd7286a1c60b4f327b9b36da18188865278128f56f8d8b4c94ef9edfd9492990b4dacd06b062ebb6cc91f8045d2e38eefa5
6
+ metadata.gz: d46c7d5fe48d0fd2ad01082fe95c98e419921dce8b20617c73330794907215d8dcbdc66ce5e2d13d3c39b38a79b4b36c7ce99cd3bca183f12f6dcd48ae63890e
7
+ data.tar.gz: 9dfe974bb276d7682e2331dfba270055c162b02a0999b1749e65316f1308cc76fe781a22ed645fccc8e0f8be6047ff2dd1d94960207fcedd80319996d3b2612f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- scc_ruby (0.1.1)
4
+ scc_ruby (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # SccRuby
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/scc_ruby`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ Spring cloud config client in ruby, just return a hash.
6
4
 
7
5
  ## Installation
8
6
 
@@ -24,6 +22,8 @@ Or install it yourself as:
24
22
 
25
23
  ```ruby
26
24
  h = SccRuby::Api.fetch('config_server_url', 'app_name', Rails.env)
25
+ # or
26
+ h = SccRuby::Api.fetch('config_server_url', 'app_name', Rails.env, 'basic_auth_username', 'basic_auth_password')
27
27
  pp h
28
28
  ```
29
29
 
@@ -1,3 +1,3 @@
1
1
  module SccRuby
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
data/lib/scc_ruby.rb CHANGED
@@ -4,9 +4,13 @@ require 'json'
4
4
 
5
5
  module SccRuby
6
6
  class Api
7
- def self.fetch(config_server_url, app_name, app_env = 'default')
7
+ def self.fetch(config_server_url, app_name, app_env = 'default', basic_auth_username = '', basic_auth_password = '')
8
8
  uri = URI(build_url(config_server_url, app_name, app_env))
9
- res = Net::HTTP.get_response(uri)
9
+ req = Net::HTTP::Get.new(uri)
10
+ req.basic_auth(basic_auth_username, basic_auth_password) unless basic_auth_username.empty? && basic_auth_password.empty?
11
+ res = Net::HTTP.start(uri.hostname, uri.port) do |http|
12
+ http.request(req)
13
+ end
10
14
 
11
15
  if res.code != '200'
12
16
  raise "Fail to fetch from spring cloud config server, http code #{res.code}, message #{res.message}"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scc_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - FlowerWrong
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-27 00:00:00.000000000 Z
11
+ date: 2019-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler