cloudflair 0.2.5 → 0.3.0
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 +4 -4
- data/.rubocop.yml +38 -0
- data/.ruby-gemset +1 -0
- data/Gemfile +2 -0
- data/Rakefile +2 -0
- data/VERSION +1 -1
- data/cloudflair.gemspec +7 -6
- data/lib/cloudflair.rb +2 -0
- data/lib/cloudflair/api.rb +2 -0
- data/lib/cloudflair/api/railguns.rb +2 -0
- data/lib/cloudflair/api/zone.rb +2 -0
- data/lib/cloudflair/api/zone/analytics.rb +2 -0
- data/lib/cloudflair/api/zone/available_plan.rb +2 -0
- data/lib/cloudflair/api/zone/available_rate_plan.rb +2 -0
- data/lib/cloudflair/api/zone/custom_hostname.rb +2 -0
- data/lib/cloudflair/api/zone/dns_record.rb +3 -0
- data/lib/cloudflair/api/zone/purge_cache.rb +2 -0
- data/lib/cloudflair/api/zone/railgun.rb +2 -0
- data/lib/cloudflair/api/zone/settings.rb +30 -28
- data/lib/cloudflair/api/zone/settings/advanced_ddos.rb +2 -0
- data/lib/cloudflair/api/zone/settings/always_online.rb +2 -0
- data/lib/cloudflair/api/zone/settings/browser_cache_ttl.rb +2 -0
- data/lib/cloudflair/api/zone/settings/browser_check.rb +2 -0
- data/lib/cloudflair/api/zone/settings/cache_level.rb +2 -0
- data/lib/cloudflair/api/zone/settings/challenge_ttl.rb +2 -0
- data/lib/cloudflair/api/zone/settings/development_mode.rb +2 -0
- data/lib/cloudflair/api/zone/settings/email_obfuscation.rb +2 -0
- data/lib/cloudflair/api/zone/settings/hotlink_protection.rb +2 -0
- data/lib/cloudflair/api/zone/settings/ip_geolocation.rb +2 -0
- data/lib/cloudflair/api/zone/settings/ipv6.rb +2 -0
- data/lib/cloudflair/api/zone/settings/minify.rb +2 -0
- data/lib/cloudflair/api/zone/settings/mirage.rb +2 -0
- data/lib/cloudflair/api/zone/settings/mobile_redirect.rb +2 -0
- data/lib/cloudflair/api/zone/settings/origin_error_page_pass_thru.rb +2 -0
- data/lib/cloudflair/api/zone/settings/polish.rb +2 -0
- data/lib/cloudflair/api/zone/settings/prefetch_preload.rb +2 -0
- data/lib/cloudflair/api/zone/settings/response_buffering.rb +2 -0
- data/lib/cloudflair/api/zone/settings/rocket_loader.rb +2 -0
- data/lib/cloudflair/api/zone/settings/security_header.rb +2 -0
- data/lib/cloudflair/api/zone/settings/security_level.rb +2 -0
- data/lib/cloudflair/api/zone/settings/server_side_exclude.rb +2 -0
- data/lib/cloudflair/api/zone/settings/sort_query_string_for_cache.rb +2 -0
- data/lib/cloudflair/api/zone/settings/ssl.rb +2 -0
- data/lib/cloudflair/api/zone/settings/tls_1_2_only.rb +2 -0
- data/lib/cloudflair/api/zone/settings/tls_1_3.rb +2 -0
- data/lib/cloudflair/api/zone/settings/tls_client_auth.rb +2 -0
- data/lib/cloudflair/api/zone/settings/true_client_ip_header.rb +2 -0
- data/lib/cloudflair/api/zone/settings/waf.rb +2 -0
- data/lib/cloudflair/api/zone/settings/websockets.rb +2 -0
- data/lib/cloudflair/api/zone__available_plans.rb +2 -0
- data/lib/cloudflair/api/zone__custom_hostnames.rb +2 -0
- data/lib/cloudflair/api/zone__dns_records.rb +2 -2
- data/lib/cloudflair/api/zone__railguns.rb +2 -0
- data/lib/cloudflair/communication.rb +23 -20
- data/lib/cloudflair/connection.rb +21 -12
- data/lib/cloudflair/entity.rb +41 -42
- data/lib/cloudflair/error/cloudflair_error.rb +2 -0
- data/lib/cloudflair/error/cloudflare_error.rb +2 -0
- data/lib/cloudflair/version.rb +2 -0
- metadata +40 -24
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a94ec96903e9723de8176769d1ca3fa0a3d51fda907b6d53b17b7ad163cb73b0
|
|
4
|
+
data.tar.gz: 73d08b577e5c0bbd77d8f79afec19cb407882c03c6775aefa2da37ced0e60f22
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 521bc18990e5dd9d733da59353377385d95dc9c7e3d3342a9e79ff6dde48fa07ccc91be13420456fd4fc823c1bfdd92e1b1c20187cc9b76e7b1be865edc9415b
|
|
7
|
+
data.tar.gz: 76e763b2a0ad7614217b214ff19521af5c75b6ccfe4235a09450ce0878499632e32d172149fe6e1b855d90ff6db71b4338173ed3ff7e562bdeab38551280d893
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require:
|
|
2
|
+
- rubocop-performance
|
|
3
|
+
- rubocop-rspec
|
|
4
|
+
|
|
5
|
+
AllCops:
|
|
6
|
+
Exclude:
|
|
7
|
+
- 'bin/**/*'
|
|
8
|
+
- 'db/**/*'
|
|
9
|
+
TargetRubyVersion: 2.6.1
|
|
10
|
+
|
|
11
|
+
Layout/AlignHash:
|
|
12
|
+
EnforcedColonStyle: table
|
|
13
|
+
EnforcedHashRocketStyle: table
|
|
14
|
+
|
|
15
|
+
Metrics/BlockLength:
|
|
16
|
+
Exclude:
|
|
17
|
+
- Guardfile
|
|
18
|
+
- 'spec/**/*spec.rb'
|
|
19
|
+
|
|
20
|
+
Metrics/LineLength:
|
|
21
|
+
Exclude:
|
|
22
|
+
- Guardfile
|
|
23
|
+
Max: 110
|
|
24
|
+
|
|
25
|
+
Rails:
|
|
26
|
+
Enabled: true
|
|
27
|
+
|
|
28
|
+
Rails/HttpPositionalArguments:
|
|
29
|
+
Exclude:
|
|
30
|
+
|
|
31
|
+
Rails/SkipsModelValidations:
|
|
32
|
+
Enabled: false
|
|
33
|
+
|
|
34
|
+
RSpec/MultipleExpectations:
|
|
35
|
+
Enabled: false
|
|
36
|
+
|
|
37
|
+
Style/Documentation:
|
|
38
|
+
Enabled: false
|
data/.ruby-gemset
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cloudflair
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.3.0
|
data/cloudflair.gemspec
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
lib = File.expand_path('
|
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
require 'cloudflair/version'
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
|
8
8
|
spec.name = 'cloudflair'
|
|
9
9
|
spec.version = File.read('VERSION')
|
|
10
10
|
spec.authors = ['Christian Mäder']
|
|
11
|
-
spec.email = %w
|
|
11
|
+
spec.email = %w[christian.maeder@nine.ch]
|
|
12
12
|
|
|
13
13
|
spec.summary = "Wrapper to CloudFlare's v4 REST API."
|
|
14
14
|
spec.description = "Cloudflair aims to provide easy access to CloudFlare's public API."
|
|
@@ -22,15 +22,16 @@ Gem::Specification.new do |spec|
|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
23
23
|
spec.require_paths = %w[lib]
|
|
24
24
|
|
|
25
|
-
spec.add_runtime_dependency 'faraday', '>= 0.10.0'
|
|
26
|
-
spec.add_runtime_dependency 'faraday_middleware'
|
|
27
25
|
spec.add_runtime_dependency 'dry-configurable', '~> 0.1'
|
|
26
|
+
spec.add_runtime_dependency 'faraday', '>= 0.10.0'
|
|
28
27
|
spec.add_runtime_dependency 'faraday-detailed_logger'
|
|
28
|
+
spec.add_runtime_dependency 'faraday_middleware'
|
|
29
29
|
|
|
30
30
|
spec.add_development_dependency 'bundler', '~> 2.0.0'
|
|
31
|
+
spec.add_development_dependency 'dotenv', '~> 2.1'
|
|
31
32
|
spec.add_development_dependency 'rake', '~> 12.0'
|
|
32
33
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
|
33
|
-
spec.add_development_dependency 'dotenv', '~> 2.1'
|
|
34
34
|
spec.add_development_dependency 'rubocop', '~> 0.48'
|
|
35
|
+
spec.add_development_dependency 'rubocop-performance'
|
|
35
36
|
spec.add_development_dependency 'rubocop-rspec', '~> 1.15'
|
|
36
37
|
end
|
data/lib/cloudflair.rb
CHANGED
data/lib/cloudflair/api.rb
CHANGED
data/lib/cloudflair/api/zone.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'cloudflair/entity'
|
|
2
4
|
|
|
3
5
|
module Cloudflair
|
|
@@ -6,6 +8,7 @@ module Cloudflair
|
|
|
6
8
|
|
|
7
9
|
attr_reader :zone_id, :record_id
|
|
8
10
|
deletable true
|
|
11
|
+
patchable_fields :content
|
|
9
12
|
path 'zones/:zone_id/dns_records/:record_id'
|
|
10
13
|
|
|
11
14
|
def initialize(zone_id, record_id)
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'cloudflair/api/zone/settings/advanced_ddos'
|
|
2
4
|
require 'cloudflair/api/zone/settings/always_online'
|
|
3
5
|
require 'cloudflair/api/zone/settings/browser_cache_ttl'
|
|
@@ -38,36 +40,36 @@ module Cloudflair
|
|
|
38
40
|
end
|
|
39
41
|
|
|
40
42
|
{
|
|
41
|
-
advanced_ddos:
|
|
42
|
-
always_online:
|
|
43
|
-
browser_cache_ttl:
|
|
44
|
-
browser_check:
|
|
45
|
-
cache_level:
|
|
46
|
-
challenge_ttl:
|
|
47
|
-
development_mode:
|
|
48
|
-
email_obfuscation:
|
|
49
|
-
hotlink_protection:
|
|
50
|
-
ip_geolocation:
|
|
51
|
-
ipv6:
|
|
52
|
-
minify:
|
|
53
|
-
mirage:
|
|
54
|
-
mobile_redirect:
|
|
43
|
+
advanced_ddos: Cloudflair::AdvancedDdos,
|
|
44
|
+
always_online: Cloudflair::AlwaysOnline,
|
|
45
|
+
browser_cache_ttl: Cloudflair::BrowserCacheTtl,
|
|
46
|
+
browser_check: Cloudflair::BrowserCheck,
|
|
47
|
+
cache_level: Cloudflair::CacheLevel,
|
|
48
|
+
challenge_ttl: Cloudflair::ChallengeTtl,
|
|
49
|
+
development_mode: Cloudflair::DevelopmentMode,
|
|
50
|
+
email_obfuscation: Cloudflair::EmailObfuscation,
|
|
51
|
+
hotlink_protection: Cloudflair::HotlinkProtection,
|
|
52
|
+
ip_geolocation: Cloudflair::IpGeolocation,
|
|
53
|
+
ipv6: Cloudflair::Ipv6,
|
|
54
|
+
minify: Cloudflair::Minify,
|
|
55
|
+
mirage: Cloudflair::Mirage,
|
|
56
|
+
mobile_redirect: Cloudflair::MobileRedirect,
|
|
55
57
|
origin_error_page_pass_thru: Cloudflair::OriginErrorPagePassThru,
|
|
56
|
-
polish:
|
|
57
|
-
prefetch_preload:
|
|
58
|
-
response_buffering:
|
|
59
|
-
rocket_loader:
|
|
60
|
-
security_header:
|
|
61
|
-
security_level:
|
|
62
|
-
server_side_exclude:
|
|
58
|
+
polish: Cloudflair::Polish,
|
|
59
|
+
prefetch_preload: Cloudflair::PrefetchPreload,
|
|
60
|
+
response_buffering: Cloudflair::ResponseBuffering,
|
|
61
|
+
rocket_loader: Cloudflair::RocketLoader,
|
|
62
|
+
security_header: Cloudflair::SecurityHeader,
|
|
63
|
+
security_level: Cloudflair::SecurityLevel,
|
|
64
|
+
server_side_exclude: Cloudflair::ServerSideExclude,
|
|
63
65
|
sort_query_string_for_cache: Cloudflair::SortQueryStringForCache,
|
|
64
|
-
ssl:
|
|
65
|
-
tls_client_auth:
|
|
66
|
-
tls_1_2_only:
|
|
67
|
-
tls_1_3:
|
|
68
|
-
true_client_ip_header:
|
|
69
|
-
waf:
|
|
70
|
-
websockets:
|
|
66
|
+
ssl: Cloudflair::Ssl,
|
|
67
|
+
tls_client_auth: Cloudflair::TlsClientAuth,
|
|
68
|
+
tls_1_2_only: Cloudflair::Tls12Only,
|
|
69
|
+
tls_1_3: Cloudflair::Tls13,
|
|
70
|
+
true_client_ip_header: Cloudflair::TrueClientIpHeader,
|
|
71
|
+
waf: Cloudflair::Waf,
|
|
72
|
+
websockets: Cloudflair::Websockets
|
|
71
73
|
}.each do |method, klass|
|
|
72
74
|
define_method method do
|
|
73
75
|
klass.new @zone_id
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'cloudflair/api/zone/dns_record'
|
|
2
4
|
|
|
3
5
|
module Cloudflair
|
|
4
6
|
class Zone
|
|
5
7
|
def dns_records(filter = {})
|
|
6
8
|
raw_records = response connection.get("#{path}/dns_records", filter)
|
|
7
|
-
|
|
8
9
|
raw_records.map { |raw_record| build_dns_record(raw_record) }
|
|
9
10
|
end
|
|
10
11
|
|
|
@@ -14,7 +15,6 @@ module Cloudflair
|
|
|
14
15
|
|
|
15
16
|
def new_dns_record(record_data)
|
|
16
17
|
raw_record = response connection.post("#{path}/dns_records", record_data)
|
|
17
|
-
|
|
18
18
|
build_dns_record raw_record
|
|
19
19
|
end
|
|
20
20
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'cloudflair/error/cloudflare_error'
|
|
2
4
|
require 'cloudflair/error/cloudflair_error'
|
|
3
5
|
require 'cloudflair/connection'
|
|
@@ -35,8 +37,9 @@ module Cloudflair
|
|
|
35
37
|
body = response.body
|
|
36
38
|
|
|
37
39
|
unless body['success']
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
raise Cloudflair::CloudflairError, "Unrecognized response format: '#{body}'" unless body['errors']
|
|
41
|
+
|
|
42
|
+
raise Cloudflair::CloudflareError, body['errors']
|
|
40
43
|
end
|
|
41
44
|
|
|
42
45
|
body['result']
|
|
@@ -44,32 +47,32 @@ module Cloudflair
|
|
|
44
47
|
|
|
45
48
|
def raise_on_http_error(status)
|
|
46
49
|
case status
|
|
47
|
-
when 200..399
|
|
48
|
-
when 400..499
|
|
50
|
+
when 200..399
|
|
51
|
+
when 400..499
|
|
49
52
|
raise_on_http_client_error status
|
|
50
|
-
when 500..599
|
|
51
|
-
|
|
53
|
+
when 500..599
|
|
54
|
+
raise Cloudflair::CloudflairError, "#{status} Remote Error"
|
|
52
55
|
else
|
|
53
|
-
|
|
56
|
+
raise Cloudflair::CloudflairError, "#{status} Unknown Error Code"
|
|
54
57
|
end
|
|
55
58
|
end
|
|
56
59
|
|
|
57
60
|
def raise_on_http_client_error(status)
|
|
58
61
|
case status
|
|
59
|
-
when 400
|
|
60
|
-
|
|
61
|
-
when 401
|
|
62
|
-
|
|
63
|
-
when 403
|
|
64
|
-
|
|
65
|
-
when 405
|
|
66
|
-
|
|
67
|
-
when 415
|
|
68
|
-
|
|
69
|
-
when 429
|
|
70
|
-
|
|
62
|
+
when 400
|
|
63
|
+
raise Cloudflair::CloudflairError, '400 Bad Request'
|
|
64
|
+
when 401
|
|
65
|
+
raise Cloudflair::CloudflairError, '401 Unauthorized'
|
|
66
|
+
when 403
|
|
67
|
+
raise Cloudflair::CloudflairError, '403 Forbidden'
|
|
68
|
+
when 405
|
|
69
|
+
raise Cloudflair::CloudflairError, '405 Method Not Allowed'
|
|
70
|
+
when 415
|
|
71
|
+
raise Cloudflair::CloudflairError, '415 Unsupported Media Type'
|
|
72
|
+
when 429
|
|
73
|
+
raise Cloudflair::CloudflairError, '429 Too Many Requests'
|
|
71
74
|
else
|
|
72
|
-
|
|
75
|
+
raise Cloudflair::CloudflairError, "#{status} Request Error"
|
|
73
76
|
end
|
|
74
77
|
end
|
|
75
78
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'faraday'
|
|
2
4
|
require 'faraday_middleware'
|
|
3
5
|
require 'faraday/detailed_logger'
|
|
@@ -7,25 +9,32 @@ module Cloudflair
|
|
|
7
9
|
class Connection
|
|
8
10
|
def self.new
|
|
9
11
|
config = Cloudflair.config
|
|
10
|
-
|
|
11
12
|
new_faraday_from config
|
|
12
13
|
end
|
|
13
14
|
|
|
14
|
-
def self.headers
|
|
15
|
-
headers = {}
|
|
15
|
+
def self.headers # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
16
16
|
cloudflare_auth_config = Cloudflair.config.cloudflare.auth
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
raise CloudflairError, 'Neither email & key nor user_service_key have been defined.'
|
|
17
|
+
|
|
18
|
+
if !cloudflare_auth_config.key.nil? && !cloudflare_auth_config.email.nil?
|
|
19
|
+
return({
|
|
20
|
+
'X-Auth-Key' => cloudflare_auth_config.key,
|
|
21
|
+
'X-Auth-Email' => cloudflare_auth_config.email
|
|
22
|
+
})
|
|
24
23
|
end
|
|
25
|
-
|
|
24
|
+
|
|
25
|
+
unless cloudflare_auth_config.user_service_key.nil?
|
|
26
|
+
return({
|
|
27
|
+
'Authorization' => "Bearer #{cloudflare_auth_config.user_service_key}"
|
|
28
|
+
})
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
raise(
|
|
32
|
+
CloudflairError,
|
|
33
|
+
'Neither email & key nor user_service_key have been defined.'
|
|
34
|
+
)
|
|
26
35
|
end
|
|
27
36
|
|
|
28
|
-
private_class_method def self.new_faraday_from(config)
|
|
37
|
+
private_class_method def self.new_faraday_from(config) # rubocop:disable Metrics/AbcSize
|
|
29
38
|
Faraday.new(url: config.cloudflare.api_base_url, headers: headers) do |faraday|
|
|
30
39
|
faraday.request :json
|
|
31
40
|
faraday.response config.faraday.logger if config.faraday.logger
|
data/lib/cloudflair/entity.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'cloudflair/communication'
|
|
2
4
|
|
|
3
5
|
module Cloudflair
|
|
@@ -16,13 +18,14 @@ module Cloudflair
|
|
|
16
18
|
def patchable_fields(*fields)
|
|
17
19
|
return @patchable_fields if @patchable_fields
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
@patchable_fields =
|
|
22
|
+
if fields.nil?
|
|
23
|
+
[]
|
|
24
|
+
elsif fields.is_a?(Array)
|
|
25
|
+
fields.map(&:to_s)
|
|
26
|
+
else
|
|
27
|
+
[fields.to_s]
|
|
28
|
+
end
|
|
26
29
|
end
|
|
27
30
|
|
|
28
31
|
def deletable(deletable = false)
|
|
@@ -34,7 +37,7 @@ module Cloudflair
|
|
|
34
37
|
def path(path = nil)
|
|
35
38
|
return @path if @path
|
|
36
39
|
|
|
37
|
-
|
|
40
|
+
raise ArgumentError, 'path is not defined' if path.nil?
|
|
38
41
|
|
|
39
42
|
@path = path
|
|
40
43
|
end
|
|
@@ -42,11 +45,12 @@ module Cloudflair
|
|
|
42
45
|
def object_fields(*fields)
|
|
43
46
|
return @object_fields if @object_fields
|
|
44
47
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
@object_fields =
|
|
49
|
+
if fields.nil? || fields.empty?
|
|
50
|
+
[]
|
|
51
|
+
else
|
|
52
|
+
fields.map(&:to_s)
|
|
53
|
+
end
|
|
50
54
|
end
|
|
51
55
|
|
|
52
56
|
# allowed values:
|
|
@@ -69,17 +73,17 @@ module Cloudflair
|
|
|
69
73
|
end
|
|
70
74
|
|
|
71
75
|
def turn_all_items_into_a_single_hash(fields_to_class_map)
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
{}.tap do |fields_map|
|
|
77
|
+
fields_to_class_map.each do |field_definition|
|
|
78
|
+
if field_definition.is_a?(Hash)
|
|
79
|
+
fields_to_class_map[0].each do |field, klass_or_proc|
|
|
80
|
+
fields_map[field.to_s] = klass_or_proc
|
|
81
|
+
end
|
|
82
|
+
else
|
|
83
|
+
fields_map[field_definition.to_s] = nil
|
|
77
84
|
end
|
|
78
|
-
else
|
|
79
|
-
fields_map[field_definition.to_s] = nil
|
|
80
85
|
end
|
|
81
86
|
end
|
|
82
|
-
fields_map
|
|
83
87
|
end
|
|
84
88
|
end
|
|
85
89
|
|
|
@@ -102,7 +106,7 @@ module Cloudflair
|
|
|
102
106
|
end
|
|
103
107
|
|
|
104
108
|
def delete
|
|
105
|
-
|
|
109
|
+
raise Cloudflair::CloudflairError, "Can't delete unless deletable=true" unless deletable
|
|
106
110
|
return self if @deleted
|
|
107
111
|
|
|
108
112
|
@data = response connection.delete path
|
|
@@ -126,27 +130,23 @@ module Cloudflair
|
|
|
126
130
|
def method_missing(name_as_symbol, *args, &block)
|
|
127
131
|
name = normalize_accessor name_as_symbol
|
|
128
132
|
|
|
129
|
-
return data if :_raw_data!
|
|
133
|
+
return data if name_as_symbol == :_raw_data!
|
|
130
134
|
|
|
131
135
|
if name.end_with?('=')
|
|
132
136
|
if patchable_fields.include?(name[0..-2])
|
|
133
137
|
dirty_data[name[0..-2]] = args[0]
|
|
134
138
|
return
|
|
135
|
-
else
|
|
136
|
-
super
|
|
137
139
|
end
|
|
138
|
-
end
|
|
139
140
|
|
|
140
|
-
|
|
141
|
-
if name.end_with?('!') && data.keys.include?(name[0..-2])
|
|
142
|
-
return data[name[0..2]]
|
|
141
|
+
super
|
|
143
142
|
end
|
|
144
143
|
|
|
144
|
+
# allow access to the unmodified data using 'zone.always_string!' or 'zone._name!'
|
|
145
|
+
return data[name[0..2]] if name.end_with?('!') && data.key?(name[0..-2])
|
|
145
146
|
return objectify(name) if object_fields.include? name
|
|
146
|
-
return arrayify(name, array_object_fields[name]) if array_object_fields.
|
|
147
|
-
|
|
148
|
-
return
|
|
149
|
-
return data[name] if data.is_a?(Hash) && data.keys.include?(name)
|
|
147
|
+
return arrayify(name, array_object_fields[name]) if array_object_fields.key?(name)
|
|
148
|
+
return dirty_data[name] if dirty_data.key?(name)
|
|
149
|
+
return data[name] if data.is_a?(Hash) && data.key?(name)
|
|
150
150
|
|
|
151
151
|
super
|
|
152
152
|
end
|
|
@@ -154,16 +154,13 @@ module Cloudflair
|
|
|
154
154
|
def respond_to_missing?(name_as_symbol, *args)
|
|
155
155
|
name = normalize_accessor name_as_symbol
|
|
156
156
|
|
|
157
|
-
return true if :_raw_data!
|
|
158
|
-
|
|
157
|
+
return true if name_as_symbol == :_raw_data!
|
|
159
158
|
return true if name.end_with?('=') && patchable_fields.include?(name[0..-2])
|
|
160
|
-
return true if name.end_with?('!') && data.
|
|
161
|
-
|
|
159
|
+
return true if name.end_with?('!') && data.key?(name[0..-2])
|
|
162
160
|
return true if object_fields.include? name
|
|
163
|
-
return true if array_object_fields.
|
|
164
|
-
|
|
165
|
-
return true if
|
|
166
|
-
return true if data.is_a?(Hash) && data.keys.include?(name)
|
|
161
|
+
return true if array_object_fields.key?(name)
|
|
162
|
+
return true if dirty_data.key?(name)
|
|
163
|
+
return true if data.is_a?(Hash) && data.key?(name)
|
|
167
164
|
|
|
168
165
|
super
|
|
169
166
|
end
|
|
@@ -235,9 +232,11 @@ module Cloudflair
|
|
|
235
232
|
|
|
236
233
|
def replace_path_variables_in(path)
|
|
237
234
|
interpreted_path = path.clone
|
|
235
|
+
|
|
238
236
|
path.scan(/:([a-zA-Z_][a-zA-Z0-9_]+[!?=]?)/) do |match, *|
|
|
239
|
-
interpreted_path.gsub
|
|
237
|
+
interpreted_path = interpreted_path.gsub ":#{match}", send(match).to_s
|
|
240
238
|
end
|
|
239
|
+
|
|
241
240
|
interpreted_path
|
|
242
241
|
end
|
|
243
242
|
|
data/lib/cloudflair/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cloudflair
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Christian Mäder
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-
|
|
11
|
+
date: 2019-09-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
14
|
+
name: dry-configurable
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 0.
|
|
19
|
+
version: '0.1'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- - "
|
|
24
|
+
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 0.
|
|
26
|
+
version: '0.1'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
28
|
+
name: faraday
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version:
|
|
33
|
+
version: 0.10.0
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - ">="
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version:
|
|
40
|
+
version: 0.10.0
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
42
|
+
name: faraday-detailed_logger
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
|
-
- - "
|
|
45
|
+
- - ">="
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '0
|
|
47
|
+
version: '0'
|
|
48
48
|
type: :runtime
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
|
-
- - "
|
|
52
|
+
- - ">="
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '0
|
|
54
|
+
version: '0'
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
56
|
+
name: faraday_middleware
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
59
|
- - ">="
|
|
@@ -80,6 +80,20 @@ dependencies:
|
|
|
80
80
|
- - "~>"
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: 2.0.0
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: dotenv
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '2.1'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '2.1'
|
|
83
97
|
- !ruby/object:Gem::Dependency
|
|
84
98
|
name: rake
|
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -109,33 +123,33 @@ dependencies:
|
|
|
109
123
|
- !ruby/object:Gem::Version
|
|
110
124
|
version: '3.0'
|
|
111
125
|
- !ruby/object:Gem::Dependency
|
|
112
|
-
name:
|
|
126
|
+
name: rubocop
|
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
|
114
128
|
requirements:
|
|
115
129
|
- - "~>"
|
|
116
130
|
- !ruby/object:Gem::Version
|
|
117
|
-
version: '
|
|
131
|
+
version: '0.48'
|
|
118
132
|
type: :development
|
|
119
133
|
prerelease: false
|
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
|
121
135
|
requirements:
|
|
122
136
|
- - "~>"
|
|
123
137
|
- !ruby/object:Gem::Version
|
|
124
|
-
version: '
|
|
138
|
+
version: '0.48'
|
|
125
139
|
- !ruby/object:Gem::Dependency
|
|
126
|
-
name: rubocop
|
|
140
|
+
name: rubocop-performance
|
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
|
128
142
|
requirements:
|
|
129
|
-
- - "
|
|
143
|
+
- - ">="
|
|
130
144
|
- !ruby/object:Gem::Version
|
|
131
|
-
version: '0
|
|
145
|
+
version: '0'
|
|
132
146
|
type: :development
|
|
133
147
|
prerelease: false
|
|
134
148
|
version_requirements: !ruby/object:Gem::Requirement
|
|
135
149
|
requirements:
|
|
136
|
-
- - "
|
|
150
|
+
- - ">="
|
|
137
151
|
- !ruby/object:Gem::Version
|
|
138
|
-
version: '0
|
|
152
|
+
version: '0'
|
|
139
153
|
- !ruby/object:Gem::Dependency
|
|
140
154
|
name: rubocop-rspec
|
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -159,6 +173,8 @@ extra_rdoc_files: []
|
|
|
159
173
|
files:
|
|
160
174
|
- ".gitignore"
|
|
161
175
|
- ".rspec"
|
|
176
|
+
- ".rubocop.yml"
|
|
177
|
+
- ".ruby-gemset"
|
|
162
178
|
- ".ruby-version"
|
|
163
179
|
- ".travis.yml"
|
|
164
180
|
- Gemfile
|