lib/yard-api/serializer.rb in yard-api-0.3.0 vs lib/yard-api/serializer.rb in yard-api-0.3.1
- old
+ new
@@ -1,22 +1,16 @@
module YARD::APIPlugin
- class Serializer < ::YARD::Serializers::FileSystemSerializer
- USNSEP = '__' # url-safe namespace separator
- FSSEP = '/'
+ class Serializer < ::YARD::Serializers::FileSystemSerializer
+ USNSEP = '__' # url-safe namespace separator
+ FSSEP = '/'
- def self.topicize(str)
- str.lines.first.gsub(/\W+/, '_').downcase
- end
+ def self.topicize(str)
+ str.lines.first.gsub(/\W+/, '_').downcase
+ end
def serialize(object, data)
path = File.join(basepath, serialized_path(object))
-
- if path.include?(' ')
- debugger
- end
-
- log.debug "Serializing to #{path}"
File.open!(path, "wb") {|f| f.write data }
end
def serialized_path(object)
return object if object.is_a?(String)
@@ -25,37 +19,33 @@
if object.is_a?(YARD::CodeObjects::ExtraFileObject)
fspath = 'file.' + object.name + (extension.empty? ? '' : ".#{extension}")
else
fspath = if object == YARD::Registry.root
- "top-level-namespace"
+ "top-level-namespace"
else
- self.class.topicize(get_api_id(object))
+ self.class.topicize(get_api_id(object))
end
if object.is_a?(YARD::CodeObjects::MethodObject)
- fspath += '_' + object.scope.to_s[0,1]
+ fspath += '_' + object.scope.to_s[0,1]
end
unless extension.empty?
- fspath += ".#{extension}"
- end
+ fspath += ".#{extension}"
+ end
end
- if (fspath.include?(' '))
- debugger
- end
-
fspath.gsub(/[^\w\.\-_\/]+/, '-')
end
- def get_api_id(object)
- if object[:api_id]
- object.api_id
- elsif tag = object.tag(:API)
- tag.text.lines.first.strip
- else
- object.name.to_s
- end
- end
- end
+ def get_api_id(object)
+ if object[:api_id]
+ object.api_id
+ elsif tag = object.tag(:API)
+ tag.text.lines.first.strip
+ else
+ object.to_s
+ end
+ end
+ end
end
\ No newline at end of file