acts_as_chattable 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dd602c446ee80af094e8606a6f9195f128f2a174
4
- data.tar.gz: a642a418bf4d939034a5aeeaa946d03d51b1876f
3
+ metadata.gz: 2f8e906e0614193eeee9549776718acea58a3b28
4
+ data.tar.gz: f3598cd1632b6eb2654e8622a59dd2db5a0a7688
5
5
  SHA512:
6
- metadata.gz: aca9ec1fd084ae06607fea02c19731509ac00b6767666a161e14a6ca4f04aa7c38bddd82ed59bb2080a85689407ffafb1eb48a4be6127987c975448a49c1d96b
7
- data.tar.gz: fb7be8257ac061d105b83590e74095ffd11a32ffc6aa108da206076ccfb6f21b43397100316e13d4f3fd23dbcef717eeba3d86e57762af40f90dc91e48dbbca9
6
+ metadata.gz: c2e4e893e082032e62e21fa27150593105ce18668b32fc309e7a4b8ea1f591ffade5becbc2f63e2db4159def3f3f51fc63881ece46f602f1d9fc65f21b1fcb97
7
+ data.tar.gz: 060419d0e25833962b3699db90a380bb3fba42d2c79ecdeb1bc967c493d32093ee5619eb67bcc6bebb66d51af4fb43dd25f89d85f0a429e18293ff2a2802fc96
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010 Piotr Niełacny Inc.
1
+ Copyright (c) 2013 Ben Bruscella
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
1
  ActsAsChattable
2
2
  =================
3
3
 
4
- The Acts As Chattable allows communication between the models.
4
+ The Acts As Chattable allows communication between models.
5
+
6
+ It was designed for a mobile app that needs private communications with attachments, like the iPhone SMS app for example.
5
7
 
6
8
  [![Build Status](https://secure.travis-ci.org/LTe/acts-as-messageable.png)](http://travis-ci.org/LTe/acts-as-messageable)
7
9
  [![Dependency Status](https://gemnasium.com/LTe/acts-as-messageable.png)](https://gemnasium.com/LTe/acts-as-messageable)
@@ -33,8 +35,8 @@ Usage
33
35
 
34
36
  ```ruby
35
37
  class User < ActiveRecord::Base
36
- acts_as_messageable :required => :body # default [:body]
37
- :dependent => :destroy # default :nullify
38
+ acts_as_chattable :required => :body # default [:body]
39
+ :dependent => :destroy # default :nullify
38
40
  end
39
41
  ```
40
42
 
@@ -45,14 +47,14 @@ Send message
45
47
  @alice = User.first
46
48
  @bob = User.last
47
49
 
48
- @alice.send_message(@bob, "Message topic", "Hi bob!")
49
- @bob.send_message(@alice, "Re: Message topic", "Hi alice!")
50
+ @alice.send_message(@bob, "Hi bob!")
51
+ @bob.send_message(@alice, Hi alice!")
50
52
  ```
51
53
 
52
54
  ## With hash
53
55
 
54
56
  ```ruby
55
- @alice.send_message(@bob, { :body => "Hash body", :topic => "Hash topic" })
57
+ @alice.send_message(@bob, { :body => "Hash body" })
56
58
  ```
57
59
 
58
60
  Custom required (validation)
@@ -62,7 +64,7 @@ In User model
62
64
 
63
65
  ```ruby
64
66
  class User < ActiveRecord::Base
65
- acts_as_messageable :required => :body
67
+ acts_as_chattable :required => :body
66
68
  end
67
69
  ```
68
70
 
@@ -78,55 +80,6 @@ end
78
80
  @alice.send_message(@bob, "body")
79
81
  ```
80
82
 
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
83
  Conversation
131
84
  ============
132
85
 
@@ -288,32 +241,6 @@ end
288
241
  @alice.restore_message(@message) # @alice restore message from trash
289
242
  ```
290
243
 
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
244
 
318
245
  Search
319
246
  ======
@@ -324,4 +251,14 @@ Search
324
251
  @alice.messages.search("Search me") @alice seach text "Search me" from all messages
325
252
  ```
326
253
 
327
- Copyright © 2011-2012 Piotr Niełacny (http://ruby-blog.pl), released under the MIT license
254
+ Gem
255
+ ===========
256
+ ```
257
+ rspec spec
258
+ rake gemspec
259
+ gem build acts_as_chattable.gemspec
260
+ gem push acts_as_chattable-0.0.x.gem
261
+
262
+
263
+
264
+ Copyright © 2013 Ben Bruscella, released under the MIT license
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "acts_as_chattable"
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ben Bruscella"]
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "result": {
3
- "covered_percent": 93.24
3
+ "covered_percent": 93.92
4
4
  }
5
5
  }
@@ -53,36 +53,36 @@
53
53
  null,
54
54
  null,
55
55
  1,
56
- 30,
56
+ 31,
57
57
  null,
58
58
  null,
59
59
  null,
60
60
  null,
61
61
  null,
62
- 30,
62
+ 31,
63
63
  null,
64
- 30,
64
+ 31,
65
65
  null,
66
66
  null,
67
67
  null,
68
- 30,
68
+ 31,
69
69
  null,
70
70
  null,
71
71
  null,
72
72
  null,
73
- 30,
73
+ 31,
74
74
  null,
75
- 30,
76
- 30,
75
+ 31,
76
+ 31,
77
77
  null,
78
78
  0,
79
79
  0,
80
80
  null,
81
81
  null,
82
- 30,
83
- 30,
82
+ 31,
83
+ 31,
84
84
  null,
85
- 30,
85
+ 31,
86
86
  null,
87
87
  null,
88
88
  null,
@@ -95,6 +95,7 @@
95
95
  null,
96
96
  1,
97
97
  null,
98
+ null,
98
99
  1,
99
100
  35,
100
101
  35,
@@ -102,6 +103,13 @@
102
103
  35,
103
104
  null,
104
105
  null,
106
+ 1,
107
+ null,
108
+ null,
109
+ null,
110
+ 4,
111
+ null,
112
+ null,
105
113
  null,
106
114
  1,
107
115
  12,
@@ -132,23 +140,23 @@
132
140
  null,
133
141
  null,
134
142
  1,
135
- 36,
143
+ 38,
136
144
  null,
137
- 36,
145
+ 38,
138
146
  null,
139
- 35,
140
- 35,
147
+ 37,
148
+ 37,
141
149
  null,
142
150
  null,
143
151
  1,
144
152
  null,
145
153
  null,
146
- 36,
147
- 36,
148
- 36,
149
- 36,
154
+ 38,
155
+ 38,
156
+ 38,
157
+ 38,
150
158
  null,
151
- 36,
159
+ 38,
152
160
  null,
153
161
  null,
154
162
  null,
@@ -210,9 +218,6 @@
210
218
  null,
211
219
  null,
212
220
  null,
213
- 1,
214
- 0,
215
- null,
216
221
  null,
217
222
  null
218
223
  ],
@@ -306,7 +311,7 @@
306
311
  null,
307
312
  null,
308
313
  1,
309
- 125,
314
+ 133,
310
315
  null,
311
316
  null,
312
317
  1,
@@ -314,14 +319,14 @@
314
319
  null,
315
320
  null,
316
321
  1,
317
- 124,
322
+ 132,
318
323
  null,
319
324
  null,
320
325
  null
321
326
  ],
322
327
  "/Users/benbruscella/Projects/Github/acts_as_chattable/spec/support/send_message.rb": [
323
328
  1,
324
- 33,
329
+ 34,
325
330
  null
326
331
  ],
327
332
  "/Users/benbruscella/Projects/Github/acts_as_chattable/spec/support/user.rb": [
@@ -333,6 +338,6 @@
333
338
  null
334
339
  ]
335
340
  },
336
- "timestamp": 1376114433
341
+ "timestamp": 1376119382
337
342
  }
338
343
  }
@@ -55,6 +55,7 @@ module ActsAsChattable
55
55
  end
56
56
 
57
57
  module InstanceMethods
58
+
58
59
  # @return [ActiveRecord::Relation] all messages connected with user
59
60
  def messages(trash = false)
60
61
  result = self.class.messages_class_name.connected_with(self, trash)
@@ -63,6 +64,13 @@ module ActsAsChattable
63
64
  result
64
65
  end
65
66
 
67
+ def messages_with(friend)
68
+ ActsAsChattable::Message.where("(received_messageable_id = #{self.id} AND sent_messageable_id = #{friend.id})
69
+ OR
70
+ (sent_messageable_id = #{self.id} AND received_messageable_id = #{friend.id})")
71
+ .order('id DESC')
72
+ end
73
+
66
74
  # @return [ActiveRecord::Relation] returns all messages from inbox
67
75
  def received_messages
68
76
  result = ActsAsChattable.rails_api.new(received_messages_relation)
@@ -10,8 +10,5 @@ module ActsAsChattable
10
10
  end
11
11
  end
12
12
 
13
- def conversations
14
- map { |r| r.root.subtree.order("id desc").first }.uniq
15
- end
16
13
  end
17
14
  end
@@ -157,14 +157,14 @@ describe "ActsAsChattable" do
157
157
  @bob.messages.first.body == "Body"
158
158
  end
159
159
 
160
- # describe "conversation" do
161
- # it "bob send message to alice, and alice reply to bob message and show proper tree" do
162
- # @reply_message = @alice.reply_to(@message, "Re: Topic", "Body")
163
-
164
- # @reply_message.conversation.size.should == 2
165
- # @reply_message.conversation.last.topic.should == "Topic"
166
- # @reply_message.conversation.first.topic.should == "Re: Topic"
167
- # end
160
+ describe "conversation" do
161
+ it "bob send message to alice, and alice reply to bob message and show proper tree" do
162
+ @alice.send_message(@bob, "Re: Body")
163
+ @alice.messages_with(@bob).size.should eq(2)
164
+ @alice.messages_with(@bob).last.body.should == "Body"
165
+ @alice.messages_with(@bob).first.body.should == "Re: Body"
166
+ @bob.messages_with(@alice).size.should eq(2)
167
+ end
168
168
 
169
169
  # it "bob send message to alice, alice answer, and bob answer for alice answer" do
170
170
  # @reply_message = @alice.reply_to(@message, "Re: Topic", "Body")
@@ -177,7 +177,7 @@ describe "ActsAsChattable" do
177
177
  # @message.conversation.first.should == @reply_reply_message
178
178
  # @reply_reply_message.conversation.first.should == @reply_reply_message
179
179
  # end
180
- # end
180
+ end
181
181
 
182
182
  # describe "conversations" do
183
183
  # before do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_chattable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Bruscella