wbxml 0.0.1
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/History.txt +4 -0
- data/License.txt +20 -0
- data/Manifest.txt +10 -0
- data/README.txt +54 -0
- data/config/hoe.rb +75 -0
- data/config/requirements.rb +15 -0
- data/ext/wbxml/extconf.rb +7 -0
- data/ext/wbxml/wbxml.c +81 -0
- data/lib/wbxml/version.rb +9 -0
- data/setup.rb +1585 -0
- data/test/test_wbxml_extn.rb +10 -0
- metadata +68 -0
data/History.txt
ADDED
data/License.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 Clifford Heath
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
= wbxml
|
2
|
+
|
3
|
+
* http://wbxml.rubyforge.org/
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Convert XML to WBXML for WAP mobile phone services
|
8
|
+
wbxml is a simple Ruby wrapper for the wbxml2 library.
|
9
|
+
|
10
|
+
== FEATURES/PROBLEMS:
|
11
|
+
|
12
|
+
* WBXML.xml_to_wbxml - converts XML to WBXML
|
13
|
+
* WBXML.wbxml_to_xml - converts WBXML to XML
|
14
|
+
|
15
|
+
== SYNOPSIS:
|
16
|
+
|
17
|
+
xml = File.open("message.xml"){|f| f.read}
|
18
|
+
wbxml = WBXML.xml_to_wbxml xml
|
19
|
+
$output.print wbxml
|
20
|
+
|
21
|
+
== REQUIREMENTS:
|
22
|
+
|
23
|
+
* a working wbxml2
|
24
|
+
** OSX: port install wbxml2
|
25
|
+
** Debian: apt-get install libwbxml2
|
26
|
+
|
27
|
+
== INSTALL:
|
28
|
+
|
29
|
+
* sudo gem install
|
30
|
+
|
31
|
+
== LICENSE:
|
32
|
+
|
33
|
+
(The MIT License)
|
34
|
+
|
35
|
+
Copyright (c) 2008 FIX
|
36
|
+
|
37
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
38
|
+
a copy of this software and associated documentation files (the
|
39
|
+
'Software'), to deal in the Software without restriction, including
|
40
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
41
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
42
|
+
permit persons to whom the Software is furnished to do so, subject to
|
43
|
+
the following conditions:
|
44
|
+
|
45
|
+
The above copyright notice and this permission notice shall be
|
46
|
+
included in all copies or substantial portions of the Software.
|
47
|
+
|
48
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
49
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
50
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
51
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
52
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
53
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
54
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/config/hoe.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'wbxml/version'
|
2
|
+
|
3
|
+
AUTHOR = 'Clifford Heath' # can also be an array of Authors
|
4
|
+
EMAIL = "cjheath@rubyforge.org"
|
5
|
+
DESCRIPTION = "Wrapper for wbxml2, a WAP<->XML converter"
|
6
|
+
GEM_NAME = 'wbxml' # what ppl will type to install your gem
|
7
|
+
RUBYFORGE_PROJECT = 'wbxml' # The unix name for your project
|
8
|
+
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
9
|
+
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
10
|
+
EXTRA_DEPENDENCIES = [
|
11
|
+
# ['activesupport', '>= 1.3.1']
|
12
|
+
] # An array of rubygem dependencies [name, version]
|
13
|
+
|
14
|
+
@config_file = "~/.rubyforge/user-config.yml"
|
15
|
+
@config = nil
|
16
|
+
RUBYFORGE_USERNAME = "unknown"
|
17
|
+
def rubyforge_username
|
18
|
+
unless @config
|
19
|
+
begin
|
20
|
+
@config = YAML.load(File.read(File.expand_path(@config_file)))
|
21
|
+
rescue
|
22
|
+
puts <<-EOS
|
23
|
+
ERROR: No rubyforge config file found: #{@config_file}
|
24
|
+
Run 'rubyforge setup' to prepare your env for access to Rubyforge
|
25
|
+
- See http://newgem.rubyforge.org/rubyforge.html for more details
|
26
|
+
EOS
|
27
|
+
exit
|
28
|
+
end
|
29
|
+
end
|
30
|
+
RUBYFORGE_USERNAME.replace @config["username"]
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
REV = nil
|
35
|
+
# UNCOMMENT IF REQUIRED:
|
36
|
+
# REV = YAML.load(`svn info`)['Revision']
|
37
|
+
VERS = Wbxml::VERSION::STRING + (REV ? ".#{REV}" : "")
|
38
|
+
RDOC_OPTS = ['--quiet', '--title', 'wbxml documentation',
|
39
|
+
"--opname", "index.html",
|
40
|
+
"--line-numbers",
|
41
|
+
"--main", "README",
|
42
|
+
"--inline-source"]
|
43
|
+
|
44
|
+
class Hoe
|
45
|
+
def extra_deps
|
46
|
+
@extra_deps.reject! { |x| Array(x).first == 'hoe' }
|
47
|
+
@extra_deps
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Generate all the Rake tasks
|
52
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
53
|
+
$hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
54
|
+
p.developer(AUTHOR, EMAIL)
|
55
|
+
p.description = DESCRIPTION
|
56
|
+
p.summary = DESCRIPTION
|
57
|
+
p.url = HOMEPATH
|
58
|
+
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
59
|
+
# p.test_globs = ["spec/**/spec_*.rb"]
|
60
|
+
p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store', 'ext/wbxml/*.o*' ] #An array of file patterns to delete on clean.
|
61
|
+
|
62
|
+
# == Optional
|
63
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
64
|
+
#p.extra_deps = EXTRA_DEPENDENCIES
|
65
|
+
|
66
|
+
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
67
|
+
end
|
68
|
+
|
69
|
+
# Arrange to build the extension on install:
|
70
|
+
$hoe.spec.extensions = ['ext/wbxml/extconf.rb']
|
71
|
+
|
72
|
+
CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
|
73
|
+
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
74
|
+
$hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
|
75
|
+
$hoe.rsync_args = '-av --delete --ignore-errors'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
include FileUtils
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
%w[rake hoe newgem rubigen].each do |req_gem|
|
6
|
+
begin
|
7
|
+
require req_gem
|
8
|
+
rescue LoadError
|
9
|
+
puts "This Rakefile requires the '#{req_gem}' RubyGem."
|
10
|
+
puts "Installation: gem install #{req_gem} -y"
|
11
|
+
exit
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
|
data/ext/wbxml/wbxml.c
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
/*
|
2
|
+
* Ruby extension to expose the conversion methods of WBXML,
|
3
|
+
* the WAP XML to XML (and back) converter.
|
4
|
+
*
|
5
|
+
* Copyright 2008 Clifford Heath. SOME RIGHTS RESERVED, READ THE COPYRIGHT.
|
6
|
+
* This work was paid for by Gekocard Pty Ltd for http://mobiblast.com
|
7
|
+
*/
|
8
|
+
#include <ruby.h>
|
9
|
+
#include <wbxml.h> /* libwbxml2 */
|
10
|
+
|
11
|
+
VALUE mWBXML; /* The WBXML module object */
|
12
|
+
|
13
|
+
VALUE
|
14
|
+
xml_to_wbxml(VALUE self, VALUE xml_source)
|
15
|
+
{
|
16
|
+
WBXMLError ret = WBXML_OK;
|
17
|
+
WBXMLConvXML2WBXMLParams params;
|
18
|
+
WB_UTINY* xml = NULL; /* Must be null terminated */
|
19
|
+
WB_UTINY* wbxml = NULL;
|
20
|
+
WB_ULONG wbxml_len = 0;
|
21
|
+
VALUE value;
|
22
|
+
|
23
|
+
Check_SafeStr(xml_source);
|
24
|
+
if (TYPE(xml_source) != T_STRING)
|
25
|
+
rb_raise(rb_eTypeError, "parameter to xml_to_wbxml must be a string");
|
26
|
+
xml = (WB_UTINY*)STR2CSTR(xml_source);
|
27
|
+
|
28
|
+
params.wbxml_version = WBXML_VERSION_13;
|
29
|
+
params.use_strtbl = TRUE;
|
30
|
+
params.keep_ignorable_ws = FALSE;
|
31
|
+
|
32
|
+
ret = wbxml_conv_xml2wbxml(xml, &wbxml, &wbxml_len, ¶ms);
|
33
|
+
if (ret != WBXML_OK)
|
34
|
+
rb_raise(rb_eRuntimeError, (const char*)wbxml_errors_string(ret));
|
35
|
+
|
36
|
+
value = rb_str_new((const char*)wbxml, wbxml_len);
|
37
|
+
|
38
|
+
if (wbxml != NULL)
|
39
|
+
wbxml_free(wbxml);
|
40
|
+
return value;
|
41
|
+
}
|
42
|
+
|
43
|
+
VALUE
|
44
|
+
wbxml_to_xml(VALUE self, VALUE wbxml_source)
|
45
|
+
{
|
46
|
+
WBXMLError ret = WBXML_OK;
|
47
|
+
WBXMLConvWBXML2XMLParams params;
|
48
|
+
WB_UTINY* wbxml = NULL;
|
49
|
+
WB_ULONG wbxml_len = 0;
|
50
|
+
WB_UTINY* xml = NULL; /* Must be null terminated */
|
51
|
+
VALUE value;
|
52
|
+
|
53
|
+
Check_SafeStr(wbxml_source);
|
54
|
+
if (TYPE(wbxml_source) != T_STRING)
|
55
|
+
rb_raise(rb_eTypeError, "parameter to wbxml_to_xml must be a string");
|
56
|
+
wbxml = (WB_UTINY*)STR2CSTR(wbxml_source);
|
57
|
+
wbxml_len = RSTRING_LEN(wbxml_source);
|
58
|
+
|
59
|
+
params.gen_type = WBXML_ENCODER_XML_GEN_INDENT;
|
60
|
+
params.lang = WBXML_LANG_UNKNOWN; /* Don't force the language */
|
61
|
+
params.indent = 2;
|
62
|
+
params.keep_ignorable_ws = FALSE;
|
63
|
+
|
64
|
+
ret = wbxml_conv_wbxml2xml(wbxml, wbxml_len, &xml, ¶ms);
|
65
|
+
if (ret != WBXML_OK)
|
66
|
+
rb_raise(rb_eRuntimeError, (const char*)wbxml_errors_string(ret));
|
67
|
+
|
68
|
+
value = rb_str_new((const char*)xml, strlen(xml));
|
69
|
+
|
70
|
+
if (xml != NULL)
|
71
|
+
wbxml_free(xml);
|
72
|
+
return value;
|
73
|
+
}
|
74
|
+
|
75
|
+
void
|
76
|
+
Init_wbxml()
|
77
|
+
{
|
78
|
+
mWBXML = rb_define_module("WBXML");
|
79
|
+
rb_define_singleton_method(mWBXML, "xml_to_wbxml", xml_to_wbxml, 1);
|
80
|
+
rb_define_singleton_method(mWBXML, "wbxml_to_xml", wbxml_to_xml, 1);
|
81
|
+
}
|