Skip to content

Commit

Permalink
Update require methods to not use lib/, full path and other dirty quirks
Browse files Browse the repository at this point in the history
  • Loading branch information
alsemyonov committed Mar 3, 2012
1 parent 956089f commit 9b5717c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 24 deletions.
38 changes: 23 additions & 15 deletions lib/rxsd.rb
Expand Up @@ -3,21 +3,29 @@
# Copyright (C) 2010 Mohammed Morsi <movitto@yahoo.com>
# See COPYING for the License of this software

lib = File.dirname(__FILE__)

$: << lib + '/rxsd/'

require 'rubygems'
require 'active_support/core_ext/string/inflections'

require lib + '/rxsd/exceptions'
require lib + '/rxsd/common'
require lib + '/rxsd/builtin_types'
require lib + '/rxsd/xml'
require lib + '/rxsd/loader'
require lib + '/rxsd/resolver'
require lib + '/rxsd/parser'
require lib + '/rxsd/builder'
require lib + '/rxsd/translator'
require 'rxsd/exceptions'
require 'rxsd/common'
require 'rxsd/builtin_types'
require 'rxsd/xml'
require 'rxsd/loader'
require 'rxsd/resolver'
require 'rxsd/parser'
require 'rxsd/builder'
require 'rxsd/translator'

Dir[lib + '/rxsd/xsd/*.rb'].each { |xsd_module| require xsd_module }
require 'rxsd/xsd/attribute'
require 'rxsd/xsd/attribute_group'
require 'rxsd/xsd/choice'
require 'rxsd/xsd/complex_content'
require 'rxsd/xsd/complex_type'
require 'rxsd/xsd/element'
require 'rxsd/xsd/extension'
require 'rxsd/xsd/group'
require 'rxsd/xsd/list'
require 'rxsd/xsd/restriction'
require 'rxsd/xsd/schema'
require 'rxsd/xsd/sequence'
require 'rxsd/xsd/simple_content'
require 'rxsd/xsd/simple_type'
6 changes: 3 additions & 3 deletions lib/rxsd/translator.rb
Expand Up @@ -6,9 +6,9 @@
# See COPYING for the License of this software

# include whatever output builders you want here,
require 'builders/ruby_class'
require 'builders/ruby_definition'
require 'builders/ruby_object'
require 'rxsd/builders/ruby_class'
require 'rxsd/builders/ruby_definition'
require 'rxsd/builders/ruby_object'

module RXSD

Expand Down
12 changes: 6 additions & 6 deletions lib/rxsd/xml.rb
Expand Up @@ -6,26 +6,26 @@
require 'rubygems'

# require libxml adapter
require 'libxml_adapter'
require 'rxsd/libxml_adapter'

module RXSD
module XML

# RXSD XML node interface that subclasses must conform to and implement methods
class Node

# Should return name of node, eg <foo> => "foo"
virtual :name

# Return hash of attribute name / values
virtual :attrs

# Should return bool if node has a parent
virtual :parent?

# Should return this nodes's parent, if any
virtual :parent

# Should return children nodes
virtual :children

Expand All @@ -47,7 +47,7 @@ class Node
def self.factory(args = {})
backend = args[:backend]
xml = args[:xml]

# add additional backend drivers here if desired
return LibXMLNode.xml_root(xml) if backend == :libxml
return nil
Expand All @@ -64,7 +64,7 @@ def root
# Instantiate all children of provided class type
def children_objs(klass)
elements = []
children.find_all { |c| c.name == klass.tag_name }.each { |c|
children.find_all { |c| c.name == klass.tag_name }.each { |c|
elements << klass.from_xml(c)
}
return elements
Expand Down

0 comments on commit 9b5717c

Please sign in to comment.