scholarsphere-client 0.1.0 → 0.1.1

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: 683f69f3cc0b3710f0b00fd18fbafc05efe11c54f7399a277665403d6b8fb10a
4
- data.tar.gz: cccc924aa267339669331de7d92fb45fb1bc446fb29740ebc87c298041ba3b19
3
+ metadata.gz: 84b082e1c474c137dd8202b5ae6666eb73938f9b1bd806f053308a715272c28f
4
+ data.tar.gz: c94c0532b48c3b0f9f3b9918f01275a572f75a8ff3f7d5112837b7fd78e474ad
5
5
  SHA512:
6
- metadata.gz: dc35ef489babe5c2d303325b4ae9f7d818a3394eaaffb1574433db957834b88db149ca19c627d666a567f9752c2822d29b67be9a00db680b339cca97262d1b32
7
- data.tar.gz: 22d55ab65a3a090b927163fdaa4ad22e4334fcf720ce6a4cd86b02e52088bea64c5c6702d34f6c8ca443164ba2fe5ae5a788dba1d26565c26fd95bc1c78da7bf
6
+ metadata.gz: 517ddf088ccad9da2fbdae7b0d674c3017c5085e850d568f23fa0eaff95899e4bfe728de6f144f2480d09d65025801c22e0929eeb60bf3548c7613e041b40cb8
7
+ data.tar.gz: a7b2df6784f547a3ceb9b9de3e82497398e76b794dfe0fe22cdbbc6214e7a068940b8df7957195b61a417f9f8d4f4b1dd115693630467661b821907675b32b94
@@ -7,3 +7,7 @@ Metrics/BlockLength:
7
7
  Exclude:
8
8
  - 'spec/**/*'
9
9
  - 'scholarsphere-client.gemspec'
10
+
11
+ Gemspec/RequiredRubyVersion:
12
+ Exclude:
13
+ - 'scholarsphere-client.gemspec'
@@ -0,0 +1,2 @@
1
+ --markup markdown
2
+ --no-private
data/README.md CHANGED
@@ -20,4 +20,8 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- This client is in development and currently not supporting any features.
23
+ You can read the [ruby docs](https://www.rubydoc.info/gems/scholarsphere-client) for the latest features.
24
+
25
+ **Warning!**
26
+
27
+ This is not yet in 1.0 status and features will change without the customary deprecation warnings.
@@ -5,10 +5,10 @@ module Scholarsphere
5
5
  class Collection
6
6
  attr_reader :metadata, :depositor, :permissions, :work_noids
7
7
 
8
- # @param [Hash] metadata
9
- # @param [String] depositor
10
- # @param optional [Hash] permissions
11
- # @param optional [Array] work_noids
8
+ # @param metadata [Hash] Attributes for the collection
9
+ # @param depositor [String] Access ID of the depositor
10
+ # @param permissions [Hash] Additional permissions for the collection (optional)
11
+ # @param work_noids [Array<String>] List of of identifiers for works that belong to the collection
12
12
  def initialize(metadata:, depositor:, permissions: {}, work_noids: [])
13
13
  @metadata = metadata
14
14
  @depositor = depositor
@@ -2,18 +2,33 @@
2
2
 
3
3
  module Scholarsphere
4
4
  module Client
5
+ ##
6
+ #
7
+ # Loads the yaml configuration file for the client. The default location is `config/scholarsphere-client.yml` and
8
+ # the client will load this file automatically whenever it is invoked.
9
+ #
10
+ # The configuration file should contain the endpoint of the Scholarsphere API.
11
+ #
12
+ # # Example
13
+ #
14
+ # SS4_ENDPOINT: "http://scholarsphere.psu.edu/api/v1"
15
+ #
5
16
  class Config
17
+ # @private
6
18
  def self.load_defaults
7
19
  new.load_config
8
20
  end
9
21
 
22
+ # @return [Pathname]
10
23
  attr_reader :file
11
24
 
25
+ # @param [Pathname] file
12
26
  def initialize(file = Pathname.pwd.join('config', 'scholarsphere-client.yml'))
13
27
  @file = file
14
28
  load_config
15
29
  end
16
30
 
31
+ # @private
17
32
  def load_config
18
33
  return unless file.exist?
19
34
 
@@ -5,10 +5,10 @@ module Scholarsphere
5
5
  class Ingest
6
6
  attr_reader :content, :metadata, :depositor, :permissions
7
7
 
8
- # @param [Hash] metadata
9
- # @param [Array<File,IO,Pathnme,Hash>] files as an array of File or IO, or a hash with a :file param
10
- # @param [String] depositor
11
- # @param optional [Hash] permissions
8
+ # @param metadata [Hash] Metadata attributes
9
+ # @param files [Array<File,IO,Pathnme>,Hash] An array of File or IO objects, or a hash with a :file param
10
+ # @param depositor [String] The access ID of the depositor
11
+ # @param permissions [Hash] (optional) Additional permissions to apply to the resource
12
12
  def initialize(metadata:, files:, depositor:, permissions: {})
13
13
  @content = build_content_hash(files)
14
14
  @metadata = metadata
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Scholarsphere
4
4
  module Client
5
- VERSION = '0.1.0'
5
+ VERSION = '0.1.1'
6
6
  end
7
7
  end
@@ -2,17 +2,39 @@
2
2
 
3
3
  module Scholarsphere
4
4
  module S3
5
+ ##
6
+ #
7
+ # Represents a file on the client's file system that will be uploaded, but hasn't been yet. The object is
8
+ # constructed using a pathname for the file, and if desired, a checksum. The checksum is not required, and if it is
9
+ # not provided, the client will calculate one. Once initialized, the uploaded file object can be used by the client
10
+ # to make additional calls to the application.
11
+ #
12
+ # ## Examples
13
+ #
14
+ # The most common use case would be:
15
+ #
16
+ # pathname = Pathname.new('path/to/your/file')
17
+ # uploaded_file = UploadedFile.new(pathname)
18
+ #
19
+ # If the file is large, then calculating a checksum could be time-intensive. Providing one can avoid that. Or, if
20
+ # you already have a checksum from a trusted source, you can pass that along for the client to use:
21
+ #
22
+ # uploaded_file = UploadedFile.new(pathname, checksum: '[md5 checksum hash]')
23
+ #
5
24
  class UploadedFile
6
- attr_reader :source, :checksum
25
+ # @return [Pathname] The location of the file to be uploaded
26
+ attr_reader :source
7
27
 
8
- # @param [Pathname]
9
- # @option option [String] :checksum in md5 format
28
+ # @param source [Pathname] The file to be uploaded
29
+ # @param options [Hash]
30
+ # @option options [String] :checksum The file's md5 checksum. If one is not provided, it will be calculated at
31
+ # upload
10
32
  def initialize(source, options = {})
11
33
  @source = source
12
34
  @checksum = options[:checksum]
13
35
  end
14
36
 
15
- # @return [Hash]
37
+ # @return [Hash] Set of metadata needed by Shrine to upload the file
16
38
  # @note this can be passed to a controller for uploading the file to Shrine
17
39
  def to_shrine
18
40
  {
@@ -22,22 +44,22 @@ module Scholarsphere
22
44
  }
23
45
  end
24
46
 
25
- # @return [String]
26
- # @note This is the name of the file that will be stored in S3. It's using the same procedure that the
27
- # Uppy::S3Multipart gem is using.
47
+ # @return [String] A unique, randomly-generated UUID
48
+ # @note This serves as the name of the file in the S3 bucket. However, this original name of the file is kept as
49
+ # metadata within the application so that it can be downloaded.
28
50
  def id
29
51
  @id ||= "#{SecureRandom.uuid}#{source.extname}"
30
52
  end
31
53
 
32
- # @return [String]
33
- # @note Path of the file relative to the bucket
54
+ # @return [String] Path of the file relative to the bucket in S3
34
55
  def key
35
56
  "#{prefix}/#{id}"
36
57
  end
37
58
 
38
- # @return [String]
39
- # @note When sending the md5 checksum to verify the file's integrity, Amazon requires that the value of the
40
- # checksum be base64 encoded.
59
+ # @return [String] The md5 checksum encoded in base64. If you provided a checksum at initialization, that one will
60
+ # be encoded, if not, a checksum will be calculated and then encoded.
61
+ # @note When sending the checksum to verify the file's integrity, Amazon requires that the value be base64
62
+ # encoded.
41
63
  # @example The equivalent operation in bash would be:
42
64
  # openssl dgst -md5 -binary file.jpg | openssl enc -base64
43
65
  def content_md5
@@ -48,12 +70,15 @@ module Scholarsphere
48
70
  end
49
71
  end
50
72
 
73
+ # @return [String] Size of the file in bytes
51
74
  def size
52
75
  source.size
53
76
  end
54
77
 
55
78
  private
56
79
 
80
+ attr_reader :checksum
81
+
57
82
  def metadata
58
83
  {
59
84
  size: source.size,
@@ -15,9 +15,9 @@ module Scholarsphere
15
15
  @multipart_threshold = options[:multipart_threshold] || FIFTEEN_MEGABYTES
16
16
  end
17
17
 
18
- # @param [UploadedFile]
19
- # @param [Hash] of additional options
20
- # @options options [String] content_md5 a base64-encoded string representating the md5 checksum
18
+ # @param [UploadedFile] uploaded_file
19
+ # @param [Hash] options of additional options
20
+ # @option options [String] content_md5 a base64-encoded string representating the md5 checksum
21
21
  # @return [void]
22
22
  # @note The content_md5 hash cannot be used when doing a multipart upload.
23
23
  def upload(uploaded_file, options = {})
@@ -14,11 +14,12 @@ Gem::Specification.new do |spec|
14
14
  spec.description = 'Client software to create new content for the Scholarsphere repository at Penn State.'
15
15
  spec.homepage = 'https://github.com/psu-stewardship/scholarsphere-client'
16
16
 
17
- spec.metadata['allowed_push_host'] = 'https://rubygems.org'
18
-
19
- spec.metadata['homepage_uri'] = spec.homepage
20
- spec.metadata['source_code_uri'] = 'https://github.com/psu-stewardship/scholarsphere-client'
21
- # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
17
+ spec.metadata = {
18
+ 'homepage_uri' => spec.homepage,
19
+ 'source_code_uri' => spec.homepage,
20
+ 'documentation' => 'https://www.rubydoc.info/gems/scholarsphere-client',
21
+ 'allowed_push_host' => 'https://rubygems.org'
22
+ }
22
23
 
23
24
  # Specify which files should be added to the gem when it is released.
24
25
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -41,4 +42,5 @@ Gem::Specification.new do |spec|
41
42
  spec.add_development_dependency 'rspec', '~> 3.0'
42
43
  spec.add_development_dependency 'rspec-its', '~> 1.3'
43
44
  spec.add_development_dependency 'simplecov', '~> 0.18'
45
+ spec.add_development_dependency 'yard', '< 1.0'
44
46
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scholarsphere-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Wead
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-20 00:00:00.000000000 Z
11
+ date: 2021-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3
@@ -164,6 +164,20 @@ dependencies:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0.18'
167
+ - !ruby/object:Gem::Dependency
168
+ name: yard
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "<"
172
+ - !ruby/object:Gem::Version
173
+ version: '1.0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "<"
179
+ - !ruby/object:Gem::Version
180
+ version: '1.0'
167
181
  description: Client software to create new content for the Scholarsphere repository
168
182
  at Penn State.
169
183
  email:
@@ -175,6 +189,7 @@ files:
175
189
  - ".gitignore"
176
190
  - ".rspec"
177
191
  - ".rubocop.yml"
192
+ - ".yardopts"
178
193
  - Gemfile
179
194
  - README.md
180
195
  - Rakefile
@@ -193,9 +208,10 @@ files:
193
208
  homepage: https://github.com/psu-stewardship/scholarsphere-client
194
209
  licenses: []
195
210
  metadata:
196
- allowed_push_host: https://rubygems.org
197
211
  homepage_uri: https://github.com/psu-stewardship/scholarsphere-client
198
212
  source_code_uri: https://github.com/psu-stewardship/scholarsphere-client
213
+ documentation: https://www.rubydoc.info/gems/scholarsphere-client
214
+ allowed_push_host: https://rubygems.org
199
215
  post_install_message:
200
216
  rdoc_options: []
201
217
  require_paths: