cloudflare 1.1.3 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fa0a65ba715bee7ab59e903cf0b5090e617d3e0c
4
+ data.tar.gz: 8d05554c82112f191239f894e6c3ead5ae1e6a45
5
+ SHA512:
6
+ metadata.gz: df66569beed0dd565f0dac9157f196430cf52d65ef092b1bbe4d04e69cf248dde62c1bbf9253b687767c65fb8cd26f8de380e591de3c9a1c15cb64887cf73b84
7
+ data.tar.gz: 6dfbed17d3b719dc57cd42fa9fdd3c5305288864ecedb9127490276eaca8800ae03d48f9856d005644e58f2adc76df805522e89214bbf91dda3bcca593f2bf1f
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in build.gemspec
4
+ gemspec
data/README.md CHANGED
@@ -1,75 +1,90 @@
1
- NOTICE
2
- ------
3
-
4
- In version 1.1.x some functions were renamed. Please see documentation.
5
-
6
-
7
- CloudFlare
8
- ==========
1
+ # CloudFlare
9
2
 
10
3
  It is a Ruby wrapper for the CloudFlare API.
11
4
 
12
- Official home page is [here](https://github.com/B4k3r/cloudflare). The complete [RDoc](http://rdoc.info/github/B4k3r/cloudflare/) is online.
5
+ [![Build Status](https://travis-ci.org/b4k3r/cloudflare.png?branch=master)](https://travis-ci.org/b4k3r/cloudflare)
6
+
7
+ Official home page is [here](https://github.com/b4k3r/cloudflare). The complete [RDoc](http://rdoc.info/github/b4k3r/cloudflare/) is online.
13
8
 
14
9
  Visit also a CloudFlare API documentation:
15
10
 
16
11
  - [Client](http://www.cloudflare.com/docs/client-api.html)
17
12
  - [Host](http://www.cloudflare.com/docs/host-api.html)
18
13
 
19
- Installation
20
- ------------
14
+ ## Installation
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ gem 'cloudflare'
19
+
20
+ And then execute:
21
21
 
22
- ```
23
- gem install cloudflare
24
- ```
22
+ $ bundle
25
23
 
26
- Or, if use Rails, include the gem in your Gemfile:
24
+ Or install it yourself as:
27
25
 
28
- ```
29
- gem 'cloudflare'
30
- ```
26
+ $ gem install cloudflare
31
27
 
32
- Usage
33
- -----
28
+ ## Usage
34
29
 
35
30
  **Example for Client API:**
36
31
 
37
- ```
38
- require 'cloudflare'
32
+ require 'cloudflare'
39
33
 
40
- cf = CloudFlare.new('user_api_key', 'user_email')
41
- output = cf.rec_new('domain.com', 'A', 'subdomain', '212.11.6.211', 1)
34
+ cf = CloudFlare::connection('user_api_key', 'user_email')
42
35
 
43
- if output['result'] == 'success'
44
- puts 'Successfuly added DNS record'
45
- else
46
- puts output['msg'] # error message
47
- end
48
- ```
36
+ begin
37
+ cf.rec_new('domain.com', 'A', 'subdomain', '212.11.6.211', 1)
38
+ rescue => e
39
+ puts e.message # error message
40
+ else
41
+ puts 'Successfuly added DNS record'
42
+ end
49
43
 
50
44
  **Example for Host API:**
51
45
 
52
- ```
53
- require 'cloudflare'
46
+ require 'cloudflare'
54
47
 
55
- cf = CloudFlare.new('host_api_key')
56
- output = cf.create_user('john@example.com', 'secret', 'john')
48
+ cf = CloudFlare::connection('host_api_key')
57
49
 
58
- if output['result'] == 'success'
59
- puts output['msg']
60
- puts "Your login is #{output['response']['cloudflare_username']}" # => john
61
- else
62
- puts output['msg'] # error message
63
- end
64
- ```
50
+ begin
51
+ output = cf.create_user('john@example.com', 'secret', 'john')
52
+ rescue => e
53
+ puts e.message # error message
54
+ else
55
+ puts output['msg']
56
+ puts "Your login is #{output['response']['cloudflare_username']}" # => john
57
+ end
65
58
 
66
- License
67
- -------
59
+ ## Contributing
68
60
 
69
- Copyright © 2012 - 2013. It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
61
+ 1. Fork it
62
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
63
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
64
+ 4. Push to the branch (`git push origin my-new-feature`)
65
+ 5. Create new Pull Request
70
66
 
67
+ ## License
71
68
 
69
+ Released under the MIT license.
72
70
 
71
+ Copyright, 2012, 2014, by [Marcin Prokop](https://github.com/b4k3r).
72
+ Copyright, 2014, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams).
73
73
 
74
+ Permission is hereby granted, free of charge, to any person obtaining a copy
75
+ of this software and associated documentation files (the "Software"), to deal
76
+ in the Software without restriction, including without limitation the rights
77
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
78
+ copies of the Software, and to permit persons to whom the Software is
79
+ furnished to do so, subject to the following conditions:
74
80
 
81
+ The above copyright notice and this permission notice shall be included in
82
+ all copies or substantial portions of the Software.
75
83
 
84
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
85
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
86
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
87
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
88
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
89
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
90
+ THE SOFTWARE.
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $LOAD_PATH.push File.expand_path("../lib", __FILE__)
3
+ require 'cloudflare/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'cloudflare'
7
+ s.version = CloudFlare::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+
10
+ s.description = 'A Ruby wrapper for the CloudFlare API.'
11
+ s.summary = 'A Ruby wrapper for the CloudFlare API.'
12
+ s.authors = ['Marcin Prokop']
13
+ s.email = 'marcin@prokop.co'
14
+ s.homepage = 'https://github.com/b4k3r/cloudflare'
15
+ s.licenses = ['MIT']
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = ['test/test_cloudflare.rb']
19
+ s.rdoc_options = ['--main', 'README.md', '--charset=UTF-8']
20
+ s.extra_rdoc_files = ['README.md', 'LICENSE']
21
+
22
+ s.required_ruby_version = '>= 1.9.0'
23
+ s.add_runtime_dependency 'json', '~> 1'
24
+ s.add_development_dependency 'rake'
25
+ end
data/lib/cloudflare.rb CHANGED
@@ -1,515 +1,27 @@
1
- require 'net/http'
2
- require 'json'
3
-
4
- # All public functions return (Hash) result: success or error with message and error code
5
- #
6
- # For more information please visit:
7
- # - http://www.cloudflare.com/docs/client-api.html
8
- # - http://www.cloudflare.com/docs/host-api.html
9
- #
10
-
11
- class CloudFlare
12
-
13
- # URL for Client and Host API
14
-
15
- URL_API = {
16
- client: 'https://www.cloudflare.com/api_json.html',
17
- host: 'https://api.cloudflare.com/host-gw.html'
18
- }
19
-
20
- TIMEOUT = 5 # Default is 5 seconds
21
-
22
- # @param api_key [String] user or Host API key.
23
- # @param email [String] it is for a Client API.
24
- def initialize(api_key, email = nil)
25
- @params = Hash.new
26
-
27
- if email.nil?
28
- @params[:api_key] = api_key
29
- else
30
- @params[:api_key] = api_key
31
- @params[:email] = email
32
- end
33
-
34
- end
35
-
36
- # CLIENT
37
-
38
- # This function can be used to get currently settings of values such as the security level.
39
- #
40
- # @see http://www.cloudflare.com/docs/client-api.html#s3.1
41
- #
42
- # @param zone [String]
43
- # @param interval [Integer]
44
-
45
- def stats(zone, interval = 20)
46
- send_req({a: :stats, z: zone, interval: interval})
47
- end
48
-
49
- # This function lists all domains in a CloudFlare account along with other data.
50
- #
51
- # @see http://www.cloudflare.com/docs/client-api.html#s3.2
52
-
53
- def zone_load_multi
54
- send_req(a: :zone_load_multi)
55
- end
56
-
57
- # This function lists all of the DNS records from a particular domain in a CloudFlare account.
58
- #
59
- # @see http://www.cloudflare.com/docs/client-api.html#s3.3
60
- #
61
- # @param zone [String]
62
-
63
- def rec_load_all(zone)
64
- send_req({a: :rec_load_all, z: zone})
65
- end
66
-
67
- # This function checks whether one or more websites/domains are active under an account and return the zone ids (zids) for these.
68
- #
69
- # @see http://www.cloudflare.com/docs/client-api.html#s3.4
70
- #
71
- # @param zones [String or Array]
72
-
73
- def zone_check(*zones)
74
- send_req({a: :zone_check, zones: zones.kind_of?(Array) ? zones.join(',') : zones})
75
- end
76
-
77
- # This function pulls recent IPs hitting your site.
78
- #
79
- # @see http://www.cloudflare.com/docs/client-api.html#s3.5
80
- #
81
- # @param zone [String]
82
- # @param hours [Integer] max 48
83
- # @param classification [String] (optional) values: r|c|t
84
- # @param geo [Fixnum] (optional)
85
-
86
- def zone_ips(zone, classification = nil, hours = 24, geo = 1)
87
- send_req({a: :zone_ips, z: zone, hours: hours, "class" => classification, geo: geo})
88
- end
89
-
90
- # This function checks the threat score for a given IP.
91
- #
92
- # @see http://www.cloudflare.com/docs/client-api.html#s3.6
93
- #
94
- # @param ip [String]
95
-
96
- def ip_lkup(ip)
97
- send_req({a: :ip_lkup, ip: ip})
98
- end
99
-
100
- # This function retrieves all current settings for a given domain.
101
- #
102
- # @see http://www.cloudflare.com/docs/client-api.html#s3.7
103
- #
104
- # @param zone [String]
105
-
106
- def zone_settings(zone)
107
- send_req({a: :zone_settings, z: zone})
108
- end
109
-
110
- # This function sets the Basic Security Level to HELP I'M UNDER ATTACK / HIGH / MEDIUM / LOW / ESSENTIALLY OFF.
111
- #
112
- # @see http://www.cloudflare.com/docs/client-api.html#s4.1
113
- #
114
- # @param zone [String]
115
- # @param value [String] values: low|med|high|help|eoff
116
-
117
- def sec_lvl(zone, value)
118
- send_req({a: :sec_lvl, z: zone, v: value})
119
- end
120
-
121
- # This function sets the Caching Level to Aggressive or Basic.
122
- #
123
- # @see http://www.cloudflare.com/docs/client-api.html#s4.2
124
- #
125
- # @param zone [String]
126
- # @param value [String] values: agg|basic
127
-
128
- def cache_lvl(zone, value)
129
- send_req({a: :cache_lvl, z: zone, v: value})
130
- end
131
-
132
- # This function allows you to toggle Development Mode on or off for a particular domain.
133
- #
134
- # @see http://www.cloudflare.com/docs/client-api.html#s4.3
135
- #
136
- # @param zone [String]
137
- # @param value [Boolean]
138
-
139
- def devmode(zone, value)
140
- send_req({a: :devmode, z: zone, v: value ? 1 : 0})
141
- end
142
-
143
- # This function will purge CloudFlare of any cached files.
144
- #
145
- # @see http://www.cloudflare.com/docs/client-api.html#s4.4
146
- #
147
- # @param zone [String]
148
-
149
- def fpurge_ts(zone)
150
- send_req({a: :fpurge_ts, z: zone, v: 1})
151
- end
152
-
153
- # This function will purge a single file from CloudFlare's cache.
154
- #
155
- # @see http://www.cloudflare.com/docs/client-api.html#s4.5
156
- #
157
- # @param zone [String]
158
- # @param url [String]
159
-
160
- def zone_file_purge(zone, url)
161
- send_req({a: :zone_file_purge, z: zone, url: url})
162
- end
163
-
164
- # This function updates the snapshot of your site for CloudFlare's challenge page.
165
- #
166
- # @see http://www.cloudflare.com/docs/client-api.html#s4.6
167
- #
168
- # @param zoneid [Integer]
169
-
170
- def zone_grab(zoneid)
171
- send_req({a: :zone_grab, zid: zoneid})
172
- end
173
-
174
- # This function adds an IP address to your white lists.
175
- #
176
- # @see http://www.cloudflare.com/docs/client-api.html#s4.7
177
- #
178
- # @param ip [String]
179
-
180
- def whitelist(ip)
181
- send_req({a: :wl, key: ip})
182
- end
183
-
184
-
185
- # This function adds an IP address to your black lists.
186
- #
187
- # @see http://www.cloudflare.com/docs/client-api.html#s4.7
188
- #
189
- # @param ip [String]
190
-
191
- def blacklist(ip)
192
- send_req({a: :ban, key: ip})
193
- end
194
-
195
- # This function removes the IP from whitelist or blacklist.
196
- #
197
- # @see http://www.cloudflare.com/docs/client-api.html#s4.7
198
- #
199
- # @param ip [String]
200
-
201
- def remove_ip(ip)
202
- send_req({a: :nul, key: ip})
203
- end
204
-
205
- # This function toggles IPv6 support.
206
- #
207
- # @see http://www.cloudflare.com/docs/client-api.html#s4.8
208
- #
209
- # @param zone [String]
210
- # @param value [Boolean]
211
-
212
- def ipv46(zone, value)
213
- send_req({a: :ipv46, z: zone, v: value ? 1 : 0})
214
- end
215
-
216
- # This function changes Rocket Loader setting.
217
- #
218
- # @see http://www.cloudflare.com/docs/client-api.html#s4.9
219
- #
220
- # @param zone [String]
221
- # @param value [Integer or String] values: 0|a|m
222
-
223
- def async(zone, value)
224
- send_req({a: :async, z: zone, v: value})
225
- end
226
-
227
- # This function changes minification settings.
228
- #
229
- # @see http://www.cloudflare.com/docs/client-api.html#s4.9
230
- #
231
- # @param zone [String]
232
- # @param value [Integer] values: 0|2|3|4|5|6|7
233
-
234
- def minify(zone, value)
235
- send_req({a: :minify, z: zone, v: value})
236
- end
237
-
238
- # This function creates a new DNS record for your site. This can be either a CNAME or A record.
239
- #
240
- # @see http://www.cloudflare.com/docs/client-api.html#s5.1
241
- #
242
- # @param zone [String]
243
- # @param type [String] values: A|CNAME|MX|TXT|SPF|AAAA|NS|SRV|LOC
244
- # @param name [String]
245
- # @param content [String]
246
- # @param ttl [Integer] values: 1|120...4294967295
247
- # @param prio [Integer] (applies to MX/SRV)
248
- # @param service [String] (applies to SRV)
249
- # @param srvname [String] (applies to SRV)
250
- # @param protocol [Integer] (applies to SRV) values: _tcp|_udp|_tls
251
- # @param weight [Intger] (applies to SRV)
252
- # @param port [Integer] (applies to SRV)
253
- # @param target [String] (applies to SRV)
254
-
255
- def rec_new(zone, type, name, content, ttl, prio = nil, service = nil, srvname = nil, protocol = nil, weight = nil, port = nil, target = nil)
256
- send_req({
257
- a: :rec_new,
258
- z: zone,
259
- type: type,
260
- name: name,
261
- content: content,
262
- ttl: ttl,
263
- prio: prio,
264
- service: service,
265
- srvname: srvname,
266
- protocol: protocol,
267
- weight: weight,
268
- port: port,
269
- target: target
270
- })
271
- end
272
-
273
- # This function edits a DNS record for a zone.
274
- #
275
- # @see http://www.cloudflare.com/docs/client-api.html#s5.2
276
- #
277
- # @param zone [String]
278
- # @param type [String] values: A|CNAME|MX|TXT|SPF|AAAA|NS|SRV|LOC
279
- # @param zoneid [Integer]
280
- # @param name [String]
281
- # @param content [String]
282
- # @param ttl [Integer] values: 1|120...4294967295
283
- # @param service_mode [Boolean] (applies to A/AAAA/CNAME)
284
- # @param prio [Integer] (applies to MX/SRV)
285
- # @param service [String] (applies to SRV)
286
- # @param srvname [String] (applies to SRV)
287
- # @param protocol [Integer] (applies to SRV) values: _tcp/_udp/_tls
288
- # @param weight [Intger] (applies to SRV)
289
- # @param port [Integer] (applies to SRV)
290
- # @param target [String] (applies to SRV)
291
-
292
- def rec_edit(zone, type, zoneid, name, content, ttl, service_mode = nil, prio = nil, service = nil, srvname = nil, protocol = nil, weight = nil, port = nil, target = nil)
293
- send_req({
294
- a: :rec_edit,
295
- z: zone,
296
- type: type,
297
- id: zoneid,
298
- name: name,
299
- content: content,
300
- ttl: ttl,
301
- service_mode: service_mode ? 1 : 0,
302
- prio: prio,
303
- service: service,
304
- srvname: srvname,
305
- protocol: protocol,
306
- weight: weight,
307
- port: port,
308
- target: target
309
- })
310
- end
311
-
312
- # This functon deletes a record for a domain.
313
- #
314
- # @see http://www.cloudflare.com/docs/client-api.html#s5.3
315
- #
316
- # @param zone [String]
317
- # @param zoneid [Integer]
318
-
319
- def rec_delete(zone, zoneid)
320
- send_req({a: :rec_delete, z: zone, id: zoneid})
321
- end
322
-
323
- # HOST
324
-
325
- # This function creates a CloudFlare account mapped to your user.
326
- #
327
- # @see http://www.cloudflare.com/docs/host-api.html#s3.2.1
328
- #
329
- # @param email [String]
330
- # @param pass [String]
331
- # @param login [String] (optional) cloudflare_username
332
- # @param id [Integer] (optional) unique_id
333
- # @param cui [Integer] (optional) clobber_unique_id
334
-
335
- def create_user(email, pass, login = nil, id = nil, cui = nil)
336
- send_req({
337
- act: :user_create,
338
- cloudflare_email: email,
339
- cloudflare_pass: pass,
340
- cloudflare_username: login,
341
- unique_id: id,
342
- clobber_unique_id: cui
343
- })
344
- end
345
-
346
- # This function setups a User's zone for CNAME hosting.
347
- #
348
- # @see http://www.cloudflare.com/docs/host-api.html#s3.2.2
349
- #
350
- # @param user_key [String]
351
- # @param zone [String]
352
- # @param resolve_to [String]
353
- # @param subdomains [String or Array]
354
-
355
- def add_zone(user_key, zone, resolve_to, subdomains)
356
- send_req({
357
- act: :zone_set,
358
- user_key: user_key,
359
- zone_name: zone,
360
- resolve_to: resolve_to,
361
- subdomains: subdomains.kind_of?(Array) ? zones.join(',') : subdomains
362
- })
363
- end
364
-
365
- # This function lookups a user's CloudFlare account information.
366
- #
367
- # @see http://www.cloudflare.com/docs/host-api.html#s3.2.3
368
- #
369
- # *Example:*
370
- #
371
- # cf = CloudFlare('your_host_key')
372
- # cf.user_lookup('unique_id', true)
373
- #
374
- # If +id+ is set to true, email is a unique_id.
375
- #
376
- # @param email [String or Integer]
377
- # @param id [Boolean]
378
-
379
- def user_lookup(email, id = false)
380
- if id
381
- send_req({act: :user_lookup, unique_id: email})
382
- else
383
- send_req({act: :user_lookup, cloudflare_email: email})
384
- end
385
- end
386
-
387
- # This function authorizes access to a user's existing CloudFlare account.
388
- #
389
- # @see http://www.cloudflare.com/docs/host-api.html#s3.2.4
390
- #
391
- # @param email [String]
392
- # @param pass [String]
393
- # @param unique_id [Integer] (optional)
394
- # @param cui [Integer] (optional) clobber_unique_id
395
-
396
- def user_auth(email, pass, id = nil, cui = nil)
397
- send_req({
398
- act: :user_auth,
399
- cloudflare_email: email,
400
- cloudflare_pass: pass,
401
- unique_id: id,
402
- clobber_unique_id: cui
403
- })
404
- end
405
-
406
- # This function lookups a specific user's zone.
407
- #
408
- # @see http://www.cloudflare.com/docs/host-api.html#s3.2.5
409
- #
410
- # @param user_key [String]
411
- # @param zone [String]
412
-
413
- def zone_lookup(user_key, zone)
414
- send_req({act: :zone_lookup, user_key: user_key, zone_name: zone})
415
- end
416
-
417
- # This function deletes a specific zone on behalf of a user.
418
- #
419
- # @see http://www.cloudflare.com/docs/host-api.html#s3.2.6
420
- #
421
- # @param user_key [String]
422
- # @param zone [String]
423
-
424
- def del_zone(user_key, zone)
425
- send_req({act: :zone_delete, user_key: user_key, zone_name: zone})
426
- end
427
-
428
- # This function creates a new child host provider.
429
- #
430
- # @see http://www.cloudflare.com/docs/host-api.html#s3.2.7
431
- #
432
- # @param host_name [String]
433
- # @param pub_name [String]
434
- # @param prefix [String]
435
- # @param website [String]
436
- # @param email [String]
437
-
438
- def host_child_new(host_name, pub_name, prefix, website, email)
439
- send_req({
440
- act: :host_child_new,
441
- pub_name: pub_name,
442
- prefix: prefix,
443
- website: website,
444
- email: email
445
- })
446
- end
447
-
448
- # This function regenerates your host key.
449
- #
450
- # @see http://www.cloudflare.com/docs/host-api.html#s3.2.8
451
-
452
- def host_key_regen
453
- send_req(act: :host_key_regen)
454
- end
455
-
456
- # This function stops a child host provider account.
457
- #
458
- # @see http://www.cloudflare.com/docs/host-api.html#s3.2.9
459
- #
460
- # @param id [Integer] child_id
461
-
462
- def host_child_stop(id)
463
- send_req({act: :host_child_stop, child_id: id})
464
- end
465
-
466
- # This function lists the domains currently active on CloudFlare for the given host.
467
- #
468
- # @see http://www.cloudflare.com/docs/host-api.html#s3.2.10
469
- #
470
- # @param limit [Integer] (optional)
471
- # @param offset [Integer] (optional)
472
- # @param name [String] (optional) zone_name
473
- # @param sub_id [Integer] (optional) sub_id
474
- # @param status [String] (optional) values: V|D|ALL
475
-
476
- def zone_list(limit = 100, offset = 0, name = nil, sub_id = nil, status = nil)
477
- send_req({
478
- act: :zone_list,
479
- offset: offset,
480
- zone_name: name,
481
- sub_id: sub_id,
482
- zone_status: status
483
- })
484
- end
485
-
486
- private
487
-
488
- def send_req(params)
489
-
490
- if @params[:email]
491
- params[:tkn] = @params[:api_key]
492
- params[:u] = @params[:email]
493
- uri = URI(URL_API[:client])
494
- else
495
- params[:host_key] = @params[:api_key]
496
- uri = URI(URL_API[:host])
497
- end
498
-
499
- req = Net::HTTP::Post.new(uri.path)
500
- req.set_form_data(params)
501
-
502
- http = Net::HTTP.new(uri.host, uri.port)
503
- http.use_ssl = true
504
- http.read_timeout = TIMEOUT
505
-
506
- begin
507
- res = http.request(req)
508
- JSON.parse(res.body)
509
- rescue => e
510
- puts "#{e.class} #{e.message}"
511
- end
512
-
513
- end
514
-
1
+ # Copyright, 2012, by Marcin Prokop.
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ require 'cloudflare/connection'
22
+
23
+ module CloudFlare
24
+ def self.connection(api_key, email = nil)
25
+ Connection.new(api_key, email = nil)
26
+ end
515
27
  end