acts_as_chattable 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dd602c446ee80af094e8606a6f9195f128f2a174
4
+ data.tar.gz: a642a418bf4d939034a5aeeaa946d03d51b1876f
5
+ SHA512:
6
+ metadata.gz: aca9ec1fd084ae06607fea02c19731509ac00b6767666a161e14a6ca4f04aa7c38bddd82ed59bb2080a85689407ffafb1eb48a4be6127987c975448a49c1d96b
7
+ data.tar.gz: fb7be8257ac061d105b83590e74095ffd11a32ffc6aa108da206076ccfb6f21b43397100316e13d4f3fd23dbcef717eeba3d86e57762af40f90dc91e48dbbca9
data/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --color
2
+ --fail-fast
3
+ --profile
4
+ --format documentation
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ acts_as_chattable
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.0.0-p247
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "activerecord", ">= 3.0.0"
4
+ gem "activesupport", ">= 3.0.0"
5
+ gem "dragonfly", ">= 0.9.15"
6
+ gem "railties", ">= 3.0.0"
7
+
8
+ group :development do
9
+ gem "rspec", "~> 2.0"
10
+ gem "jeweler", "~> 1.8.0"
11
+ gem "sqlite3"
12
+ gem "coveralls", :require => false
13
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,122 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ actionpack (4.0.0)
5
+ activesupport (= 4.0.0)
6
+ builder (~> 3.1.0)
7
+ erubis (~> 2.7.0)
8
+ rack (~> 1.5.2)
9
+ rack-test (~> 0.6.2)
10
+ activemodel (4.0.0)
11
+ activesupport (= 4.0.0)
12
+ builder (~> 3.1.0)
13
+ activerecord (4.0.0)
14
+ activemodel (= 4.0.0)
15
+ activerecord-deprecated_finders (~> 1.0.2)
16
+ activesupport (= 4.0.0)
17
+ arel (~> 4.0.0)
18
+ activerecord-deprecated_finders (1.0.3)
19
+ activesupport (4.0.0)
20
+ i18n (~> 0.6, >= 0.6.4)
21
+ minitest (~> 4.2)
22
+ multi_json (~> 1.3)
23
+ thread_safe (~> 0.1)
24
+ tzinfo (~> 0.3.37)
25
+ addressable (2.3.5)
26
+ arel (4.0.0)
27
+ atomic (1.1.10)
28
+ builder (3.1.4)
29
+ colorize (0.5.8)
30
+ coveralls (0.6.7)
31
+ colorize
32
+ multi_json (~> 1.3)
33
+ rest-client
34
+ simplecov (>= 0.7)
35
+ thor
36
+ diff-lcs (1.2.4)
37
+ dragonfly (0.9.15)
38
+ multi_json (~> 1.0)
39
+ rack
40
+ erubis (2.7.0)
41
+ faraday (0.8.7)
42
+ multipart-post (~> 1.1)
43
+ git (1.2.5)
44
+ github_api (0.10.1)
45
+ addressable
46
+ faraday (~> 0.8.1)
47
+ hashie (>= 1.2)
48
+ multi_json (~> 1.4)
49
+ nokogiri (~> 1.5.2)
50
+ oauth2
51
+ hashie (2.0.5)
52
+ highline (1.6.19)
53
+ httpauth (0.2.0)
54
+ i18n (0.6.4)
55
+ jeweler (1.8.6)
56
+ builder
57
+ bundler (~> 1.0)
58
+ git (>= 1.2.5)
59
+ github_api (= 0.10.1)
60
+ highline (>= 1.6.15)
61
+ nokogiri (= 1.5.10)
62
+ rake
63
+ rdoc
64
+ json (1.8.0)
65
+ jwt (0.1.8)
66
+ multi_json (>= 1.5)
67
+ mime-types (1.23)
68
+ minitest (4.7.5)
69
+ multi_json (1.7.7)
70
+ multi_xml (0.5.4)
71
+ multipart-post (1.2.0)
72
+ nokogiri (1.5.10)
73
+ oauth2 (0.9.2)
74
+ faraday (~> 0.8)
75
+ httpauth (~> 0.2)
76
+ jwt (~> 0.1.4)
77
+ multi_json (~> 1.0)
78
+ multi_xml (~> 0.5)
79
+ rack (~> 1.2)
80
+ rack (1.5.2)
81
+ rack-test (0.6.2)
82
+ rack (>= 1.0)
83
+ railties (4.0.0)
84
+ actionpack (= 4.0.0)
85
+ activesupport (= 4.0.0)
86
+ rake (>= 0.8.7)
87
+ thor (>= 0.18.1, < 2.0)
88
+ rake (10.1.0)
89
+ rdoc (4.0.1)
90
+ json (~> 1.4)
91
+ rest-client (1.6.7)
92
+ mime-types (>= 1.16)
93
+ rspec (2.14.1)
94
+ rspec-core (~> 2.14.0)
95
+ rspec-expectations (~> 2.14.0)
96
+ rspec-mocks (~> 2.14.0)
97
+ rspec-core (2.14.4)
98
+ rspec-expectations (2.14.0)
99
+ diff-lcs (>= 1.1.3, < 2.0)
100
+ rspec-mocks (2.14.1)
101
+ simplecov (0.7.1)
102
+ multi_json (~> 1.0)
103
+ simplecov-html (~> 0.7.1)
104
+ simplecov-html (0.7.1)
105
+ sqlite3 (1.3.7)
106
+ thor (0.18.1)
107
+ thread_safe (0.1.2)
108
+ atomic
109
+ tzinfo (0.3.37)
110
+
111
+ PLATFORMS
112
+ ruby
113
+
114
+ DEPENDENCIES
115
+ activerecord (>= 3.0.0)
116
+ activesupport (>= 3.0.0)
117
+ coveralls
118
+ dragonfly (>= 0.9.15)
119
+ jeweler (~> 1.8.0)
120
+ railties (>= 3.0.0)
121
+ rspec (~> 2.0)
122
+ sqlite3
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Piotr Niełacny Inc.
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/README.md ADDED
@@ -0,0 +1,327 @@
1
+ ActsAsChattable
2
+ =================
3
+
4
+ The Acts As Chattable allows communication between the models.
5
+
6
+ [![Build Status](https://secure.travis-ci.org/LTe/acts-as-messageable.png)](http://travis-ci.org/LTe/acts-as-messageable)
7
+ [![Dependency Status](https://gemnasium.com/LTe/acts-as-messageable.png)](https://gemnasium.com/LTe/acts-as-messageable)
8
+ [![Code Climate](https://codeclimate.com/github/LTe/acts-as-messageable.png)](https://codeclimate.com/github/LTe/acts-as-messageable)
9
+ [![Coverage Status](https://coveralls.io/repos/LTe/acts-as-messageable/badge.png?branch=master)](https://coveralls.io/r/LTe/acts-as-messageable?branch=master)
10
+ [![Gem Version](https://badge.fury.io/rb/acts-as-messageable.png)](http://badge.fury.io/rb/acts-as-messageable)
11
+
12
+ Usage
13
+ =====
14
+
15
+ To use it, add it to your Gemfile:
16
+
17
+ ### Rails 3 & 4
18
+
19
+ ```ruby
20
+ gem 'acts_as_chattable'
21
+ ```
22
+
23
+ Post instalation
24
+ ================
25
+
26
+ ```
27
+ rails g acts_as_chattable:migration
28
+ rake db:migrate
29
+ ```
30
+
31
+ Usage
32
+ =====
33
+
34
+ ```ruby
35
+ class User < ActiveRecord::Base
36
+ acts_as_messageable :required => :body # default [:body]
37
+ :dependent => :destroy # default :nullify
38
+ end
39
+ ```
40
+
41
+ Send message
42
+ ============
43
+
44
+ ```ruby
45
+ @alice = User.first
46
+ @bob = User.last
47
+
48
+ @alice.send_message(@bob, "Message topic", "Hi bob!")
49
+ @bob.send_message(@alice, "Re: Message topic", "Hi alice!")
50
+ ```
51
+
52
+ ## With hash
53
+
54
+ ```ruby
55
+ @alice.send_message(@bob, { :body => "Hash body", :topic => "Hash topic" })
56
+ ```
57
+
58
+ Custom required (validation)
59
+ ============================
60
+
61
+ In User model
62
+
63
+ ```ruby
64
+ class User < ActiveRecord::Base
65
+ acts_as_messageable :required => :body
66
+ end
67
+ ```
68
+
69
+ ## With hash
70
+
71
+ ```ruby
72
+ @alice.send_message(@bob, { :body => "Hash body" })
73
+ ```
74
+
75
+ ## Normal
76
+
77
+ ```ruby
78
+ @alice.send_message(@bob, "body")
79
+ ```
80
+
81
+ ## Required sequence
82
+
83
+ ```ruby
84
+ class User < ActiveRecord::Base
85
+ acts_as_messageable :required => [:body, :topic]
86
+ end
87
+
88
+ @alice.send_message(@bob, "body", "topic")
89
+ ```
90
+
91
+ ## First topic
92
+
93
+ ```ruby
94
+ class User < ActiveRecord::Base
95
+ acts_as_messageable :required => [:topic, :body]
96
+ end
97
+
98
+ @alice.send_message(@bob, "topic", "body")
99
+ ```
100
+
101
+ Custom class
102
+ ============
103
+
104
+ You can use your own class that will represent the message object. First of all create custom class
105
+
106
+ ```ruby
107
+ class CustomMessage < ActsAsMessageable::Message
108
+ def capitalize_title
109
+ title.capitalize
110
+ end
111
+ end
112
+ ```
113
+
114
+ After that you can sepcify custom class in options.
115
+
116
+ ```ruby
117
+ class User
118
+ acts_as_messageable :class_name => "CustomMessage"
119
+ end
120
+ ```
121
+
122
+ From now on, your message has custom class.
123
+
124
+ ```ruby
125
+ @message = @alice.send_message(@bob, "hi!")
126
+ @message # => #<CustomMessage:0x000000024b6278>
127
+ @message.capitalize_title # => "Hi!"
128
+ ```
129
+
130
+ Conversation
131
+ ============
132
+
133
+ You can get conversation list from messages scope. For example:
134
+
135
+ ```ruby
136
+ @message = @alice.send_message(@bob, "Hello bob!", "How are you?")
137
+ @reply_message = @bob.reply_to(@message, "Re: Hello bob!", "I'm fine!")
138
+
139
+ @alice.received_messages.conversations # => [@reply_message]
140
+ ```
141
+
142
+ should receive list of latest messages in conversations (like in facebook).
143
+
144
+ To create conversation just reply to a message.
145
+
146
+ ```ruby
147
+ @message = @alice.send_message(@bob, "Hello bob!", "How are you?")
148
+ @message.reply("Re: Hello bob!", "I'm fine")
149
+ ```
150
+
151
+ **Or with hash**
152
+
153
+ ```ruby
154
+ @message.reply(:topic => "Re: Hello bob!", :body => "I'm fine")
155
+ ```
156
+
157
+ **Or in old style**
158
+
159
+ ```ruby
160
+ @message = @alice.send_message(@bob, "Hello bob!", "How are you?")
161
+ @reply_message = @bob.reply_to(@message, "Re: Hello bob!", "I'm fine!")
162
+ ```
163
+
164
+ ## Get conversation for a specific message
165
+
166
+ ```ruby
167
+ @message.conversation #=> [@message, @reply_message]
168
+ @reply_message.conversation #=> [@message, @reply_message]
169
+ ```
170
+
171
+ Search
172
+ ======
173
+
174
+ You can search text from messages and get the records where match exist. For example:
175
+
176
+ ### Search text from messages
177
+
178
+ ```ruby
179
+ records = @alice.messages.search("Search me") @alice seach text "Search me" from all messages
180
+ ```
181
+
182
+ ### Inbox
183
+ ```ruby
184
+ @alice.received_messages
185
+ ```
186
+
187
+ ### Outbox
188
+ ```ruby
189
+ @alice.sent_messages
190
+ ```
191
+ ### Inbox + Outbox. All messages connected with __@alice__
192
+ ```ruby
193
+ @alice.messages
194
+ ```
195
+
196
+ ### Trash
197
+ ```ruby
198
+ @alice.deleted_messages
199
+ ```
200
+
201
+ ## Filters
202
+ ==========
203
+
204
+ ```ruby
205
+ @alice.messages.are_from(@bob) # all message form @bob
206
+ @alice.messages.are_to(@bob) # all message to @bob
207
+ @alice.messages.with_id(@id_of_message) # message with id id_of_message
208
+ @alice.messages.readed # all readed @alice messages
209
+ @alice.messages.unreaded # all unreaded @alice messages
210
+ ```
211
+
212
+
213
+ **You can use multiple filters at the same time**
214
+
215
+ ```ruby
216
+ @alice.messages.are_from(@bob).are_to(@alice).readed # all message from @bob to @alice and readed
217
+ @alice.deleted_messages.are_from(@bob) # all deleted messages from @bob
218
+ ```
219
+
220
+ Read messages
221
+ =============
222
+
223
+ ### Read message
224
+
225
+ ```ruby
226
+ @message.open # open message
227
+ @message.read
228
+ @message.mark_as_read
229
+ ```
230
+
231
+ ### Unread message
232
+
233
+ ```ruby
234
+ @message.close # unread message
235
+ @message.mark_as_unread
236
+ ```
237
+
238
+
239
+ Delete message
240
+ ==============
241
+
242
+ **__We must know who delete message. That why we use *.process* method to save context__**
243
+
244
+ ```ruby
245
+ @message = @alice.send_message(@bob, "Topic", "Body")
246
+
247
+ @alice.messages.process do |message|
248
+ message.delete # @alice delete message
249
+ end
250
+ ```
251
+
252
+ Now we can find message in **trash**
253
+
254
+ ```ruby
255
+ @alice.deleted_messages #=> [@message]
256
+ ```
257
+
258
+ We can delete the message **permanently**
259
+
260
+ ```ruby
261
+ @alice.deleted_messages.process do |message|
262
+ message.delete
263
+ end
264
+
265
+ @alice.delete_message #=> []
266
+ ```
267
+
268
+ Message has been deleted **permanently**
269
+
270
+ ## Delete message without context
271
+
272
+ ```ruby
273
+ @alice.delete_message(@message) # @alice delete @message
274
+ ```
275
+
276
+ Restore message
277
+ ===============
278
+
279
+ ```ruby
280
+ @alice.deleted_messages.process do |m|
281
+ m.restore # @alice restore 'm' message from trash
282
+ end
283
+ ```
284
+
285
+ ## Restore message without context
286
+
287
+ ```ruby
288
+ @alice.restore_message(@message) # @alice restore message from trash
289
+ ```
290
+
291
+ Group message
292
+ =============
293
+
294
+ ## Enable group messages
295
+
296
+ ```ruby
297
+ class User
298
+ acts_as_messageable :group_messages => true
299
+ end
300
+ ```
301
+
302
+ ## How to join other users's conversation
303
+
304
+ ```ruby
305
+ @message = @alice.send_message(@bob, :topic => "Helou bob!", :body => "What's up?")
306
+ @reply_message = @sukhi.reply_to(@message, "Hi there!", "I would like to join to this conversation!")
307
+ @sec_reply_message = @bob.reply_to(@message, "Hi!", "Fine!")
308
+ @third_reply_message = @alice.reply_to(@reply_message, "hi!", "no problem")
309
+ ```
310
+
311
+ ## Know the people involved in conversation
312
+
313
+ ```ruby
314
+ @message.people # will give you participants users object
315
+ @message.people # => [@alice, @bob, @sukhi]
316
+ ```
317
+
318
+ Search
319
+ ======
320
+
321
+ ## Search text from messages
322
+
323
+ ```ruby
324
+ @alice.messages.search("Search me") @alice seach text "Search me" from all messages
325
+ ```
326
+
327
+ Copyright © 2011-2012 Piotr Niełacny (http://ruby-blog.pl), released under the MIT license