cloudflare 4.0.0 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0bdda4cf1d75b71db4667d63da7382958e2cbebedb052e51adce192bf5db2a81
4
- data.tar.gz: ea73942a2251da8f3de0e9a4b46af6a0f877cb1d52b39567ea5aee0c5514aff3
3
+ metadata.gz: 93312512447e91ad4a4e49d249d0474ce69304fbaed539a49cee2277afdc35f7
4
+ data.tar.gz: 40c655960faf06672e9b0720cb9e24bfa2b47d09e87bc6e24f23b7def429f014
5
5
  SHA512:
6
- metadata.gz: cbe1fe27c1dcbdf5bcf1480c21058e8b2f82d3c43829c606355e864e56390b9f0e128e80af3d6274ce09c45a40548e0a5ce29d1dd70d9ca9bfa707a86982a477
7
- data.tar.gz: d1c18b4b98110472759b0e3400f3e22717d91cb1022292a997b21920eca74ceabefa78b830c22231f9338efda14d99ff99e0310b1f33ffbd2f637b0a092b5d21
6
+ metadata.gz: 212b1e7f5ec0c274676c6458a940eff14c9df4d2e43d990e1a03833bfa2ece184cb85e002a9eafe879ac6e8001e7750d23ebb07efb10bd8f1c02ae31686c5766
7
+ data.tar.gz: c8e62b92827dc64b0833f821f07b526164a1da58cd408dfbe9b597d5c64a38d51ab805359655049a4dc98ce3e2e520f330ddf58f98039cfcb6e04dfdbeea5c2a
data/.travis.yml CHANGED
@@ -8,6 +8,8 @@ matrix:
8
8
  - rvm: 2.4
9
9
  - rvm: 2.5
10
10
  - rvm: 2.6
11
+ - rvm: 2.6
12
+ env: COVERAGE=BriefSummary,Coveralls
11
13
  - rvm: jruby-head
12
14
  env: JRUBY_OPTS="--debug -X+O"
13
15
  - rvm: truffleruby
data/README.md CHANGED
@@ -3,6 +3,7 @@
3
3
  It is a Ruby wrapper for the Cloudflare V4 API. It provides a light weight wrapper using `RestClient::Resource`. The wrapper functionality is limited to zones and DNS records at this time, *PRs welcome*.
4
4
 
5
5
  [![Build Status](https://secure.travis-ci.org/socketry/cloudflare.svg)](http://travis-ci.org/socketry/cloudflare)
6
+ [![Coverage Status](https://coveralls.io/repos/socketry/cloudflare/badge.svg)](https://coveralls.io/r/socketry/cloudflare)
6
7
 
7
8
  ## Installation
8
9
 
@@ -26,7 +27,7 @@ $ gem install cloudflare
26
27
 
27
28
  ## Usage
28
29
 
29
- Prepare a connection to the remote API:
30
+ Here are some basic examples. For more details, refer to the code and specs.
30
31
 
31
32
  ```ruby
32
33
  require 'cloudflare'
@@ -35,66 +36,31 @@ require 'cloudflare'
35
36
  email = ENV['CLOUDFLARE_EMAIL']
36
37
  key = ENV['CLOUDFLARE_KEY']
37
38
 
38
- # Set up the connection:
39
- connection = Cloudflare.connect(key: key, email: email)
40
- ```
41
-
42
- Get all available zones:
43
-
44
- ```ruby
45
- zones = connection.zones
46
- ```
47
-
48
- Get a specific zone:
49
-
50
- ```ruby
51
- zone = connection.zones.find_by_id("...")
52
- zone = connection.zones.find_by_name("example.com")
53
- ```
54
-
55
- Get DNS records for a given zone:
56
-
57
- ```ruby
58
- dns_records = zones.first.dns_records
59
- ```
60
-
61
- Show some details of the DNS record:
62
-
63
- ```ruby
64
- dns_record = records.first
65
- puts records.first.record[:name]
66
- puts records
67
- ```
68
-
69
- Get firewall rules:
70
-
71
- ```ruby
72
- all_rules = zones.first.firewall_rules
73
- block_rules = zones.first.firewall_rules("block") # or "whitelist" or "challenge"
74
- ```
75
-
76
- Get blocked ips:
77
-
78
- ```ruby
79
- block_rules = zones.first.firewall_rules("block")
80
- blocked_ips = zones.first.firewall_rules.firewalled_ips(block_rules)
81
- ```
82
-
83
- Block an ip:
84
-
85
- ```ruby
86
- # ip = "nnn.nnn.nnn.nnn"
87
- # note: "some note about the block"
88
- data = {"mode":"block","configuration":{"target":"ip","value":"#{ip}"},"notes":"#{note} #{Time.now.strftime("%m/%d/%y")} "}
89
- response = zones.first.firewall_rules.post(data.to_json, content_type: 'application/json')
90
- ```
91
-
92
- Add a DNS record dynamically. Here we add an A record for `batman.example.com`:
93
-
94
- ```ruby
95
- client = Cloudflare.connect(key: CF_KEY, email: CF_EMAIL)
96
- zone = client.zones.find_by_name("example.com")
97
- zone.dns_records.post({"type":"A","name":"batman","content":"127.0.0.1","proxied":false}.to_json, :content_type => "application/json")
39
+ Cloudflare.connect(key: key, email: email) do
40
+ # Get all available zones:
41
+ zones = connection.zones
42
+
43
+ # Get a specific zone:
44
+ zone = connection.zones.find_by_id("...")
45
+ zone = connection.zones.find_by_name("example.com")
46
+
47
+ # Get DNS records for a given zone:
48
+ dns_records = zone.dns_records
49
+
50
+ # Show some details of the DNS record:
51
+ dns_record = dns_records.first
52
+ puts dns_record.name
53
+
54
+ # Add a DNS record. Here we add an A record for `batman.example.com`:
55
+ zone = zones.find_by_name("example.com")
56
+ zone.dns_records.create('A', 'batman', '1.2.3.4', proxied: false)
57
+
58
+ # Get firewall rules:
59
+ all_rules = zone.firewall_rules
60
+
61
+ # Block an ip:
62
+ rule = zone.firewall_rules.set('block', '1.2.3.4', notes: "ssh dictionary attack")
63
+ end
98
64
  ```
99
65
 
100
66
  ## Contributing
data/cloudflare.gemspec CHANGED
@@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
25
25
 
26
26
  spec.add_development_dependency 'async-rspec'
27
27
 
28
+ spec.add_development_dependency 'covered'
28
29
  spec.add_development_dependency 'bundler'
29
30
  spec.add_development_dependency 'rake'
30
31
  spec.add_development_dependency 'rspec', '~> 3.6'
@@ -22,5 +22,5 @@
22
22
  # THE SOFTWARE.
23
23
 
24
24
  module Cloudflare
25
- VERSION = '4.0.0'
25
+ VERSION = '4.0.1'
26
26
  end
@@ -56,6 +56,8 @@ module Cloudflare
56
56
  def name
57
57
  value[:name]
58
58
  end
59
+
60
+ alias to_s name
59
61
  end
60
62
 
61
63
  class Zones < Representation
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,5 @@
1
1
 
2
+ require 'covered/rspec'
2
3
  require 'async/rspec'
3
4
 
4
5
  require 'cloudflare/rspec/connection'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudflare
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcin Prokop
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-01-26 00:00:00.000000000 Z
12
+ date: 2019-02-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: async-rest
@@ -39,6 +39,20 @@ dependencies:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: covered
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
42
56
  - !ruby/object:Gem::Dependency
43
57
  name: bundler
44
58
  requirement: !ruby/object:Gem::Requirement
@@ -131,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
145
  - !ruby/object:Gem::Version
132
146
  version: '0'
133
147
  requirements: []
134
- rubygems_version: 3.0.1
148
+ rubygems_version: 3.0.2
135
149
  signing_key:
136
150
  specification_version: 4
137
151
  summary: A Ruby wrapper for the Cloudflare API.