Module: CSL

Defined in:
lib/csl/extensions.rb,
lib/csl.rb,
lib/csl/info.rb,
lib/csl/node.rb,
lib/csl/style.rb,
lib/csl/errors.rb,
lib/csl/loader.rb,
lib/csl/locale.rb,
lib/csl/parser.rb,
lib/csl/schema.rb,
lib/csl/version.rb,
lib/csl/treelike.rb,
lib/csl/date_part.rb,
lib/csl/style/date.rb,
lib/csl/style/sort.rb,
lib/csl/style/text.rb,
lib/csl/locale/date.rb,
lib/csl/locale/term.rb,
lib/csl/style/group.rb,
lib/csl/style/label.rb,
lib/csl/style/macro.rb,
lib/csl/style/names.rb,
lib/csl/name_options.rb,
lib/csl/style/choose.rb,
lib/csl/style/layout.rb,
lib/csl/style/number.rb,
lib/csl/compatibility.rb,
lib/csl/compatibility.rb,
lib/csl/pretty_printer.rb,
lib/csl/style/citation.rb,
lib/csl/style/bibliography.rb,
lib/csl/locale/style_options.rb

Overview

Some methods in this file are taken from ActiveSupport and are copyright © 2005-2010 David Heinemeier Hansson. They are loaded only if ActiveSupport is not present.

Defined Under Namespace

Modules: DatePart, Extensions, InheritableNameOptions, InheritsNameOptions, Loader, PrettyPrinter, Treelike Classes: Error, Info, Locale, Node, ParseError, Parser, Schema, Style, TextNode, ValidationError

Constant Summary collapse

VERSION =
'2.0.0'.freeze
XML_ENTITY_SUBSTITUTION =
Hash[*%w{
 & &amp; < &lt; > &gt; ' &apos; " &quot;
}].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse(*arguments) ⇒ Object



53
54
55
# File 'lib/csl.rb', line 53

def parse(*arguments)
  Parser.instance.parse(*arguments)
end

.parse!(*arguments) ⇒ Object



57
58
59
# File 'lib/csl.rb', line 57

def parse!(*arguments)
  Parser.instance.parse!(*arguments)
end

.silence_warningsObject



4
5
6
7
8
9
# File 'lib/csl/compatibility.rb', line 4

def silence_warnings
  original_verbosity, $VERBOSE = $VERBOSE, nil
  yield
ensure
  $VERBOSE = original_verbosity
end

.valid?(node) ⇒ Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/csl.rb', line 65

def valid?(node)
  Schema.valid?(node)
end

.validate(node) ⇒ Object



61
62
63
# File 'lib/csl.rb', line 61

def validate(node)
  Schema.validate(node)
end

Instance Method Details

#encode_xml_attr(string) ⇒ Object



41
42
43
44
45
# File 'lib/csl/compatibility.rb', line 41

def encode_xml_attr(string)
  string.gsub(/[&<>'"]/) { |match|
    XML_ENTITY_SUBSTITUTION[match]
  }.inspect
end

#encode_xml_text(string) ⇒ Object



35
36
37
38
39
# File 'lib/csl/compatibility.rb', line 35

def encode_xml_text(string)
  string.gsub(/[&<>]/) { |match|
    XML_ENTITY_SUBSTITUTION[match]
  }
end