mongoid_noteable 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.idea/misc.xml CHANGED
@@ -3,6 +3,6 @@
3
3
  <component name="DependencyValidationManager">
4
4
  <option name="SKIP_IMPORT_STATEMENTS" value="false" />
5
5
  </component>
6
- <component name="ProjectRootManager" version="2" project-jdk-name="RVM: ruby-1.9.2-p136" project-jdk-type="RUBY_SDK" />
6
+ <component name="ProjectRootManager" version="2" project-jdk-name="ruby-1.9.2-p0" project-jdk-type="RUBY_SDK" />
7
7
  </project>
8
8
 
@@ -13,6 +13,12 @@
13
13
  </requirement>
14
14
  <source from="Gemfile" />
15
15
  </requirement>
16
+ <requirement>
17
+ <requirement>
18
+ <dependency name="mongoid_followable" version="0.1.1" bound="LATEST_IN_BRANCH" git="false" path="false" doRequire="true" />
19
+ </requirement>
20
+ <source from="Gemfile" />
21
+ </requirement>
16
22
  </component>
17
23
  <component name="NewModuleRootManager">
18
24
  <content url="file://$MODULE_DIR$" />
@@ -28,6 +34,7 @@
28
34
  <orderEntry type="library" scope="PROVIDED" name="[gem] activesupport (v3.0.9, /home/tomato/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.9)" level="application" />
29
35
  <orderEntry type="library" scope="PROVIDED" name="[gem] tzinfo (v0.3.28, /home/tomato/.rvm/gems/ruby-1.9.2-p136/gems/tzinfo-0.3.28)" level="application" />
30
36
  <orderEntry type="library" scope="PROVIDED" name="[gem] mongo (v1.3.1, /home/tomato/.rvm/gems/ruby-1.9.2-p136/gems/mongo-1.3.1)" level="application" />
37
+ <orderEntry type="library" scope="PROVIDED" name="[gem] bundler (v1.0.13, /home/tomato/.gem/ruby/1.9.1/gems/bundler-1.0.13)" level="application" />
31
38
  </component>
32
39
  </module>
33
40
 
data/.idea/workspace.xml CHANGED
@@ -1,7 +1,14 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <project version="4">
3
3
  <component name="ChangeListManager">
4
- <list default="true" id="1a94e103-1ad3-40a8-891c-00696e1e7b3a" name="Default" comment="" />
4
+ <list default="true" id="1a94e103-1ad3-40a8-891c-00696e1e7b3a" name="Default" comment="">
5
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/mongoid_noteable.iml" afterPath="$PROJECT_DIR$/.idea/mongoid_noteable.iml" />
6
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/app/models/news.rb" afterPath="$PROJECT_DIR$/app/models/news.rb" />
7
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/mongoid_noteable/noteable.rb" afterPath="$PROJECT_DIR$/lib/mongoid_noteable/noteable.rb" />
8
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/mongoid_noteable/version.rb" afterPath="$PROJECT_DIR$/lib/mongoid_noteable/version.rb" />
9
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/mongoid_noteable.gemspec" afterPath="$PROJECT_DIR$/mongoid_noteable.gemspec" />
10
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/spec/mongoid/noteable_spec.rb" afterPath="$PROJECT_DIR$/spec/mongoid/noteable_spec.rb" />
11
+ </list>
5
12
  <ignored path="mongoid_noteable.iws" />
6
13
  <ignored path=".idea/workspace.xml" />
7
14
  <option name="TRACKING_ENABLED" value="true" />
@@ -24,10 +31,10 @@
24
31
  </component>
25
32
  <component name="FileEditorManager">
26
33
  <leaf>
27
- <file leaf-file-name="mongoid_noteable.gemspec" pinned="false" current="true" current-in-tab="true">
28
- <entry file="file://$PROJECT_DIR$/mongoid_noteable.gemspec">
34
+ <file leaf-file-name="noteable_spec.rb" pinned="false" current="true" current-in-tab="true">
35
+ <entry file="file://$PROJECT_DIR$/spec/mongoid/noteable_spec.rb">
29
36
  <provider selected="true" editor-type-id="text-editor">
30
- <state line="10" column="64" selection-start="391" selection-end="391" vertical-scroll-proportion="0.2173913">
37
+ <state line="44" column="18" selection-start="1959" selection-end="1959" vertical-scroll-proportion="1.137931">
31
38
  <folding />
32
39
  </state>
33
40
  </provider>
@@ -50,12 +57,12 @@
50
57
  <option value="$PROJECT_DIR$/lib/mongoid_noteable.rb" />
51
58
  <option value="$PROJECT_DIR$/spec/models/user.rb" />
52
59
  <option value="$PROJECT_DIR$/spec/spec_helper.rb" />
53
- <option value="$PROJECT_DIR$/lib/mongoid_noteable/version.rb" />
60
+ <option value="$PROJECT_DIR$/README.rdoc" />
54
61
  <option value="$PROJECT_DIR$/app/models/news.rb" />
55
- <option value="$PROJECT_DIR$/spec/mongoid/noteable_spec.rb" />
56
62
  <option value="$PROJECT_DIR$/lib/mongoid_noteable/noteable.rb" />
57
- <option value="$PROJECT_DIR$/README.rdoc" />
58
63
  <option value="$PROJECT_DIR$/mongoid_noteable.gemspec" />
64
+ <option value="$PROJECT_DIR$/lib/mongoid_noteable/version.rb" />
65
+ <option value="$PROJECT_DIR$/spec/mongoid/noteable_spec.rb" />
59
66
  </list>
60
67
  </option>
61
68
  </component>
@@ -85,6 +92,8 @@
85
92
  <sortByType />
86
93
  </navigator>
87
94
  <panes>
95
+ <pane id="Scope" />
96
+ <pane id="Favorites" />
88
97
  <pane id="ProjectPane">
89
98
  <subPane>
90
99
  <PATH>
@@ -135,24 +144,6 @@
135
144
  <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
136
145
  </PATH_ELEMENT>
137
146
  </PATH>
138
- <PATH>
139
- <PATH_ELEMENT>
140
- <option name="myItemId" value="mongoid_noteable" />
141
- <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
142
- </PATH_ELEMENT>
143
- <PATH_ELEMENT>
144
- <option name="myItemId" value="mongoid_noteable" />
145
- <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
146
- </PATH_ELEMENT>
147
- <PATH_ELEMENT>
148
- <option name="myItemId" value="spec" />
149
- <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
150
- </PATH_ELEMENT>
151
- <PATH_ELEMENT>
152
- <option name="myItemId" value="models" />
153
- <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
154
- </PATH_ELEMENT>
155
- </PATH>
156
147
  <PATH>
157
148
  <PATH_ELEMENT>
158
149
  <option name="myItemId" value="mongoid_noteable" />
@@ -205,8 +196,6 @@
205
196
  </PATH>
206
197
  </subPane>
207
198
  </pane>
208
- <pane id="Favorites" />
209
- <pane id="Scope" />
210
199
  </panes>
211
200
  </component>
212
201
  <component name="RunManager">
@@ -255,14 +244,14 @@
255
244
  <servers />
256
245
  </component>
257
246
  <component name="ToolWindowManager">
258
- <frame x="1" y="24" width="1598" height="851" extended-state="1" />
247
+ <frame x="0" y="24" width="1280" height="752" extended-state="4" />
259
248
  <editor active="true" />
260
249
  <layout>
261
250
  <window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
262
251
  <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
263
252
  <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="true" content_ui="tabs" />
264
253
  <window_info id="Dependency Viewer" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
265
- <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.1910828" sideWeight="0.67128986" order="0" side_tool="false" content_ui="tabs" />
254
+ <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.19059011" sideWeight="0.67128986" order="0" side_tool="false" content_ui="tabs" />
266
255
  <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
267
256
  <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
268
257
  <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
@@ -319,52 +308,52 @@
319
308
  <state line="13" column="52" selection-start="340" selection-end="340" vertical-scroll-proportion="0.2826087" />
320
309
  </provider>
321
310
  </entry>
322
- <entry file="file://$PROJECT_DIR$/lib/mongoid_noteable/version.rb">
311
+ <entry file="file://$PROJECT_DIR$/Rakefile">
323
312
  <provider selected="true" editor-type-id="text-editor">
324
- <state line="3" column="5" selection-start="60" selection-end="60" vertical-scroll-proportion="0.06521739" />
313
+ <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0" />
325
314
  </provider>
326
315
  </entry>
327
- <entry file="file://$PROJECT_DIR$/Rakefile">
316
+ <entry file="file://$PROJECT_DIR$/lib/mongoid_noteable.rb">
328
317
  <provider selected="true" editor-type-id="text-editor">
329
- <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0" />
318
+ <state line="0" column="59" selection-start="59" selection-end="59" vertical-scroll-proportion="0.0" />
330
319
  </provider>
331
320
  </entry>
332
- <entry file="file://$PROJECT_DIR$/spec/mongoid/noteable_spec.rb">
321
+ <entry file="file://$PROJECT_DIR$/README.rdoc">
333
322
  <provider selected="true" editor-type-id="text-editor">
334
- <state line="42" column="23" selection-start="1836" selection-end="1836" vertical-scroll-proportion="0.86410636">
335
- <folding />
336
- </state>
323
+ <state line="40" column="61" selection-start="1134" selection-end="1134" vertical-scroll-proportion="0.0" />
337
324
  </provider>
338
325
  </entry>
339
- <entry file="file://$PROJECT_DIR$/app/models/news.rb">
326
+ <entry file="file://$PROJECT_DIR$/lib/mongoid_noteable/version.rb">
340
327
  <provider selected="true" editor-type-id="text-editor">
341
- <state line="13" column="15" selection-start="451" selection-end="451" vertical-scroll-proportion="0.2826087">
328
+ <state line="2" column="20" selection-start="53" selection-end="53" vertical-scroll-proportion="0.05059022">
342
329
  <folding />
343
330
  </state>
344
331
  </provider>
345
332
  </entry>
346
- <entry file="file://$PROJECT_DIR$/lib/mongoid_noteable.rb">
333
+ <entry file="file://$PROJECT_DIR$/mongoid_noteable.gemspec">
347
334
  <provider selected="true" editor-type-id="text-editor">
348
- <state line="0" column="59" selection-start="59" selection-end="59" vertical-scroll-proportion="0.0" />
335
+ <state line="7" column="26" selection-start="245" selection-end="245" vertical-scroll-proportion="0.17706576">
336
+ <folding />
337
+ </state>
349
338
  </provider>
350
339
  </entry>
351
- <entry file="file://$PROJECT_DIR$/README.rdoc">
340
+ <entry file="file://$PROJECT_DIR$/app/models/news.rb">
352
341
  <provider selected="true" editor-type-id="text-editor">
353
- <state line="49" column="30" selection-start="1314" selection-end="1314" vertical-scroll-proportion="1.0652174">
342
+ <state line="8" column="54" selection-start="225" selection-end="225" vertical-scroll-proportion="0.0">
354
343
  <folding />
355
344
  </state>
356
345
  </provider>
357
346
  </entry>
358
347
  <entry file="file://$PROJECT_DIR$/lib/mongoid_noteable/noteable.rb">
359
348
  <provider selected="true" editor-type-id="text-editor">
360
- <state line="64" column="21" selection-start="1409" selection-end="1409" vertical-scroll-proportion="1.3913044">
349
+ <state line="36" column="39" selection-start="921" selection-end="921" vertical-scroll-proportion="0.31034482">
361
350
  <folding />
362
351
  </state>
363
352
  </provider>
364
353
  </entry>
365
- <entry file="file://$PROJECT_DIR$/mongoid_noteable.gemspec">
354
+ <entry file="file://$PROJECT_DIR$/spec/mongoid/noteable_spec.rb">
366
355
  <provider selected="true" editor-type-id="text-editor">
367
- <state line="10" column="64" selection-start="391" selection-end="391" vertical-scroll-proportion="0.2173913">
356
+ <state line="44" column="18" selection-start="1959" selection-end="1959" vertical-scroll-proportion="1.137931">
368
357
  <folding />
369
358
  </state>
370
359
  </provider>
data/README.rdoc CHANGED
@@ -23,7 +23,7 @@ To make model noteable you need to include Mongoid::Noteable into your document.
23
23
  include Mongoid::Followable
24
24
  end
25
25
 
26
- Now you can follow others in your controller:
26
+ Now you can spread news in your controller:
27
27
  ...
28
28
  # This is what mongoid_followable does
29
29
  @group = Group.new
@@ -37,13 +37,15 @@ Now you can follow others in your controller:
37
37
  current_user.news_with_subject(@group.name)
38
38
  current_user.news_with_action("published")
39
39
  current_user.news_with_object(@some_object.some_attribute)
40
+
41
+ current_user.all_followers.news # get all followers' news
40
42
  ...
41
43
 
42
44
  * Any bug or issue, please send me an email: ustc.flyingfox@gmail.com
43
45
 
44
46
  == TODO
45
47
 
46
- * fix bug in test
48
+ * fix bug in test #FINISHED#
47
49
  * news_like_* methods for fuzzy search
48
50
  * more fields(Besides "subject", "action" and "object") in News.
49
51
 
data/app/models/news.rb CHANGED
@@ -6,6 +6,8 @@ class News
6
6
  field :action, :type => String
7
7
  field :object, :type => String
8
8
 
9
+ field :headline, :type => Boolean, :default => false
10
+
9
11
  belongs_to :noteable, :polymorphic => true
10
12
 
11
13
  scope :desc_created_at, desc(:created_at)
@@ -32,7 +32,7 @@ module Mongoid
32
32
  # args => news objects
33
33
 
34
34
  def add_news(*args)
35
- self.news.create!(:subject => args[0].to_s, :action => args[1].to_s, :object => args[2].to_s)
35
+ self.news.create!(:subject => args[0].to_s, :action => args[1].to_s, :object => args[2].to_s, :headline => (args[3] == 1 ? true : false))
36
36
 
37
37
  if self.news.count > self.news_count
38
38
  self.news[self.news_count..-1].each do |news|
@@ -47,6 +47,12 @@ module Mongoid
47
47
  rebuild_news(self.news.desc_created_at)
48
48
  end
49
49
 
50
+ #highlighted news
51
+
52
+ def highlight_news
53
+ rebuild_news(self.news.by_field("headline", true))
54
+ end
55
+
50
56
  #get all recent news
51
57
 
52
58
  def recent_news(time = 3600)
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module Noteable
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -5,7 +5,7 @@ require "mongoid_noteable/version"
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "mongoid_noteable"
7
7
  s.version = Mongoid::Noteable::VERSION
8
- s.date = "2011-06-23"
8
+ s.date = "2011-07-04"
9
9
  s.authors = ["Jie Fan"]
10
10
  s.email = ["ustc.flyingfox@gmail.com"]
11
11
  s.homepage = "https://github.com/lastomato/mongoid_noteable"
@@ -19,15 +19,15 @@ describe Mongoid::Noteable do
19
19
  end
20
20
 
21
21
  it "adding several news" do
22
- u.add_news("Shannon", "published", "A Symbolic Analysis of Relay and Switching Circuits")
22
+ u.add_news("Shannon", "published", "A Symbolic Analysis of Relay and Switching Circuits", 1)
23
23
  sleep(1)
24
- u.add_news("Shamir", "commented", "'Great Job!'")
24
+ u.add_news("Shamir", "commented", "'Great Job!'", 0)
25
25
  sleep(1)
26
- u.add_news("Cover", "commented", "'Nice!'")
26
+ u.add_news("Cover", "commented", "'Nice!'", 0)
27
27
  sleep(1)
28
- u.add_news("Zheng", "shouted", "'Wow!'")
28
+ u.add_news("Zheng", "shouted", "'Wow!'", 0)
29
29
  sleep(1)
30
- u.add_news("I", "cannot understand", "what they are saying")
30
+ u.add_news("I", "cannot understand", "what they are saying", 0)
31
31
  sleep(1)
32
32
 
33
33
  u.all_news.should == ["I cannot understand what they are saying", "Zheng shouted 'Wow!'", "Cover commented 'Nice!'", "Shamir commented 'Great Job!'", "Shannon published A Symbolic Analysis of Relay and Switching Circuits"]
@@ -38,9 +38,11 @@ describe Mongoid::Noteable do
38
38
  u.news_with_action("commented").should == ["Cover commented 'Nice!'", "Shamir commented 'Great Job!'"]
39
39
  u.news_with_object("'Wow!'").should == ["Zheng shouted 'Wow!'"]
40
40
 
41
- u.add_news("I", "come back", "again")
41
+ u.highlight_news.should == ["Shannon published A Symbolic Analysis of Relay and Switching Circuits"]
42
42
 
43
- u.all_news[0..4].should == ["I come back again", "I cannot understand what they are saying", "Zheng shouted 'Wow!'", "Cover commented 'Nice!'", "Shamir commented 'Great Job!'"]
43
+ u.add_news("I", "come back", "again", 0)
44
+
45
+ u.all_news.should == ["I come back again", "I cannot understand what they are saying", "Zheng shouted 'Wow!'", "Cover commented 'Nice!'", "Shamir commented 'Great Job!'"]
44
46
  end
45
47
  end
46
48
  end
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_noteable
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
5
4
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 1
10
- version: 0.0.1
5
+ version: 0.0.3
11
6
  platform: ruby
12
7
  authors:
13
8
  - Jie Fan
@@ -15,7 +10,7 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2011-06-23 00:00:00 -04:00
13
+ date: 2011-07-04 00:00:00 -04:00
19
14
  default_executable:
20
15
  dependencies:
21
16
  - !ruby/object:Gem::Dependency
@@ -26,11 +21,6 @@ dependencies:
26
21
  requirements:
27
22
  - - ~>
28
23
  - !ruby/object:Gem::Version
29
- hash: 13
30
- segments:
31
- - 2
32
- - 0
33
- - 1
34
24
  version: 2.0.1
35
25
  type: :runtime
36
26
  version_requirements: *id001
@@ -42,11 +32,6 @@ dependencies:
42
32
  requirements:
43
33
  - - ~>
44
34
  - !ruby/object:Gem::Version
45
- hash: 27
46
- segments:
47
- - 1
48
- - 3
49
- - 0
50
35
  version: 1.3.0
51
36
  type: :runtime
52
37
  version_requirements: *id002
@@ -58,11 +43,6 @@ dependencies:
58
43
  requirements:
59
44
  - - ~>
60
45
  - !ruby/object:Gem::Version
61
- hash: 25
62
- segments:
63
- - 0
64
- - 1
65
- - 1
66
46
  version: 0.1.1
67
47
  type: :runtime
68
48
  version_requirements: *id003
@@ -74,10 +54,6 @@ dependencies:
74
54
  requirements:
75
55
  - - ~>
76
56
  - !ruby/object:Gem::Version
77
- hash: 7
78
- segments:
79
- - 0
80
- - 6
81
57
  version: "0.6"
82
58
  type: :development
83
59
  version_requirements: *id004
@@ -89,10 +65,6 @@ dependencies:
89
65
  requirements:
90
66
  - - ~>
91
67
  - !ruby/object:Gem::Version
92
- hash: 15
93
- segments:
94
- - 2
95
- - 6
96
68
  version: "2.6"
97
69
  type: :development
98
70
  version_requirements: *id005
@@ -140,23 +112,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
140
112
  requirements:
141
113
  - - ">="
142
114
  - !ruby/object:Gem::Version
143
- hash: 3
144
- segments:
145
- - 0
146
115
  version: "0"
147
116
  required_rubygems_version: !ruby/object:Gem::Requirement
148
117
  none: false
149
118
  requirements:
150
119
  - - ">="
151
120
  - !ruby/object:Gem::Version
152
- hash: 3
153
- segments:
154
- - 0
155
121
  version: "0"
156
122
  requirements: []
157
123
 
158
124
  rubyforge_project: mongoid_noteable
159
- rubygems_version: 1.4.1
125
+ rubygems_version: 1.6.2
160
126
  signing_key:
161
127
  specification_version: 3
162
128
  summary: adds news feature to models