fastly 1.1.4 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,40 +1,40 @@
1
1
  class Fastly
2
- # An endpoint to stream syslogs to
3
- class Condition < BelongsToServiceAndVersion
4
- attr_accessor :service_id, :name, :priority, :statement, :type
2
+ # An endpoint to stream syslogs to
3
+ class Condition < BelongsToServiceAndVersion
4
+ attr_accessor :service_id, :name, :priority, :statement, :type
5
5
 
6
- ##
7
- # :attr: service_id
8
- #
9
- # The id of the service this belongs to.
6
+ ##
7
+ # :attr: service_id
8
+ #
9
+ # The id of the service this belongs to.
10
10
 
11
- ##
12
- # :attr: version
13
- #
14
- # The number of the version this belongs to.
11
+ ##
12
+ # :attr: version
13
+ #
14
+ # The number of the version this belongs to.
15
15
 
16
- ##
17
- # :attr: name
18
- #
19
- # The name of the condition
16
+ ##
17
+ # :attr: name
18
+ #
19
+ # The name of the condition
20
20
 
21
- ##
22
- # :attr: statement
23
- #
24
- # The statement of the condition, should be a varnish if statement line
21
+ ##
22
+ # :attr: statement
23
+ #
24
+ # The statement of the condition, should be a varnish if statement line
25
25
 
26
- ##
27
- # :attr: priority
28
- #
29
- # What order to run them in, higher priority gets executed after lower priority
26
+ ##
27
+ # :attr: priority
28
+ #
29
+ # What order to run them in, higher priority gets executed after lower priority
30
30
 
31
- ##
32
- # :attr: type
33
- #
34
- # request, cache or response
35
- #
36
- # request has req. object only
37
- # cache has req. and beresp.
38
- # response has req. and resp.
39
- end
31
+ ##
32
+ # :attr: type
33
+ #
34
+ # request, cache or response
35
+ #
36
+ # request has req. object only
37
+ # cache has req. and beresp.
38
+ # response has req. and resp.
39
+ end
40
40
  end
@@ -20,7 +20,7 @@ class Fastly
20
20
 
21
21
  # Return a user object representing the owner of this Customer
22
22
  def owner
23
- self.fetcher.get(User,self.owner_id)
23
+ fetcher.get(User, owner_id)
24
24
  end
25
25
  end
26
26
  end
@@ -48,16 +48,16 @@ class Fastly
48
48
  #
49
49
  # Return true on success and false on failure
50
50
  def add_backend(backend)
51
- hash = fetcher.client.post(Fastly::Director.put_path(self)+"/backend/#{backend.name}")
52
- return !hash.nil?
51
+ hash = fetcher.client.post("#{Director.put_path(self)}/backend/#{backend.name}")
52
+ !hash.nil?
53
53
  end
54
54
 
55
55
  # Delete a Backend object from a Director
56
56
  #
57
57
  # Return true on success and false on failure
58
58
  def delete_backend(backend)
59
- hash = fetcher.client.delete(Fastly::Director.put_path(self)+"/backend/#{backend.name}")
60
- return !hash.nil?
59
+ hash = fetcher.client.delete("#{Director.put_path(self)}/backend/#{backend.name}")
60
+ !hash.nil?
61
61
  end
62
62
  end
63
63
  end
@@ -2,7 +2,7 @@ class Fastly
2
2
  # :nodoc:
3
3
  class AuthRequired < RuntimeError; end
4
4
  # :nodoc:
5
- class FullAuthRequired < Fastly::AuthRequired; end
5
+ class FullAuthRequired < AuthRequired; end
6
6
  # :nodoc:
7
7
  class Error < RuntimeError; end
8
8
  # :nodoc:
@@ -10,14 +10,14 @@ class Fastly
10
10
  # :nodoc:
11
11
  class AdminRequired < AuthRequired; end
12
12
 
13
+ # Encapsulates HTTP client interactions
13
14
  module Fetcher # :nodoc: all
14
-
15
15
  # Get the current Fastly::Client
16
- def client(opts={})
17
- @client ||= Fastly::Client.new(opts)
16
+ def client(opts = {})
17
+ @client ||= Client.new(opts)
18
18
  end
19
19
 
20
- def list(klass, opts={})
20
+ def list(klass, opts = {})
21
21
  list = client.get(klass.list_path(opts))
22
22
  return [] if list.nil?
23
23
  list.map { |hash| klass.new(hash, self) }
@@ -29,23 +29,21 @@ class Fastly
29
29
  else
30
30
  hash = client.get(klass.get_path(*args))
31
31
  end
32
- return nil if hash.nil?
33
- return klass.new(hash, self)
32
+ hash.nil? ? nil : klass.new(hash, self)
34
33
  end
35
34
 
36
35
  def create(klass, opts)
37
- hash = client.post(klass.post_path(opts),opts)
38
- return klass.new(hash, self)
36
+ hash = client.post(klass.post_path(opts), opts)
37
+ klass.new(hash, self)
39
38
  end
40
39
 
41
40
  def update(klass, obj)
42
41
  hash = client.put(klass.put_path(obj), obj.as_hash)
43
- return klass.new(hash, self)
42
+ klass.new(hash, self)
44
43
  end
45
44
 
46
45
  def delete(klass, obj)
47
- return client.delete(klass.delete_path(obj))
46
+ client.delete(klass.delete_path(obj))
48
47
  end
49
-
50
48
  end
51
49
  end
@@ -1,4 +1,4 @@
1
+ # The current version of the library
1
2
  class Fastly
2
- # The current version of the library
3
- VERSION = "1.1.4"
3
+ VERSION = "1.1.5"
4
4
  end
data/lib/fastly/gzip.rb CHANGED
@@ -3,37 +3,36 @@ class Fastly
3
3
  class Gzip < BelongsToServiceAndVersion
4
4
  attr_accessor :service_id, :name, :extensions, :content_types, :cache_condition
5
5
 
6
- ##
7
- # :attr: service_id
8
- #
9
- # The id of the service this belongs to.
6
+ ##
7
+ # :attr: service_id
8
+ #
9
+ # The id of the service this belongs to.
10
10
 
11
- ##
12
- # :attr: version
13
- #
14
- # The number of the version this belongs to.
11
+ ##
12
+ # :attr: version
13
+ #
14
+ # The number of the version this belongs to.
15
15
 
16
- ##
17
- # :attr: name
18
- #
19
- # The name of the condition
16
+ ##
17
+ # :attr: name
18
+ #
19
+ # The name of the condition
20
20
 
21
- ##
22
- # :attr: extensions
23
- #
24
- # File extensions to be gzipped. Seems to want them in a list like
25
- # "js css html"
21
+ ##
22
+ # :attr: extensions
23
+ #
24
+ # File extensions to be gzipped. Seems to want them in a list like
25
+ # "js css html"
26
26
 
27
- ##
28
- # :attr: content_types
29
- #
30
- # Content types to be gzipped. Seems to want them in a list like
31
- # "text/html application/x-javascript"
32
-
33
- ##
34
- # :attr" cache_condition
35
- #
36
- # Cache condition to be used to determine when to apply this gzip setting
27
+ ##
28
+ # :attr: content_types
29
+ #
30
+ # Content types to be gzipped. Seems to want them in a list like
31
+ # "text/html application/x-javascript"
37
32
 
33
+ ##
34
+ # :attr" cache_condition
35
+ #
36
+ # Cache condition to be used to determine when to apply this gzip setting
38
37
  end
39
38
  end
data/lib/fastly/header.rb CHANGED
@@ -3,86 +3,85 @@ class Fastly
3
3
  class Header < BelongsToServiceAndVersion
4
4
  attr_accessor :service_id, :name, :action, :cache_condition, :request_condition, :response_condition, :ignore_if_set, :type, :dst, :src, :substitution, :priority, :regexp
5
5
 
6
- ##
7
- # :attr: service_id
8
- #
9
- # The id of the service this belongs to.
6
+ ##
7
+ # :attr: service_id
8
+ #
9
+ # The id of the service this belongs to.
10
10
 
11
- ##
12
- # :attr: version
13
- #
14
- # The number of the version this belongs to.
11
+ ##
12
+ # :attr: version
13
+ #
14
+ # The number of the version this belongs to.
15
15
 
16
- ##
17
- # :attr: name
18
- #
19
- # The name of the header setting
16
+ ##
17
+ # :attr: name
18
+ #
19
+ # The name of the header setting
20
20
 
21
- ##
22
- # :attr: action
23
- #
24
- # Action to perform on the header. Can be:
25
- # - 'set' - Sets (or resets) a header
26
- # - 'append' - Appends to an existing header
27
- # - 'delete' - Delete a header
28
- # - 'regex' - Perform a single regex replacement on a header
29
- # - 'regex_repeat' - Perform a global regex replacement on a header
21
+ ##
22
+ # :attr: action
23
+ #
24
+ # Action to perform on the header. Can be:
25
+ # - 'set' - Sets (or resets) a header
26
+ # - 'append' - Appends to an existing header
27
+ # - 'delete' - Delete a header
28
+ # - 'regex' - Perform a single regex replacement on a header
29
+ # - 'regex_repeat' - Perform a global regex replacement on a header
30
30
 
31
- ##
32
- # :attr: ignore_if_set
33
- #
34
- # Don't add the header if it is already set. Only applies to the 'set'
35
- # action
31
+ ##
32
+ # :attr: ignore_if_set
33
+ #
34
+ # Don't add the header if it is already set. Only applies to the 'set'
35
+ # action
36
36
 
37
- ##
38
- # :attr: type
39
- #
40
- # - 'request' - Performs on the request before lookup occurs
41
- # - 'fetch' - Performs on the request to the origin server
42
- # - 'cache' - Performs on the response before it's stored in the cache
43
- # - 'response' - Performs on the response before delivering to the client
37
+ ##
38
+ # :attr: type
39
+ #
40
+ # - 'request' - Performs on the request before lookup occurs
41
+ # - 'fetch' - Performs on the request to the origin server
42
+ # - 'cache' - Performs on the response before it's stored in the cache
43
+ # - 'response' - Performs on the response before delivering to the client
44
44
 
45
- ##
46
- # :attr: dst
47
- #
48
- # Header to set
45
+ ##
46
+ # :attr: dst
47
+ #
48
+ # Header to set
49
49
 
50
- ##
51
- # :attr: src
52
- #
53
- # Variable to be used as a source for the header content. Does not apply
54
- # to the 'delete' action.
50
+ ##
51
+ # :attr: src
52
+ #
53
+ # Variable to be used as a source for the header content. Does not apply
54
+ # to the 'delete' action.
55
55
 
56
- ##
57
- # :attr: regexp
58
- #
59
- # Regular expression to use with the 'regex' and 'regex_repeat' actions.
56
+ ##
57
+ # :attr: regexp
58
+ #
59
+ # Regular expression to use with the 'regex' and 'regex_repeat' actions.
60
60
 
61
- ##
62
- # :attr: substitution
63
- #
64
- # Value to substitute in place of regular expression. (Only applies to
65
- # 'regex' and 'regex_repeat'.)
61
+ ##
62
+ # :attr: substitution
63
+ #
64
+ # Value to substitute in place of regular expression. (Only applies to
65
+ # 'regex' and 'regex_repeat'.)
66
66
 
67
- ##
68
- # :attr: priority
69
- #
70
- # Lower priorities execute first.
67
+ ##
68
+ # :attr: priority
69
+ #
70
+ # Lower priorities execute first.
71
71
 
72
- ##
73
- # :attr: request_condition
74
- #
75
- # Optional name of a request condition to apply
72
+ ##
73
+ # :attr: request_condition
74
+ #
75
+ # Optional name of a request condition to apply
76
76
 
77
- ##
78
- # :attr: cache_condition
79
- #
80
- # Optional name of a cache condition to apply
81
-
82
- ##
83
- # :attr: response_condition
84
- #
85
- # Optional name of a response condition to apply
77
+ ##
78
+ # :attr: cache_condition
79
+ #
80
+ # Optional name of a cache condition to apply
86
81
 
82
+ ##
83
+ # :attr: response_condition
84
+ #
85
+ # Optional name of a response condition to apply
87
86
  end
88
87
  end
@@ -1,3 +1,4 @@
1
+ # Invoice object
1
2
  class Fastly
2
3
  # An invoice for a time period
3
4
  class Invoice < Base
@@ -38,7 +39,6 @@ class Fastly
38
39
  #
39
40
  # A hash reference with all the different regions and their subtotals
40
41
 
41
-
42
42
  # Get the start time of this invoice as a DateTime object in UTC
43
43
  def start
44
44
  DateTime.parse(start_time).new_offset(0)
@@ -52,14 +52,16 @@ class Fastly
52
52
  private
53
53
 
54
54
  def self.get_path(*args)
55
- opts = args.size>0 ? args[0] : {}
56
- url = "/billing"
57
- if opts.has_key?(:service_id)
58
- url += "/service/#{opts[:service_id]}"
59
- end
60
- if opts.has_key?(:year) && opts.has_key?(:month)
55
+ opts = args.size > 0 ? args[0] : {}
56
+
57
+ url = '/billing'
58
+
59
+ url += "/service/#{opts[:service_id]}" if opts.key?(:service_id)
60
+
61
+ if opts.key?(:year) && opts.key?(:month)
61
62
  url += "/year/#{opts[:year]}/month/#{opts[:month]}"
62
63
  end
64
+
63
65
  url
64
66
  end
65
67
 
@@ -68,39 +70,38 @@ class Fastly
68
70
  end
69
71
 
70
72
  def self.post_path
71
- raise "You can't POST to an invoice"
73
+ fail "You can't POST to an invoice"
72
74
  end
73
75
 
74
76
  def self.put_path
75
- raise "You can't PUT to an invoice"
77
+ fail "You can't PUT to an invoice"
76
78
  end
77
79
 
78
80
  def self.delete_path
79
- raise "You can't DELETE to an invoice"
81
+ fail "You can't DELETE to an invoice"
80
82
  end
81
83
 
82
84
  def save!
83
- raise "You can't save an invoice"
85
+ fail "You can't save an invoice"
84
86
  end
85
87
 
86
88
  def delete!
87
- raise "You can't delete an invoice"
89
+ fail "You can't delete an invoice"
88
90
  end
89
91
  end
90
92
 
91
-
92
93
  # Return an array of Invoice objects representing invoices for all services.
93
94
  #
94
95
  # If a year and month are passed in returns the invoices for that whole month.
95
96
  #
96
97
  # Otherwise it returns the invoices for the current month so far.
97
- def get_invoice(year=nil, month=nil)
98
+ def get_invoice(year = nil, month = nil)
98
99
  opts = {}
99
100
  unless year.nil? || month.nil?
100
101
  opts[:year] = year
101
102
  opts[:month] = month
102
103
  end
103
- get(Fastly::Invoice, opts)
104
- end
105
104
 
105
+ get(Invoice, opts)
106
+ end
106
107
  end