lib/jets/stack/function.rb in jets-1.7.2 vs lib/jets/stack/function.rb in jets-1.8.0

- old
+ new

@@ -12,10 +12,12 @@ handler = attributes['Properties']['Handler'] handler.split('.').last end def lang + return if internal? + if source_file # Detect language from file extension ext = File.extname(source_file).sub(/^\./,'').to_sym lang_map[ext] else @@ -35,26 +37,33 @@ Dir.glob(search_expression).first end memoize :source_file def search_expression + base_search_expression.sub('handlers/shared/', "#{Jets.root}/app/shared/") + end + + def internal_search_expression + internal = File.expand_path("../internal", File.dirname(__FILE__)) + base_search_expression.sub('handlers/shared/', "#{internal}/app/shared/") + end + + def base_search_expression attributes = @template.values.first handler = attributes['Properties']['Handler'] - search_expression = handler.split('.')[0..-2].join('.') + '.*' - search_expression.sub('handlers/shared/', "#{Jets.root}/app/shared/") + handler.split('.')[0..-2].join('.') + '.*' # search_expression + # Example: handlers/shared/functions/jets/s3_bucket_config.* end + # Internal flag is mainly used to disable WARN messages + def internal? + !!Dir.glob(internal_search_expression).first + end + # Relative path # app/shared/functions/kevin.py => handlers/shared/functions/kevin.py def handler_dest return unless source_file - - dest = source_file.sub(%r{.*/app/}, "handlers/") - if lang == :ruby - filename = dest.split('.').first - filename + '.js' # change extension to .js because ruby uses a node shim - else - dest - end + source_file.sub(%r{.*/app/}, "handlers/") end end end \ No newline at end of file