Module: Xcode::Deploy::WebAssets

Defined in:
lib/xcode/deploy/web_assets.rb

Defined Under Namespace

Classes: BindingContext

Class Method Summary collapse

Class Method Details

.generate(builder, base_url, &block) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/xcode/deploy/web_assets.rb', line 14

def self.generate(builder, base_url, &block)
	Dir.mktmpdir do |dist_path|

		context = BindingContext.new
		context.product_name = builder.product_name
		context.manifest_url = "#{base_url}/manifest.plist"
		context.deployment_url = "#{base_url}/#{builder.ipa_name}"
		context.bundle_version = builder.bundle_version
		context.bundle_identifier = builder.bundle_identifier

      rhtml = ERB.new(File.read("#{File.dirname(__FILE__)}/templates/manifest.rhtml"))
      File.open("#{dist_path}/manifest.plist", "w") do |io|
        io.write(rhtml.result(context.get_binding))
      end

      rhtml = ERB.new(File.read("#{File.dirname(__FILE__)}/templates/index.rhtml"))
      File.open("#{dist_path}/index.html", "w") do |io|
        io.write(rhtml.result(context.get_binding))
      end

      yield dist_path
    end
end