JackDanger-wave 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +1 -1
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/lib/wave/blip.rb +2 -1
- data/lib/wave/document.rb +9 -7
- data/lib/wave/operation.rb +34 -0
- data/test/blip_test.rb +3 -0
- data/test/document_test.rb +26 -3
- data/test/test_helper.rb +1 -0
- data/wave.gemspec +6 -2
- metadata +14 -4
data/README.markdown
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Wave
|
2
2
|
|
3
|
-
Ruby client for
|
3
|
+
Ruby client for accessing a Google Wave Server
|
4
4
|
|
5
5
|
based on the [whitepapers](http://www.waveprotocol.org/whitepapers)
|
6
6
|
for use in building [robots](http://code.google.com/intl/it/apis/wave/extensions/robots/index.html) or
|
data/Rakefile
CHANGED
@@ -9,6 +9,7 @@ begin
|
|
9
9
|
gem.email = "google-wave@jackcanty.com"
|
10
10
|
gem.homepage = "http://github.com/JackDanger/wave"
|
11
11
|
gem.authors = ["Jack Danger Canty"]
|
12
|
+
gem.add_dependency "rack", ">= 1.0.0"
|
12
13
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
13
14
|
end
|
14
15
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
data/lib/wave/blip.rb
CHANGED
@@ -14,7 +14,7 @@ class Wave
|
|
14
14
|
class Blip
|
15
15
|
|
16
16
|
attr_reader :wavelet, :parent, :children, :creator
|
17
|
-
attr_accessor :document
|
17
|
+
attr_accessor :document, :content
|
18
18
|
|
19
19
|
def initialize(options = {})
|
20
20
|
if options[:parent]
|
@@ -26,6 +26,7 @@ class Wave
|
|
26
26
|
raise Wave::WaveError, "Blip has no wavelet" unless @wavelet
|
27
27
|
@creator = options[:creator]
|
28
28
|
raise Wave::WaveError, "Blip has no creator" unless @creator
|
29
|
+
@content = options[:content]
|
29
30
|
@wavelet.blips << self
|
30
31
|
@children ||= []
|
31
32
|
end
|
data/lib/wave/document.rb
CHANGED
@@ -10,22 +10,24 @@
|
|
10
10
|
class Wave
|
11
11
|
class Document
|
12
12
|
|
13
|
-
|
14
|
-
'BUTTON', 'RADIO_BUTTON', 'RADIO_BUTTON_GROUP',
|
15
|
-
'PASSWORD', 'GADGET', 'IMAGE']
|
16
|
-
|
17
|
-
attr_reader :blip, :elements, :annotations
|
13
|
+
attr_reader :blip, :source, :annotations
|
18
14
|
|
19
15
|
def initialize(type, options = {})
|
20
|
-
@type = type
|
21
16
|
@blip = options.delete(:blip)
|
22
17
|
@options = options
|
23
|
-
@elements = []
|
24
18
|
@annotations = []
|
25
19
|
raise Wave::WaveError, "Document has no blip" unless blip
|
26
20
|
blip.document = self
|
27
21
|
end
|
28
22
|
|
23
|
+
def items
|
24
|
+
source.to_s.scan(/<.*?>|./).flatten
|
25
|
+
end
|
26
|
+
|
27
|
+
def source
|
28
|
+
blip.content
|
29
|
+
end
|
30
|
+
|
29
31
|
def wavelet
|
30
32
|
blip.wavelet
|
31
33
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class Wave
|
2
|
+
class Operation
|
3
|
+
|
4
|
+
# Wave document operations sport the following mutation components:
|
5
|
+
# skip
|
6
|
+
# insert characters
|
7
|
+
# insert element start
|
8
|
+
# insert element end
|
9
|
+
# insert anti-element start
|
10
|
+
# insert anti-element end
|
11
|
+
# delete characters
|
12
|
+
# delete element start
|
13
|
+
# delete element end
|
14
|
+
# delete anti-element start
|
15
|
+
# delete anti-element end
|
16
|
+
# set attributes
|
17
|
+
# update attributes
|
18
|
+
# commence annotation
|
19
|
+
# conclude annotation
|
20
|
+
#
|
21
|
+
# The following is a more complex example document operation.
|
22
|
+
#
|
23
|
+
# skip 3
|
24
|
+
# insert element start with tag "p" and no attributes
|
25
|
+
# insert characters "Hi there!"
|
26
|
+
# insert element end
|
27
|
+
# skip 5
|
28
|
+
# delete characters 4
|
29
|
+
#
|
30
|
+
# From this, one could see how an entire XML document can be represented as a single document operation.
|
31
|
+
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
data/test/blip_test.rb
CHANGED
@@ -13,6 +13,9 @@ class BlipTest < Test::Unit::TestCase
|
|
13
13
|
should "have a creator" do
|
14
14
|
assert @blip.creator
|
15
15
|
end
|
16
|
+
should "have some content for use in crafting a document" do
|
17
|
+
assert @blip.content
|
18
|
+
end
|
16
19
|
should "have a collection of child blips" do
|
17
20
|
assert @blip.children
|
18
21
|
end
|
data/test/document_test.rb
CHANGED
@@ -16,11 +16,34 @@ class DocumentTest < Test::Unit::TestCase
|
|
16
16
|
should "have a collection of annotations" do
|
17
17
|
assert @document.annotations
|
18
18
|
end
|
19
|
-
should "have a collection of non-text elements" do
|
20
|
-
assert @document.elements
|
21
|
-
end
|
22
19
|
should "register itself as its blip's document" do
|
23
20
|
assert_equal @document, @document.blip.document
|
24
21
|
end
|
22
|
+
should "have raw xml content" do
|
23
|
+
assert @document.source
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context "document parsing" do
|
28
|
+
setup {
|
29
|
+
@xml = "<xml><p>frist psot</p><p>great</p></xml>"
|
30
|
+
@document = Factory.document :blip => Factory.blip(
|
31
|
+
:content => @xml
|
32
|
+
)
|
33
|
+
}
|
34
|
+
should "have xml source available via Document#source" do
|
35
|
+
assert_equal @xml, @document.source
|
36
|
+
end
|
37
|
+
should "properly count the number of items" do
|
38
|
+
# <xml><p>frist psot</p><p>great</p></xml>
|
39
|
+
# ^ ^ ^^^^^^^^^^ ^ ^ ^^^^^ ^ ^
|
40
|
+
assert_equal 21, @document.items.size
|
41
|
+
end
|
42
|
+
should "have its items properly ordered" do
|
43
|
+
# <xml><p>frist psot</p><p>great</p></xml>
|
44
|
+
# ^ ^ ^^^^^^^^^^ ^ ^ ^^^^^ ^ ^
|
45
|
+
assert_equal "<p>", @document.items[1]
|
46
|
+
assert_equal "s", @document.items[9]
|
47
|
+
end
|
25
48
|
end
|
26
49
|
end
|
data/test/test_helper.rb
CHANGED
data/wave.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{wave}
|
5
|
-
s.version = "0.0.
|
5
|
+
s.version = "0.0.5"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Jack Danger Canty"]
|
9
|
-
s.date = %q{2009-
|
9
|
+
s.date = %q{2009-06-03}
|
10
10
|
s.email = %q{google-wave@jackcanty.com}
|
11
11
|
s.extra_rdoc_files = [
|
12
12
|
"LICENSE",
|
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
|
|
22
22
|
"lib/wave/blip.rb",
|
23
23
|
"lib/wave/document.rb",
|
24
24
|
"lib/wave/events.rb",
|
25
|
+
"lib/wave/operation.rb",
|
25
26
|
"lib/wave/participant.rb",
|
26
27
|
"lib/wave/robot.rb",
|
27
28
|
"lib/wave/wavelet.rb",
|
@@ -56,8 +57,11 @@ Gem::Specification.new do |s|
|
|
56
57
|
s.specification_version = 3
|
57
58
|
|
58
59
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
60
|
+
s.add_runtime_dependency(%q<rack>, [">= 1.0.0"])
|
59
61
|
else
|
62
|
+
s.add_dependency(%q<rack>, [">= 1.0.0"])
|
60
63
|
end
|
61
64
|
else
|
65
|
+
s.add_dependency(%q<rack>, [">= 1.0.0"])
|
62
66
|
end
|
63
67
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: JackDanger-wave
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jack Danger Canty
|
@@ -9,10 +9,19 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-06-03 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rack
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.0.0
|
24
|
+
version:
|
16
25
|
description:
|
17
26
|
email: google-wave@jackcanty.com
|
18
27
|
executables: []
|
@@ -32,6 +41,7 @@ files:
|
|
32
41
|
- lib/wave/blip.rb
|
33
42
|
- lib/wave/document.rb
|
34
43
|
- lib/wave/events.rb
|
44
|
+
- lib/wave/operation.rb
|
35
45
|
- lib/wave/participant.rb
|
36
46
|
- lib/wave/robot.rb
|
37
47
|
- lib/wave/wavelet.rb
|