fog-backblaze 0.2.0 → 0.3.0

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
- SHA1:
3
- metadata.gz: 5decfdf565507b6f9426990d2a6b4a7d5df99d1f
4
- data.tar.gz: e5b109b24fbf90c10644d890a31358e236991822
2
+ SHA256:
3
+ metadata.gz: a78389a8f10d5fbb3db2898d5b8e5753a83efff4a0597298ab6d025e84890bcd
4
+ data.tar.gz: 6b810bccc7ab401b8ef658f18a4e2217f436ed2f0228e3efa4215bf4039c74b2
5
5
  SHA512:
6
- metadata.gz: 01cb22086898cbbc02f5daedcfb13f8315210f43769bf04c0b82f29d71804bfcd3a35c44ffe90a56f93db8861af201356c1bbe3bd04e12a4876a0a13b5dace55
7
- data.tar.gz: 6898b75ab5cb46e06ede150d7b0e0b707e64d05378602279ef62b647c02c59fa49f361a27ee11b66876a14bf3e30bbed14437103372983537a5123a4fd7d7774
6
+ metadata.gz: 73d97139b00707f5445c235201310377132dc7243732679e325b8a0b8e92be938fad44eedb0a9db1b99c147b390aaea258158b90c7453249ac2ba4177c421c1b
7
+ data.tar.gz: f84b8deeb28d28810cef58344fad698765fd2280e48786b09549995e1b7e6d2eb0c5cb940ed30514a3b0c3c54f2fb1a39bddfa7aad4d8f7d8475406d383c8955
@@ -1,6 +1,7 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.4.0
5
- - 2.5.0
6
- before_install: gem install bundler -v 1.15.1
4
+ - 2.4.5
5
+ - 2.5.3
6
+ - 2.6.1
7
+ before_install: gem install bundler
@@ -1,3 +1,10 @@
1
+ 0.3.0 2019-06-27
2
+ ==========================================================
3
+
4
+ - Fixes issues with not saving a file content_type as well as bad calls for the fog methods (Thanks @dan)
5
+ - method name typo: josn_response?->json_response? (Thanks @MatthiasWinkelmann)
6
+ - Change Fog::Storage::Backblaze -> Fog::Backblaze::Storage
7
+
1
8
  0.2.0 2018-08-16
2
9
  ==========================================================
3
10
 
data/Gemfile CHANGED
@@ -9,4 +9,5 @@ gemspec
9
9
  gem "bundler", ">= 1.15"
10
10
  gem "rake", "~> 12.0"
11
11
  gem "minitest", ">= 5.0"
12
- gem 'minitest-reporters', '1.3.2.beta2'
12
+ gem 'minitest-reporters'
13
+ gem 'm'
@@ -1,16 +1,13 @@
1
1
  require 'fog/core'
2
- require 'json'
3
2
 
4
3
  module Fog
5
4
  module Backblaze
6
5
  autoload :JSONResponse, File.expand_path("../backblaze/json_response", __FILE__)
7
6
  autoload :TokenCache, File.expand_path("../backblaze/token_cache", __FILE__)
8
7
 
8
+ autoload :Storage, File.expand_path("../backblaze/storage", __FILE__)
9
+
9
10
  extend Fog::Provider
10
11
  service(:storage, "Storage")
11
12
  end
12
-
13
- module Storage
14
- autoload :Backblaze, File.expand_path("../storage/backblaze", __FILE__)
15
- end
16
13
  end
@@ -1,3 +1,5 @@
1
+ require 'json'
2
+
1
3
  module Fog
2
4
  module Backblaze
3
5
  module JSONResponse
@@ -16,7 +18,7 @@ module Fog
16
18
  self.body = json
17
19
  end
18
20
 
19
- def josn_response?
21
+ def json_response?
20
22
  headers['Content-Type'].start_with?("application/json")
21
23
  end
22
24
 
@@ -2,17 +2,17 @@ require 'json'
2
2
  require 'digest'
3
3
  require 'cgi'
4
4
 
5
- class Fog::Storage::Backblaze < Fog::Service
5
+ class Fog::Backblaze::Storage < Fog::Service
6
6
  #requires
7
7
  recognizes :b2_account_id, :b2_account_token, :b2_key_id, :b2_key_token,
8
8
  :b2_bucket_name, :b2_bucket_id, :token_cache, :logger
9
9
 
10
- model_path 'fog/storage/backblaze/models'
10
+ model_path 'fog/backblaze/storage/models'
11
11
  model :directory
12
12
  collection :directories
13
13
  model :file
14
14
  collection :files
15
15
 
16
- autoload :Mock, File.expand_path("../backblaze/mock", __FILE__)
17
- autoload :Real, File.expand_path("../backblaze/real", __FILE__)
16
+ autoload :Mock, File.expand_path("../storage/mock", __FILE__)
17
+ autoload :Real, File.expand_path("../storage/real", __FILE__)
18
18
  end
@@ -1,4 +1,4 @@
1
- class Fog::Storage::Backblaze::Mock
1
+ class Fog::Backblaze::Storage::Mock
2
2
  def self.data
3
3
  @data ||= Hash.new do |hash, key|
4
4
  hash[key] = {}
@@ -1,5 +1,5 @@
1
- class Fog::Storage::Backblaze::Directories < Fog::Collection
2
- model Fog::Storage::Backblaze::Directory
1
+ class Fog::Backblaze::Storage::Directories < Fog::Collection
2
+ model Fog::Backblaze::Storage::Directory
3
3
 
4
4
  def all
5
5
  data = service.list_buckets
@@ -1,4 +1,4 @@
1
- class Fog::Storage::Backblaze::Directory < Fog::Model
1
+ class Fog::Backblaze::Storage::Directory < Fog::Model
2
2
  identity :key, aliases: %w(bucketName)
3
3
 
4
4
  attribute :bucket_id#, aliases: 'bucketId'
@@ -56,7 +56,7 @@ class Fog::Storage::Backblaze::Directory < Fog::Model
56
56
  end
57
57
 
58
58
  def files
59
- @files ||= Fog::Storage::Backblaze::Files.new(directory: self, service: service)
59
+ @files ||= Fog::Backblaze::Storage::Files.new(directory: self, service: service)
60
60
  end
61
61
 
62
62
  def public?
@@ -1,8 +1,8 @@
1
- class Fog::Storage::Backblaze::File < Fog::Model
1
+ class Fog::Backblaze::Storage::File < Fog::Model
2
2
 
3
3
  identity :file_name, aliases: %w{fileName key name}
4
4
 
5
- attribute :content_length, aliases: 'contentLength'
5
+ attribute :content_length, aliases: 'contentLength', :type => :integer
6
6
  attribute :content_type, aliases: 'contentType'
7
7
  attribute :file_id, aliases: 'fileId'
8
8
  attribute :file_info, aliases: 'fileInfo'
@@ -1,5 +1,5 @@
1
- class Fog::Storage::Backblaze::Files < Fog::Collection
2
- model Fog::Storage::Backblaze::File
1
+ class Fog::Backblaze::Storage::Files < Fog::Collection
2
+ model Fog::Backblaze::Storage::File
3
3
 
4
4
  attribute :directory
5
5
  #attribute :common_prefixes, :aliases => "CommonPrefixes"
@@ -8,7 +8,7 @@ class Fog::Storage::Backblaze::Files < Fog::Collection
8
8
  #attribute :max_results, :aliases => ["MaxKeys", "max-keys"]
9
9
  #attribute :prefix, :aliases => "Prefix"
10
10
 
11
- model Fog::Storage::Backblaze::File
11
+ model Fog::Backblaze::Storage::File
12
12
 
13
13
  def all(options = {})
14
14
  requires :directory
@@ -46,7 +46,7 @@ class Fog::Storage::Backblaze::Files < Fog::Collection
46
46
  def head(file_name, options = {})
47
47
  requires :directory
48
48
  data = service.head_object(directory.key, file_name, options)
49
- file_data = _headers_to_attrs(file_response)
49
+ file_data = _headers_to_attrs(data)
50
50
  new(file_data)
51
51
  rescue Excon::Errors::NotFound
52
52
  nil
@@ -54,11 +54,11 @@ class Fog::Storage::Backblaze::Files < Fog::Collection
54
54
 
55
55
  def _headers_to_attrs(file_response)
56
56
  {
57
- fileName: file_response.headers['x-bz-file-name'],
58
- fileId: file_response.headers['x-bz-file-id'],
59
- uploadTimestamp: file_response.headers['X-Bz-Upload-Timestamp'],
60
- contentType: file_response.headers['Content-Type'],
61
- contentLength: file_response.headers['Content-Length']
57
+ 'fileName' => file_response.headers['x-bz-file-name'],
58
+ 'fileId' => file_response.headers['x-bz-file-id'],
59
+ 'uploadTimestamp' => file_response.headers['X-Bz-Upload-Timestamp'],
60
+ 'contentType' => file_response.headers['Content-Type'],
61
+ 'contentLength' => file_response.headers['Content-Length']
62
62
  }
63
63
  end
64
64
 
@@ -1,4 +1,4 @@
1
- class Fog::Storage::Backblaze::Real
1
+ class Fog::Backblaze::Storage::Real
2
2
  attr_reader :token_cache, :options
3
3
 
4
4
  def initialize(options = {})
@@ -145,7 +145,7 @@ class Fog::Storage::Backblaze::Real
145
145
  }.merge(options))
146
146
  end
147
147
 
148
- def head_object(bucket_name, file_path)
148
+ def head_object(bucket_name, file_path, options = {})
149
149
  file_url = get_object_url(bucket_name, file_path)
150
150
 
151
151
  result = b2_command(nil,
@@ -443,7 +443,7 @@ class Fog::Storage::Backblaze::Real
443
443
  options[:headers]['Authorization'] ||= auth_response['authorizationToken']
444
444
 
445
445
  if options[:body] && !options[:body].is_a?(String)
446
- options[:body] = JSON.generate(options[:body])
446
+ options[:body] = ::JSON.generate(options[:body])
447
447
  end
448
448
 
449
449
  request_url = options.delete(:url) || "#{auth_response['apiUrl']}/b2api/v1/#{command}"
@@ -473,7 +473,7 @@ class Fog::Storage::Backblaze::Real
473
473
  end
474
474
 
475
475
  http_response.extend(Fog::Backblaze::JSONResponse)
476
- if http_response.josn_response? && http_response.body.size > 0
476
+ if http_response.json_response? && http_response.body.size > 0
477
477
  http_response.assign_json_body!
478
478
  end
479
479
 
@@ -22,6 +22,8 @@
22
22
  # Fog::Storage.new(provider: 'backblaze', ..., token_cache: RedisTokenCache.new)
23
23
  #
24
24
 
25
+ require 'json'
26
+
25
27
  class Fog::Backblaze::TokenCache
26
28
 
27
29
  def initialize
@@ -116,7 +118,7 @@ class Fog::Backblaze::TokenCache
116
118
 
117
119
  def save_data
118
120
  File.open(@file, 'wb') do |f|
119
- f.write(JSON.pretty_generate(@data) + "\n")
121
+ f.write(::JSON.pretty_generate(@data) + "\n")
120
122
  end
121
123
  end
122
124
  end
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Backblaze
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-backblaze
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Evstigneev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-16 00:00:00.000000000 Z
11
+ date: 2019-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-core
@@ -52,15 +52,15 @@ files:
52
52
  - fog-backblaze.gemspec
53
53
  - lib/fog/backblaze.rb
54
54
  - lib/fog/backblaze/json_response.rb
55
+ - lib/fog/backblaze/storage.rb
56
+ - lib/fog/backblaze/storage/mock.rb
57
+ - lib/fog/backblaze/storage/models/directories.rb
58
+ - lib/fog/backblaze/storage/models/directory.rb
59
+ - lib/fog/backblaze/storage/models/file.rb
60
+ - lib/fog/backblaze/storage/models/files.rb
61
+ - lib/fog/backblaze/storage/real.rb
55
62
  - lib/fog/backblaze/token_cache.rb
56
63
  - lib/fog/backblaze/version.rb
57
- - lib/fog/storage/backblaze.rb
58
- - lib/fog/storage/backblaze/mock.rb
59
- - lib/fog/storage/backblaze/models/directories.rb
60
- - lib/fog/storage/backblaze/models/directory.rb
61
- - lib/fog/storage/backblaze/models/file.rb
62
- - lib/fog/storage/backblaze/models/files.rb
63
- - lib/fog/storage/backblaze/real.rb
64
64
  homepage: https://github.com/fog/fog-backblaze
65
65
  licenses: []
66
66
  metadata: {}
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
80
  version: '0'
81
81
  requirements: []
82
82
  rubyforge_project:
83
- rubygems_version: 2.6.8
83
+ rubygems_version: 2.7.6.2
84
84
  signing_key:
85
85
  specification_version: 4
86
86
  summary: Module for the 'fog' gem to support Blackblade B2 stogate.