fog-k5 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: 4c593584d55d83577e53c4cc244b74b6314544528b2377bb72d882ad4fa0e625
4
- data.tar.gz: 93a88324000f99c9b9f1c232ae057f50edc652da935faed9fcb6cc3bb338a177
3
+ metadata.gz: e40070f77c9bd70b3000574e08cfc6d19ac6af256749778d6d84c1c7559891fd
4
+ data.tar.gz: 6afad60e397d964e0effdd1b4ddf7d0f738a9f35a4e4e31ec0d46eedc2e7cee2
5
5
  SHA512:
6
- metadata.gz: e8d32d67418d671e22270479173fff9f8eedb125dcb487d2e8642b41c229a05b599753711dc0df2817bf0d45d4af8208fd45481a9d23116badc885c0a0d5c7dd
7
- data.tar.gz: 9970618c0b35bf80e239c0f0f6f2de8a146490dd575e79c50c26190f5cbb07215aa335724abf624bf322415076501d94811187efb315bb7a0e0bd2fa48777ebc
6
+ metadata.gz: 7c8c576a850fd39a458a5a063113a8c207835a68f032b31ae9bf48c3321381730b6a488f749352cbc18295b9e8d39d691b2e92a8919b20e11121bd28ad9db2dd
7
+ data.tar.gz: c58e542bc8744ca2b8dab2965f97ab20a3e843f253c3162278fe1091b5201f8e470857915eb7bee77787bdc247e463c75286d2d5f629cb2eaa370efc96eca0cc
data/CHANGELOG.md ADDED
@@ -0,0 +1,23 @@
1
+ # Change Log
2
+
3
+ ## [v0.1.1](https://github.com/blooper05/fog-k5/tree/v0.1.1) (2018-05-17)
4
+ [Full Changelog](https://github.com/blooper05/fog-k5/compare/v0.1.0...v0.1.1)
5
+
6
+ **Fixed bugs:**
7
+
8
+ - Exception does not occur even if file upload fails [\#6](https://github.com/blooper05/fog-k5/issues/6)
9
+ - File with Japanese file name can not be uploaded to Object Storage [\#3](https://github.com/blooper05/fog-k5/issues/3)
10
+ - Redundant slashes are included in the URL [\#2](https://github.com/blooper05/fog-k5/issues/2)
11
+
12
+ **Merged pull requests:**
13
+
14
+ - 💚 Allow codeclimate duplication on requests [\#8](https://github.com/blooper05/fog-k5/pull/8) ([blooper05](https://github.com/blooper05))
15
+ - 🐛 Add the expected response HTTP status codes [\#7](https://github.com/blooper05/fog-k5/pull/7) ([blooper05](https://github.com/blooper05))
16
+ - 🐛 Add Excon::Middleware::EscapePath to middlewares param [\#5](https://github.com/blooper05/fog-k5/pull/5) ([blooper05](https://github.com/blooper05))
17
+ - 🐛 Remove redundant slashes included in the URL [\#4](https://github.com/blooper05/fog-k5/pull/4) ([blooper05](https://github.com/blooper05))
18
+ - Update rake requirement to ~\> 12.3 [\#1](https://github.com/blooper05/fog-k5/pull/1) ([dependabot[bot]](https://github.com/apps/dependabot))
19
+
20
+ ## [v0.1.0](https://github.com/blooper05/fog-k5/tree/v0.1.0) (2018-05-14)
21
+
22
+
23
+ \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
data/lib/fog/k5/shared.rb CHANGED
@@ -4,8 +4,8 @@ module Fog
4
4
  K5_URL_SCHEME = 'https'.freeze
5
5
  K5_URL_SUFFIX = 'cloud.global.fujitsu.com'.freeze
6
6
 
7
- def build_url(url_type:)
8
- region = Fog.credentials[:k5_region]
7
+ def build_url(url_type:, region: nil)
8
+ region ||= @k5_region
9
9
  "#{K5_URL_SCHEME}://#{url_type}.#{region}.#{K5_URL_SUFFIX}"
10
10
  end
11
11
 
@@ -16,16 +16,16 @@ module Fog
16
16
  private
17
17
 
18
18
  def auth_token_expired?
19
- !Fog.credentials[:k5_auth_token_expires_at] ||
20
- Fog.credentials[:k5_auth_token_expires_at] - 300 < Fog::Time.now
19
+ !@k5_auth_token_expires_at ||
20
+ @k5_auth_token_expires_at - 300 < Fog::Time.now
21
21
  end
22
22
 
23
23
  def refresh_auth_token
24
24
  connection = Excon.new(build_url(url_type: 'identity'))
25
25
  response = connection.post(auth_request_params)
26
26
 
27
- Fog.credentials[:k5_auth_token] = response.headers['X-Subject-Token']
28
- Fog.credentials[:k5_auth_token_expires_at] = Fog::Time.parse(
27
+ @k5_auth_token = response.headers['X-Subject-Token']
28
+ @k5_auth_token_expires_at = Fog::Time.parse(
29
29
  Fog::JSON.decode(response.body)['token']['expires_at'],
30
30
  )
31
31
  end
@@ -47,16 +47,16 @@ module Fog
47
47
  password: {
48
48
  user: {
49
49
  domain: {
50
- name: Fog.credentials[:k5_domain_name],
50
+ name: @k5_domain_name,
51
51
  },
52
- name: Fog.credentials[:k5_user_name],
53
- password: Fog.credentials[:k5_user_password],
52
+ name: @k5_user_name,
53
+ password: @k5_user_password,
54
54
  },
55
55
  },
56
56
  },
57
57
  scope: {
58
58
  project: {
59
- id: Fog.credentials[:k5_project_id],
59
+ id: @k5_project_id,
60
60
  },
61
61
  },
62
62
  },
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module K5
3
- VERSION = '0.1.1'.freeze
3
+ VERSION = '0.1.2'.freeze
4
4
  end
5
5
  end
@@ -20,9 +20,10 @@ module Fog
20
20
  def public_url
21
21
  requires :directory, :key
22
22
 
23
- project_id = Fog.credentials[:k5_project_id]
23
+ region = service.k5_region
24
+ project_id = service.k5_project_id
24
25
  version = K5_STORAGE_URL_VERSION
25
- url = build_url(url_type: K5_STORAGE_URL_TYPE)
26
+ url = build_url(url_type: K5_STORAGE_URL_TYPE, region: region)
26
27
  container = directory.key
27
28
 
28
29
  "#{url}/#{version}/AUTH_#{project_id}/#{container}/#{key}"
@@ -5,14 +5,10 @@ module Fog
5
5
  include Utils
6
6
  include Fog::K5::Shared
7
7
 
8
- def initialize(options = {})
9
- Fog.credentials[:k5_region] = options[:k5_region]
10
- Fog.credentials[:k5_project_id] = options[:k5_project_id]
11
- Fog.credentials[:k5_domain_name] = options[:k5_domain_name]
12
- Fog.credentials[:k5_user_name] = options[:k5_user_name]
13
- Fog.credentials[:k5_user_password] = options[:k5_user_password]
8
+ attr_reader :k5_region, :k5_project_id
14
9
 
15
- refresh_auth_token_if_expired
10
+ def initialize(options = {})
11
+ refresh_credentials(options)
16
12
 
17
13
  url = build_url(url_type: K5_STORAGE_URL_TYPE)
18
14
  @connection = Fog::Core::Connection.new(url, false, params)
@@ -20,13 +16,20 @@ module Fog
20
16
 
21
17
  private
22
18
 
19
+ def refresh_credentials(options)
20
+ @k5_region = options[:k5_region]
21
+ @k5_project_id = options[:k5_project_id]
22
+ @k5_domain_name = options[:k5_domain_name]
23
+ @k5_user_name = options[:k5_user_name]
24
+ @k5_user_password = options[:k5_user_password]
25
+
26
+ refresh_auth_token_if_expired
27
+ end
28
+
23
29
  def params
24
- token = Fog.credentials[:k5_auth_token]
25
- project_id = Fog.credentials[:k5_project_id]
26
- version = K5_STORAGE_URL_VERSION
27
30
  {
28
- headers: { 'X-Auth-Token' => token },
29
- path_prefix: "#{version}/AUTH_#{project_id}",
31
+ headers: { 'X-Auth-Token' => @k5_auth_token },
32
+ path_prefix: "#{K5_STORAGE_URL_VERSION}/AUTH_#{@k5_project_id}",
30
33
  query: { format: :json },
31
34
  }
32
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-k5
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
  - blooper05
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-17 00:00:00.000000000 Z
11
+ date: 2018-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-core
@@ -121,6 +121,7 @@ files:
121
121
  - ".rspec"
122
122
  - ".rubocop.yml"
123
123
  - ".travis.yml"
124
+ - CHANGELOG.md
124
125
  - CODE_OF_CONDUCT.md
125
126
  - Gemfile
126
127
  - LICENSE