Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update require methods to not use lib/, full path and other dirty quirks

  • Loading branch information...
commit 9b5717cdf9f5de87bd14fd64e2c774b735632e93 1 parent 956089f
@alsemyonov authored
Showing with 32 additions and 24 deletions.
  1. +23 −15 lib/rxsd.rb
  2. +3 −3 lib/rxsd/translator.rb
  3. +6 −6 lib/rxsd/xml.rb
View
38 lib/rxsd.rb
@@ -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'
View
6 lib/rxsd/translator.rb
@@ -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
View
12 lib/rxsd/xml.rb
@@ -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
@@ -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
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.