etherpad-lite 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,4 +1,8 @@
1
- ** RELEASE 0.2.0 (?) **
1
+ ** RELEASE 0.2.1 (2012-12-13) **
2
+
3
+ * Support for the Etherpad Lite 1.2 release
4
+
5
+ ** RELEASE 0.2.0 (2012-09-29) **
2
6
 
3
7
  * Adds support for multiple API versions
4
8
  * Use rest_client
@@ -2,7 +2,7 @@
2
2
 
3
3
  The etherpad-lite Ruby Gem is a Ruby client for Etherpad Lite's HTTP JSON API. Etherpad Lite is a collaborative editor provided by the {Etherpad Foundation}[http://etherpad.org].
4
4
 
5
- See {github.com/Pita/etherpad-lite}[https://github.com/Pita/etherpad-lite] for information on how to install and configure your own Etherpad Lite instance, and read {github.com/Pita/etherpad-lite/wiki/HTTP-API}[https://github.com/Pita/etherpad-lite/wiki/HTTP-API] for an in-depth description of Etherpad Lite's HTTP API.
5
+ See {github.com/ether/etherpad-lite}[https://github.com/ether/etherpad-lite] for information on how to install and configure your own Etherpad Lite instance, and read {etherpad.org/doc/v1.2.0/#index_http_api}[http://etherpad.org/doc/v1.2.0/#index_http_api] for an in-depth description of Etherpad Lite's HTTP API.
6
6
 
7
7
  == Installation
8
8
  gem install etherpad-lite
@@ -34,8 +34,6 @@ See {github.com/Pita/etherpad-lite}[https://github.com/Pita/etherpad-lite] for i
34
34
  puts pad_rev.text
35
35
  end
36
36
 
37
- Full docs are at {jordanhollinger.com/docs/ruby-etherpad-lite/}[http://jordanhollinger.com/docs/ruby-etherpad-lite/]
38
-
39
37
  == Advanced usage
40
38
  The above example deals with public pads, accessible to anyone through the Web UI. There is another class of pads - group pads - which deal with groups, authors and sessions.
41
39
  Examples are documented in EtherpadLite::Group, EtherpadLite::Author, and EtherpadLite::Session.
@@ -101,7 +99,7 @@ or you can explicitly load just the low-level client:
101
99
  client = EtherpadLite.client('http://beta.etherpad.org/api', 'api key', 1.1)
102
100
  client.setText(padID: 'my first etherpad lite pad', text: "lots of new text and stuff")
103
101
 
104
- The methods and parameters exactly match the HTTP API. For a full list of them, see {github.com/Pita/etherpad-lite/wiki/HTTP-API}[https://github.com/Pita/etherpad-lite/wiki/HTTP-API].
102
+ The methods and parameters exactly match the HTTP API. For a full list of them, see {etherpad.org/doc/v1.2.0/#index_http_api}[http://etherpad.org/doc/v1.2.0/#index_http_api].
105
103
 
106
104
  == Testing
107
105
  Testing this library is fairly simple. It requires:
@@ -4,7 +4,7 @@ require 'rest_client'
4
4
 
5
5
  # A client library for Etherpad Lite's JSON API.
6
6
  #
7
- # A thin wrapper around the HTTP API. See the API documentation at https://github.com/Pita/etherpad-lite/wiki/HTTP-API.
7
+ # A thin wrapper around the HTTP API. See the API documentation at http://etherpad.org/doc/v1.2.0/#index_api_methods.
8
8
  #
9
9
  # client = EtherpadLite.client('http://localhost:9001', 'api key', '1.1')
10
10
  # client.getText(:padID => 'foo')
@@ -31,7 +31,7 @@ module EtherpadLite
31
31
  Client.new(url_or_port, api_key_or_file, api_version)
32
32
  end
33
33
 
34
- # A thin wrapper around Etherpad Lite's HTTP JSON API. See the API documentation at https://github.com/Pita/etherpad-lite/wiki/HTTP-API.
34
+ # A thin wrapper around Etherpad Lite's HTTP JSON API. See the API documentation at http://etherpad.org/doc/v1.2.0/#index_api_methods.
35
35
  class Client
36
36
  # A URI object containing the URL of the Etherpad Lite instance
37
37
  attr_reader :uri
@@ -188,6 +188,11 @@ module EtherpadLite
188
188
  @instance.client.setPassword(padID: @id, password: new_password)
189
189
  end
190
190
 
191
+ # Sends a custom message of type msg to the pad.
192
+ def message(msg)
193
+ @instance.client.sendClientsMessage(padID: @id, msg: msg)
194
+ end
195
+
191
196
  # Deletes the Pad
192
197
  def delete
193
198
  @instance.client.deletePad(padID: @id)
@@ -1,4 +1,4 @@
1
1
  module EtherpadLite
2
2
  # The library version
3
- VERSION = '0.2.0'
3
+ VERSION = '0.2.1'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: etherpad-lite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-07 00:00:00.000000000 Z
12
+ date: 2012-12-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -44,14 +44,6 @@ files:
44
44
  - lib/etherpad-lite/client.rb
45
45
  - lib/etherpad-lite/version.rb
46
46
  - lib/etherpad-lite/models.rb
47
- - spec/pad_spec.rb
48
- - spec/config.yml.example
49
- - spec/config.yml
50
- - spec/spec_helper.rb
51
- - spec/instance_spec.rb
52
- - spec/session_spec.rb
53
- - spec/author_spec.rb
54
- - spec/group_spec.rb
55
47
  - README.rdoc
56
48
  - CHANGELOG
57
49
  - LICENSE
@@ -75,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
67
  version: '0'
76
68
  requirements: []
77
69
  rubyforge_project:
78
- rubygems_version: 1.8.21
70
+ rubygems_version: 1.8.23
79
71
  signing_key:
80
72
  specification_version: 3
81
73
  summary: A Ruby client library for Etherpad Lite
@@ -1,37 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- describe EtherpadLite::Author do
4
- before do
5
- @eth = EtherpadLite.connect TEST_CONFIG[:url], TEST_CONFIG[:api_key_file] || TEST_CONFIG[:api_key], TEST_CONFIG[:api_version]
6
- end
7
-
8
- it "should be created" do
9
- author = @eth.create_author
10
- author.id.nil?.should == false
11
- end
12
-
13
- it "should be mapped to 'Author A'" do
14
- author = @eth.create_author :mapper => 'Author A'
15
- author.id.nil?.should == false
16
- end
17
-
18
- it "should be mapped to 'Author A'" do
19
- author1 = @eth.create_author :mapper => 'Author A'
20
- author2 = @eth.author 'Author A'
21
- # They should be the same
22
- author1.id.should == author2.id
23
- end
24
-
25
- it "should list pads of 'Author A'" do
26
- author = @eth.create_author :mapper => 'Author A'
27
- author.pad_ids.should == []
28
- author.pads.should == []
29
- end
30
-
31
- if TEST_CONFIG[:api_version] > 1
32
- it "should get the name" do
33
- author = @eth.create_author :mapper => 'Author B', :name => 'Jim Jimmers'
34
- author.name.should == 'Jim Jimmers'
35
- end
36
- end
37
- end
@@ -1,5 +0,0 @@
1
- :url: 9001
2
- :api_key: #kvwTIROV9p2h2gjNRCrO8fVa6pNXSqOc
3
- # Full filesystem path to APIKEY.txt, may be used instead of the above :api_key setting
4
- :api_key_file: /home/jhollinger/devel/etherpad-lite/APIKEY.txt
5
- :api_version: 1.1
@@ -1,5 +0,0 @@
1
- :url: http://localhost:9001
2
- :api_key: your api key
3
- # Full filesystem path to APIKEY.txt, may be used instead of the above :api_key setting
4
- :api_key_file:
5
- :api_version: 1.1
@@ -1,141 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- describe EtherpadLite::Group do
4
- before do
5
- @eth = EtherpadLite.connect TEST_CONFIG[:url], TEST_CONFIG[:api_key_file] || TEST_CONFIG[:api_key], TEST_CONFIG[:api_version]
6
- end
7
-
8
- it "should be created" do
9
- group = @eth.create_group
10
- group.id.nil?.should == false
11
- end
12
-
13
- it "should be mapped to 'Group A'" do
14
- group = @eth.create_group :mapper => 'Group A'
15
- group.id.nil?.should == false
16
- end
17
-
18
- it "should be mapped to 'Group A'" do
19
- group1 = @eth.create_group :mapper => 'Group A'
20
- group2 = @eth.group 'Group A'
21
- # They should be the same
22
- group1.id.should == group2.id
23
- end
24
-
25
- it "should create a Group Pad" do
26
- group = @eth.group 'Group A'
27
- pad = group.pad 'Important Group Stuff'
28
- pad.id.should == "#{group.id}$Important Group Stuff"
29
- end
30
-
31
- it "should create another Group Pad" do
32
- group = @eth.group 'Group A'
33
- pad = @eth.create_pad 'Other Important Group Stuff', :groupID => group.id, :text => 'foo'
34
- pad.text.should == "foo\n"
35
- end
36
-
37
- it "should create a Group Pad with the right name" do
38
- group = @eth.group 'Group A'
39
- pad = group.pad 'Important Group Stuff'
40
- pad.name.should == "Important Group Stuff"
41
- end
42
-
43
- it "should find a Group Pad with the right group" do
44
- group = @eth.group 'Group A'
45
- group.get_pad('Important Group Stuff').group_id.should == group.id
46
- end
47
-
48
- it "should find another Group Pad with the right group" do
49
- group = @eth.group 'Group A'
50
- @eth.get_pad('Other Important Group Stuff', :groupID => group.id).group_id.should == group.id
51
- end
52
-
53
- it "should find yet another Group Pad with the right group" do
54
- group = @eth.group 'Group A'
55
- @eth.get_pad("Other Important Group Stuff", :groupID => group.id).text.should == "foo\n"
56
- end
57
-
58
- it "should find another Group Pad with the right text" do
59
- group = @eth.group 'Group A'
60
- @eth.get_pad("#{group.id}$Other Important Group Stuff").text.should == "foo\n"
61
- end
62
-
63
- it "should find yet another Group Pad with the right text" do
64
- group = @eth.group 'Group A'
65
- @eth.get_pad("#{group.id}$Other Important Group Stuff").text.should == "foo\n"
66
- end
67
-
68
- it "should find a Group Pad with the right ids" do
69
- group = @eth.group 'Group A'
70
- group.pad_ids.should == ["#{group.id}$Important_Group_Stuff", "#{group.id}$Other_Important_Group_Stuff"]
71
- end
72
-
73
- it "should find a Group Pad with the right name" do
74
- group = @eth.group 'Group A'
75
- group.pads.first.name.should == "Important_Group_Stuff"
76
- end
77
-
78
- it "should explicitly create a Group Pad" do
79
- group = @eth.group 'Group A'
80
- pad = group.create_pad 'new group pad', :text => 'abc'
81
- pad.text.should == "abc\n"
82
- end
83
-
84
- if TEST_CONFIG[:api_version] > 1
85
- it "should list all group ids" do
86
- group_ids = @eth.group_ids
87
- group_ids.size.should == 4
88
- end
89
-
90
- it "should list all groups" do
91
- groups = @eth.groups
92
- groups.size.should == 4
93
- groups.first.class.name.should == 'EtherpadLite::Group'
94
- end
95
- end
96
-
97
- context 'Group Pad' do
98
- context 'Privacy' do
99
- it "should be private" do
100
- group = @eth.group 'Group A'
101
- pad = group.get_pad 'new group pad'
102
- pad.private?.should == true
103
- end
104
-
105
- it "should not be public" do
106
- group = @eth.group 'Group A'
107
- pad = group.get_pad 'new group pad'
108
- pad.public?.should == false
109
- end
110
-
111
- it "should change to public" do
112
- group = @eth.group 'Group A'
113
- pad = group.get_pad 'new group pad'
114
- pad.public = true
115
- pad.public?.should == true
116
- end
117
-
118
- it "should change to not private" do
119
- group = @eth.group 'Group A'
120
- pad = group.get_pad 'new group pad'
121
- pad.private = false
122
- pad.private?.should == false
123
- end
124
- end
125
-
126
- context 'Password' do
127
- it "should not have a password" do
128
- group = @eth.group 'Group A'
129
- pad = group.get_pad 'new group pad'
130
- pad.password?.should == false
131
- end
132
-
133
- it "should have a password set" do
134
- group = @eth.group 'Group A'
135
- pad = group.get_pad 'new group pad'
136
- pad.password = 'correct horse battery staple'
137
- pad.password?.should == true
138
- end
139
- end
140
- end
141
- end
@@ -1,12 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- describe EtherpadLite::Instance do
4
- before do
5
- @eth = EtherpadLite.connect TEST_CONFIG[:url], TEST_CONFIG[:api_key_file] || TEST_CONFIG[:api_key], TEST_CONFIG[:api_version]
6
- end
7
-
8
- it "should have the right API key" do
9
- api_key = TEST_CONFIG[:api_key_file] || TEST_CONFIG[:api_key]
10
- @eth.client.api_key.should == api_key
11
- end
12
- end
@@ -1,128 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- describe EtherpadLite::Pad do
4
- before do
5
- @eth = EtherpadLite.connect TEST_CONFIG[:url], TEST_CONFIG[:api_key_file] || TEST_CONFIG[:api_key], TEST_CONFIG[:api_version]
6
- end
7
-
8
- it "should blow up when querying a non-existing pad" do
9
- pad = @eth.get_pad 'a non-existant pad'
10
- begin
11
- txt = pad.text
12
- rescue EtherpadLite::Error => e
13
- end
14
- e.message.should == 'padID does not exist'
15
- end
16
-
17
- it "should create a new pad" do
18
- pad = @eth.create_pad 'my new pad', :text => 'The initial text'
19
- pad.text.should == "The initial text\n"
20
- end
21
-
22
- it "should blow up when creating a Pad that already exists" do
23
- begin
24
- pad = @eth.create_pad 'my new pad', :text => 'The initial text'
25
- rescue EtherpadLite::Error => e
26
- end
27
- e.message.should == 'padID does already exist'
28
- end
29
-
30
- it "should automatically create a Pad" do
31
- pad = @eth.pad 'another new pad'
32
- pad.text = "The initial text"
33
- pad.text.should == "The initial text\n"
34
- end
35
-
36
- it "should automatically find a Pad" do
37
- pad = @eth.pad 'another new pad'
38
- pad.text.should == "The initial text\n"
39
- end
40
-
41
- it "should find a Pad" do
42
- pad = @eth.get_pad 'another new pad'
43
- pad.text.should == "The initial text\n"
44
- end
45
-
46
- it "should have a read-only id" do
47
- pad = @eth.get_pad 'another new pad'
48
- pad.read_only_id.should =~ /^r\.\w+/
49
- end
50
-
51
- it "should add revisions" do
52
- pad = @eth.get_pad 'another new pad'
53
- pad.text == "New text"
54
- pad.revision_numbers.last == 2
55
- end
56
-
57
- it "should set HTML" do
58
- pad = @eth.get_pad 'another new pad'
59
- pad.html = "<div><p>Here's some HTML.</p>\n<p>Please rewind it when you're finished.</p></div>"
60
- pad.html.should == "Here&#x27;s some HTML.<br>Please rewind it when you&#x27;re finished.<br>"
61
- end
62
-
63
- it "should have the first revision" do
64
- pad = @eth.get_pad 'another new pad'
65
- pad.text(:rev => 1).should == "The initial text\n"
66
- end
67
-
68
- it "should have the first revision" do
69
- pad = @eth.get_pad 'another new pad'
70
- pad.revisions[1].text.should == "The initial text\n"
71
- end
72
-
73
- it "should have the first revision as HTML" do
74
- pad = @eth.get_pad 'another new pad'
75
- pad.revisions[1].html.should == "The initial text<br>"
76
- end
77
-
78
- it "should have the same name and id" do
79
- pad = @eth.get_pad 'another new pad'
80
- pad.name.should == pad.id
81
- end
82
-
83
- it "should be initialized as revision 0" do
84
- pad = @eth.pad 'brand new pad', :text => 'Brand new text'
85
- pad.text = 'Even newer text'
86
- pad.text = 'Even even newer text'
87
- pad = @eth.get_pad 'brand new pad', :rev => 0
88
- pad.text.should == "Brand new text\n"
89
- end
90
-
91
- it "should list author ids" do
92
- pad = @eth.pad 'brand new pad2'
93
- pad.author_ids.should == []
94
- pad.authors.should == []
95
- end
96
-
97
- it "should get the last edit date" do
98
- pad = @eth.pad 'brand new pad3'
99
- pad.last_edited.>(1).should == true
100
- end
101
-
102
- it "should return the number of users" do
103
- pad = @eth.pad 'brand new pad3'
104
- pad.user_count.should == 0
105
- end
106
-
107
- it "should not crash when setting null text" do
108
- err_msg = nil
109
- begin
110
- @eth.client.setText(:padID => 'brand new pad3')
111
- rescue EtherpadLite::Error => e
112
- err_msg = e.message
113
- end
114
- err_msg.should == 'text is no string'
115
- end
116
-
117
- it "should be deleted" do
118
- @eth.get_pad('another new pad').delete
119
- @eth.create_pad('another new pad').id.should_not == nil
120
- end
121
-
122
- if TEST_CONFIG[:api_version] > 1
123
- it "should get the pad users" do
124
- puts @eth.pad('pad with users').users
125
- @eth.pad('pad with users').users.should == []
126
- end
127
- end
128
- end
@@ -1,45 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- describe EtherpadLite::Session do
4
- before do
5
- @eth = EtherpadLite.connect TEST_CONFIG[:url], TEST_CONFIG[:api_key_file] || TEST_CONFIG[:api_key], TEST_CONFIG[:api_version]
6
- end
7
-
8
- it "should be created for a Group" do
9
- group = @eth.group 'Maycomb'
10
- author = @eth.author 'Atticus'
11
- session = group.create_session(author, 20)
12
- session.valid_until.should == Time.now.to_i + 20 * 60
13
- end
14
-
15
- it "should be created for an Author" do
16
- group = @eth.group 'Maycomb'
17
- author = @eth.author 'Scout'
18
- session = author.create_session(group, 15)
19
- session.valid_until.should == Time.now.to_i + 15 * 60
20
- end
21
-
22
- it "should be found in a Group" do
23
- group = @eth.group 'Maycomb'
24
- author = @eth.author 'Atticus'
25
- group.sessions.map(&:author_id).include?(author.id).should == true
26
- end
27
-
28
- it "shouldn be found in a Group" do
29
- group = @eth.group 'Maycomb'
30
- author = @eth.author 'Atticus'
31
- author.sessions.map(&:group_id).include?(group.id).should == true
32
- end
33
-
34
- it "shouldn't be found in the wrong Group" do
35
- group = @eth.group 'Other group'
36
- author = @eth.author 'Scout'
37
- group.sessions.map(&:author_id).include?(author.id).should == false
38
- end
39
-
40
- it "shouldn't be found in the wrong Group" do
41
- group = @eth.group 'Other group'
42
- author = @eth.author 'Scout'
43
- author.sessions.map(&:group_id).include?(group.id).should == false
44
- end
45
- end
@@ -1,14 +0,0 @@
1
- require 'rspec'
2
-
3
- # Load etherpad-lite
4
- $LOAD_PATH.unshift File.dirname(__FILE__) + '/..'
5
- require 'etherpad-lite'
6
-
7
- RSpec.configure do |c|
8
- c.mock_with :rspec
9
- end
10
-
11
- # Load test config
12
- require 'yaml'
13
- TEST_CONFIG = YAML.load_file(File.dirname(__FILE__) + '/config.yml')
14
- TEST_CONFIG[:api_key_file] = File.open(TEST_CONFIG[:api_key_file], &:read) unless TEST_CONFIG[:api_key_file].nil?