Sha256: 5c0cbb4f1dbfe88f6be96c631aedb4ed1bc521090614b24107f92e3d8e4a8fbd

Contents?: true

Size: 910 Bytes

Versions: 4

Compression:

Stored size: 910 Bytes

Contents

module FaaStRuby
  module Local
    class RubyFunction < Function
      include Local::Logger

      def self.default_gemfile
        faastruby_rpc_version = Gem::DependencyList.from_specs.select{|d| d.name == 'faastruby-rpc'}[0]&.version || '0.2.3'
        "source 'https://rubygems.org'\n"
      end

      def yaml_hash
        debug "yaml_hash"
        hash = {
          'cli_version' => FaaStRuby::VERSION,
          'name' => @name,
          'runtime' => DEFAULT_RUBY_RUNTIME
        }
      end

      def write_handler
        debug "write_handler"
        content = "def handler(event)\n  # Write code here\n  \nend"
        file = "#{@absolute_folder}/handler.rb"
        if File.size(file) > 0
          puts "New Ruby function '#{@name}' detected."
        else
          File.write(file, content)
          puts "New Ruby function '#{@name}' initialized."
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
faastruby-0.5.30 lib/faastruby/local/functions/ruby.rb
faastruby-0.5.29 lib/faastruby/local/functions/ruby.rb
faastruby-0.5.28 lib/faastruby/local/functions/ruby.rb
faastruby-0.5.27 lib/faastruby/local/functions/ruby.rb