wakizashi 0.1.0

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.
Files changed (42) hide show
  1. data/.gitignore +8 -0
  2. data/Gemfile +4 -0
  3. data/README.md +54 -0
  4. data/Rakefile +24 -0
  5. data/app/app_delegate.rb +9 -0
  6. data/lib/wakizashi/base.rb +13 -0
  7. data/lib/wakizashi/version.rb +3 -0
  8. data/lib/wakizashi/xml_document.rb +148 -0
  9. data/lib/wakizashi/xml_element.rb +45 -0
  10. data/lib/wakizashi/xml_node.rb +5 -0
  11. data/lib/wakizashi.rb +15 -0
  12. data/spec/wakizashi_spec.rb +28 -0
  13. data/spec/xml_document_spec.rb +24 -0
  14. data/spec/xml_element_spec.rb +16 -0
  15. data/spec/xml_node_spec.rb +2 -0
  16. data/vendor/Podfile.lock +5 -0
  17. data/vendor/Pods/GDataXML-HTML/.gitignore +13 -0
  18. data/vendor/Pods/GDataXML-HTML/GDataXML-HTML/GDataXML-HTML-Info.plist +38 -0
  19. data/vendor/Pods/GDataXML-HTML/GDataXML-HTML/GDataXML-HTML-Prefix.pch +14 -0
  20. data/vendor/Pods/GDataXML-HTML/GDataXML-HTML/GDataXML_HTMLAppDelegate.h +28 -0
  21. data/vendor/Pods/GDataXML-HTML/GDataXML-HTML/GDataXML_HTMLAppDelegate.m +82 -0
  22. data/vendor/Pods/GDataXML-HTML/GDataXML-HTML/GDataXML_HTMLViewController.h +29 -0
  23. data/vendor/Pods/GDataXML-HTML/GDataXML-HTML/GDataXML_HTMLViewController.m +89 -0
  24. data/vendor/Pods/GDataXML-HTML/GDataXML-HTML/en.lproj/GDataXML_HTMLViewController.xib +351 -0
  25. data/vendor/Pods/GDataXML-HTML/GDataXML-HTML/en.lproj/InfoPlist.strings +2 -0
  26. data/vendor/Pods/GDataXML-HTML/GDataXML-HTML/en.lproj/MainWindow.xib +444 -0
  27. data/vendor/Pods/GDataXML-HTML/GDataXML-HTML/html.html +34 -0
  28. data/vendor/Pods/GDataXML-HTML/GDataXML-HTML/lib/GDataXMLNode.h +229 -0
  29. data/vendor/Pods/GDataXML-HTML/GDataXML-HTML/lib/GDataXMLNode.m +1910 -0
  30. data/vendor/Pods/GDataXML-HTML/GDataXML-HTML/main.m +24 -0
  31. data/vendor/Pods/GDataXML-HTML/GDataXML-HTML/xml.xml +15 -0
  32. data/vendor/Pods/GDataXML-HTML/GDataXML-HTML.xcodeproj/project.pbxproj +317 -0
  33. data/vendor/Pods/GDataXML-HTML/GDataXML-HTML.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  34. data/vendor/Pods/GDataXML-HTML/README.markdown +55 -0
  35. data/vendor/Pods/Headers/GDataXML-HTML/GDataXMLNode.h +229 -0
  36. data/vendor/Pods/Pods-prefix.pch +3 -0
  37. data/vendor/Pods/Pods-resources.sh +15 -0
  38. data/vendor/Pods/Pods.bridgesupport +231 -0
  39. data/vendor/Pods/Pods.xcconfig +4 -0
  40. data/vendor/Pods/build-iPhoneSimulator/libPods.a +0 -0
  41. data/wakizashi.gemspec +18 -0
  42. metadata +124 -0
@@ -0,0 +1,229 @@
1
+ /* Modifications for HTML parser support:
2
+ * Copyright (c) 2011 Simon Grätzer simon@graetzer.org
3
+ *
4
+ * Copyright (c) 2008 Google Inc.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ // These node, element, and document classes implement a subset of the methods
20
+ // provided by NSXML. While NSXML behavior is mimicked as much as possible,
21
+ // there are important differences.
22
+ //
23
+ // The biggest difference is that, since this is based on libxml2, there
24
+ // is no retain model for the underlying node data. Rather than copy every
25
+ // node obtained from a parse tree (which would have a substantial memory
26
+ // impact), we rely on weak references, and it is up to the code that
27
+ // created a document to retain it for as long as any
28
+ // references rely on nodes inside that document tree.
29
+
30
+
31
+ #import <Foundation/Foundation.h>
32
+
33
+ // libxml includes require that the target Header Search Paths contain
34
+ //
35
+ // /usr/include/libxml2
36
+ //
37
+ // and Other Linker Flags contain
38
+ //
39
+ // -lxml2
40
+
41
+ #import <libxml/tree.h>
42
+ #import <libxml/parser.h>
43
+ #import <libxml/xmlstring.h>
44
+ #import <libxml/HTMLparser.h>
45
+ #import <libxml/xpath.h>
46
+ #import <libxml/xpathInternals.h>
47
+
48
+
49
+ #if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4) || defined(GDATA_TARGET_NAMESPACE)
50
+ // we need NSInteger for the 10.4 SDK, or we're using target namespace macros
51
+ #import "GDataDefines.h"
52
+ #endif
53
+
54
+ #undef _EXTERN
55
+ #undef _INITIALIZE_AS
56
+ #ifdef GDATAXMLNODE_DEFINE_GLOBALS
57
+ #define _EXTERN
58
+ #define _INITIALIZE_AS(x) =x
59
+ #else
60
+ #if defined(__cplusplus)
61
+ #define _EXTERN extern "C"
62
+ #else
63
+ #define _EXTERN extern
64
+ #endif
65
+ #define _INITIALIZE_AS(x)
66
+ #endif
67
+
68
+ // when no namespace dictionary is supplied for XPath, the default namespace
69
+ // for the evaluated tree is registered with the prefix _def_ns
70
+ _EXTERN const char* kGDataXMLXPathDefaultNamespacePrefix _INITIALIZE_AS("_def_ns");
71
+
72
+ // Nomenclature for method names:
73
+ //
74
+ // Node = GData node
75
+ // XMLNode = xmlNodePtr
76
+ //
77
+ // So, for example:
78
+ // + (id)nodeConsumingXMLNode:(xmlNodePtr)theXMLNode;
79
+
80
+ @class NSArray, NSDictionary, NSError, NSString, NSURL;
81
+ @class GDataXMLElement, GDataXMLDocument;
82
+
83
+ enum {
84
+ GDataXMLInvalidKind = 0,
85
+ GDataXMLDocumentKind,
86
+ GDataXMLElementKind,
87
+ GDataXMLAttributeKind,
88
+ GDataXMLNamespaceKind,
89
+ GDataXMLProcessingInstructionKind,
90
+ GDataXMLCommentKind,
91
+ GDataXMLTextKind,
92
+ GDataXMLDTDKind,
93
+ GDataXMLEntityDeclarationKind,
94
+ GDataXMLAttributeDeclarationKind,
95
+ GDataXMLElementDeclarationKind,
96
+ GDataXMLNotationDeclarationKind
97
+ };
98
+
99
+ typedef NSUInteger GDataXMLNodeKind;
100
+
101
+ @interface GDataXMLNode : NSObject <NSCopying> {
102
+ @protected
103
+ // NSXMLNodes can have a namespace URI or prefix even if not part
104
+ // of a tree; xmlNodes cannot. When we create nodes apart from
105
+ // a tree, we'll store the dangling prefix or URI in the xmlNode's name,
106
+ // like
107
+ // "prefix:name"
108
+ // or
109
+ // "{http://uri}:name"
110
+ //
111
+ // We will fix up the node's namespace and name (and those of any children)
112
+ // later when adding the node to a tree with addChild: or addAttribute:.
113
+ // See fixUpNamespacesForNode:.
114
+
115
+ xmlNodePtr xmlNode_; // may also be an xmlAttrPtr or xmlNsPtr
116
+ BOOL shouldFreeXMLNode_; // if yes, xmlNode_ will be free'd in dealloc
117
+
118
+ // cached values
119
+ NSString *cachedName_;
120
+ NSArray *cachedChildren_;
121
+ NSArray *cachedAttributes_;
122
+ }
123
+
124
+ + (GDataXMLElement *)elementWithName:(NSString *)name;
125
+ + (GDataXMLElement *)elementWithName:(NSString *)name stringValue:(NSString *)value;
126
+ + (GDataXMLElement *)elementWithName:(NSString *)name URI:(NSString *)value;
127
+
128
+ + (id)attributeWithName:(NSString *)name stringValue:(NSString *)value;
129
+ + (id)attributeWithName:(NSString *)name URI:(NSString *)attributeURI stringValue:(NSString *)value;
130
+
131
+ + (id)namespaceWithName:(NSString *)name stringValue:(NSString *)value;
132
+
133
+ + (id)textWithStringValue:(NSString *)value;
134
+
135
+ - (NSString *)stringValue;
136
+ - (void)setStringValue:(NSString *)str;
137
+
138
+ - (NSUInteger)childCount;
139
+ - (NSArray *)children;
140
+ - (GDataXMLNode *)childAtIndex:(unsigned)index;
141
+
142
+ - (NSString *)localName;
143
+ - (NSString *)name;
144
+ - (NSString *)prefix;
145
+ - (NSString *)URI;
146
+
147
+ - (GDataXMLNodeKind)kind;
148
+
149
+ - (NSString *)XMLString;
150
+
151
+ + (NSString *)localNameForName:(NSString *)name;
152
+ + (NSString *)prefixForName:(NSString *)name;
153
+
154
+ // This is the preferred entry point for nodesForXPath. This takes an explicit
155
+ // namespace dictionary (keys are prefixes, values are URIs).
156
+ - (NSArray *)nodesForXPath:(NSString *)xpath namespaces:(NSDictionary *)namespaces error:(NSError **)error;
157
+
158
+ // This implementation of nodesForXPath registers namespaces only from the
159
+ // document's root node. _def_ns may be used as a prefix for the default
160
+ // namespace, though there's no guarantee that the default namespace will
161
+ // be consistenly the same namespace in server responses.
162
+ - (NSArray *)nodesForXPath:(NSString *)xpath error:(NSError **)error;
163
+
164
+ // access to the underlying libxml node; be sure to release the cached values
165
+ // if you change the underlying tree at all
166
+ - (xmlNodePtr)XMLNode;
167
+ - (void)releaseCachedValues;
168
+
169
+ @end
170
+
171
+
172
+ @interface GDataXMLElement : GDataXMLNode
173
+
174
+ - (id)initWithXMLString:(NSString *)str error:(NSError **)error;
175
+ - (id)initWithHTMLString:(NSString *)str error:(NSError **)error;
176
+
177
+ - (NSArray *)namespaces;
178
+ - (void)setNamespaces:(NSArray *)namespaces;
179
+ - (void)addNamespace:(GDataXMLNode *)aNamespace;
180
+
181
+ // addChild adds a copy of the child node to the element
182
+ - (void)addChild:(GDataXMLNode *)child;
183
+ - (void)removeChild:(GDataXMLNode *)child;
184
+
185
+ - (NSArray *)elementsForName:(NSString *)name;
186
+ - (NSArray *)elementsForLocalName:(NSString *)localName URI:(NSString *)URI;
187
+
188
+ - (NSArray *)attributes;
189
+ - (GDataXMLNode *)attributeForName:(NSString *)name;
190
+ - (GDataXMLNode *)attributeForLocalName:(NSString *)name URI:(NSString *)attributeURI;
191
+ - (void)addAttribute:(GDataXMLNode *)attribute;
192
+
193
+ - (NSString *)resolvePrefixForNamespaceURI:(NSString *)namespaceURI;
194
+
195
+ @end
196
+
197
+ @interface GDataXMLDocument : NSObject {
198
+ @protected
199
+ xmlDoc* xmlDoc_; // strong; always free'd in dealloc
200
+ }
201
+
202
+ - (id)initWithXMLString:(NSString *)str options:(unsigned int)mask error:(NSError **)error;
203
+ - (id)initWithHTMLString:(NSString *)str options:(unsigned int)mask error:(NSError **)error;
204
+
205
+ - (id)initWithData:(NSData *)data options:(unsigned int)mask error:(NSError **)error;
206
+ - (id)initWithHTMLData:(NSData *)data options:(unsigned int)mask error:(NSError **)error;
207
+
208
+ // initWithRootElement uses a copy of the argument as the new document's root
209
+ - (id)initWithRootElement:(GDataXMLElement *)element;
210
+
211
+ - (GDataXMLElement *)rootElement;
212
+
213
+ - (NSData *)XMLData;
214
+
215
+ - (void)setVersion:(NSString *)version;
216
+ - (void)setCharacterEncoding:(NSString *)encoding;
217
+
218
+ // This is the preferred entry point for nodesForXPath. This takes an explicit
219
+ // namespace dictionary (keys are prefixes, values are URIs).
220
+ - (NSArray *)nodesForXPath:(NSString *)xpath namespaces:(NSDictionary *)namespaces error:(NSError **)error;
221
+
222
+ // This implementation of nodesForXPath registers namespaces only from the
223
+ // document's root node. _def_ns may be used as a prefix for the default
224
+ // namespace, though there's no guarantee that the default namespace will
225
+ // be consistenly the same namespace in server responses.
226
+ - (NSArray *)nodesForXPath:(NSString *)xpath error:(NSError **)error;
227
+
228
+ - (NSString *)description;
229
+ @end