Sha256: a48d954c42c2fb6be58717f6ec55f13ff2a986bfab25813a602488cf4e8fef73

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require 'erb'
require 'ostruct'
require 'tmpdir'

module Xcode
	module Deploy
		module WebAssets
			class BindingContext < OpenStruct
				def get_binding
    	    return binding()
		    end
			end

			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
		end
	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
xcoder-0.1.18 lib/xcode/deploy/web_assets.rb