lib/csl/style.rb in csl-1.0.2 vs lib/csl/style.rb in csl-1.1.0

- old
+ new

@@ -1,10 +1,12 @@ module CSL class Style < Node types << CSL::Info << CSL::Locale + include InheritableNameOptions + @default = :apa @root = '/usr/local/share/csl/styles'.freeze @extension = '.csl'.freeze @@ -12,13 +14,13 @@ class << self include Loader attr_accessor :default - - def load(input = Style.default) - super + + def load(input = nil) + super(input || Style.default) end end attr_defaults :version => Schema.major_version, :xmlns => Schema.namespace @@ -43,12 +45,11 @@ :self_link!, :template_link, :template_link=, :has_template_link?, :documentation_link, :documentation_link=, :has_documentation_link?, :independent_parent_link, :independent_parent_link=, :has_independent_parent_link?, :title=, :id=, :has_title?, :has_id?, :published_at, :updated_at, :citation_format, :citation_format=, - :updated_at, :update!, :license, :license=, :default_license?, - :default_license! + :update!, :license, :license=, :default_license?, :default_license! def initialize(attributes = {}) super(attributes, &nil) children[:locale], children[:macro], @macros, @errors = [], [], {}, [] @@ -75,10 +76,11 @@ def valid? validate.empty? end + remove_method :info # generated by struct_children def info children[:info] ||= Info.new end alias_child :metadata, :info @@ -112,21 +114,43 @@ def independent_parent return unless dependent? load_related_style_from independent_parent_link end + def demote_non_dropping_particle + attributes[:'demote-non-dropping-particle'] + end + alias demote_particle demote_non_dropping_particle + + def demote_non_dropping_particle? + attribute?(:'demote-non-dropping-particle') + end + alias demote_particle? demote_non_dropping_particle? + + def initialize_without_hyphen? + attribute?(:'initialize-with-hyphen') && !attributes[:'initialize-with-hyphen'] + end + + def has_page_range_format? + attribute?(:'page-range-format') + end + + def page_range_format + attributes[:'page-range-format'] + end + private def preamble Schema.preamble.dup end def load_related_style_from(uri) # TODO try local first Style.load(uri) end - + def added_macro(node) unless node.attribute?(:name) raise ValidationError, "failed to register macro #{node.inspect}: name attribute missing" end @@ -136,12 +160,12 @@ "failed to register macro #{node.inspect}: duplicate name" end macros[node[:name]] = node end - + def deleted_macro(node) macros.delete node[:name] end end -end \ No newline at end of file +end