stashify 3.0.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: d58d66a14fbcb4c923eadefaf83b0df6a163c2a1fd78a204445e051d90609c8f
4
- data.tar.gz: d677085f1b105082435520617d3e545d2d206c3e040b4fa21585d7b29ffe0c0f
3
+ metadata.gz: f8498e1f869ce0f940cbf5e1f1eb65d77fb0692b1df9446b86547a070dcaa6ae
4
+ data.tar.gz: f27dc8f8accaa1ec01c6aee2705cc3919205d168d82b8fab5b81aa452f90e24a
5
5
  SHA512:
6
- metadata.gz: 374b7a1aacdaca2f0ea4a889670bccec77fbebeb7113bf396f16cdd9bb799606b0bfd4acecb809f73721399c4e32ee7b6a15b03610f30bc8bb0337131858ec93
7
- data.tar.gz: cacebe50a69383c925921dea17cfaabec77b2ad7dc020a3c5b5922dbf43c8ca2bd7c63eb33aa200430e80992a65966fd8a9b8e597bff8d7e48693d9f6bcb9da5
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/.rubocop.yml CHANGED
@@ -19,6 +19,7 @@ Layout/LineLength:
19
19
  Metrics/BlockLength:
20
20
  AllowedMethods:
21
21
  - describe
22
+ - shared_examples
22
23
 
23
24
  Style/TrailingCommaInArguments:
24
25
  EnforcedStyleForMultiline: consistent_comma
data/Gemfile CHANGED
@@ -17,4 +17,6 @@ gem "guard-rspec"
17
17
  gem "guard-rubocop"
18
18
 
19
19
  gem "byebug"
20
- gem "rantly"
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.0.0)
4
+ stashify (3.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -70,7 +70,7 @@ GEM
70
70
  rspec-expectations (3.12.2)
71
71
  diff-lcs (>= 1.2.0, < 2.0)
72
72
  rspec-support (~> 3.12.0)
73
- rspec-mocks (3.12.4)
73
+ rspec-mocks (3.12.5)
74
74
  diff-lcs (>= 1.2.0, < 2.0)
75
75
  rspec-support (~> 3.12.0)
76
76
  rspec-support (3.12.0)
@@ -84,12 +84,18 @@ GEM
84
84
  rubocop-ast (>= 1.26.0, < 2.0)
85
85
  ruby-progressbar (~> 1.7)
86
86
  unicode-display_width (>= 2.4.0, < 3.0)
87
- rubocop-ast (1.27.0)
87
+ rubocop-ast (1.28.0)
88
88
  parser (>= 3.2.1.0)
89
89
  ruby-progressbar (1.13.0)
90
90
  shellany (0.0.1)
91
+ stashify-contract (1.0.1)
92
+ rantly (~> 2.0.0)
93
+ rspec (~> 3.0)
91
94
  thor (1.2.1)
92
95
  unicode-display_width (2.4.2)
96
+ webrick (1.7.0)
97
+ yard (0.9.28)
98
+ webrick (~> 1.7.0)
93
99
 
94
100
  PLATFORMS
95
101
  x86_64-linux
@@ -101,11 +107,12 @@ DEPENDENCIES
101
107
  guard-rspec
102
108
  guard-rubocop
103
109
  rake (~> 13.0)
104
- rantly
105
110
  reek (~> 6.1.4)
106
111
  rspec (~> 3.0)
107
112
  rubocop (~> 1.21)
108
113
  stashify!
114
+ stashify-contract
115
+ yard
109
116
 
110
117
  BUNDLED WITH
111
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).
data/lib/st ADDED
@@ -0,0 +1,9 @@
1
+ require "rantly/rspec_extensions"
2
+
3
+ shared_example "a file" do
4
+ it "has a reasonable name" do
5
+ property_of do
6
+ require "byebug";byebug
7
+ end
8
+ end
9
+ end
@@ -11,18 +11,20 @@ module Stashify
11
11
  super
12
12
  end
13
13
 
14
+ def parent
15
+ Stashify::Directory::Local.new(path: ::File.dirname(path))
16
+ end
17
+
18
+ def exists?(name)
19
+ ::File.exist?(path_of(name))
20
+ end
21
+
14
22
  def files
15
23
  Dir.entries(path).grep_v(/^[.][.]?$/).map do |file_name|
16
24
  find(::File.basename(file_name))
17
25
  end
18
26
  end
19
27
 
20
- private
21
-
22
- def file?(name)
23
- ::File.exist?(path_of(name))
24
- end
25
-
26
28
  def file(name)
27
29
  Stashify::File::Local.new(path: path_of(name))
28
30
  end
@@ -15,7 +15,7 @@ module Stashify
15
15
  def find(name)
16
16
  if directory?(name)
17
17
  directory(name)
18
- elsif file?(name)
18
+ elsif exists?(name)
19
19
  file(name)
20
20
  end
21
21
  end
@@ -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)
@@ -16,6 +16,10 @@ module Stashify
16
16
  def delete
17
17
  ::File.delete(path)
18
18
  end
19
+
20
+ def exists?
21
+ ::File.exist?(path)
22
+ end
19
23
  end
20
24
  end
21
25
  end
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.0.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.0.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-03-30 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:
@@ -29,6 +29,7 @@ files:
29
29
  - Rakefile
30
30
  - bin/console
31
31
  - bin/setup
32
+ - lib/st
32
33
  - lib/stashify.rb
33
34
  - lib/stashify/directory.rb
34
35
  - lib/stashify/directory/local.rb
@@ -37,6 +38,7 @@ files:
37
38
  - lib/stashify/local.rb
38
39
  - lib/stashify/version.rb
39
40
  - sig/stashify.rbs
41
+ - stashify.gemspec
40
42
  homepage: https://github.com/Lambda-Null/stashify
41
43
  licenses:
42
44
  - MIT