Sha256: 1cc32e4333f2f7d74d602eebf2f290bff37526efe8c6c19a3414f21bda218253
Contents?: true
Size: 1.35 KB
Versions: 2
Compression:
Stored size: 1.35 KB
Contents
module Roger # Loader for mockupfile class Mockupfile # This is the context for the mockupfile evaluation. It should be empty except for the # #mockup method. class Context def initialize(mockupfile) @_mockupfile = mockupfile end def mockup @_mockupfile end def binding ::Kernel.binding end end # @attr :path [Pathname] The path of the Mockupfile for this project attr_accessor :path, :project def initialize(project, path = nil) @project = project @path = (path && Pathname.new(path)) || Pathname.new(project.path + "Mockupfile") end # Actually load the mockupfile def load if File.exist?(@path) && !self.loaded? @source = File.read(@path) context = Context.new(self) eval @source, context.binding, @path.to_s, 1 @loaded = true end end # Wether or not the Mockupfile has been loaded def loaded? @loaded end def release if block_given? yield(self.project.release) end self.project.release end def serve if block_given? yield(self.project.server) end self.project.server end alias :server :serve def test if block_given? yield(self.project.test) end self.project.test end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
roger-1.0.1 | lib/roger/mockupfile.rb |
roger-1.0.0 | lib/roger/mockupfile.rb |