bucket_sdk 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: 0e63e7694da2110ae72c26db24cfacf06c487fb4fc2069b679d5ee6148d33a94
4
- data.tar.gz: 6e102e2b9d062deb0bda5e1dd0d41216a4c2ae9b6940e07fe7f9c3e33257de49
3
+ metadata.gz: d23795c8e442e8de774bbe7ef7e1f8f67ca377bf6464e4466ea01a2e4428ea5a
4
+ data.tar.gz: 7ef4565e268664a4e5c624b976f2491896701955edd1799c0a0ff3bf7d4296b9
5
5
  SHA512:
6
- metadata.gz: 3626020e7ba3b3315fcb08a526bc7a539eed87891fa859b97caae877ecf008b171d08dfa6c66ae5356f3c9d04d020a2e0ca41d7601122fa56d96c6eda057761a
7
- data.tar.gz: 6afa6bdec2ceaef32e0503bc637d38d3b172ea9f403696a34b05550f983f6d767f686ea86b0fff9ae465b292e2dbff239c0382eea51f1dfbb4826fed0a8762f3
6
+ metadata.gz: b4d2587b608b760ee60310e30e3b9a15986d975adef29ed48121a395d61355b0d88f1f0257ad40525071ab80ec29ec93a63b76d0afae880b9f95f8a560b726df
7
+ data.tar.gz: f7ffa850c1635efb0f5d5ec43cdfc98dfaff9507e3d7165723d21f20aeed60ddefe52dc22816e723decc211cab50113f5bba9b7984644273ac1c33700bc10337
data/.idea/.gitignore CHANGED
@@ -1,8 +1,8 @@
1
- # Default ignored files
2
- /shelf/
3
- /workspace.xml
4
- # Editor-based HTTP Client requests
5
- /httpRequests/
6
- # Datasource local storage ignored files
7
- /dataSources/
8
- /dataSources.local.xml
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
4
+ # Editor-based HTTP Client requests
5
+ /httpRequests/
6
+ # Datasource local storage ignored files
7
+ /dataSources/
8
+ /dataSources.local.xml
data/.idea/bucket-sdk.iml CHANGED
@@ -1,93 +1,93 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="RUBY_MODULE" version="4">
3
- <component name="ModuleRunConfigurationManager">
4
- <shared />
5
- </component>
6
- <component name="NewModuleRootManager">
7
- <content url="file://$MODULE_DIR$">
8
- <sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
9
- <sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
10
- <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
11
- </content>
12
- <orderEntry type="jdk" jdkName="ruby-3.4.1-p0" jdkType="RUBY_SDK" />
13
- <orderEntry type="sourceFolder" forTests="false" />
14
- <orderEntry type="library" scope="PROVIDED" name="addressable (v2.8.7, ruby-3.4.1-p0) [gem]" level="application" />
15
- <orderEntry type="library" scope="PROVIDED" name="ast (v2.4.3, ruby-3.4.1-p0) [gem]" level="application" />
16
- <orderEntry type="library" scope="PROVIDED" name="bigdecimal (v3.1.9, ruby-3.4.1-p0) [gem]" level="application" />
17
- <orderEntry type="library" scope="PROVIDED" name="bundler (v2.6.2, ruby-3.4.1-p0) [gem]" level="application" />
18
- <orderEntry type="library" scope="PROVIDED" name="crack (v1.0.0, ruby-3.4.1-p0) [gem]" level="application" />
19
- <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.6.0, ruby-3.4.1-p0) [gem]" level="application" />
20
- <orderEntry type="library" scope="PROVIDED" name="faraday (v2.12.2, ruby-3.4.1-p0) [gem]" level="application" />
21
- <orderEntry type="library" scope="PROVIDED" name="faraday-multipart (v1.1.0, ruby-3.4.1-p0) [gem]" level="application" />
22
- <orderEntry type="library" scope="PROVIDED" name="faraday-net_http (v3.4.0, ruby-3.4.1-p0) [gem]" level="application" />
23
- <orderEntry type="library" scope="PROVIDED" name="hashdiff (v1.1.2, ruby-3.4.1-p0) [gem]" level="application" />
24
- <orderEntry type="library" scope="PROVIDED" name="json (v2.10.2, ruby-3.4.1-p0) [gem]" level="application" />
25
- <orderEntry type="library" scope="PROVIDED" name="language_server-protocol (v3.17.0.4, ruby-3.4.1-p0) [gem]" level="application" />
26
- <orderEntry type="library" scope="PROVIDED" name="lint_roller (v1.1.0, ruby-3.4.1-p0) [gem]" level="application" />
27
- <orderEntry type="library" scope="PROVIDED" name="logger (v1.6.6, ruby-3.4.1-p0) [gem]" level="application" />
28
- <orderEntry type="library" scope="PROVIDED" name="multipart-post (v2.4.1, ruby-3.4.1-p0) [gem]" level="application" />
29
- <orderEntry type="library" scope="PROVIDED" name="net-http (v0.6.0, ruby-3.4.1-p0) [gem]" level="application" />
30
- <orderEntry type="library" scope="PROVIDED" name="parallel (v1.26.3, ruby-3.4.1-p0) [gem]" level="application" />
31
- <orderEntry type="library" scope="PROVIDED" name="parser (v3.3.7.2, ruby-3.4.1-p0) [gem]" level="application" />
32
- <orderEntry type="library" scope="PROVIDED" name="public_suffix (v6.0.1, ruby-3.4.1-p0) [gem]" level="application" />
33
- <orderEntry type="library" scope="PROVIDED" name="racc (v1.8.1, ruby-3.4.1-p0) [gem]" level="application" />
34
- <orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, ruby-3.4.1-p0) [gem]" level="application" />
35
- <orderEntry type="library" scope="PROVIDED" name="rake (v13.2.1, ruby-3.4.1-p0) [gem]" level="application" />
36
- <orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.10.0, ruby-3.4.1-p0) [gem]" level="application" />
37
- <orderEntry type="library" scope="PROVIDED" name="rexml (v3.4.1, ruby-3.4.1-p0) [gem]" level="application" />
38
- <orderEntry type="library" scope="PROVIDED" name="rspec (v3.13.0, ruby-3.4.1-p0) [gem]" level="application" />
39
- <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.13.3, ruby-3.4.1-p0) [gem]" level="application" />
40
- <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.13.3, ruby-3.4.1-p0) [gem]" level="application" />
41
- <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.13.2, ruby-3.4.1-p0) [gem]" level="application" />
42
- <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.13.2, ruby-3.4.1-p0) [gem]" level="application" />
43
- <orderEntry type="library" scope="PROVIDED" name="rubocop (v1.74.0, ruby-3.4.1-p0) [gem]" level="application" />
44
- <orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.41.0, ruby-3.4.1-p0) [gem]" level="application" />
45
- <orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.13.0, ruby-3.4.1-p0) [gem]" level="application" />
46
- <orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v3.1.4, ruby-3.4.1-p0) [gem]" level="application" />
47
- <orderEntry type="library" scope="PROVIDED" name="unicode-emoji (v4.0.4, ruby-3.4.1-p0) [gem]" level="application" />
48
- <orderEntry type="library" scope="PROVIDED" name="uri (v1.0.3, ruby-3.4.1-p0) [gem]" level="application" />
49
- <orderEntry type="library" scope="PROVIDED" name="webmock (v3.25.1, ruby-3.4.1-p0) [gem]" level="application" />
50
- <orderEntry type="library" scope="PROVIDED" name="zeitwerk (v2.7.2, ruby-3.4.1-p0) [gem]" level="application" />
51
- </component>
52
- <component name="RakeTasksCache-v2">
53
- <option name="myRootTask">
54
- <RakeTaskImpl id="rake">
55
- <subtasks>
56
- <RakeTaskImpl description="Build bucket_sdk-0.1.0.gem into the pkg directory" fullCommand="build" id="build" />
57
- <RakeTaskImpl id="build">
58
- <subtasks>
59
- <RakeTaskImpl description="Generate SHA512 checksum of bucket_sdk-0.1.0.gem into the checksums directory" fullCommand="build:checksum" id="checksum" />
60
- </subtasks>
61
- </RakeTaskImpl>
62
- <RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
63
- <RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
64
- <RakeTaskImpl description="Build and install bucket_sdk-0.1.0.gem into system gems" fullCommand="install" id="install" />
65
- <RakeTaskImpl id="install">
66
- <subtasks>
67
- <RakeTaskImpl description="Build and install bucket_sdk-0.1.0.gem into system gems without network access" fullCommand="install:local" id="local" />
68
- </subtasks>
69
- </RakeTaskImpl>
70
- <RakeTaskImpl description="Create tag v0.1.0 and build and push bucket_sdk-0.1.0.gem to https://rubygems.org" fullCommand="release[remote]" id="release[remote]" />
71
- <RakeTaskImpl description="Run RuboCop" fullCommand="rubocop" id="rubocop" />
72
- <RakeTaskImpl id="rubocop">
73
- <subtasks>
74
- <RakeTaskImpl description="Autocorrect RuboCop offenses (only when it's safe)" fullCommand="rubocop:autocorrect" id="autocorrect" />
75
- <RakeTaskImpl description="Autocorrect RuboCop offenses (safe and unsafe)" fullCommand="rubocop:autocorrect_all" id="autocorrect_all" />
76
- <RakeTaskImpl description="" fullCommand="rubocop:auto_correct" id="auto_correct" />
77
- </subtasks>
78
- </RakeTaskImpl>
79
- <RakeTaskImpl description="Run RSpec code examples" fullCommand="spec" id="spec" />
80
- <RakeTaskImpl description="" fullCommand="default" id="default" />
81
- <RakeTaskImpl description="" fullCommand="release" id="release" />
82
- <RakeTaskImpl id="release">
83
- <subtasks>
84
- <RakeTaskImpl description="" fullCommand="release:guard_clean" id="guard_clean" />
85
- <RakeTaskImpl description="" fullCommand="release:rubygem_push" id="rubygem_push" />
86
- <RakeTaskImpl description="" fullCommand="release:source_control_push" id="source_control_push" />
87
- </subtasks>
88
- </RakeTaskImpl>
89
- </subtasks>
90
- </RakeTaskImpl>
91
- </option>
92
- </component>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="ModuleRunConfigurationManager">
4
+ <shared />
5
+ </component>
6
+ <component name="NewModuleRootManager">
7
+ <content url="file://$MODULE_DIR$">
8
+ <sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
9
+ <sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
10
+ <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
11
+ </content>
12
+ <orderEntry type="jdk" jdkName="rbenv: 3.3.5" jdkType="RUBY_SDK" />
13
+ <orderEntry type="sourceFolder" forTests="false" />
14
+ <orderEntry type="library" scope="PROVIDED" name="addressable (v2.8.7, rbenv: 3.3.5) [gem]" level="application" />
15
+ <orderEntry type="library" scope="PROVIDED" name="ast (v2.4.3, rbenv: 3.3.5) [gem]" level="application" />
16
+ <orderEntry type="library" scope="PROVIDED" name="bigdecimal (v3.1.9, rbenv: 3.3.5) [gem]" level="application" />
17
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v2.6.2, rbenv: 3.3.5) [gem]" level="application" />
18
+ <orderEntry type="library" scope="PROVIDED" name="crack (v1.0.0, rbenv: 3.3.5) [gem]" level="application" />
19
+ <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.6.0, rbenv: 3.3.5) [gem]" level="application" />
20
+ <orderEntry type="library" scope="PROVIDED" name="faraday (v2.12.2, rbenv: 3.3.5) [gem]" level="application" />
21
+ <orderEntry type="library" scope="PROVIDED" name="faraday-multipart (v1.1.0, rbenv: 3.3.5) [gem]" level="application" />
22
+ <orderEntry type="library" scope="PROVIDED" name="faraday-net_http (v3.4.0, rbenv: 3.3.5) [gem]" level="application" />
23
+ <orderEntry type="library" scope="PROVIDED" name="hashdiff (v1.1.2, rbenv: 3.3.5) [gem]" level="application" />
24
+ <orderEntry type="library" scope="PROVIDED" name="json (v2.10.2, rbenv: 3.3.5) [gem]" level="application" />
25
+ <orderEntry type="library" scope="PROVIDED" name="language_server-protocol (v3.17.0.4, rbenv: 3.3.5) [gem]" level="application" />
26
+ <orderEntry type="library" scope="PROVIDED" name="lint_roller (v1.1.0, rbenv: 3.3.5) [gem]" level="application" />
27
+ <orderEntry type="library" scope="PROVIDED" name="logger (v1.6.6, rbenv: 3.3.5) [gem]" level="application" />
28
+ <orderEntry type="library" scope="PROVIDED" name="multipart-post (v2.4.1, rbenv: 3.3.5) [gem]" level="application" />
29
+ <orderEntry type="library" scope="PROVIDED" name="net-http (v0.6.0, rbenv: 3.3.5) [gem]" level="application" />
30
+ <orderEntry type="library" scope="PROVIDED" name="parallel (v1.26.3, rbenv: 3.3.5) [gem]" level="application" />
31
+ <orderEntry type="library" scope="PROVIDED" name="parser (v3.3.7.2, rbenv: 3.3.5) [gem]" level="application" />
32
+ <orderEntry type="library" scope="PROVIDED" name="public_suffix (v6.0.1, rbenv: 3.3.5) [gem]" level="application" />
33
+ <orderEntry type="library" scope="PROVIDED" name="racc (v1.8.1, rbenv: 3.3.5) [gem]" level="application" />
34
+ <orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, rbenv: 3.3.5) [gem]" level="application" />
35
+ <orderEntry type="library" scope="PROVIDED" name="rake (v13.2.1, rbenv: 3.3.5) [gem]" level="application" />
36
+ <orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.10.0, rbenv: 3.3.5) [gem]" level="application" />
37
+ <orderEntry type="library" scope="PROVIDED" name="rexml (v3.4.1, rbenv: 3.3.5) [gem]" level="application" />
38
+ <orderEntry type="library" scope="PROVIDED" name="rspec (v3.13.0, rbenv: 3.3.5) [gem]" level="application" />
39
+ <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.13.3, rbenv: 3.3.5) [gem]" level="application" />
40
+ <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.13.3, rbenv: 3.3.5) [gem]" level="application" />
41
+ <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.13.2, rbenv: 3.3.5) [gem]" level="application" />
42
+ <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.13.2, rbenv: 3.3.5) [gem]" level="application" />
43
+ <orderEntry type="library" scope="PROVIDED" name="rubocop (v1.74.0, rbenv: 3.3.5) [gem]" level="application" />
44
+ <orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.41.0, rbenv: 3.3.5) [gem]" level="application" />
45
+ <orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.13.0, rbenv: 3.3.5) [gem]" level="application" />
46
+ <orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v3.1.4, rbenv: 3.3.5) [gem]" level="application" />
47
+ <orderEntry type="library" scope="PROVIDED" name="unicode-emoji (v4.0.4, rbenv: 3.3.5) [gem]" level="application" />
48
+ <orderEntry type="library" scope="PROVIDED" name="uri (v1.0.3, rbenv: 3.3.5) [gem]" level="application" />
49
+ <orderEntry type="library" scope="PROVIDED" name="webmock (v3.25.1, rbenv: 3.3.5) [gem]" level="application" />
50
+ <orderEntry type="library" scope="PROVIDED" name="zeitwerk (v2.7.2, rbenv: 3.3.5) [gem]" level="application" />
51
+ </component>
52
+ <component name="RakeTasksCache-v2">
53
+ <option name="myRootTask">
54
+ <RakeTaskImpl id="rake">
55
+ <subtasks>
56
+ <RakeTaskImpl description="Build bucket_sdk-0.1.0.gem into the pkg directory" fullCommand="build" id="build" />
57
+ <RakeTaskImpl id="build">
58
+ <subtasks>
59
+ <RakeTaskImpl description="Generate SHA512 checksum of bucket_sdk-0.1.0.gem into the checksums directory" fullCommand="build:checksum" id="checksum" />
60
+ </subtasks>
61
+ </RakeTaskImpl>
62
+ <RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
63
+ <RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
64
+ <RakeTaskImpl description="Build and install bucket_sdk-0.1.0.gem into system gems" fullCommand="install" id="install" />
65
+ <RakeTaskImpl id="install">
66
+ <subtasks>
67
+ <RakeTaskImpl description="Build and install bucket_sdk-0.1.0.gem into system gems without network access" fullCommand="install:local" id="local" />
68
+ </subtasks>
69
+ </RakeTaskImpl>
70
+ <RakeTaskImpl description="Create tag v0.1.0 and build and push bucket_sdk-0.1.0.gem to https://rubygems.org" fullCommand="release[remote]" id="release[remote]" />
71
+ <RakeTaskImpl description="Run RuboCop" fullCommand="rubocop" id="rubocop" />
72
+ <RakeTaskImpl id="rubocop">
73
+ <subtasks>
74
+ <RakeTaskImpl description="Autocorrect RuboCop offenses (only when it's safe)" fullCommand="rubocop:autocorrect" id="autocorrect" />
75
+ <RakeTaskImpl description="Autocorrect RuboCop offenses (safe and unsafe)" fullCommand="rubocop:autocorrect_all" id="autocorrect_all" />
76
+ <RakeTaskImpl description="" fullCommand="rubocop:auto_correct" id="auto_correct" />
77
+ </subtasks>
78
+ </RakeTaskImpl>
79
+ <RakeTaskImpl description="Run RSpec code examples" fullCommand="spec" id="spec" />
80
+ <RakeTaskImpl description="" fullCommand="default" id="default" />
81
+ <RakeTaskImpl description="" fullCommand="release" id="release" />
82
+ <RakeTaskImpl id="release">
83
+ <subtasks>
84
+ <RakeTaskImpl description="" fullCommand="release:guard_clean" id="guard_clean" />
85
+ <RakeTaskImpl description="" fullCommand="release:rubygem_push" id="rubygem_push" />
86
+ <RakeTaskImpl description="" fullCommand="release:source_control_push" id="source_control_push" />
87
+ </subtasks>
88
+ </RakeTaskImpl>
89
+ </subtasks>
90
+ </RakeTaskImpl>
91
+ </option>
92
+ </component>
93
93
  </module>
data/.idea/modules.xml CHANGED
@@ -1,8 +1,8 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/bucket-sdk.iml" filepath="$PROJECT_DIR$/.idea/bucket-sdk.iml" />
6
- </modules>
7
- </component>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/bucket-sdk.iml" filepath="$PROJECT_DIR$/.idea/bucket-sdk.iml" />
6
+ </modules>
7
+ </component>
8
8
  </project>
@@ -1,38 +1,38 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "bucket_sdk"
5
-
6
- # Initialize the client
7
- client = BucketSdk.new(
8
- base_url: "https://api.example.com"
9
- )
10
-
11
- # Upload an object
12
- begin
13
- response = client.upload_object(
14
- file: File.open('path/to/local/file.txt', 'r'),
15
- destination: "path/to/file.txt"
16
- )
17
- puts "File uploaded successfully. URL: #{response.url}"
18
- rescue BucketSdk::Error => e
19
- puts "Error uploading file: #{e.message}"
20
- end
21
-
22
- # List objects
23
- begin
24
- response = client.list_objects
25
- puts "Objects in bucket:"
26
- response.objects.each do |object|
27
- puts "- #{object.inspect}"
28
- end
29
-
30
- # List objects recursively
31
- response = client.list_objects(recurse: true)
32
- puts "\nAll objects (recursive):"
33
- response.objects.each do |object|
34
- puts "- #{object.inspect}"
35
- end
36
- rescue BucketSdk::Error => e
37
- puts "Error listing objects: #{e.message}"
38
- end
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bucket_sdk"
5
+
6
+ # Initialize the client
7
+ client = BucketSdk.new(
8
+ base_url: "https://api.example.com"
9
+ )
10
+
11
+ # Upload an object
12
+ begin
13
+ response = client.upload_object(
14
+ file: File.open("path/to/local/file.txt", "r"),
15
+ destination: "path/to/file.txt"
16
+ )
17
+ puts "File uploaded successfully. URL: #{response.url}"
18
+ rescue BucketSdk::Error => e
19
+ puts "Error uploading file: #{e.message}"
20
+ end
21
+
22
+ # List objects
23
+ begin
24
+ response = client.list_objects
25
+ puts "Objects in bucket:"
26
+ response.objects.each do |object|
27
+ puts "- #{object.inspect}"
28
+ end
29
+
30
+ # List objects recursively
31
+ response = client.list_objects(recurse: true)
32
+ puts "\nAll objects (recursive):"
33
+ response.objects.each do |object|
34
+ puts "- #{object.inspect}"
35
+ end
36
+ rescue BucketSdk::Error => e
37
+ puts "Error listing objects: #{e.message}"
38
+ end
@@ -1,72 +1,72 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "bundler/setup"
5
- require "bucket_sdk"
6
-
7
- # Initialize the client
8
- client = BucketSdk::Client.new(base_url: "http://localhost:8000")
9
-
10
- # Upload a file from disk using File object
11
- file_path = "README.md"
12
- destination = "uploads/readme.md"
13
- puts "Uploading #{file_path} to #{destination} using File object"
14
-
15
- begin
16
- response = client.upload_object(
17
- file: File.open(file_path, "r"),
18
- destination: destination
19
- )
20
- puts "File uploaded successfully!"
21
- puts "URL: #{response.url}"
22
- rescue => e
23
- puts "Error uploading file: #{e.message}"
24
- end
25
-
26
- # Upload a file from disk using file path
27
- file_path = "README.md"
28
- destination = "uploads/readme2.md"
29
- puts "\nUploading #{file_path} to #{destination} using file path"
30
-
31
- begin
32
- response = client.upload_object(
33
- file: file_path,
34
- destination: destination
35
- )
36
- puts "File uploaded successfully!"
37
- puts "URL: #{response.url}"
38
- rescue => e
39
- puts "Error uploading file: #{e.message}"
40
- end
41
-
42
- # Create a temporary file and upload it
43
- puts "\nUploading temporary file"
44
- temp_file = Tempfile.new('example')
45
- begin
46
- temp_file.write("Hello, world!")
47
- temp_file.rewind
48
-
49
- response = client.upload_object(
50
- file: temp_file,
51
- destination: "uploads/temp.txt"
52
- )
53
- puts "Temporary file uploaded successfully!"
54
- puts "URL: #{response.url}"
55
- rescue => e
56
- puts "Error uploading temporary file: #{e.message}"
57
- ensure
58
- temp_file.close
59
- temp_file.unlink
60
- end
61
-
62
- # List objects
63
- puts "\nListing objects:"
64
- begin
65
- response = client.list_objects(recurse: true)
66
- puts "Total objects: #{response.objects.count}"
67
- response.objects.each do |obj|
68
- puts "- #{obj.inspect}"
69
- end
70
- rescue => e
71
- puts "Error listing objects: #{e.message}"
72
- end
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "bucket_sdk"
6
+
7
+ # Initialize the client
8
+ client = BucketSdk::Client.new(base_url: "http://localhost:8000")
9
+
10
+ # Upload a file from disk using File object
11
+ file_path = "README.md"
12
+ destination = "uploads/readme.md"
13
+ puts "Uploading #{file_path} to #{destination} using File object"
14
+
15
+ begin
16
+ response = client.upload_object(
17
+ file: File.open(file_path, "r"),
18
+ destination: destination
19
+ )
20
+ puts "File uploaded successfully!"
21
+ puts "URL: #{response.url}"
22
+ rescue StandardError => e
23
+ puts "Error uploading file: #{e.message}"
24
+ end
25
+
26
+ # Upload a file from disk using file path
27
+ file_path = "README.md"
28
+ destination = "uploads/readme2.md"
29
+ puts "\nUploading #{file_path} to #{destination} using file path"
30
+
31
+ begin
32
+ response = client.upload_object(
33
+ file: file_path,
34
+ destination: destination
35
+ )
36
+ puts "File uploaded successfully!"
37
+ puts "URL: #{response.url}"
38
+ rescue StandardError => e
39
+ puts "Error uploading file: #{e.message}"
40
+ end
41
+
42
+ # Create a temporary file and upload it
43
+ puts "\nUploading temporary file"
44
+ temp_file = Tempfile.new("example")
45
+ begin
46
+ temp_file.write("Hello, world!")
47
+ temp_file.rewind
48
+
49
+ response = client.upload_object(
50
+ file: temp_file,
51
+ destination: "uploads/temp.txt"
52
+ )
53
+ puts "Temporary file uploaded successfully!"
54
+ puts "URL: #{response.url}"
55
+ rescue StandardError => e
56
+ puts "Error uploading temporary file: #{e.message}"
57
+ ensure
58
+ temp_file.close
59
+ temp_file.unlink
60
+ end
61
+
62
+ # List objects
63
+ puts "\nListing objects:"
64
+ begin
65
+ response = client.list_objects(recurse: true)
66
+ puts "Total objects: #{response.objects.count}"
67
+ response.objects.each do |obj|
68
+ puts "- #{obj.inspect}"
69
+ end
70
+ rescue StandardError => e
71
+ puts "Error listing objects: #{e.message}"
72
+ end
@@ -1,79 +1,81 @@
1
- # frozen_string_literal: true
2
-
3
- require "faraday"
4
- require "faraday/multipart"
5
- require "json"
6
- require "tempfile"
7
-
8
- class BucketSdk::Client
9
- attr_reader :base_url, :timeout
10
-
11
- def initialize(base_url:, timeout: 60)
12
- @base_url = base_url
13
- @timeout = timeout
14
- end
15
-
16
- # Upload an object to the bucket
17
- # @param file [File, String] The file to upload (either a File object or a path to a file)
18
- # @param destination [String] The destination path in the bucket
19
- # @return [Models::LoadResponse] The response containing the URL of the uploaded object
20
- def upload_object(file:, destination:)
21
- response = connection.post("/api/v2/objects") do |req|
22
- req.options.timeout = timeout
23
-
24
- # Set up multipart form data
25
- payload = {}
26
-
27
- if file.is_a?(File) || file.is_a?(Tempfile)
28
- payload[:file] = Faraday::Multipart::FilePart.new(file, 'application/octet-stream')
29
- elsif file.is_a?(String) && File.exist?(file)
30
- # If a string is provided and it's a valid file path, open the file
31
- payload[:file] = Faraday::Multipart::FilePart.new(File.open(file, 'r'), 'application/octet-stream')
32
- else
33
- raise ArgumentError, "File must be a File object or a valid file path"
34
- end
35
-
36
- req.params[:destination] = destination
37
- req.body = payload
38
- end
39
-
40
- handle_response(response, BucketSdk::Models::LoadResponse)
41
- end
42
-
43
- # List objects in the bucket
44
- # @param recurse [Boolean] Whether to list objects recursively (default: false)
45
- # @return [Models::ListResponse] The list of objects
46
- def list_objects(recurse: false)
47
- response = connection.get("/api/v2/objects") do |req|
48
- req.params[:recurse] = recurse
49
- end
50
-
51
- handle_response(response, BucketSdk::Models::ListResponse)
52
- end
53
-
54
- private
55
-
56
- def connection
57
- @connection ||= Faraday.new(url: base_url) do |conn|
58
- conn.request :multipart
59
- conn.request :json
60
-
61
- conn.headers["Accept"] = "application/json"
62
-
63
- conn.options.timeout = timeout
64
- conn.adapter Faraday.default_adapter
65
- end
66
- end
67
-
68
- def handle_response(response, model_class)
69
- case response.status
70
- when 200..299
71
- model_class.new(JSON.parse(response.body))
72
- when 422
73
- error_data = JSON.parse(response.body)
74
- raise BucketSdk::Models::ValidationError.new(error_data["detail"])
75
- else
76
- raise BucketSdk::Error, "API request failed with status #{response.status}: #{response.body}"
77
- end
78
- end
79
- end
1
+ # frozen_string_literal: true
2
+
3
+ require "faraday"
4
+ require "faraday/multipart"
5
+ require "json"
6
+ require "tempfile"
7
+
8
+ module BucketSdk
9
+ class Client
10
+ attr_reader :base_url, :timeout
11
+
12
+ def initialize(base_url:, timeout: 60)
13
+ @base_url = base_url
14
+ @timeout = timeout
15
+ end
16
+
17
+ # Upload an object to the bucket
18
+ # @param file [File, String] The file to upload (either a File object or a path to a file)
19
+ # @param destination [String] The destination path in the bucket
20
+ # @return [Models::LoadResponse] The response containing the URL of the uploaded object
21
+ def upload_object(file:, destination:)
22
+ response = connection.post("/api/v2/objects") do |req|
23
+ req.options.timeout = timeout
24
+
25
+ # Set up multipart form data
26
+ payload = {}
27
+
28
+ if file.is_a?(File) || file.is_a?(Tempfile)
29
+ payload[:file] = Faraday::Multipart::FilePart.new(file, "application/octet-stream")
30
+ elsif file.is_a?(String) && File.exist?(file)
31
+ # If a string is provided and it's a valid file path, open the file
32
+ payload[:file] = Faraday::Multipart::FilePart.new(File.open(file, "r"), "application/octet-stream")
33
+ else
34
+ raise ArgumentError, "File must be a File object or a valid file path"
35
+ end
36
+
37
+ req.params[:destination] = destination
38
+ req.body = payload
39
+ end
40
+
41
+ handle_response(response, BucketSdk::Models::LoadResponse)
42
+ end
43
+
44
+ # List objects in the bucket
45
+ # @param recurse [Boolean] Whether to list objects recursively (default: false)
46
+ # @return [Models::ListResponse] The list of objects
47
+ def list_objects(recurse: false)
48
+ response = connection.get("/api/v2/objects") do |req|
49
+ req.params[:recurse] = recurse
50
+ end
51
+
52
+ handle_response(response, BucketSdk::Models::ListResponse)
53
+ end
54
+
55
+ private
56
+
57
+ def connection
58
+ @connection ||= Faraday.new(url: base_url) do |conn|
59
+ conn.request :multipart
60
+ conn.request :json
61
+
62
+ conn.headers["Accept"] = "application/json"
63
+
64
+ conn.options.timeout = timeout
65
+ conn.adapter Faraday.default_adapter
66
+ end
67
+ end
68
+
69
+ def handle_response(response, model_class)
70
+ case response.status
71
+ when 200..299
72
+ model_class.new(JSON.parse(response.body))
73
+ when 422
74
+ error_data = JSON.parse(response.body)
75
+ raise BucketSdk::Models::ValidationError, error_data["detail"]
76
+ else
77
+ raise BucketSdk::Error, "API request failed with status #{response.status}: #{response.body}"
78
+ end
79
+ end
80
+ end
81
+ end
@@ -1,19 +1,19 @@
1
- # frozen_string_literal: true
2
-
3
- module BucketSdk
4
- module Models
5
- class ListResponse
6
- attr_reader :objects
7
-
8
- def initialize(data)
9
- @objects = data["objects"] || []
10
- end
11
-
12
- def to_h
13
- {
14
- objects: objects
15
- }
16
- end
17
- end
18
- end
19
- end
1
+ # frozen_string_literal: true
2
+
3
+ module BucketSdk
4
+ module Models
5
+ class ListResponse
6
+ attr_reader :objects
7
+
8
+ def initialize(data)
9
+ @objects = data["objects"] || []
10
+ end
11
+
12
+ def to_h
13
+ {
14
+ objects: objects
15
+ }
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,24 +1,24 @@
1
- # frozen_string_literal: true
2
-
3
- module BucketSdk
4
- module Models
5
- class LoadRequest
6
- attr_reader :file, :destination
7
-
8
- # Initialize a new LoadRequest
9
- # @param file [File, String] The file to upload (either a File object or a path to a file)
10
- # @param destination [String] The destination path in the bucket
11
- def initialize(file:, destination:)
12
- @file = file
13
- @destination = destination
14
- end
15
-
16
- def to_h
17
- {
18
- file: file,
19
- destination: destination
20
- }
21
- end
22
- end
23
- end
24
- end
1
+ # frozen_string_literal: true
2
+
3
+ module BucketSdk
4
+ module Models
5
+ class LoadRequest
6
+ attr_reader :file, :destination
7
+
8
+ # Initialize a new LoadRequest
9
+ # @param file [File, String] The file to upload (either a File object or a path to a file)
10
+ # @param destination [String] The destination path in the bucket
11
+ def initialize(file:, destination:)
12
+ @file = file
13
+ @destination = destination
14
+ end
15
+
16
+ def to_h
17
+ {
18
+ file: file,
19
+ destination: destination
20
+ }
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,19 +1,19 @@
1
- # frozen_string_literal: true
2
-
3
- module BucketSdk
4
- module Models
5
- class LoadResponse
6
- attr_reader :url
7
-
8
- def initialize(data)
9
- @url = data["url"]
10
- end
11
-
12
- def to_h
13
- {
14
- url: url
15
- }
16
- end
17
- end
18
- end
19
- end
1
+ # frozen_string_literal: true
2
+
3
+ module BucketSdk
4
+ module Models
5
+ class LoadResponse
6
+ attr_reader :url
7
+
8
+ def initialize(data)
9
+ @url = data["url"]
10
+ end
11
+
12
+ def to_h
13
+ {
14
+ url: url
15
+ }
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,20 +1,20 @@
1
- # frozen_string_literal: true
2
-
3
- module BucketSdk
4
- module Models
5
- class ValidationError < BucketSdk::Error
6
- attr_reader :details
7
-
8
- def initialize(details)
9
- @details = details
10
- super("Validation error: #{details.map { |d| "#{d['msg']} at #{d['loc'].join('.')}" }.join(', ')}")
11
- end
12
-
13
- def to_h
14
- {
15
- details: details
16
- }
17
- end
18
- end
19
- end
20
- end
1
+ # frozen_string_literal: true
2
+
3
+ module BucketSdk
4
+ module Models
5
+ class ValidationError < BucketSdk::Error
6
+ attr_reader :details
7
+
8
+ def initialize(details)
9
+ @details = details
10
+ super("Validation error: #{details.map { |d| "#{d["msg"]} at #{d["loc"].join(".")}" }.join(", ")}")
11
+ end
12
+
13
+ def to_h
14
+ {
15
+ details: details
16
+ }
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,11 +1,11 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "models/load_request"
4
- require_relative "models/load_response"
5
- require_relative "models/list_response"
6
- require_relative "models/validation_error"
7
-
8
- module BucketSdk
9
- module Models
10
- end
11
- end
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "models/load_request"
4
+ require_relative "models/load_response"
5
+ require_relative "models/list_response"
6
+ require_relative "models/validation_error"
7
+
8
+ module BucketSdk
9
+ module Models
10
+ end
11
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BucketSdk
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
data/lib/bucket_sdk.rb CHANGED
@@ -3,16 +3,16 @@
3
3
  require_relative "bucket_sdk/version"
4
4
 
5
5
  module BucketSdk
6
- class Error < StandardError; end
6
+ class Error < StandardError; end
7
7
 
8
- # Creates a new client instance
9
- # @param base_url [String] The base URL of the API
10
- # @param timeout [Integer] The timeout in seconds for API requests
11
- # @return [Bucket::Sdk::Client] A new client instance
12
- def self.new(base_url:, timeout: 60)
13
- Client.new(base_url: base_url, timeout: timeout)
14
- end
8
+ # Creates a new client instance
9
+ # @param base_url [String] The base URL of the API
10
+ # @param timeout [Integer] The timeout in seconds for API requests
11
+ # @return [Bucket::Sdk::Client] A new client instance
12
+ def self.new(base_url:, timeout: 60)
13
+ Client.new(base_url: base_url, timeout: timeout)
15
14
  end
15
+ end
16
16
 
17
17
  require_relative "bucket_sdk/models"
18
18
  require_relative "bucket_sdk/client"
@@ -1,8 +1,8 @@
1
- module BucketSdk
2
- class Client
3
- attr_reader base_url: string
4
- attr_reader timeout: int
5
-
6
- def upload_object: -> Models::LoadResponse
7
- end
8
- end
1
+ module BucketSdk
2
+ class Client
3
+ attr_reader base_url: string
4
+ attr_reader timeout: int
5
+
6
+ def upload_object: -> Models::LoadResponse
7
+ end
8
+ end
@@ -1,9 +1,9 @@
1
- module BucketSdk
2
- module Models
3
- class ListResponse
4
- attr_reader objects: array[untyped]
5
-
6
- def to_h: -> Hash[:objects, untyped]
7
- end
8
- end
9
- end
1
+ module BucketSdk
2
+ module Models
3
+ class ListResponse
4
+ attr_reader objects: array[untyped]
5
+
6
+ def to_h: -> Hash[:objects, untyped]
7
+ end
8
+ end
9
+ end
@@ -1,10 +1,10 @@
1
- module BucketSdk
2
- module Models
3
- class LoadRequest
4
- attr_reader data: untyped
5
- attr_reader destination: string
6
-
7
- def to_h: -> untyped
8
- end
9
- end
10
- end
1
+ module BucketSdk
2
+ module Models
3
+ class LoadRequest
4
+ attr_reader data: untyped
5
+ attr_reader destination: string
6
+
7
+ def to_h: -> untyped
8
+ end
9
+ end
10
+ end
@@ -1,7 +1,7 @@
1
- module BucketSdk
2
- module Models
3
- class LoadResponse
4
- attr_reader url: string
5
- end
6
- end
7
- end
1
+ module BucketSdk
2
+ module Models
3
+ class LoadResponse
4
+ attr_reader url: string
5
+ end
6
+ end
7
+ end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bucket_sdk
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
  - drutz-cpnv
8
+ autorequire:
8
9
  bindir: exe
9
10
  cert_chain: []
10
- date: 2025-03-23 00:00:00.000000000 Z
11
+ date: 2025-03-24 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: faraday
@@ -91,6 +92,7 @@ metadata:
91
92
  allowed_push_host: https://rubygems.org
92
93
  homepage_uri: https://github.com/drutz-cpnv/ria-bucket-sdk
93
94
  source_code_uri: https://github.com/drutz-cpnv/ria-bucket-sdk
95
+ post_install_message:
94
96
  rdoc_options: []
95
97
  require_paths:
96
98
  - lib
@@ -105,7 +107,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
107
  - !ruby/object:Gem::Version
106
108
  version: '0'
107
109
  requirements: []
108
- rubygems_version: 3.6.2
110
+ rubygems_version: 3.5.16
111
+ signing_key:
109
112
  specification_version: 4
110
113
  summary: Ruby SDK for the Bucket Storage Service
111
114
  test_files: []