Class: ReleaseFile
- Inherits:
-
Object
- Object
- ReleaseFile
- Defined in:
- lib/release_party/release_file.rb
Overview
Release file just gives us some handy short hand for defining variables inside a file, e.g:
x 1 y 2
Sets the configuration variables x and y to 1 and 2 respectively, plus it supports blocks and comments
Constant Summary collapse
- FileNotFoundError =
Class.new(RuntimeError)
- RELEASE_FILE =
'Releasefile'
- RELEASE_PATH =
File.join(Dir.pwd, RELEASE_FILE)
Instance Attribute Summary collapse
-
#variables ⇒ Object
readonly
Returns the value of attribute variables.
Instance Method Summary collapse
-
#initialize(path = RELEASE_PATH) ⇒ ReleaseFile
constructor
A new instance of ReleaseFile.
- #method_missing(method_id, *args, &block) ⇒ Object
Constructor Details
#initialize(path = RELEASE_PATH) ⇒ ReleaseFile
Returns a new instance of ReleaseFile.
20 21 22 23 24 25 |
# File 'lib/release_party/release_file.rb', line 20 def initialize(path = RELEASE_PATH) @variables = {} raise FileNotFoundError, "No Releasefile found name at #{path}" unless File.exists?(path) eval File.read(path) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_id, *args, &block) ⇒ Object
27 28 29 |
# File 'lib/release_party/release_file.rb', line 27 def method_missing(method_id, *args, &block) @variables[method_id.to_sym] = args.first || block end |
Instance Attribute Details
#variables ⇒ Object (readonly)
Returns the value of attribute variables.
18 19 20 |
# File 'lib/release_party/release_file.rb', line 18 def variables @variables end |