Class: Lamma::Code
- Inherits:
-
Object
- Object
- Lamma::Code
- Defined in:
- lib/lamma/code.rb
Constant Summary collapse
- BUILD_FILE_NAME =
'build.zip'
Instance Method Summary collapse
-
#initialize(function, yaml) ⇒ Code
constructor
A new instance of Code.
- #to_h ⇒ Object
- #zip_io ⇒ Object
Constructor Details
#initialize(function, yaml) ⇒ Code
Returns a new instance of Code.
10 11 12 13 14 15 |
# File 'lib/lamma/code.rb', line 10 def initialize(function, yaml) @function = function @source_path = yaml.fetch('source_path', '.') @prebuild = yaml.fetch('prebuild', nil) @build_path = yaml.fetch('build_path', nil) end |
Instance Method Details
#to_h ⇒ Object
37 38 39 40 41 |
# File 'lib/lamma/code.rb', line 37 def to_h { zip_file: zip_io } end |
#zip_io ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/lamma/code.rb', line 17 def zip_io h = cached_build_hash if h bp = File.join(build_path, h, BUILD_FILE_NAME) Lamma.logger.info "Using cached build: #{bp}" @zip_io = File.open(bp, 'rb') else unless File.directory?(@source_path) raise "Source path #{@source_path} doesn't exists" end prebuild @zip_io = zip_and_save end @zip_io end |