bfs 0.3.7 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f63579ab84fab2e5ebe18ad08e9565c4510fbaf812a7bc71316df2b4cc9c6c3a
4
- data.tar.gz: ee8adb7378ca2fddb0b476fd0ca3ea85429d5ab0afde19593b6557a0dae418b5
3
+ metadata.gz: f6a37891cce4971bd933f31f0539a551ed03bb730a348363db854e944ca4befe
4
+ data.tar.gz: 3c47f220dfd7a45f2e59eb2f73493eb7724137021c2f7770231282e823aa318b
5
5
  SHA512:
6
- metadata.gz: 974f6428f3dbfefa68aa9fa2497e4763ee6418fed59afe5408cee7e7166a26952d25fb754737af318c28a8ebd755a50786c04d589742cb073105139fddf4d787
7
- data.tar.gz: edc36b9aab8e1aabf9846235e50546d01aac0efd5477234bd0bff5ab39b67c85e527972beaba42cfdba545b854cae531c4e02703d298113339facc368e3b605f
6
+ metadata.gz: 77d82c55b279127518da424b440edb550b0b07956d33698c0547aa88e4884cf374b4cd2baa1d9608fcf8cf9b13bdbe7347c3a635ece334c89639832c978031c9
7
+ data.tar.gz: c85adb1bb78c2ea5b822ef8839d2943b2c32281f9e3b40bbd039d08987f2ff0e4156baee58df7dfd85adb2eaaa526d95c453ae67bef16716712db01037480c3a
data/bfs.gemspec CHANGED
@@ -15,5 +15,5 @@ Gem::Specification.new do |s|
15
15
  s.files = `git ls-files`.split("\n")
16
16
  s.test_files = `git ls-files -- spec/*`.split("\n")
17
17
  s.require_paths = ['lib']
18
- s.required_ruby_version = '>= 2.2.0'
18
+ s.required_ruby_version = '>= 2.4.0'
19
19
  end
@@ -3,6 +3,13 @@ require 'bfs'
3
3
  module BFS
4
4
  module Bucket
5
5
  class Abstract
6
+ # Initializes a new bucket
7
+ # @param [Hash] opts options
8
+ # @option opts [String] :encoding default encoding, default: binary.
9
+ def initialize(opts={})
10
+ @encoding = opts.delete(:encoding) || Encoding::BINARY
11
+ end
12
+
6
13
  # Lists the contents of a bucket using a glob pattern
7
14
  def ls(_pattern='**', _opts={})
8
15
  raise 'not implemented'
data/lib/bfs/bucket/fs.rb CHANGED
@@ -6,7 +6,9 @@ module BFS
6
6
  module Bucket
7
7
  # FS buckets are operating on the file system
8
8
  class FS < Abstract
9
- def initialize(root, _opts={})
9
+ def initialize(root, opts={})
10
+ super(opts.dup)
11
+
10
12
  @root = Pathname.new(root.to_s)
11
13
  @prefix = "#{@root.to_s.chomp('/')}/"
12
14
  end
@@ -38,7 +40,8 @@ module BFS
38
40
  full = @root.join(norm_path(path))
39
41
  FileUtils.mkdir_p(full.dirname.to_s)
40
42
 
41
- temp = BFS::TempWriter.new(full, opts) {|t| FileUtils.mv t, full.to_s }
43
+ enc = opts[:encoding] || @encoding
44
+ temp = BFS::TempWriter.new(full, encoding: enc) {|t| FileUtils.mv t, full.to_s }
42
45
  return temp unless block
43
46
 
44
47
  begin
@@ -7,7 +7,8 @@ module BFS
7
7
  class InMem < Abstract
8
8
  Entry = Struct.new(:io, :mtime, :content_type, :metadata)
9
9
 
10
- def initialize
10
+ def initialize(opts={})
11
+ super(opts.dup)
11
12
  @files = {}
12
13
  end
13
14
 
@@ -43,7 +44,7 @@ module BFS
43
44
  # @option opts [Hash] :metadata Metadata key-value pairs.
44
45
  def create(path, opts={}, &block)
45
46
  io = StringIO.new
46
- opts[:encoding] ? io.set_encoding(opts[:encoding]) : io.binmode
47
+ io.set_encoding(opts[:encoding] || @encoding)
47
48
 
48
49
  @files[norm_path(path)] = Entry.new(io, Time.now, opts[:content_type], opts[:metadata] || {})
49
50
  return io unless block
data/lib/bfs/helpers.rb CHANGED
@@ -3,8 +3,6 @@ require 'tempfile'
3
3
  module BFS
4
4
  class TempWriter
5
5
  def initialize(name, opts={}, &closer)
6
- opts = opts.merge(binmode: true) unless opts[:encoding]
7
-
8
6
  @closer = closer
9
7
  @tempfile = ::Tempfile.new(File.basename(name.to_s), opts)
10
8
  end
@@ -26,7 +24,7 @@ module BFS
26
24
 
27
25
  path = @tempfile.path
28
26
  @tempfile.close
29
- @closer.call(path) if @closer
27
+ @closer&.call(path)
30
28
  @tempfile.unlink
31
29
  end
32
30
  end
data/lib/bfs.rb CHANGED
@@ -22,6 +22,7 @@ module BFS
22
22
  path = path.to_s.dup
23
23
  path.gsub!(File::SEPARATOR, '/')
24
24
  path.sub!(%r{^/+}, '')
25
+ path.sub!(%r{/+$}, '')
25
26
  path
26
27
  end
27
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bfs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitrij Denissenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-02 00:00:00.000000000 Z
11
+ date: 2019-06-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Minimalist abstraction for bucket storage
14
14
  email: dimitrij@blacksquaremedia.com
@@ -40,14 +40,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
- version: 2.2.0
43
+ version: 2.4.0
44
44
  required_rubygems_version: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - ">="
47
47
  - !ruby/object:Gem::Version
48
48
  version: '0'
49
49
  requirements: []
50
- rubygems_version: 3.0.2
50
+ rubygems_version: 3.0.3
51
51
  signing_key:
52
52
  specification_version: 4
53
53
  summary: Multi-platform cloud bucket adapter