newsfeed 1.0.5 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/newsfeed/logging.rb +56 -0
- data/newsfeed.gemspec +3 -2
- metadata +4 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0
|
1
|
+
1.1.0
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Newsfeed
|
2
|
+
module Logging
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
set_callback :create, :after, :log_create_activity
|
7
|
+
set_callback :update, :after, :log_update_activity
|
8
|
+
set_callback :destroy, :after, :log_destroy_activity
|
9
|
+
end
|
10
|
+
|
11
|
+
def init_newsfeedlab(feed_name=nil, feed_id=nil)
|
12
|
+
newsfeedlab_config = YAML.load(ERB.new(Rails.root.join('config', 'newsfeedlab.yml').read).result)[Rails.env] || {}
|
13
|
+
client = Newsfeed::Client.new(newsfeedlab_config['api_url'])
|
14
|
+
project = client.projects(newsfeedlab_config['project_name'])
|
15
|
+
|
16
|
+
@log_config = self.newsfeed_log_settings rescue {}
|
17
|
+
feed = project.feed(feed_name || @log_config[:feed_name], feed_id || @log_config[:feed_id])
|
18
|
+
return feed
|
19
|
+
end
|
20
|
+
|
21
|
+
def log_create_activity
|
22
|
+
return unless @log_config[:log].include?(:create)
|
23
|
+
|
24
|
+
feed = init_newsfeedlab()
|
25
|
+
obj = {:event => "create", :type => self.class.to_s.downcase, :id => (self.id.to_s rescue nil)}
|
26
|
+
obj[:obj] = @log_config[:obj] unless @log_config[:obj].nil?
|
27
|
+
feed.push(obj)
|
28
|
+
end
|
29
|
+
|
30
|
+
def log_update_activity
|
31
|
+
return unless @log_config[:log].include?(:update)
|
32
|
+
|
33
|
+
feed = init_newsfeedlab()
|
34
|
+
obj = {:event => "update", :type => self.class.to_s.downcase, :id => (self.id.to_s rescue nil)}
|
35
|
+
obj[:obj] = @log_config[:obj] unless @log_config[:obj].nil?
|
36
|
+
feed.push(obj)
|
37
|
+
end
|
38
|
+
|
39
|
+
def log_destroy_activity
|
40
|
+
return unless @log_config[:log].include?(:destroy)
|
41
|
+
|
42
|
+
feed = init_newsfeedlab()
|
43
|
+
obj = {:event => "destroy", :type => self.class.to_s.downcase, :id => (self.id.to_s rescue nil)}
|
44
|
+
obj[:obj] = @log_config[:obj] unless @log_config[:obj].nil?
|
45
|
+
feed.push(obj)
|
46
|
+
end
|
47
|
+
|
48
|
+
def activities(opts={})
|
49
|
+
defaults = {:start => 0, :count => 49, :feed_name => nil, :feed_id => nil}
|
50
|
+
opts = defaults.merge(opts)
|
51
|
+
|
52
|
+
feed = init_newsfeedlab(opts[:feed_name], opts[:feed_id])
|
53
|
+
feed.fetch(opts[:start], opts[:count])
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/newsfeed.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "newsfeed"
|
8
|
-
s.version = "1.0
|
8
|
+
s.version = "1.1.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Adeel Raza"]
|
12
|
-
s.date = "2011-09-
|
12
|
+
s.date = "2011-09-05"
|
13
13
|
s.description = "Ruby wrapper for Newsfeed Lab. Implements a simple way to add news feeds and activity streams to your apps."
|
14
14
|
s.email = "adeelr@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
"lib/newsfeed/client.rb",
|
29
29
|
"lib/newsfeed/exceptions.rb",
|
30
30
|
"lib/newsfeed/feed.rb",
|
31
|
+
"lib/newsfeed/logging.rb",
|
31
32
|
"lib/newsfeed/project.rb",
|
32
33
|
"newsfeed.gemspec",
|
33
34
|
"test/helper.rb",
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: newsfeed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.0
|
5
|
+
version: 1.1.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Adeel Raza
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-09-
|
13
|
+
date: 2011-09-05 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: faraday-stack
|
@@ -88,6 +88,7 @@ files:
|
|
88
88
|
- lib/newsfeed/client.rb
|
89
89
|
- lib/newsfeed/exceptions.rb
|
90
90
|
- lib/newsfeed/feed.rb
|
91
|
+
- lib/newsfeed/logging.rb
|
91
92
|
- lib/newsfeed/project.rb
|
92
93
|
- newsfeed.gemspec
|
93
94
|
- test/helper.rb
|
@@ -105,7 +106,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
105
106
|
requirements:
|
106
107
|
- - ">="
|
107
108
|
- !ruby/object:Gem::Version
|
108
|
-
hash: -
|
109
|
+
hash: -834485594261079923
|
109
110
|
segments:
|
110
111
|
- 0
|
111
112
|
version: "0"
|