bunnyrb 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: 6798312b6bf1d864caf87e8331507defe7facee7e64457883f67560a4c80e066
4
- data.tar.gz: 9b5cc5bd385953364c54506745ed2a0f04b5fe9b92644562ad615e094a81df62
3
+ metadata.gz: 41968365eb6493147602183e1dd012fb715f96008f7ce5df4732af4f061e3b26
4
+ data.tar.gz: 2ad19c203efb1b34275caf9b8f191759f46d9662851cb2f1d55fc3990fceed3d
5
5
  SHA512:
6
- metadata.gz: 21ef362e4cf360bea1d3aa75fd3375707da629213b0ef439e9f2ee22f56f3d3c06f82a4a9380148e021fcdcd2aa5eac90f12bc570b8de16fa752fedc3731f032
7
- data.tar.gz: 144602b91d7a09fbba760645dd034fa74b6741bcecbb758936ee0bc2c84963b05137f3d45de6757a200d8ded6605c618b97e68574ce4183a19691f9a8ef7cc80
6
+ metadata.gz: 43db54ef0574d4e3bdcd311f058c41a841584592b6f7446c77952e3c2054d2b143e5ea5a9294ebe24e414ff625692a86f3f1ae24653192192a878768182efd18
7
+ data.tar.gz: 6c2339499332a2e7a622eae723e2c2744ebe671bf667b7f20b18182ed74b76f353c5f7d40b116fe9546bc21cf54658a192a67f36368b64056a378ec622121bf0
@@ -1,8 +1,22 @@
1
1
  name: CI
2
2
  on: push
3
3
  jobs:
4
+ lint:
5
+ runs-on: ubuntu-latest
6
+ steps:
7
+ - name: Checkout code
8
+ uses: actions/checkout@v4
9
+ - name: Set up Ruby
10
+ uses: ruby/setup-ruby@v1
11
+ with:
12
+ ruby-version: 3.3
13
+ bundler-cache: true
14
+ - name: Lint code for consistent style
15
+ run: bundle exec rubocop -f github
16
+
4
17
  test:
5
18
  runs-on: ubuntu-latest
19
+ needs: [lint]
6
20
  strategy:
7
21
  fail-fast: false
8
22
  matrix:
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ # Omakase Ruby styling for Rails
2
+ inherit_gem: { rubocop-rails-omakase: rubocop.yml }
3
+
4
+ # Overwrite or add rules to create your own house style
5
+ #
6
+ # # Use `[a, [b, c]]` not `[ a, [ b, c ] ]`
7
+ # Layout/SpaceInsideArrayLiteralBrackets:
8
+ # Enabled: false
data/Gemfile CHANGED
@@ -6,5 +6,5 @@ gemspec
6
6
  gem "rake", "~> 12.0"
7
7
  gem "minitest", "~> 5.0"
8
8
  gem "dotenv"
9
-
10
9
  gem "vcr"
10
+ gem "rubocop-rails-omakase", require: false
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bunnyrb (0.1.0)
4
+ bunnyrb (0.1.1)
5
5
  faraday (~> 2.0)
6
6
  faraday-multipart (~> 1.0)
7
7
  marcel (~> 1.0)
@@ -9,19 +9,84 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
+ activesupport (7.1.3.4)
13
+ base64
14
+ bigdecimal
15
+ concurrent-ruby (~> 1.0, >= 1.0.2)
16
+ connection_pool (>= 2.2.5)
17
+ drb
18
+ i18n (>= 1.6, < 2)
19
+ minitest (>= 5.1)
20
+ mutex_m
21
+ tzinfo (~> 2.0)
22
+ ast (2.4.2)
23
+ base64 (0.2.0)
24
+ bigdecimal (3.1.8)
25
+ concurrent-ruby (1.3.3)
26
+ connection_pool (2.4.1)
12
27
  dotenv (3.1.2)
28
+ drb (2.2.1)
13
29
  faraday (2.9.1)
14
30
  faraday-net_http (>= 2.0, < 3.2)
15
31
  faraday-multipart (1.0.4)
16
32
  multipart-post (~> 2)
17
33
  faraday-net_http (3.1.0)
18
34
  net-http
35
+ i18n (1.14.5)
36
+ concurrent-ruby (~> 1.0)
37
+ json (2.7.2)
38
+ language_server-protocol (3.17.0.3)
19
39
  marcel (1.0.4)
20
40
  minitest (5.23.1)
21
41
  multipart-post (2.4.1)
42
+ mutex_m (0.2.0)
22
43
  net-http (0.4.1)
23
44
  uri
45
+ parallel (1.25.1)
46
+ parser (3.3.3.0)
47
+ ast (~> 2.4.1)
48
+ racc
49
+ racc (1.8.0)
50
+ rack (3.1.3)
51
+ rainbow (3.1.1)
24
52
  rake (12.3.3)
53
+ regexp_parser (2.9.2)
54
+ rexml (3.3.0)
55
+ strscan
56
+ rubocop (1.64.1)
57
+ json (~> 2.3)
58
+ language_server-protocol (>= 3.17.0)
59
+ parallel (~> 1.10)
60
+ parser (>= 3.3.0.2)
61
+ rainbow (>= 2.2.2, < 4.0)
62
+ regexp_parser (>= 1.8, < 3.0)
63
+ rexml (>= 3.2.5, < 4.0)
64
+ rubocop-ast (>= 1.31.1, < 2.0)
65
+ ruby-progressbar (~> 1.7)
66
+ unicode-display_width (>= 2.4.0, < 3.0)
67
+ rubocop-ast (1.31.3)
68
+ parser (>= 3.3.1.0)
69
+ rubocop-minitest (0.35.0)
70
+ rubocop (>= 1.61, < 2.0)
71
+ rubocop-ast (>= 1.31.1, < 2.0)
72
+ rubocop-performance (1.21.0)
73
+ rubocop (>= 1.48.1, < 2.0)
74
+ rubocop-ast (>= 1.31.1, < 2.0)
75
+ rubocop-rails (2.25.0)
76
+ activesupport (>= 4.2.0)
77
+ rack (>= 1.1)
78
+ rubocop (>= 1.33.0, < 2.0)
79
+ rubocop-ast (>= 1.31.1, < 2.0)
80
+ rubocop-rails-omakase (1.0.0)
81
+ rubocop
82
+ rubocop-minitest
83
+ rubocop-performance
84
+ rubocop-rails
85
+ ruby-progressbar (1.13.0)
86
+ strscan (3.1.0)
87
+ tzinfo (2.0.6)
88
+ concurrent-ruby (~> 1.0)
89
+ unicode-display_width (2.5.0)
25
90
  uri (0.13.0)
26
91
  vcr (6.2.0)
27
92
 
@@ -33,6 +98,7 @@ DEPENDENCIES
33
98
  dotenv
34
99
  minitest (~> 5.0)
35
100
  rake (~> 12.0)
101
+ rubocop-rails-omakase
36
102
  vcr
37
103
 
38
104
  BUNDLED WITH
data/README.md CHANGED
@@ -19,7 +19,11 @@ and then configure it like below.
19
19
 
20
20
  ```ruby
21
21
  Bunny.configure do |config|
22
- config.api_token = ENV["BUNNT_API_KEY"]
22
+ config.api_token = ENV["BUNNY_API_KEY"]
23
+
24
+ config.edge_name = ENV["BUNNY_EDGE_NAME"]
25
+ config.edge_region = ENV["BUNNY_EDGE_REGION"]
26
+ config.edge_api_token = ENV["BUNNY_EDGE_API_TOKEN"]
23
27
  end
24
28
  ```
25
29
 
data/Rakefile CHANGED
@@ -7,4 +7,4 @@ Rake::TestTask.new(:test) do |t|
7
7
  t.test_files = FileList["test/**/*_test.rb"]
8
8
  end
9
9
 
10
- task :default => :test
10
+ task default: :test
data/bunnyrb.gemspec CHANGED
@@ -3,8 +3,8 @@ require_relative 'lib/bunny/version'
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "bunnyrb"
5
5
  spec.version = Bunny::VERSION
6
- spec.authors = ["Dean Perry"]
7
- spec.email = ["dean@deanpcmad.com"]
6
+ spec.authors = [ "Dean Perry" ]
7
+ spec.email = [ "dean@deanpcmad.com" ]
8
8
 
9
9
  spec.summary = "A Ruby library for the Bunny APIs"
10
10
  spec.homepage = "https://deanpcmad.com"
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  end
23
23
  spec.bindir = "exe"
24
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
- spec.require_paths = ["lib"]
25
+ spec.require_paths = [ "lib" ]
26
26
 
27
27
  spec.add_dependency "faraday", "~> 2.0"
28
28
  spec.add_dependency "faraday-multipart", "~> 1.0"
data/lib/bunny/client.rb CHANGED
@@ -1,10 +1,8 @@
1
1
  module Bunny
2
2
  class Client
3
-
4
3
  BASE_URL = "https://api.bunny.net"
5
4
 
6
5
  class << self
7
-
8
6
  def connection
9
7
  @connection ||= Faraday.new(BASE_URL) do |conn|
10
8
  conn.headers = {
@@ -69,6 +67,5 @@ module Bunny
69
67
  response
70
68
  end
71
69
  end
72
-
73
70
  end
74
71
  end
@@ -2,9 +2,7 @@
2
2
 
3
3
  module Bunny
4
4
  class Configuration
5
-
6
5
  attr_accessor :api_token
7
- attr_accessor :edge_region, :edge_api_token
8
-
6
+ attr_accessor :edge_name, :edge_region, :edge_api_token
9
7
  end
10
8
  end
@@ -1,9 +1,7 @@
1
1
  module Bunny
2
2
  module Edge
3
3
  class Client
4
-
5
4
  class << self
6
-
7
5
  def url
8
6
  raise "An Edge Region must be specified" unless Bunny.config.edge_region
9
7
  case Bunny.config.edge_region.downcase
@@ -110,7 +108,6 @@ module Bunny
110
108
  response
111
109
  end
112
110
  end
113
-
114
111
  end
115
112
  end
116
113
  end
@@ -1,25 +1,23 @@
1
1
  module Bunny
2
2
  module Edge
3
3
  class Upload < Object
4
-
5
4
  class << self
6
-
7
- def list(zone:, path:)
5
+ def list(zone: Bunny.config.edge_name, path:)
8
6
  response = Edge::Client.get_request("#{zone}/#{path}")
9
7
  Collection.from_response(response, type: Upload)
10
8
  end
11
9
 
12
- def create(zone:, path:, name:, file:)
10
+ def create(zone: Bunny.config.edge_name, path:, name:, file:)
13
11
  headers = {
14
12
  "Content-Type" => Marcel::MimeType.for(file),
15
13
  "Content-Length" => file.size.to_s
16
14
  }
17
- response = Edge::Client.put_request([zone, path, name].join("/"), body: file, headers: headers)
15
+ response = Edge::Client.put_request([ zone, path, name ].join("/"), body: file, headers: headers)
18
16
  response.success?
19
17
  end
20
18
 
21
- def download(zone:, path:, name:)
22
- response = Edge::Client.get_request([zone, path, name].join("/"))
19
+ def download(zone: Bunny.config.edge_name, path:, name:)
20
+ response = Edge::Client.get_request([ zone, path, name ].join("/"))
23
21
 
24
22
  tempfile = Tempfile.new
25
23
  tempfile.binmode
@@ -30,12 +28,10 @@ module Bunny
30
28
  end
31
29
 
32
30
  def delete(zone:, path:, name:)
33
- response = Edge::Client.delete_request([zone, path, name].join("/"))
31
+ response = Edge::Client.delete_request([ zone, path, name ].join("/"))
34
32
  response.success?
35
33
  end
36
-
37
34
  end
38
-
39
35
  end
40
36
  end
41
37
  end
@@ -1,14 +1,10 @@
1
1
  module Bunny
2
2
  class Country < Object
3
-
4
3
  class << self
5
-
6
4
  def list
7
5
  response = Client.get_request("country")
8
6
  Collection.from_response(response, type: Country)
9
7
  end
10
-
11
8
  end
12
-
13
9
  end
14
10
  end
@@ -1,8 +1,6 @@
1
1
  module Bunny
2
2
  class PullZone < Object
3
-
4
3
  class << self
5
-
6
4
  def list
7
5
  response = Client.get_request("pullzone")
8
6
  Collection.from_response(response, type: PullZone)
@@ -30,8 +28,6 @@ module Bunny
30
28
  def purge(id:)
31
29
  Client.post_request("pullzone/#{id}/purgeCache", body: {})
32
30
  end
33
-
34
31
  end
35
-
36
32
  end
37
33
  end
@@ -1,14 +1,10 @@
1
1
  module Bunny
2
2
  class Region < Object
3
-
4
3
  class << self
5
-
6
4
  def list
7
5
  response = Client.get_request("region")
8
6
  Collection.from_response(response, type: Region)
9
7
  end
10
-
11
8
  end
12
-
13
9
  end
14
10
  end
@@ -1,8 +1,6 @@
1
1
  module Bunny
2
2
  class StorageZone < Object
3
-
4
3
  class << self
5
-
6
4
  def list
7
5
  response = Client.get_request("storagezone")
8
6
  Collection.from_response(response, type: StorageZone)
@@ -25,8 +23,6 @@ module Bunny
25
23
  def delete(id:)
26
24
  Client.delete_request("storagezone/#{id}")
27
25
  end
28
-
29
26
  end
30
-
31
27
  end
32
28
  end
@@ -1,8 +1,6 @@
1
1
  module Bunny
2
2
  class VideoLibrary < Object
3
-
4
3
  class << self
5
-
6
4
  def list
7
5
  response = Client.get_request("videolibrary")
8
6
  Collection.from_response(response, type: VideoLibrary)
@@ -26,8 +24,6 @@ module Bunny
26
24
  def delete(id:)
27
25
  Client.delete_request("videolibrary/#{id}")
28
26
  end
29
-
30
27
  end
31
-
32
28
  end
33
29
  end
@@ -1,8 +1,6 @@
1
1
  module Bunny
2
2
  class Zone < Object
3
-
4
3
  class << self
5
-
6
4
  def list
7
5
  response = Client.get_request("dnszone")
8
6
  Collection.from_response(response, type: Zone, key: "Items")
@@ -54,8 +52,6 @@ module Bunny
54
52
  def delete_record(zone:, record:)
55
53
  Client.delete_request("dnszone/#{zone}/records/#{record}")
56
54
  end
57
-
58
55
  end
59
-
60
56
  end
61
57
  end
data/lib/bunny/object.rb CHANGED
@@ -8,7 +8,7 @@ module Bunny
8
8
 
9
9
  def to_ostruct(obj)
10
10
  if obj.is_a?(Hash)
11
- OpenStruct.new(obj.map { |key, val| [camel_to_snake(key), to_ostruct(val)] }.to_h)
11
+ OpenStruct.new(obj.map { |key, val| [ camel_to_snake(key), to_ostruct(val) ] }.to_h)
12
12
  elsif obj.is_a?(Array)
13
13
  obj.map { |o| to_ostruct(o) }
14
14
  else # Assumed to be a primitive value
@@ -19,7 +19,7 @@ module Bunny
19
19
  def camel_to_snake(input)
20
20
  str = input.is_a?(Symbol) ? input.to_s : input
21
21
  snake_case_str = str.gsub(/([A-Z])/, '_\1').downcase
22
- snake_case_str.sub!(/^_/, '')
22
+ snake_case_str.sub!(/^_/, "")
23
23
  input.is_a?(Symbol) ? snake_case_str.to_sym : snake_case_str
24
24
  end
25
25
  end
data/lib/bunny/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Bunny
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/bunny.rb CHANGED
@@ -5,7 +5,6 @@ require "marcel"
5
5
  require_relative "bunny/version"
6
6
 
7
7
  module Bunny
8
-
9
8
  autoload :Configuration, "bunny/configuration"
10
9
  autoload :Client, "bunny/client"
11
10
  autoload :Collection, "bunny/collection"
@@ -39,5 +38,4 @@ module Bunny
39
38
  autoload :Client, "bunny/edge/client"
40
39
  autoload :Upload, "bunny/edge/models/upload"
41
40
  end
42
-
43
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bunnyrb
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
  - Dean Perry
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-06-10 00:00:00.000000000 Z
11
+ date: 2024-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -63,6 +63,7 @@ files:
63
63
  - ".github/FUNDING.yml"
64
64
  - ".github/workflows/ci.yml"
65
65
  - ".gitignore"
66
+ - ".rubocop.yml"
66
67
  - Gemfile
67
68
  - Gemfile.lock
68
69
  - LICENSE.txt