Class: YARD::Serializers::YardocSerializer

Inherits:
FileSystemSerializer show all
Defined in:
lib/yard/serializers/yardoc_serializer.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (YardocSerializer) initialize(yfile)

Returns a new instance of YardocSerializer



30
31
32
# File 'lib/yard/serializers/yardoc_serializer.rb', line 30

def initialize(yfile)
  super(:basepath => yfile, :extension => 'dat')
end

Instance Attribute Details

- (String) basepath Originally defined in class FileSystemSerializer

The base path to write data to.

Returns:

- (String) extension Originally defined in class FileSystemSerializer

The extension of the filename (defaults to html)

Returns:

  • (String)

    the extension of the file. Empty string for no extension.

- (SymbolHash) options (readonly) Originally defined in class Base

All serializer options are saved so they can be passed to other serializers.

Returns:

Instance Method Details

- (Object) checksums_path



37
# File 'lib/yard/serializers/yardoc_serializer.rb', line 37

def checksums_path; File.join(basepath, 'checksums') end

- (Object) deserialize(path, is_path = false)



73
74
75
76
77
78
79
80
81
82
# File 'lib/yard/serializers/yardoc_serializer.rb', line 73

def deserialize(path, is_path = false)
  path = File.join(basepath, serialized_path(path)) unless is_path
  if File.file?(path)
    log.debug "Deserializing #{path}..."
    Marshal.load(File.read_binary(path))
  else
    log.debug "Could not find #{path}"
    nil
  end
end

- (Object) object_types_path



38
# File 'lib/yard/serializers/yardoc_serializer.rb', line 38

def object_types_path; File.join(basepath, 'object_types') end

- (Object) objects_path



34
# File 'lib/yard/serializers/yardoc_serializer.rb', line 34

def objects_path; File.join(basepath, 'objects') end

- (Object) proxy_types_path

Deprecated.

The registry no longer tracks proxy types



36
# File 'lib/yard/serializers/yardoc_serializer.rb', line 36

def proxy_types_path; File.join(basepath, 'proxy_types') end

- (Object) serialize(object)



65
66
67
68
69
70
71
# File 'lib/yard/serializers/yardoc_serializer.rb', line 65

def serialize(object)
  if Hash === object
    super(object[:root], dump(object)) if object[:root]
  else
    super(object, dump(object))
  end
end

- (Object) serialized_path(object)



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/yard/serializers/yardoc_serializer.rb', line 40

def serialized_path(object)
  path = case object
  when String, Symbol
    object = object.to_s
    if object =~ /#/
      object += '_i'
    elsif object =~ /\./
      object += '_c'
    end
    object.split(/::|\.|#/).map do |p|
      p.gsub(/[^\w\.-]/) do |x|
        encoded = '_'

        x.each_byte { |b| encoded << ("%X" % b) }
        encoded
      end
    end.join('/') + '.' + extension
  when YARD::CodeObjects::RootObject
    'root.dat'
  else
    super(object)
  end
  File.join('objects', path)
end