stashify 3.1.0 → 3.2.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: 15c432cdab53f9a20369203af0e05bb8157413a622655ae28d4c36131f318a8b
4
- data.tar.gz: 5e2d87b9a660825c36d4140fa1a5c30b1a5e10573edc34df7fb6cbcff7e5f802
3
+ metadata.gz: f8498e1f869ce0f940cbf5e1f1eb65d77fb0692b1df9446b86547a070dcaa6ae
4
+ data.tar.gz: f27dc8f8accaa1ec01c6aee2705cc3919205d168d82b8fab5b81aa452f90e24a
5
5
  SHA512:
6
- metadata.gz: 73612ebce48eaf45c396d4277ea4e73a591ffb976589049101dc28c6cd8b4fbbd3ad376852db2a8e5deb0a8864982e10071821da47a2ca19e05b443e0054613a
7
- data.tar.gz: a897048fb68343a37408a5bdc43bcf93f629621fea1d21235896f32b0800e643ab791feac51d32b17df73ed2fcc3141652e43fd4bc85deac757abd78c1410080
6
+ metadata.gz: d8123084aca3264108000f72216018ca1c6e4a7a6a99bdd82f4f7f4082515bc1fe9ce0d7f268a2bba73e5165e21de903e6c973965728e00dbc7fd4ae0d94a610
7
+ data.tar.gz: 6f42c931c5dd653fe30a252ff513c3d66ded53c43df31d7aae877eafca20c87e0c2e01d90d0f1df0cab16d2fe85c75eccf5976cec2e61113252f6df06f555f35
data/.reek.yml CHANGED
@@ -19,3 +19,7 @@ detectors:
19
19
  ControlParameter:
20
20
  exclude:
21
21
  - Stashify::Directory#initialize
22
+
23
+ NilCheck:
24
+ exclude:
25
+ - Stashify::File#exists?
data/Gemfile CHANGED
@@ -18,3 +18,5 @@ gem "guard-rubocop"
18
18
 
19
19
  gem "byebug"
20
20
  gem "stashify-contract"
21
+
22
+ gem "yard"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stashify (3.1.0)
4
+ stashify (3.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -93,6 +93,9 @@ GEM
93
93
  rspec (~> 3.0)
94
94
  thor (1.2.1)
95
95
  unicode-display_width (2.4.2)
96
+ webrick (1.7.0)
97
+ yard (0.9.28)
98
+ webrick (~> 1.7.0)
96
99
 
97
100
  PLATFORMS
98
101
  x86_64-linux
@@ -109,6 +112,7 @@ DEPENDENCIES
109
112
  rubocop (~> 1.21)
110
113
  stashify!
111
114
  stashify-contract
115
+ yard
112
116
 
113
117
  BUNDLED WITH
114
118
  2.2.33
data/README.md CHANGED
@@ -1,16 +1,18 @@
1
1
  # Stashify
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/stashify`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Stashify is a common abstraction to interact with several different storage mediums in a uniform way. Provided in this gem is an implementation of the local filesystem, but other gems provide other implementations.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ * [Google Cloud Storage](https://github.com/Lambda-Null/stashify-google-cloud-storage)
6
+ * [AWS S3](https://github.com/Lambda-Null/stashify-aws-s3)
7
+ * [Azure Blob Storage](https://github.com/Lambda-Null/stashify-microsoft-azure-storage-blob)
8
+
9
+ The uniform nature of these implementations allows results from one be passed to others. This not only affords you flexibility in your implementation and testing, but a simple way of transferring information from one storage provider to another.
6
10
 
7
11
  ## Installation
8
12
 
9
13
  Add this line to your application's Gemfile:
10
14
 
11
- ```ruby
12
- gem 'stashify'
13
- ```
15
+ gem 'stashify'
14
16
 
15
17
  And then execute:
16
18
 
@@ -22,7 +24,89 @@ Or install it yourself as:
22
24
 
23
25
  ## Usage
24
26
 
25
- TODO: Write usage instructions here
27
+ Provided in this gem is an implementation of local storage. Here is an example of how to use that implementation:
28
+
29
+ > require "stashify/file/local"
30
+ => true
31
+ > file = Stashify::File::Local.new(path: "/tmp/foo")
32
+ => #<Stashify::File::Local:0x000055a2a62f53c0 @contents="", @name="foo", @path="/tmp/foo">
33
+ > file.contents
34
+ => "1\n"
35
+ > file.delete
36
+ => true
37
+ > file.write("100")
38
+ => 3
39
+ > file.contents
40
+ => "100"
41
+ > file.delete
42
+ => 1
43
+ > file.exists?
44
+ => false
45
+ > require "stashify/directory/local"
46
+ > dir = Stashify::Directory::Local.new(path: "/tmp")
47
+ > file2 = dir.find("bar")
48
+ => #<Stashify::File::Local:0x000055a2a62ff000 @contents="", @name="bar", @path="/tmp/bar">
49
+ > file2.contents
50
+ => "2\n"
51
+ > dir.exists?(file.name)
52
+ => false
53
+ > dir.write(Stashify::File.new(name: "foo", contents: "1"))
54
+ > dir.exists?("foo")
55
+ => true
56
+ > dir.find("foo").contents
57
+ => "1"
58
+ > dir.exists?("bar")
59
+ => true
60
+ > dir.delete("bar")
61
+ => 1
62
+ > dir.exists?("bar")
63
+ => false
64
+ > subdir = dir.find("foobar")
65
+ =>
66
+ #<Stashify::Directory::Local:0x000055a2a5ffb660
67
+ ...
68
+ > subdir.files.map(&:name)
69
+ => ["baz"]
70
+ > subfile = subdir.files.first
71
+ =>
72
+ #<Stashify::File::Local:0x000055a2a62937b0
73
+ ...
74
+ > subfile.name
75
+ => "baz"
76
+ > subfile.contents
77
+ => "3\n"
78
+
79
+ To interact with `Stashify::File` implementations is through `exists?`, `contents`, `write` and `delete`. To interact with `Stashify::Directory` implementations, use the methods `exists?`, `find`, `write`, `delete` and `files`. Regardless of the implementation of `Stashify::Directory`, `find` will return and `write` will take implementations of `Stashify::File`.
80
+
81
+ This consistency allows a lot of portability. For instance, pulling in a couple [other](https://github.com/Lambda-Null/stashify-google-cloud-storage) [gems](https://github.com/Lambda-Null/stashify-aws-s3) allows you to do cool things like this:
82
+
83
+ > require "stashify/directory/local"
84
+ => true
85
+ > dir = Stashify::Directory::Local.new(path: "/tmp/foobar")
86
+ =>
87
+ #<Stashify::Directory::Local:0x0000564d9e8f9f48
88
+ ...
89
+ > dir.files.map(&:name)
90
+ => ["baz"]
91
+ > require "stashify/directory/google/cloud/storage"
92
+ => true
93
+ > gdir = Stashify::Directory::Google::Cloud::Storage.new(bucket: bucket, path
94
+ : "")
95
+ =>
96
+ #<Stashify::Directory::Google::Cloud::Storage:0x0000564d9ee87140
97
+ ...
98
+ > gdir.write(dir)
99
+ > gdir.files.map(&:name)
100
+ => ["foobar"]
101
+ > require "stashify/directory/aws/s3"
102
+ => true
103
+ > adir = Stashify::Directory::AWS::S3.new(bucket: bucket, path: "")
104
+ =>
105
+ #<Stashify::Directory::AWS::S3:0x0000564da0851580
106
+ ...
107
+ > adir.write(gdir)
108
+ > adir.files.map(&:name)
109
+ => ["baz"]
26
110
 
27
111
  ## Development
28
112
 
@@ -34,6 +118,8 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
34
118
 
35
119
  Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/stashify. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/stashify/blob/master/CODE_OF_CONDUCT.md).
36
120
 
121
+ If you wish to create an implementation for a new provider, the gem [stashify-contract](https://github.com/Lambda-Null/stashify-contract) provides shared examples which verifies the consistency which maintains portability. To have your gem included in the list above, it must implement these examples in the way documented in that gem.
122
+
37
123
  ## License
38
124
 
39
125
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -62,7 +62,9 @@ module Stashify
62
62
  self.class == other.class && name == other.name && path == other.path
63
63
  end
64
64
 
65
- private
65
+ def file(name)
66
+ Stashify::File.new(path: path_of(name))
67
+ end
66
68
 
67
69
  def path_of(*name)
68
70
  ::File.join(path, *name)
data/lib/stashify/file.rb CHANGED
@@ -23,6 +23,10 @@ module Stashify
23
23
  @contents = nil
24
24
  end
25
25
 
26
+ def exists?
27
+ !contents.nil?
28
+ end
29
+
26
30
  def ==(other)
27
31
  name == other.name && contents == other.contents
28
32
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Stashify
4
- VERSION = "3.1.0"
4
+ VERSION = "3.2.0"
5
5
  end
data/stashify.gemspec ADDED
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/stashify/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "stashify"
7
+ spec.version = Stashify::VERSION
8
+ spec.authors = ["Lambda Null"]
9
+ spec.email = ["lambda.null.42@gmail.com"]
10
+
11
+ spec.summary = "Common abstraction for storing files"
12
+ spec.description = "Provides an abstraction to various services (local filesystem, S3, etc)"
13
+ spec.homepage = "https://github.com/Lambda-Null/stashify"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.6.0"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = spec.homepage
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
+ `git ls-files -z`.split("\x0").reject do |f|
24
+ (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
25
+ end
26
+ end
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ # Uncomment to register a new dependency of your gem
32
+ # spec.add_dependency "example-gem", "~> 1.0"
33
+
34
+ # For more information and examples about making a new gem, checkout our
35
+ # guide at: https://bundler.io/guides/creating_gem.html
36
+ spec.metadata["rubygems_mfa_required"] = "true"
37
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stashify
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lambda Null
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-01 00:00:00.000000000 Z
11
+ date: 2023-04-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Provides an abstraction to various services (local filesystem, S3, etc)
14
14
  email:
@@ -38,6 +38,7 @@ files:
38
38
  - lib/stashify/local.rb
39
39
  - lib/stashify/version.rb
40
40
  - sig/stashify.rbs
41
+ - stashify.gemspec
41
42
  homepage: https://github.com/Lambda-Null/stashify
42
43
  licenses:
43
44
  - MIT