etherpad-lite 0.1.0.rc2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,7 +1,7 @@
1
- ** RELEASE 0.1.0 (Pending) **
1
+ ** RELEASE 0.1.0 (07/07/2012) **
2
2
 
3
3
  * Requires Etherpad Lite 1.1+
4
- * Added support for get/setHTML
4
+ * Added support for getHTML, setHTML, listAuthorsOfPad, listPadsOfAuthor, getLastEdited, and padUsersCount
5
5
  * Uses POST for API calls which alter data - this allows much larger pad content to be written
6
6
  * Various minor improvements and bugfixes
7
7
  * More complete documentation and examples
data/lib/etherpad-lite.rb CHANGED
@@ -1,2 +1,3 @@
1
+ require 'etherpad-lite/version'
1
2
  require 'etherpad-lite/client'
2
3
  require 'etherpad-lite/models'
@@ -7,10 +7,6 @@ require 'json'
7
7
  BAD_RUBY = RUBY_VERSION < '1.9.0' # :nodoc:
8
8
 
9
9
  module EtherpadLite
10
- MAJOR_VERSION, MINOR_VERSION, TINY_VERSION, PRE_VERSION = 0, 1, 0, 'rc2' # :nodoc:
11
- # The client version
12
- VERSION = [MAJOR_VERSION, MINOR_VERSION, TINY_VERSION, PRE_VERSION].compact.join '.'
13
-
14
10
  # An error returned by the server
15
11
  class APIError < StandardError
16
12
  MESSAGE = "Error while talking to the API (%s). Make sure you are running the latest version of the Etherpad Lite server. If that is not possible, try rolling this client back to an earlier version."
@@ -140,6 +136,10 @@ module EtherpadLite
140
136
  post :createAuthorIfNotExistsFor, params
141
137
  end
142
138
 
139
+ def listPadsOfAuthor(authorID)
140
+ get :listPadsOfAuthor, :authorID => authorID
141
+ end
142
+
143
143
  # Sessions
144
144
  # Sessions can be created between a group and an author. This allows
145
145
  # an author to access more than one group. The sessionID will be set as
@@ -214,6 +214,16 @@ module EtherpadLite
214
214
  get :getRevisionsCount, :padID => padID
215
215
  end
216
216
 
217
+ # Returns the number of users currently editing the pad
218
+ def padUsersCount(padID)
219
+ get :padUsersCount, :padID => padID
220
+ end
221
+
222
+ # Returns the time the pad was last edited as a Unix timestamp
223
+ def getLastEdited(padID)
224
+ get :getLastEdited, :padID => padID
225
+ end
226
+
217
227
  # Delete the given Pad
218
228
  def deletePad(padID)
219
229
  post :deletePad, :padID => padID
@@ -224,6 +234,10 @@ module EtherpadLite
224
234
  get :getReadOnlyID, :padID => padID
225
235
  end
226
236
 
237
+ def listAuthorsOfPad(padID)
238
+ get :listAuthorsOfPad, :padID => padID
239
+ end
240
+
227
241
  # Sets a boolean for the public status of a Pad
228
242
  def setPublicStatus(padID, publicStatus)
229
243
  post :setPublicStatus, :padID => padID, :publicStatus => publicStatus
@@ -80,6 +80,16 @@ module EtherpadLite
80
80
  @name = options[:name]
81
81
  end
82
82
 
83
+ # Returns an array of pad ids that this author has edited
84
+ def pad_ids
85
+ @instance.client.listPadsOfAuthor(@id)[:padIDs] || []
86
+ end
87
+
88
+ # Returns an array of Pads that this author has edited
89
+ def pads
90
+ pad_ids.map { |id| Pad.new(@instance, id) }
91
+ end
92
+
83
93
  # Create a new session for group that will last length_in_minutes.
84
94
  def create_session(group, length_in_min)
85
95
  Session.create(@instance, group.id, @id, length_in_min)
@@ -119,11 +119,32 @@ module EtherpadLite
119
119
  revision_numbers.map { |n| Pad.new(@instance, @id, :rev => n) }
120
120
  end
121
121
 
122
+ # Returns the number of users currently editing a pad
123
+ def user_count
124
+ @instance.client.padUsersCount(@id)[:padUsersCount]
125
+ end
126
+ alias_method :users_count, :user_count
127
+
122
128
  # Returns the Pad's read-only id. This is cached.
123
129
  def read_only_id
124
130
  @read_only_id ||= @instance.client.getReadOnlyID(@id)[:readOnlyID]
125
131
  end
126
132
 
133
+ # Returns the time the pad was last edited as a Unix timestamp
134
+ def last_edited
135
+ @instance.client.getLastEdited(@id)[:lastEdited]
136
+ end
137
+
138
+ # Returns an array of ids of authors who've edited this pad
139
+ def author_ids
140
+ @instance.client.listAuthorsOfPad(@id)[:authorIDs] || []
141
+ end
142
+
143
+ # Returns an array of Authors who've edited this pad
144
+ def authors
145
+ author_ids.map { |id| Author.new(@instance, id) }
146
+ end
147
+
127
148
  # Returns true if this is a public Pad (opposite of private?).
128
149
  # This only applies to Pads belonging to a Group.
129
150
  def public?
@@ -0,0 +1,5 @@
1
+ module EtherpadLite
2
+ MAJOR_VERSION, MINOR_VERSION, TINY_VERSION, PRE_VERSION = 0, 1, 0, nil # :nodoc:
3
+ # The client version
4
+ VERSION = [MAJOR_VERSION, MINOR_VERSION, TINY_VERSION, PRE_VERSION].compact.join '.'
5
+ end
data/spec/author_spec.rb CHANGED
@@ -21,4 +21,10 @@ describe EtherpadLite::Author do
21
21
  # They should be the same
22
22
  author1.id.should == author2.id
23
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
24
30
  end
data/spec/config.yml CHANGED
@@ -1,4 +1,3 @@
1
- :url: 9001
2
- :api_key: #kvwTIROV9p2h2gjNRCrO8fVa6pNXSqOc
3
- # Full filesystem path to APIKEY.txt, may be used instead of the above :api_key setting
1
+ :url: 9003
2
+ #:api_key: UrdBfgceHYDZs4yr1rQ12rVOzo31XfEW
4
3
  :api_key_file: /home/jhollinger/devel/etherpad-lite/APIKEY.txt
data/spec/pad_spec.rb CHANGED
@@ -88,6 +88,22 @@ describe EtherpadLite::Pad do
88
88
  pad.text.should == "Brand new text\n"
89
89
  end
90
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
+
91
107
  it "should be deleted" do
92
108
  @eth.get_pad('another new pad').delete
93
109
  @eth.create_pad('another new pad').id.should_not == nil
metadata CHANGED
@@ -1,65 +1,84 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: etherpad-lite
3
- version: !ruby/object:Gem::Version
4
- version: 0.1.0.rc2
5
- prerelease: 6
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
6
10
  platform: ruby
7
- authors:
11
+ authors:
8
12
  - Jordan Hollinger
9
13
  autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
12
- date: 2012-06-20 00:00:00.000000000 Z
16
+
17
+ date: 2012-07-07 00:00:00 -04:00
18
+ default_executable:
13
19
  dependencies: []
20
+
14
21
  description: etherpad-lite is a Ruby interface to Etherpad Lite's HTTP JSON API
15
22
  email: jordan@jordanhollinger.com
16
23
  executables: []
24
+
17
25
  extensions: []
18
- extra_rdoc_files:
26
+
27
+ extra_rdoc_files:
19
28
  - README.rdoc
20
- files:
29
+ files:
21
30
  - lib/etherpad-lite.rb
31
+ - lib/etherpad-lite/models.rb
32
+ - lib/etherpad-lite/models/session.rb
22
33
  - lib/etherpad-lite/models/padded.rb
23
- - lib/etherpad-lite/models/group.rb
24
- - lib/etherpad-lite/models/pad.rb
25
34
  - lib/etherpad-lite/models/author.rb
26
35
  - lib/etherpad-lite/models/instance.rb
27
- - lib/etherpad-lite/models/session.rb
36
+ - lib/etherpad-lite/models/pad.rb
37
+ - lib/etherpad-lite/models/group.rb
28
38
  - lib/etherpad-lite/client.rb
29
- - lib/etherpad-lite/models.rb
30
- - spec/pad_spec.rb
31
- - spec/config.yml.example
32
- - spec/config.yml
39
+ - lib/etherpad-lite/version.rb
33
40
  - spec/spec_helper.rb
34
41
  - spec/instance_spec.rb
35
42
  - spec/session_spec.rb
36
- - spec/author_spec.rb
37
43
  - spec/group_spec.rb
44
+ - spec/config.yml
45
+ - spec/config.yml.example
46
+ - spec/author_spec.rb
47
+ - spec/pad_spec.rb
38
48
  - README.rdoc
39
49
  - CHANGELOG
40
50
  - LICENSE
51
+ has_rdoc: true
41
52
  homepage: http://github.com/jhollinger/ruby-etherpad-lite
42
53
  licenses: []
54
+
43
55
  post_install_message:
44
56
  rdoc_options: []
45
- require_paths:
57
+
58
+ require_paths:
46
59
  - lib
47
- required_ruby_version: !ruby/object:Gem::Requirement
60
+ required_ruby_version: !ruby/object:Gem::Requirement
48
61
  none: false
49
- requirements:
50
- - - ! '>='
51
- - !ruby/object:Gem::Version
52
- version: '0'
53
- required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ segments:
66
+ - 0
67
+ version: "0"
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
69
  none: false
55
- requirements:
56
- - - ! '>'
57
- - !ruby/object:Gem::Version
58
- version: 1.3.1
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ segments:
74
+ - 0
75
+ version: "0"
59
76
  requirements: []
77
+
60
78
  rubyforge_project:
61
- rubygems_version: 1.8.21
79
+ rubygems_version: 1.3.7
62
80
  signing_key:
63
81
  specification_version: 3
64
82
  summary: A Ruby client library for Etherpad Lite
65
83
  test_files: []
84
+