quickbooks_api 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/quickbooks/api.rb +123 -0
- data/lib/quickbooks/dtd_parser.rb +46 -0
- data/lib/quickbooks/qbxml_base.rb +212 -0
- data/lib/quickbooks/qbxml_parser.rb +96 -0
- data/lib/quickbooks/support/api.rb +88 -0
- data/lib/quickbooks/support/class_builder.rb +65 -0
- data/lib/quickbooks/support/logger.rb +56 -0
- data/lib/quickbooks/support/qbxml.rb +31 -0
- data/lib/quickbooks/support.rb +33 -0
- data/lib/quickbooks.rb +17 -0
- data/ruby_schema/qb/templates/.placeholder +0 -0
- data/ruby_schema/qbpos/templates/.placeholder +0 -0
- data/spec/quickbooks/api_spec.rb +34 -0
- data/spec/quickbooks/class_builder_spec.rb +17 -0
- data/spec/quickbooks/dtd_parser_spec.rb +20 -0
- data/spec/quickbooks/logger_spec.rb +20 -0
- data/spec/quickbooks/qbxml_parser_spec.rb +33 -0
- data/spec/quickbooks/qbxml_spec.rb +23 -0
- data/spec/quickbooks/spec_helper.rb +3 -0
- data/spec/quickbooks/support_spec.rb +118 -0
- data/xml_schema/qbposxmlops30.xml +8343 -0
- data/xml_schema/qbxmlops70.xml +26714 -0
- metadata +131 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
# namespace for dynamically gnerated schema classes
|
2
|
+
module Quickbooks::QBXML; end
|
3
|
+
module Quickbooks::QBPOSXML; end
|
4
|
+
|
5
|
+
module Quickbooks::Support
|
6
|
+
|
7
|
+
def to_attribute_name(obj)
|
8
|
+
name = \
|
9
|
+
case obj
|
10
|
+
when Class
|
11
|
+
simple_class_name(obj)
|
12
|
+
when Nokogiri::XML::Element
|
13
|
+
obj.name
|
14
|
+
else
|
15
|
+
obj.to_s
|
16
|
+
end
|
17
|
+
inflector.underscore(name)
|
18
|
+
end
|
19
|
+
|
20
|
+
def simple_class_name(klass)
|
21
|
+
klass.to_s.split("::").last
|
22
|
+
end
|
23
|
+
|
24
|
+
# easily convert between CamelCase and under_score
|
25
|
+
def inflector
|
26
|
+
ActiveSupport::Inflector
|
27
|
+
end
|
28
|
+
|
29
|
+
def log
|
30
|
+
Quickbooks::API.log
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
data/lib/quickbooks.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'ruby2ruby' # must be version 1.2.1 of ruby2ruby
|
3
|
+
require 'nokogiri'
|
4
|
+
require 'active_support'
|
5
|
+
require 'active_support/core_ext'
|
6
|
+
|
7
|
+
module Quickbooks; end
|
8
|
+
|
9
|
+
require 'quickbooks/support'
|
10
|
+
require 'quickbooks/support/api'
|
11
|
+
require 'quickbooks/support/logger'
|
12
|
+
require 'quickbooks/support/qbxml'
|
13
|
+
require 'quickbooks/support/class_builder'
|
14
|
+
require 'quickbooks/qbxml_base'
|
15
|
+
require 'quickbooks/qbxml_parser'
|
16
|
+
require 'quickbooks/dtd_parser'
|
17
|
+
require 'quickbooks/api'
|
File without changes
|
File without changes
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "spec_helper.rb")
|
2
|
+
|
3
|
+
describe Quickbooks::API do
|
4
|
+
|
5
|
+
describe "interface" do
|
6
|
+
|
7
|
+
it "should initialize" do
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should create ruby wrapper objects for any qbxml input" do
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should convert ruby wrapper objects back to qbxml" do
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "helpers" do
|
19
|
+
|
20
|
+
it "should load the schema" do
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should rebuild the schema" do
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should write the schema to disk" do
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should find a nested qbxml hash" do
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "spec_helper.rb")
|
2
|
+
|
3
|
+
describe Quickbooks::Support::ClassBuilder do
|
4
|
+
|
5
|
+
it "should add a type checked attribute accessor to a class" do
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should add a casting attribute accessor to a class" do
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should add a type accessor for an attribute" do
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should add the appropriate xml template to each ruby wrapper object" do
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "spec_helper.rb")
|
2
|
+
|
3
|
+
describe Quickbooks::DtdParser do
|
4
|
+
|
5
|
+
it "should parse a dtd file and build wrapper classes" do
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should add a casting attribute to a leaf node class" do
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should add a strict attribute to a non leaf node class" do
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should should convert a commment into a data validator for the appropriate attribute" do
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should create a new wrapper class for every xml node" do
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "spec_helper.rb")
|
2
|
+
|
3
|
+
describe Quickbooks::Support::Logger do
|
4
|
+
|
5
|
+
it "should initialize an ActiveSupport::BufferedLogger" do
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should log to a thread specific buffer" do
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should print the contents of the log buffer" do
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should indent, unindent, and reset indentation" do
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should change the format appropriately when the formatter is changed" do
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "spec_helper.rb")
|
2
|
+
|
3
|
+
describe Quickbooks::QbxmlParser do
|
4
|
+
|
5
|
+
it "should set the schema type during initialization" do
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should parse a qbxml file and build wrapper classes" do
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should parse a qbxml string and build wrapper classes" do
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should process an xml document and build wrapper classes" do
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should set the attribute value for a leaf node to a literal" do
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should set the attribute value for a non leaf node to a nested class" do
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should extract data from a leaf node" do
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should fetch the wrapper instance for any qbxml node" do
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should set an objects attribute" do
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "spec_helper.rb")
|
2
|
+
|
3
|
+
describe Quickbooks::QbxmlBase do
|
4
|
+
|
5
|
+
it "should have a type conversion map with all qb types" do
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should build up a wrapper object given an attribute hash" do
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should convert a wrapper object to its equivalent qbxml" do
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should return the attribute values of the wrapper object" do
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should return the attribute names of the wrapper class" do
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should return the type map of the wrapper class" do
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "spec_helper.rb")
|
2
|
+
|
3
|
+
include Quickbooks::Support
|
4
|
+
include Quickbooks::Support::QBXML
|
5
|
+
|
6
|
+
describe Quickbooks::Support do
|
7
|
+
|
8
|
+
describe "configuration helpers" do
|
9
|
+
|
10
|
+
it "should return the supported schema types" do
|
11
|
+
valid_schema_types.should be_an_instance_of(Array)
|
12
|
+
valid_schema_types.include?(:qb).should be_true
|
13
|
+
valid_schema_types.include?(:qbpos).should be_true
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should check if a particular schema type is supported" do
|
17
|
+
self.stub!(:schema_type => :qb)
|
18
|
+
valid_schema_type?.should be_true
|
19
|
+
self.stub!(:schema_type => :qbpos)
|
20
|
+
valid_schema_type?.should be_true
|
21
|
+
self.stub!(:schema_type => :doesntexist)
|
22
|
+
valid_schema_type?.should == false
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should determine the dtd file path for any supported schema type" do
|
26
|
+
self.stub!(:schema_type => :qb)
|
27
|
+
File.exists?(get_dtd_file).should be_true
|
28
|
+
self.stub!(:schema_type => :qbpos)
|
29
|
+
File.exists?(get_dtd_file).should be_true
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should determine the namespace for any supported schema type" do
|
33
|
+
self.stub!(:schema_type => :qb)
|
34
|
+
get_schema_namespace.should be_a_kind_of(Module)
|
35
|
+
self.stub!(:schema_type => :qbpos)
|
36
|
+
get_schema_namespace.should be_a_kind_of(Module)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should determine the container class for any supported schema type" do
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should return the disk cache path" do
|
43
|
+
self.stub!(:schema_type => :qb)
|
44
|
+
File.exists?(get_disk_cache_path).should be_true
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "other helpers" do
|
50
|
+
|
51
|
+
before :all do
|
52
|
+
@qb_api = Quickbooks::API.new(:qb)
|
53
|
+
@qbpos_api = Quickbooks::API.new(:qbpos)
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should return all the cached classes" do
|
57
|
+
self.stub!(:schema_type => :qb)
|
58
|
+
cached_classes.should be_an_instance_of(Array)
|
59
|
+
cached_classes.empty?.should be_false
|
60
|
+
self.stub!(:schema_type => :qbpos)
|
61
|
+
cached_classes.should be_an_instance_of(Array)
|
62
|
+
cached_classes.empty?.should be_false
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should check if a particular class is cached" do
|
66
|
+
self.stub!(:schema_type => :qb)
|
67
|
+
is_cached_class?(Quickbooks::QBXML::QBXML).should be_true
|
68
|
+
self.stub!(:schema_type => :qbpos)
|
69
|
+
is_cached_class?(Quickbooks::QBPOSXML::QBPOSXML).should be_true
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
describe Quickbooks::Support::QBXML do
|
77
|
+
|
78
|
+
it "should set useful parsing constants" do
|
79
|
+
XML_DOCUMENT.should == Nokogiri::XML::Document
|
80
|
+
XML_NODE_SET.should == Nokogiri::XML::NodeSet
|
81
|
+
XML_NODE.should == Nokogiri::XML::Node
|
82
|
+
XML_ELEMENT.should == Nokogiri::XML::Element
|
83
|
+
XML_COMMENT= Nokogiri::XML::Comment
|
84
|
+
XML_TEXT.should == Nokogiri::XML::Text
|
85
|
+
end
|
86
|
+
|
87
|
+
describe "xml parsing helpers" do
|
88
|
+
|
89
|
+
before :each do
|
90
|
+
@klass = Nokogiri::XML::NodeSet
|
91
|
+
stub_child = stub(:class => XML_TEXT)
|
92
|
+
@stub_xml_node = stub(:name => "SomeNodeName", :children => [stub_child])
|
93
|
+
@stub_xml_node.stub!(:is_a?).with(anything).and_return(false)
|
94
|
+
@stub_xml_node.stub!(:is_a?).with(XML_ELEMENT).and_return(true)
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should check if a node is a leaf node" do
|
98
|
+
is_leaf_node?(@stub_xml_node).should be_true
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should convert a class or xml element name to underscored" do
|
102
|
+
to_attribute_name(@klass).should == 'node_set'
|
103
|
+
to_attribute_name(@stub_xml_node).should == 'some_node_name'
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should convert a full class name to a simple class name" do
|
107
|
+
simple_class_name(@klass).should == 'NodeSet'
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should check if a class is already defined in a particular namespace" do
|
113
|
+
end
|
114
|
+
|
115
|
+
it "should cleanup qbxml" do
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|