codily 0.1.0.beta → 0.2.0

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
  SHA1:
3
- metadata.gz: 3d995bf7783e0bfd8753d031d84a17baada6c7fc
4
- data.tar.gz: 5bffd97e4de0bf768b604bd8e90673859494e58d
3
+ metadata.gz: d5ccea29ad8df53e57d7ea9a3f4f7cf39f2c4ba4
4
+ data.tar.gz: 6f15de9ea8cf711a27d9025ebbe188b67ee1c8ea
5
5
  SHA512:
6
- metadata.gz: 23f7949471655a5381d7b3c2e89ba53072e691deaafacfd95de2d217b5d5539dd9045c9570da6b242ac2869155a96b777aa6dc0fc5aab625bf4694df5bcb0bae
7
- data.tar.gz: f8d71e4a5b1a006b49d49c64bdd46852c77e4dbfa29e31cb99aa225a7ce5ba2408d66c954c1af3e06518458ed291b09d70c89224f5d561b0cc8297df0a068caa
6
+ metadata.gz: d2e8231b7369ac78b0977a95e0f77617a8cce6b6dd4f2ab075dc7c0c6d2461abe3813a116ba387a49c771c325f394249a803ec68362c8d05789f8f0e08138c63
7
+ data.tar.gz: a5195b25eddb9b7cab63133be12bf54edc7d883381b008496bdd9e4161677f12920939188c1db5334b229656c3005141a6a17e22bdc6dadbe1aa6f5e7b47eb0d
data/README.md CHANGED
@@ -43,6 +43,8 @@ codily --apply --file ./codily.rb --dry-run
43
43
  codily --apply --file ./codily.rb --target my-service
44
44
  ```
45
45
 
46
+ You have to set api key in environment variable `FASTLY_API_KEY`
47
+
46
48
  ## Restrictions
47
49
 
48
50
  - Directors are not supported due to its deprecation
data/lib/codily/cli.rb CHANGED
@@ -40,7 +40,7 @@ module Codily
40
40
  Dir.chdir(File.dirname(options[:file]))
41
41
 
42
42
  present = importer.run.root
43
- desired = Root.new(debug: options[:debug]).run_string(File.read(File.basename(options[:file])), options[:file], 1)
43
+ desired = Root.new(debug: options[:debug], service_filter: options[:target]).run_string(File.read(File.basename(options[:file])), options[:file], 1)
44
44
 
45
45
  require_fastly_auth!
46
46
 
@@ -9,6 +9,15 @@ module Codily
9
9
  statement
10
10
  )
11
11
 
12
+ def setup
13
+ delete_if_empty! *%i(
14
+ comment
15
+ )
16
+ force_integer! *%i(
17
+ priority
18
+ )
19
+ end
20
+
12
21
  def type(obj = nil)
13
22
  getset :type, obj.to_s.upcase
14
23
  end
data/lib/codily/engine.rb CHANGED
@@ -52,6 +52,17 @@ module Codily
52
52
  act_any = false
53
53
  act = false
54
54
 
55
+ present.service_versions.each do |id, version|
56
+ if !version[:dev]
57
+ puts "CLONE VERSION: #{version[:name]}.#{version[:active]}"
58
+ if !dry_run
59
+ version[:dev] = fastly.get_version(id, version[:active]).clone.number
60
+ end
61
+ end
62
+ end
63
+
64
+ puts
65
+
55
66
  creations.each do |new_element|
56
67
  act_any = act = true
57
68
  puts "CREATE: #{new_element.inspect}"
@@ -39,7 +39,7 @@ module Codily
39
39
  next unless @service_filter.any? { |_| _ === service.name }
40
40
  end
41
41
  service_version = root.service_version_set(service.name, service.id, service.versions)
42
- import_version = @import_targets[service.id] || @import_targets[service.name] || service_version[:dev]
42
+ import_version = @import_targets[service.id] || @import_targets[service.name] || service_version[:dev] || service_version[:active]
43
43
 
44
44
  root.add_element Elements::Service.new(root, service)
45
45
 
data/lib/codily/root.rb CHANGED
@@ -5,15 +5,18 @@ module Codily
5
5
  class Root
6
6
  class AlreadyDefined < StandardError; end
7
7
 
8
- def initialize(debug: false)
8
+ def initialize(debug: false, service_filter: nil)
9
9
  @debug = debug
10
10
  @elements = {}
11
11
 
12
+ @service_filter = service_filter
12
13
  @service_versions = {}
13
14
  @service_map_name_to_id = {}
14
15
  end
15
16
 
16
17
  attr_reader :elements
18
+ attr_reader :service_filter
19
+ attr_reader :service_versions
17
20
  attr_accessor :debug
18
21
 
19
22
  def as_hash
@@ -27,7 +30,8 @@ module Codily
27
30
  # XXX: is it okay having this here?
28
31
  def service_version_set(service_name, service_id, versions)
29
32
  @service_map_name_to_id[service_name] = service_id
30
- dev = versions.reverse_each.find { |_| !_.locked }.number
33
+ dev_version = versions.reverse_each.find { |_| !_.locked }
34
+ dev = dev_version && dev_version.number
31
35
  active = (versions.reverse_each.find(&:active) || versions.reverse_each.find(&:locked)).number
32
36
  @service_versions[service_id] = {dev: dev, active: active, name: service_name, id: service_id}
33
37
  end
@@ -41,6 +45,10 @@ module Codily
41
45
  end
42
46
 
43
47
  def service(name, &block)
48
+ if service_filter
49
+ return nil unless service_filter.any? { |_| _ === name }
50
+ end
51
+
44
52
  raise AlreadyDefined if services.key?(name)
45
53
  add_element(Elements::Service.new(self, {name: name}, &block))
46
54
  end
@@ -1,3 +1,3 @@
1
1
  module Codily
2
- VERSION = "0.1.0.beta"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codily
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.beta
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sorah Fukumori
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-30 00:00:00.000000000 Z
11
+ date: 2016-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fastly
@@ -126,12 +126,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
126
126
  version: '0'
127
127
  required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ">"
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
- version: 1.3.1
131
+ version: '0'
132
132
  requirements: []
133
133
  rubyforge_project:
134
- rubygems_version: 2.6.4
134
+ rubygems_version: 2.6.6
135
135
  signing_key:
136
136
  specification_version: 4
137
137
  summary: Codificate Fastly configuration