fastly 0.95 → 0.96
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.
- data/bin/fastly_upload_vcl +9 -8
- data/lib/fastly.rb +7 -6
- data/lib/fastly/belongs_to_service_and_version.rb +1 -1
- data/lib/fastly/version.rb +10 -1
- metadata +4 -4
data/bin/fastly_upload_vcl
CHANGED
@@ -46,22 +46,23 @@ die("Couldn't find any of the config files - #{configs.join(',')}") unless param
|
|
46
46
|
die("Couldn't find vcl file #{vcl_file}") unless File.file?(vcl_file)
|
47
47
|
|
48
48
|
fastly = Fastly.new(params)
|
49
|
+
|
49
50
|
service = fastly.get_service(service_id) || die("Couldn't find service #{service_id}")
|
50
|
-
|
51
|
-
|
52
|
-
puts "Uploading #{vcl_file}
|
51
|
+
version = service.version
|
52
|
+
die "Can't upload a vcl file to the last (#{version.number}) version of #{service.name} (#{service.id}) because it's locked" if version.locked?
|
53
|
+
puts "Uploading #{vcl_file} to version #{version.number}"
|
53
54
|
begin
|
54
55
|
name = File.basename(vcl_file, ".vcl")
|
55
56
|
content = File.new(vcl_file, "r").read
|
56
|
-
vcl =
|
57
|
+
vcl = version.vcl(name)
|
57
58
|
if vcl
|
58
59
|
vcl.content = content
|
59
60
|
vcl.save!
|
60
61
|
else
|
61
|
-
|
62
|
+
version.upload_vcl(name, content)
|
62
63
|
end
|
63
|
-
|
64
|
+
# version.activate!
|
64
65
|
rescue => e
|
65
|
-
die("Couldn't upload
|
66
|
+
die("Couldn't upload vcl: #{e}")
|
66
67
|
end
|
67
|
-
puts "Done!"
|
68
|
+
puts "Done! You should now go and activate it at https://app.fastly.com/#configure"
|
data/lib/fastly.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# A client library for interacting with the Fastly web acceleration service
|
6
6
|
class Fastly
|
7
7
|
# The current version of the library
|
8
|
-
VERSION = "0.
|
8
|
+
VERSION = "0.96"
|
9
9
|
|
10
10
|
require 'fastly/fetcher'
|
11
11
|
require 'fastly/client'
|
@@ -409,13 +409,14 @@ class Fastly
|
|
409
409
|
return options unless File.exist?(file)
|
410
410
|
|
411
411
|
File.open(file, "r") do |infile|
|
412
|
-
while (line = infile.gets
|
412
|
+
while (line = infile.gets) do
|
413
|
+
line.chomp!
|
413
414
|
next if line =~ /^#/;
|
414
415
|
next if line =~ /^\s*$/;
|
415
416
|
next unless line =~ /=/;
|
416
417
|
line.strip!
|
417
418
|
key, val = line.split(/\s*=\s*/, 2)
|
418
|
-
options[key] = val;
|
419
|
+
options[key.to_sym] = val;
|
419
420
|
end
|
420
421
|
end
|
421
422
|
options;
|
@@ -430,16 +431,16 @@ class Fastly
|
|
430
431
|
#
|
431
432
|
# --<key>=<value>
|
432
433
|
#
|
433
|
-
def self.get_options(files)
|
434
|
+
def self.get_options(*files)
|
434
435
|
options = {}
|
435
436
|
files.each do |file|
|
436
437
|
next unless File.exist?(file)
|
437
|
-
options =
|
438
|
+
options = load_config(file)
|
438
439
|
break
|
439
440
|
end
|
440
441
|
|
441
442
|
while (ARGV.size>0 && ARGV[0] =~ /^-+(\w+)\=(\w+)$/) do
|
442
|
-
options[$1] = $2;
|
443
|
+
options[$1.to_sym] = $2;
|
443
444
|
@ARGV.shift;
|
444
445
|
end
|
445
446
|
raise"Couldn't find options from command line arguments or #{files.join(', ')}" unless options.size>0
|
data/lib/fastly/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
class Fastly
|
2
2
|
# An iteration of your configuration
|
3
3
|
class Version < Base
|
4
|
-
attr_accessor :service_id, :number, :name, :active, :
|
4
|
+
attr_accessor :service_id, :number, :name, :active, :staging, :testing, :deployed, :comment
|
5
5
|
|
6
6
|
##
|
7
7
|
# :attr: service_id
|
@@ -52,6 +52,15 @@ class Fastly
|
|
52
52
|
#
|
53
53
|
# a free form comment field
|
54
54
|
|
55
|
+
# Is this Version locked
|
56
|
+
def locked?
|
57
|
+
return @locked.to_i > 1
|
58
|
+
end
|
59
|
+
|
60
|
+
# Set whether this Version is locked
|
61
|
+
def locked=(is_locked)
|
62
|
+
@locked = is_locked ? "1" : "0"
|
63
|
+
end
|
55
64
|
|
56
65
|
# Get the Service object this Version belongs to
|
57
66
|
def service
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 203
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: "0.
|
8
|
+
- 96
|
9
|
+
version: "0.96"
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Fastly Inc
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date:
|
17
|
+
date: 2012-01-17 00:00:00 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: json
|