xoxo 1.0.1 → 1.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.
data/.ruby ADDED
@@ -0,0 +1,36 @@
1
+ ---
2
+ spec_version: 1.0.0
3
+ replaces: []
4
+
5
+ loadpath:
6
+ - lib
7
+ name: xoxo
8
+ repositories:
9
+ public: git://github.com/rubyworks/xoxo.git
10
+ conflicts: []
11
+
12
+ engine_check: []
13
+
14
+ title: XOXO
15
+ contact: Thomas Sawyer <transfire@gmail.com>
16
+ resources:
17
+ code: http://github.com/rubyworks/xoxo
18
+ home: http://rubyworks.github.com/xoxo
19
+ maintainers: []
20
+
21
+ requires:
22
+ - group:
23
+ - build
24
+ name: redline
25
+ version: 0+
26
+ suite: rubyworks
27
+ manifest: MANIFEST.txt
28
+ version: 1.1.0
29
+ licenses:
30
+ - chneukirchen
31
+ copyright: Copyright (c) 2006 Christian Neukirchen
32
+ authors:
33
+ - Christian Neukirchen <chneukirchen@gmail.com>
34
+ description: XOXO is a Ruby XOXO parser and generator. It provides a Ruby API similar to Marshal and YAML (though more specific) to load and dump XOXO[http://microformats.org/wiki/xoxo], an simple, open outline format written in standard XHTML and suitable for embedding in (X)HTML, Atom, RSS, and arbitrary XML.
35
+ summary: XOXO Parser and Generator
36
+ created: 2006-01-01
@@ -1,3 +1,7 @@
1
+ = COPYRIGHT NOTICES
2
+
3
+ == xoxo.rb
4
+
1
5
  Copyright (c) 2007, 2008 Christian Neukirchen <purl.org/net/chneukirchen>
2
6
 
3
7
  Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -0,0 +1,30 @@
1
+ = RELEASE HISTORY
2
+
3
+
4
+ == 1.1.0 | 2011-05-05
5
+
6
+ This release improves how the library handles Struct objects and
7
+ general Object instances. The previous release applied #to_s to these
8
+ objects, which usually led to the turning a inspection string into
9
+ an XOXO document, which is certainly not the desired effect. This
10
+ release extracts the member attributes into a hash and converts this
11
+ hash to XOXO.
12
+
13
+ Changes:
14
+
15
+ * Convert Struct and general Object instances properly.
16
+ * Add QED documentation.
17
+
18
+
19
+ == 1.0.0 | 2009-07-06
20
+
21
+ This is essentially the XOXO library written Christian Neukirchen.
22
+ While the library has been distributed as part of Facets for some
23
+ time, there is no separate gem avaialbe for it. So this then is
24
+ that stand-alone release. It differs from the original only in
25
+ that it provides #to_xoxo.
26
+
27
+ Changes:
28
+
29
+ * Happy Birthday!
30
+
data/Profile ADDED
@@ -0,0 +1,30 @@
1
+ ---
2
+ title : XOXO
3
+ summary : XOXO Parser and Generator
4
+ contact : Thomas Sawyer <transfire@gmail.com>
5
+ suite : rubyworks
6
+ created : 2006-01-01
7
+ license : chneukirchen
8
+ copyright : Copyright (c) 2006 Christian Neukirchen
9
+
10
+ requires:
11
+ - redline (build)
12
+
13
+ authors:
14
+ - Christian Neukirchen <chneukirchen@gmail.com>
15
+
16
+ description:
17
+ XOXO is a Ruby XOXO parser and generator. It provides
18
+ a Ruby API similar to Marshal and YAML (though more
19
+ specific) to load and dump XOXO[http://microformats.org/wiki/xoxo],
20
+ an simple, open outline format written in standard XHTML and
21
+ suitable for embedding in (X)HTML, Atom, RSS, and arbitrary XML.
22
+
23
+ resources:
24
+ home: http://rubyworks.github.com/xoxo
25
+ code: http://github.com/rubyworks/xoxo
26
+
27
+ repositories:
28
+ public: git://github.com/rubyworks/xoxo.git
29
+
30
+
@@ -1,11 +1,6 @@
1
1
  = XOXO
2
2
 
3
- * http://rubyworks.github.com/xoxo
4
- * http://github.com/rubyworks/xoxo
5
- * http://chneukirchen.org/repos/xoxo-rb/
6
-
7
-
8
- == DESCRIPTION:
3
+ == DESCRIPTION
9
4
 
10
5
  XOXO is a Ruby XOXO parser and generator. It provides
11
6
  a Ruby API similar to Marshal and YAML (though more
@@ -14,29 +9,43 @@ an simple, open outline format written in standard XHTML and
14
9
  suitable for embedding in (X)HTML, Atom, RSS, and arbitrary XML.
15
10
 
16
11
 
17
- == FEATURES/ISSUES:
12
+ == FEATURES
18
13
 
19
14
  * Uses REXML's pull parser.
20
15
  * Serialize any object via to_xoxo.
21
16
 
22
17
 
23
- == RELEASE NOTES:
18
+ == RESOURCES
19
+
20
+ * home: http://rubyworks.github.com/xoxo
21
+ * code: http://github.com/rubyworks/xoxo
22
+
23
+ The original version of this code was written by Christian Neukirchen,
24
+ and can be found here[http://chneukirchen.org/repos/xoxo-rb/] and a
25
+ blog post on it here[http://chneukirchen.org/blog/archive/2006/01/xoxo-rb-0-1-released.html].
26
+
27
+ The offical XOXO format site is here[http://microformats.org/wiki/xoxo].
28
+
29
+
30
+ == RELEASE NOTES
24
31
 
25
32
  Please see HISTORY file.
26
33
 
27
34
 
28
- == SYNOPSIS:
35
+ == SYNOPSIS
29
36
 
30
37
  Simple way to generate XOXO.
31
38
 
32
39
  obj.to_xoxo
33
40
 
41
+ For more details see the QED and API documentation.
42
+
34
43
 
35
- == INSTALLATION:
44
+ == INSTALLATION
36
45
 
37
46
  To install with RubyGems simply open a console and type:
38
47
 
39
- gem install xoxo
48
+ $ gem install xoxo
40
49
 
41
50
  Local installation requires Setup.rb (gem install setup),
42
51
  then download the tarball package and type:
@@ -48,11 +57,11 @@ then download the tarball package and type:
48
57
  Windows users use 'ruby setup.rb all'.
49
58
 
50
59
 
51
- == COPYING:
60
+ == COPYING
52
61
 
53
62
  Copyright (C) 2006 Christian Neukirchen
54
63
 
55
64
  This program is ditributed unser the terms of the Ruby license.
56
65
 
57
- See LICENSE or COPYING file for details.
66
+ See COPYING file for details.
58
67
 
data/Redfile ADDED
@@ -0,0 +1,86 @@
1
+ ---
2
+ email:
3
+ service : Email
4
+ file : ~
5
+ subject : ~
6
+ mailto : ruby-talk@ruby-lang.org
7
+ active : true
8
+
9
+ gem:
10
+ service: Gem
11
+ active : true
12
+
13
+ testrb:
14
+ service : testrb
15
+ tests : ~
16
+ exclude : ~
17
+ loadpath : ~
18
+ requires : ~
19
+ live : false
20
+ active : false
21
+
22
+ syntax:
23
+ service : Syntax
24
+ loadpath : ~
25
+ exclude : ~
26
+ active : false
27
+
28
+ rdoc:
29
+ service : RDoc
30
+ format : newfish
31
+ include : [README.rdoc, HISTORY.rdoc, COPYING.rdoc, lib]
32
+ exclude : ~
33
+ main : ~
34
+ extra : ~
35
+ output : site/docs/api
36
+ active : true
37
+
38
+ ri:
39
+ service: RI
40
+ include: ~
41
+ exclude: ~
42
+ output : ri
43
+ active : true
44
+
45
+ qedoc:
46
+ service: Custom
47
+ document: |
48
+ system "qedoc -t XOXO -o site/docs/qed qed/"
49
+
50
+ dnote:
51
+ service : DNote
52
+ loadpath : ~
53
+ labels : ~
54
+ output : ~
55
+ format : ~
56
+ active : false
57
+
58
+ stats:
59
+ service : Stats
60
+ title : ~
61
+ loadpath : ~
62
+ exclude : ~
63
+ output : ~
64
+ active : true
65
+
66
+ #vclog:
67
+ # service : VClog
68
+ # format : html # xml, txt
69
+ # layout : rel # gnu
70
+ # typed : false
71
+ # output : ~
72
+ # active : false
73
+
74
+ #rubyforge:
75
+ # service : Forge
76
+ # unixname: <%= collection %>
77
+ # groupid : ~
78
+ # package : <%= name %>
79
+ # sitemap:
80
+ # doc/rdoc: <%= name %>
81
+ # active : false
82
+
83
+ grancher:
84
+ service: Grancher
85
+ active: true
86
+
data/Version ADDED
@@ -0,0 +1 @@
1
+ 1.1.0
@@ -2,8 +2,6 @@
2
2
  #
3
3
  # Copyright (C) 2006 Christian Neukirchen
4
4
  #
5
- # Ruby License
6
- #
7
5
  # This module is free software. You may use, modify, and/or redistribute this
8
6
  # software under the same terms as Ruby.
9
7
  #
@@ -23,10 +21,9 @@ require 'rexml/parsers/pullparser'
23
21
  #
24
22
  module XOXO
25
23
  # xoxo.rb version number
26
- VERSION = "1.0.1"
24
+ VERSION = "1.1.0"
27
25
 
28
26
  # Load and return a XOXO structure from the String, IO or StringIO or _xoxo_.
29
- #
30
27
  def self.load(xoxo)
31
28
  structs = Parser.new(xoxo).parse.structs
32
29
  while structs.kind_of?(Array) && structs.size == 1
@@ -51,7 +48,7 @@ module XOXO
51
48
  # wrapped XOXO document.
52
49
  #
53
50
  def self.dump(struct, options={})
54
- struct = [struct] unless struct.kind_of? Array
51
+ struct = [struct] unless struct.kind_of? Array
55
52
 
56
53
  if options[:html_wrap]
57
54
  result = <<EOF.strip
@@ -73,6 +70,9 @@ EOF
73
70
 
74
71
  private
75
72
 
73
+ # Serialize an object in XOXO format.
74
+ #
75
+ # @return [String] an XOXO document
76
76
  def self.make_xoxo(struct, class_name=nil)
77
77
  s = ''
78
78
  case struct
@@ -113,19 +113,39 @@ EOF
113
113
  when String
114
114
  s << struct
115
115
 
116
+ when Numeric
117
+ s << struct.to_s
118
+
119
+ when Struct
120
+ h = {}
121
+ struct.each_pair do |k,v|
122
+ h[k] = v
123
+ end
124
+ s = make_xoxo(h, class_name)
125
+
116
126
  else
117
- s << struct.to_s # too gentle?
127
+ h = {}
128
+ struct.instance_variables.each do |iv|
129
+ key = iv.sub(/^@/, '')
130
+ h[key] = struct.instance_variable_get(iv)
131
+ end
132
+ s = make_xoxo(h, class_name)
118
133
  end
119
134
 
120
135
  s
121
136
  end
137
+
122
138
  end
123
139
 
124
- class XOXO::Parser # :nodoc:
140
+ class XOXO::Parser
141
+
142
+ #
125
143
  CONTAINER_TAGS = %w{dl ol ul}
126
144
 
145
+ # @return [Array]
127
146
  attr_reader :structs
128
147
 
148
+ # Initialize new XOXO Parser.
129
149
  def initialize(xoxo)
130
150
  @parser = REXML::Parsers::PullParser.new(xoxo)
131
151
 
@@ -135,6 +155,11 @@ class XOXO::Parser # :nodoc:
135
155
  @tags = []
136
156
  end
137
157
 
158
+ # Parse XOXO document.
159
+ #
160
+ # The end result of parsing is stored in the +structs+ attribute.
161
+ #
162
+ # @return [Parser] the current parser object
138
163
  def parse
139
164
  while @parser.has_next?
140
165
  res = @parser.pull
@@ -207,6 +232,10 @@ class XOXO::Parser # :nodoc:
207
232
 
208
233
  private
209
234
 
235
+ # Take a hash of attributes and make sure the keys are all lowercase.
236
+ #
237
+ # @param [Hash] the attributes hash
238
+ # @return [Hash] the normalized attributes hash
210
239
  def normalize_attrs(attrs)
211
240
  attrs.keys.find_all { |k, v| k != k.downcase }.each { |k, v|
212
241
  v = v.downcase if k == "rel" || k == "type"
@@ -216,6 +245,7 @@ class XOXO::Parser # :nodoc:
216
245
  attrs
217
246
  end
218
247
 
248
+ #
219
249
  def push(struct)
220
250
  if struct == {} && @structs.last.kind_of?(Hash) &&
221
251
  @structs.last.has_key?('url') &&
@@ -233,7 +263,6 @@ end
233
263
  class Object
234
264
 
235
265
  # Dump object as XOXO.
236
-
237
266
  def to_xoxo(*args)
238
267
  XOXO.dump(self,*args)
239
268
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xoxo
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 19
4
5
  prerelease: false
5
6
  segments:
6
7
  - 1
7
- - 0
8
8
  - 1
9
- version: 1.0.1
9
+ - 0
10
+ version: 1.1.0
10
11
  platform: ruby
11
12
  authors:
12
13
  - Christian Neukirchen <chneukirchen@gmail.com>
@@ -14,72 +15,77 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-02-23 00:00:00 -05:00
18
+ date: 2011-05-05 00:00:00 -04:00
18
19
  default_executable:
19
- dependencies: []
20
-
21
- description: |-
22
- XOXO is a Ruby XOXO parser and generator. It provides
23
- a Ruby API similar to Marshal and YAML (though more
24
- specific) to load and dump XOXO[http://microformats.org/wiki/xoxo],
25
- an simple, open outline format written in standard XHTML and
26
- suitable for embedding in (X)HTML, Atom, RSS, and arbitrary XML.
27
- email:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: redline
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :development
34
+ version_requirements: *id001
35
+ description: XOXO is a Ruby XOXO parser and generator. It provides a Ruby API similar to Marshal and YAML (though more specific) to load and dump XOXO[http://microformats.org/wiki/xoxo], an simple, open outline format written in standard XHTML and suitable for embedding in (X)HTML, Atom, RSS, and arbitrary XML.
36
+ email: transfire@gmail.com
28
37
  executables: []
29
38
 
30
39
  extensions: []
31
40
 
32
41
  extra_rdoc_files:
33
- - README
42
+ - README.rdoc
34
43
  files:
44
+ - .ruby
35
45
  - lib/xoxo.rb
36
- - meta/authors
37
- - meta/collection
38
- - meta/created
39
- - meta/description
40
- - meta/homepage
41
- - meta/name
42
- - meta/released
43
- - meta/repository
44
- - meta/summary
45
- - meta/title
46
- - meta/version
47
46
  - test/test_xoxo.rb
48
- - README
49
- - HISTORY
50
- - COPYING
47
+ - HISTORY.rdoc
48
+ - Profile
49
+ - README.rdoc
50
+ - Version
51
+ - COPYING.rdoc
52
+ - Redfile
51
53
  has_rdoc: true
52
54
  homepage: http://rubyworks.github.com/xoxo
53
- licenses: []
54
-
55
+ licenses:
56
+ - chneukirchen
55
57
  post_install_message:
56
58
  rdoc_options:
57
59
  - --title
58
60
  - XOXO API
59
61
  - --main
60
- - README
62
+ - README.rdoc
61
63
  require_paths:
62
64
  - lib
63
65
  required_ruby_version: !ruby/object:Gem::Requirement
66
+ none: false
64
67
  requirements:
65
68
  - - ">="
66
69
  - !ruby/object:Gem::Version
70
+ hash: 3
67
71
  segments:
68
72
  - 0
69
73
  version: "0"
70
74
  required_rubygems_version: !ruby/object:Gem::Requirement
75
+ none: false
71
76
  requirements:
72
77
  - - ">="
73
78
  - !ruby/object:Gem::Version
79
+ hash: 3
74
80
  segments:
75
81
  - 0
76
82
  version: "0"
77
83
  requirements: []
78
84
 
79
85
  rubyforge_project: xoxo
80
- rubygems_version: 1.3.6.pre.3
86
+ rubygems_version: 1.3.7
81
87
  signing_key:
82
88
  specification_version: 3
83
89
  summary: XOXO Parser and Generator
84
- test_files:
85
- - test/test_xoxo.rb
90
+ test_files: []
91
+
data/HISTORY DELETED
@@ -1,14 +0,0 @@
1
- = HISTORY
2
-
3
- == 1.0.0 // 2009-07-06
4
-
5
- This is essentially the XOXO library written Christian Neukirchen.
6
- While the library has been distributed as part of Facets for some
7
- time, there is no separate gem avaialbe for it. So this then is
8
- that stand-alone release. It differs from the original only in
9
- that it provides #to_xoxo.
10
-
11
- * 1 Major Enhancement
12
-
13
- * Happy Birthday!
14
-
@@ -1 +0,0 @@
1
- Christian Neukirchen <chneukirchen@gmail.com>
@@ -1 +0,0 @@
1
- rubyworks
@@ -1 +0,0 @@
1
- 2006-01-01
@@ -1,5 +0,0 @@
1
- XOXO is a Ruby XOXO parser and generator. It provides
2
- a Ruby API similar to Marshal and YAML (though more
3
- specific) to load and dump XOXO[http://microformats.org/wiki/xoxo],
4
- an simple, open outline format written in standard XHTML and
5
- suitable for embedding in (X)HTML, Atom, RSS, and arbitrary XML.
@@ -1 +0,0 @@
1
- http://rubyworks.github.com/xoxo
data/meta/name DELETED
@@ -1 +0,0 @@
1
- xoxo
@@ -1 +0,0 @@
1
- 2010-02-23
@@ -1 +0,0 @@
1
- git://github.com/rubyworks/xoxo.git
@@ -1 +0,0 @@
1
- XOXO Parser and Generator
data/meta/title DELETED
@@ -1 +0,0 @@
1
- XOXO
@@ -1 +0,0 @@
1
- 1.0.1