bunny_cdn 1.1.0 → 1.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: bf754f9171d7ac48ac64209f2822859d5d2e29818930a6697c2b8f883f66440e
4
- data.tar.gz: 19b3e2827b72883c333fd5b32d57227adf78c2e5f58bbfe9ac3fe1fd6eb10621
3
+ metadata.gz: bea0b6898e3d9cea923f34e55c7c8d47d96ea1396a44bfd6926183a22cea11e8
4
+ data.tar.gz: 0cedfeca304e7c73baaaee1859bfc98581f822c55396b7cc11fb77d376885bff
5
5
  SHA512:
6
- metadata.gz: 11c8f7f14557a6430502d4771f593ecea2872b348d2ea300609ad5b250bf838659d812aa7198725ab98be932984908198d432b60e324ab8a4f3a664e40013584
7
- data.tar.gz: 255661ca9dc602fa9c319742446d0894b970cd654b30e97cb23bc85e95218058c3d9eff5599de1275bc681c3e8ac3e40e345478aa6fc093f287d32d203ca84fc
6
+ metadata.gz: db13a1be2ddfd7a85c89c7962fe5f25e88f64509b4aac2da5212770fdbd015a6e2b8651245a3cdc31a31474c59dd7e326e650fe47ea0f473ea206922a1892390
7
+ data.tar.gz: 1c66fc0ca92135505f098c63061d6461157a2a894803ff7adaab64f2d9a39ceeb1b46ac15524c07fe0c6d082bb71689a4e14cb075414b767006ea32f25e3b3f8
data/README.md CHANGED
@@ -34,7 +34,7 @@ Create the initializer `config/initializers/bunny_cdn.rb` and set the configurat
34
34
  BunnyCdn.configure do |config|
35
35
  config.apiKey = # The API key for your BunnyCDN account
36
36
  config.storageZone = # The storage zone you want to work with
37
- config.region = # the region of the storage zone. Options are 'eu' for Falkenstein, 'ny' for New York, or 'sg' for Asia
37
+ config.region = # the region of the storage zone. Options are 'eu' for Falkenstein, 'ny' for New York, 'la' for Los Angeles, or 'sg' for Asia
38
38
  config.accessKey = # The password for your storage zone
39
39
  end
40
40
  ```
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.add_dependency 'json', '~> 2.3'
33
33
 
34
34
  spec.add_development_dependency "bundler", "~> 2.0"
35
- spec.add_development_dependency "rake", ">= 12.3.3"
35
+ spec.add_development_dependency "rake", "~> 12.3", ">= 12.3.3"
36
36
  spec.add_development_dependency "rspec", "~> 3.0"
37
37
  spec.add_development_dependency "webmock", '~> 3.8', '>= 3.8.3'
38
38
 
@@ -2,9 +2,10 @@ module BunnyCdn
2
2
  class Configuration
3
3
  attr_accessor :storageZone, :region, :accessKey, :apiKey
4
4
 
5
+ # Sets the configuration variables upon calling BunnyCdn::Configuration.new
5
6
  def initialize
6
7
  @storageZone = nil
7
- @region = nil # Options are: eu, ny or sg (Asia)
8
+ @region = nil # Options are: eu, ny, la or sg (Asia)
8
9
  @accessKey = nil
9
10
  @apiKey = nil
10
11
  end
@@ -14,7 +15,6 @@ module BunnyCdn
14
15
  @configuration ||= Configuration.new
15
16
  end
16
17
 
17
- # Set BunnyCdn's configuration
18
18
  def self.configuration=(config)
19
19
  @configuration = config
20
20
  end
@@ -3,12 +3,14 @@ module BunnyCdn
3
3
 
4
4
  RestClient.log = STDOUT # enables RestClient logging
5
5
 
6
- BASE_URL = 'https://bunnycdn.com/api/pullzone'
6
+ BASE_URL = 'https://bunnycdn.com/api/pullzone' # URL to for BunnyCDN's Pullzone API
7
7
 
8
+ # Sets the apiKey to that in configuration
8
9
  def self.apiKey
9
10
  @apiKey = BunnyCdn.configuration.apiKey
10
11
  end
11
12
 
13
+ # Sets the necessary headers to make requests to the BunnyCDN API
12
14
  def self.headers
13
15
  {
14
16
  :accesskey => apiKey,
@@ -17,6 +19,7 @@ module BunnyCdn
17
19
  }
18
20
  end
19
21
 
22
+ # Gets all Pull Zones from BunnyCDN
20
23
  def self.getAllPullzones
21
24
  begin
22
25
  response = RestClient.get(BASE_URL, headers)
@@ -26,6 +29,11 @@ module BunnyCdn
26
29
  return response
27
30
  end
28
31
 
32
+ # Creates a new pullzone
33
+ # Params:
34
+ # +name+:: the name of the new Pull Zone
35
+ # +type+:: the pricing type of the pull zone you wish to add. 0 = Standard, 1 = High Volume
36
+ # originURL+:: the origin URL where the pull zone files are pulled from.
29
37
  def self.createPullzone(name, type = 0, originUrl)
30
38
  values = {
31
39
  :name => name,
@@ -40,6 +48,9 @@ module BunnyCdn
40
48
  return response
41
49
  end
42
50
 
51
+ # Gets the details of the pull zone using the given ID
52
+ # Params:
53
+ # +id+:: the ID of the Pull Zone to return
43
54
  def self.getSinglePullzone(id)
44
55
  begin
45
56
  response = RestClient.get("#{BASE_URL}/#{id}", headers)
@@ -49,6 +60,9 @@ module BunnyCdn
49
60
  return response
50
61
  end
51
62
 
63
+ # Deletes the pull zone using the given ID
64
+ # Params:
65
+ # +id+:: the ID of the Pull Zone to delete
52
66
  def self.deletePullzone(id)
53
67
  begin
54
68
  response = RestClient.delete("#{BASE_URL}/#{id}", headers)
@@ -58,6 +72,9 @@ module BunnyCdn
58
72
  return response
59
73
  end
60
74
 
75
+ # Purges the cache for the Pull Zone using the given ID
76
+ # Params:
77
+ # +id+:: the ID of the zone which should have the cache purged
61
78
  def self.purgeCache(id)
62
79
  begin
63
80
  response = RestClient.post("#{BASE_URL}/#{id}/purgeCache", {}.to_json, headers)
@@ -3,9 +3,11 @@ module BunnyCdn
3
3
 
4
4
  RestClient.log = STDOUT # enables RestClient logging
5
5
 
6
+ # Sets the storage zone as set in configuration
6
7
  def self.storageZone
7
8
  BunnyCdn.configuration.storageZone
8
9
  end
10
+
9
11
  # Sets the proper URL based on the region set in configuration
10
12
  def self.set_region_url
11
13
  case BunnyCdn.configuration.region
@@ -13,21 +15,28 @@ module BunnyCdn
13
15
  'https://storage.bunnycdn.com'
14
16
  when 'ny'
15
17
  'https://ny.storage.bunnycdn.com'
18
+ when 'la'
19
+ 'https://la.storage.bunnycdn.com'
16
20
  when 'sg'
17
21
  'https://sg.storage.bunnycdn.com'
18
22
  end
19
23
  end
20
-
24
+
25
+ # Sets the apiKey to that in configuration
21
26
  def self.apiKey
22
27
  BunnyCdn.configuration.accessKey
23
28
  end
24
29
 
30
+ # Sets the necessary headers to make requests to the BunnyCDN API
25
31
  def self.headers
26
32
  {
27
33
  :accesskey => apiKey
28
34
  }
29
35
  end
30
36
 
37
+ # Gets all the files from the storage zone
38
+ # Params:
39
+ # +path+:: desired path to get files
31
40
  def self.getZoneFiles(path= '')
32
41
  begin
33
42
  response = RestClient.get("#{set_region_url}/#{storageZone}/#{path}", headers)
@@ -37,6 +46,10 @@ module BunnyCdn
37
46
  return response.body
38
47
  end
39
48
 
49
+ # Gets a single file from the storage zone
50
+ # Params:
51
+ # +path+:: desired path to get file
52
+ # +file+:: specific file to get from storage zone
40
53
  def self.getFile(path= '', file)
41
54
  begin
42
55
  response = RestClient.get("#{set_region_url}/#{storageZone}/#{path}/#{file}", headers)
@@ -46,6 +59,10 @@ module BunnyCdn
46
59
  return response.body
47
60
  end
48
61
 
62
+ # Uploads a file to the storage zone
63
+ # Params:
64
+ # +path+:: desired path to upload file
65
+ # +file+:: specific file to upload to storage zone
49
66
  def self.uploadFile(path= '', file)
50
67
  fileName = File.basename(file)
51
68
  headers = {
@@ -60,6 +77,10 @@ module BunnyCdn
60
77
  return response.body
61
78
  end
62
79
 
80
+ # Deletes a file from the storage zone
81
+ # Params:
82
+ # +path+:: path to delete file from
83
+ # +file+:: specific file to delete from storage zone
63
84
  def self.deleteFile(path= '', file)
64
85
  begin
65
86
  response = RestClient.delete("#{set_region_url}/#{storageZone}/#{path}/#{file}", headers)
@@ -1,3 +1,3 @@
1
1
  module BunnyCdn
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bunny_cdn
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Meeks
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-08 00:00:00.000000000 Z
11
+ date: 2020-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -56,6 +56,9 @@ dependencies:
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '12.3'
59
62
  - - ">="
60
63
  - !ruby/object:Gem::Version
61
64
  version: 12.3.3
@@ -63,6 +66,9 @@ dependencies:
63
66
  prerelease: false
64
67
  version_requirements: !ruby/object:Gem::Requirement
65
68
  requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '12.3'
66
72
  - - ">="
67
73
  - !ruby/object:Gem::Version
68
74
  version: 12.3.3