Class: Anvil::Manifest
- Inherits:
-
Object
- Object
- Anvil::Manifest
- Includes:
- Helpers
- Defined in:
- lib/anvil/manifest.rb
Constant Summary collapse
- PUSH_THREAD_COUNT =
40
Instance Attribute Summary collapse
-
#cache_url ⇒ Object
readonly
Returns the value of attribute cache_url.
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
-
#manifest ⇒ Object
readonly
Returns the value of attribute manifest.
Instance Method Summary collapse
- #add(filename) ⇒ Object
- #build(options = {}) ⇒ Object
-
#initialize(dir = nil, cache_url = nil) ⇒ Manifest
constructor
A new instance of Manifest.
- #save ⇒ Object
- #to_json ⇒ Object
- #upload ⇒ Object
Methods included from Helpers
#anvil_metadata_dir, #json_decode, #json_encode, #read_anvil_metadata, #write_anvil_metadata
Constructor Details
#initialize(dir = nil, cache_url = nil) ⇒ Manifest
Returns a new instance of Manifest.
18 19 20 21 22 |
# File 'lib/anvil/manifest.rb', line 18 def initialize(dir=nil, cache_url=nil) @dir = dir @manifest = @dir ? directory_manifest(@dir) : {} @cache_url = cache_url end |
Instance Attribute Details
#cache_url ⇒ Object (readonly)
Returns the value of attribute cache_url.
14 15 16 |
# File 'lib/anvil/manifest.rb', line 14 def cache_url @cache_url end |
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
15 16 17 |
# File 'lib/anvil/manifest.rb', line 15 def dir @dir end |
#manifest ⇒ Object (readonly)
Returns the value of attribute manifest.
16 17 18 |
# File 'lib/anvil/manifest.rb', line 16 def manifest @manifest end |
Instance Method Details
#add(filename) ⇒ Object
87 88 89 |
# File 'lib/anvil/manifest.rb', line 87 def add(filename) @manifest[filename] = file_manifest(filename) end |
#build(options = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/anvil/manifest.rb', line 24 def build(={}) uri = URI.parse("#{anvil_host}/manifest/build") http = Net::HTTP.new(uri.host, uri.port) if uri.scheme == "https" http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE end req = Net::HTTP::Post.new uri.request_uri env = [:env] || {} req.set_form_data({ "buildpack" => [:buildpack], "cache" => @cache_url, "env" => json_encode([:env] || {}), "manifest" => self.to_json }) slug_url = nil http.request(req) do |res| slug_url = res["x-slug-url"] @cache_url = res["x-cache-url"] begin res.read_body do |chunk| yield chunk end rescue EOFError puts raise Heroku::Builder::BuildError, "terminated unexpectedly" end code = if res["x-exit-code"].nil? manifest_id = Array(res["x-manifest-id"]).first Integer(String.new(anvil["/exit/#{manifest_id}"].get.to_s)) else res["x-exit-code"].first.to_i end raise Heroku::Builder::BuildError, "exited #{code}" unless code.zero? end slug_url end |
#save ⇒ Object
72 73 74 75 |
# File 'lib/anvil/manifest.rb', line 72 def save res = anvil["/manifest"].post(:manifest => self.to_json) res.headers[:location] end |
#to_json ⇒ Object
83 84 85 |
# File 'lib/anvil/manifest.rb', line 83 def to_json json_encode(@manifest) end |
#upload ⇒ Object
77 78 79 80 81 |
# File 'lib/anvil/manifest.rb', line 77 def upload missing = json_decode(anvil["/manifest/diff"].post(:manifest => self.to_json).to_s) upload_hashes missing missing.length end |