Class: Roger::Mockupfile
- Inherits:
-
Object
- Object
- Roger::Mockupfile
- Defined in:
- lib/roger/mockupfile.rb
Overview
Loader for mockupfile
Defined Under Namespace
Classes: Context
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#initialize(project, path = nil) ⇒ Mockupfile
constructor
A new instance of Mockupfile.
-
#load ⇒ Object
Actually load the mockupfile.
-
#loaded? ⇒ Boolean
Wether or not the Mockupfile has been loaded.
- #release(options = {}) {|release| ... } ⇒ Object
- #serve(options = {}) {|server| ... } ⇒ Object (also: #server)
- #test(options = {}) {|test| ... } ⇒ Object
Constructor Details
#initialize(project, path = nil) ⇒ Mockupfile
Returns a new instance of Mockupfile.
23 24 25 26 |
# File 'lib/roger/mockupfile.rb', line 23 def initialize(project, path = nil) @project = project @path = (path && Pathname.new(path)) || Pathname.new(project.path + "Mockupfile") end |
Instance Attribute Details
#path ⇒ Object
21 22 23 |
# File 'lib/roger/mockupfile.rb', line 21 def path @path end |
#project ⇒ Object
21 22 23 |
# File 'lib/roger/mockupfile.rb', line 21 def project @project end |
Instance Method Details
#load ⇒ Object
Actually load the mockupfile
29 30 31 32 33 34 35 36 |
# File 'lib/roger/mockupfile.rb', line 29 def load return unless File.exist?(@path) && !self.loaded? @source = File.read(@path) context = Context.new(self) eval @source, context.binding, @path.to_s, 1 # rubocop:disable Lint/Eval @loaded = true end |
#loaded? ⇒ Boolean
Wether or not the Mockupfile has been loaded
39 40 41 |
# File 'lib/roger/mockupfile.rb', line 39 def loaded? @loaded end |
#release(options = {}) {|release| ... } ⇒ Object
43 44 45 46 47 |
# File 'lib/roger/mockupfile.rb', line 43 def release( = {}) release = project.release() yield(release) if block_given? release end |
#serve(options = {}) {|server| ... } ⇒ Object Also known as: server
49 50 51 52 53 |
# File 'lib/roger/mockupfile.rb', line 49 def serve( = {}) server = project.server() yield(server) if block_given? server end |
#test(options = {}) {|test| ... } ⇒ Object
57 58 59 60 61 |
# File 'lib/roger/mockupfile.rb', line 57 def test( = {}) test = project.test() yield(test) if block_given? test end |