Class: ReleaseFile

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(path = RELEASE_PATH) ⇒ ReleaseFile

Returns a new instance of ReleaseFile.

Raises:



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

#variablesObject (readonly)

Returns the value of attribute variables.



18
19
20
# File 'lib/release_party/release_file.rb', line 18

def variables
  @variables
end