narrator 0.0.1.beta → 0.0.1

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: fa1bb48cf586a6f4f347ed23bad29ef890b6a970
4
- data.tar.gz: 61fc99168cf94e4bf24b68652747e4df0822d6da
3
+ metadata.gz: 550ddf17fdbb9d5842f2dfa102e16f1f8c2542f8
4
+ data.tar.gz: ca48647697c0c8b0a3cc919e3a396dbe6eac1ae0
5
5
  SHA512:
6
- metadata.gz: fa6d4ce60133cca0a0c8596fb5bc9dfc314ddb46f278c52d2c470bac44a5d0457a4f87b29a210093bbf4191f46c64897e2f4463ffccd2920146d455a9396a3e5
7
- data.tar.gz: a264d17ae149cb7713ffed1b36f1884b62103ff442431f4539bebaaada182964ba6acc4b753ca3691440c5082d4298a65c45a1466395691dc0038854eb4ae58e
6
+ metadata.gz: 6f73733ceac06d10496b1c92c61a68f038a9a7d5abab8d4f905df6d16901faba20bbf165973d4a5113e3c5dae12dfe47f8a17ddf49367efe4e50fcc926cd4bfa
7
+ data.tar.gz: ad879003c9b482da1fa664c548d87d3d682e8c4789a7c07d3e7a4624c179f4f221ddf58b875093fcf20af304d1780122ec1203429e878e3314c920d4054a1609
@@ -1,6 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.8.7
4
3
  - 1.9.3
5
4
  #- jruby-18mode # JRuby in 1.8 mode
6
5
  #- jruby-19mode # JRuby in 1.9 mode
@@ -1,4 +1,3 @@
1
- = This gem is currently unstable as it is being developed.
2
1
  = Narrator {<img src="https://secure.travis-ci.org/jweakley/narrator.png?branch=master" />}[http://travis-ci.org/jweakley/narrator]
3
2
 
4
3
  Narrator is an activity library for Ruby on Rails that allow you to track what is happening on models and later use to build an activity or news stream. Tracking is done at the controller level with a simple narrate_resource command (which was inspired by the simplicity of Ryan Bates' CanCan gem).
data/Rakefile CHANGED
@@ -1,5 +1,4 @@
1
1
  require "bundler/gem_tasks"
2
- require 'rake'
3
2
  require 'rspec/core/rake_task'
4
3
 
5
4
  RSpec::Core::RakeTask.new(:spec)
@@ -1,4 +1,5 @@
1
1
  require 'narrator/version'
2
+ require 'active_record'
2
3
  require 'narrator/activity'
3
4
  require 'narrator/model_additions'
4
5
  require 'narrator/model_resources'
@@ -1,28 +1,22 @@
1
1
  module Narrator
2
2
  class Activity < ::ActiveRecord::Base
3
- ###
4
- # Attribute accessible
5
- ###
6
- attr_accessible :owner, :subject, :actor, :target, :verb, :context, :has_seen
3
+ attr_accessible :owner,
4
+ :subject,
5
+ :actor,
6
+ :target,
7
+ :verb,
8
+ :context,
9
+ :has_seen
7
10
 
8
- ###
9
- # Associations
10
- ###
11
- belongs_to :owner, polymorphic: true
12
- belongs_to :actor, polymorphic: true
13
- belongs_to :subject, polymorphic: true
14
- belongs_to :target, polymorphic: true
11
+ belongs_to :owner, polymorphic: true
12
+ belongs_to :actor, polymorphic: true
13
+ belongs_to :subject, polymorphic: true
14
+ belongs_to :target, polymorphic: true
15
15
 
16
- ###
17
- # Validate
18
- ###
19
- validates :subject, presence: true
20
- validates :verb, presence: true
16
+ validates :subject, presence: true
17
+ validates :verb, presence: true
21
18
 
22
- ###
23
- # Scopes
24
- ###
25
- scope :unseen, where(has_seen: false)
26
- scope :seen, where(has_seen: true)
19
+ scope :unseen, where(has_seen: false)
20
+ scope :seen, where(has_seen: true)
27
21
  end
28
22
  end
@@ -3,7 +3,11 @@ module Narrator
3
3
  module ClassMethods
4
4
 
5
5
  def narrate_resource(*args)
6
- narrator_resource_class.add_after_filter(self, :narrate_resource, *args)
6
+ narrator_resource_class.add_after_filter(
7
+ self,
8
+ :narrate_resource,
9
+ *args
10
+ )
7
11
  end
8
12
 
9
13
  def narrator_resource_class
@@ -20,7 +24,13 @@ module Narrator
20
24
  base.helper_method :narrate
21
25
  end
22
26
 
23
- def narrate(subject, actor = current_user, target = nil, verb = params[:action], context = nil)
27
+ def narrate(
28
+ subject,
29
+ actor = current_user,
30
+ target = nil,
31
+ verb = params[:action],
32
+ context = nil
33
+ )
24
34
  if subject.class.respond_to? :track_user_activity
25
35
  # Add some config way of determining to use delayed jobs.
26
36
  subject.class.track_user_activity(
@@ -10,25 +10,47 @@ module Narrator
10
10
  ###
11
11
  # Associations
12
12
  ###
13
- has_many :activities, as: :subject, class_name: 'Narrator::Activity', dependent: :destroy
13
+ has_many :activities,
14
+ as: :subject,
15
+ class_name: 'Narrator::Activity',
16
+ dependent: :destroy
14
17
 
15
18
  ###
16
19
  # Instance Methods
17
20
  ###
18
21
 
19
- # TODO Add documentation once format is determined.
20
- def track_user_activity(subject_id, subject_class, actor_id, actor_class, target_id, target_class, verb, context)
22
+ def track_user_activity(
23
+ subject_id,
24
+ subject_class,
25
+ actor_id,
26
+ actor_class,
27
+ target_id,
28
+ target_class,
29
+ verb,
30
+ context
31
+ )
21
32
  actor = actor_id.blank? ? nil : actor_class.constantize.find_by_id(actor_id)
22
33
  subject = subject_id.blank? ? nil : subject_class.constantize.find_by_id(subject_id)
23
34
  target = target_id.blank? ? nil : target_class.constantize.find_by_id(target_id)
24
- Narrator::Activity.create!(owner: nil, subject: subject, actor: actor, target: target, verb: verb, context: context)
35
+ Narrator::Activity.create!(
36
+ owner: nil,
37
+ subject: subject,
38
+ actor: actor,
39
+ target: target,
40
+ verb: verb,
41
+ context: context
42
+ )
25
43
  end
26
44
  end
45
+
27
46
  def narratable_actor
28
47
  ###
29
48
  # Associations
30
49
  ###
31
- has_many :activities, as: :actor, class_name: 'Narrator::Activity', dependent: :destroy
50
+ has_many :activities,
51
+ as: :actor,
52
+ class_name: 'Narrator::Activity',
53
+ dependent: :destroy
32
54
  end
33
55
  end
34
56
  end
@@ -1,3 +1,3 @@
1
1
  module Narrator
2
- VERSION = '0.0.1.beta'
2
+ VERSION = '0.0.1'
3
3
  end
@@ -4,21 +4,24 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'narrator/version'
5
5
 
6
6
  Gem::Specification.new do |gem|
7
- gem.name = "narrator"
7
+ gem.name = 'narrator'
8
8
  gem.version = Narrator::VERSION
9
- gem.authors = ["Joe Weakley"]
10
- gem.email = ["joe.weakley@digitalaugment.com"]
11
- gem.description = %q{Straightforward and flexable activity tracking for rails that is designed to be fast and scalable.}
9
+ gem.authors = ['Joe Weakley']
10
+ gem.email = ['joe.weakley@digitalaugment.com']
11
+ gem.description = %q{Straightforward and flexable activity tracking for rails.}
12
12
  gem.summary = %q{Straightforward and flexable activity tracking for rails.}
13
- gem.homepage = "https://github.com/jweakley/narrator"
13
+ gem.homepage = 'https://github.com/jweakley/narrator'
14
14
 
15
- gem.files = `git ls-files`.split($/)
16
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
15
+ gem.files = `git ls-files`.split($RS)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
- gem.require_paths = ["lib"]
18
+ gem.require_paths = ['lib']
19
19
 
20
- gem.add_dependency('rails', '~>3.0')
20
+ gem.required_ruby_version = '>= 1.9'
21
21
 
22
- gem.add_development_dependency "rspec"
23
- gem.add_development_dependency "rake"
22
+ gem.add_dependency('rails', '~> 3.0')
23
+
24
+ gem.add_development_dependency 'rspec'
25
+ gem.add_development_dependency 'rake'
26
+ gem.add_development_dependency 'rubocop'
24
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: narrator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.beta
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Weakley
@@ -52,8 +52,21 @@ dependencies:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description: Straightforward and flexable activity tracking for rails that is designed
56
- to be fast and scalable.
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Straightforward and flexable activity tracking for rails.
57
70
  email:
58
71
  - joe.weakley@digitalaugment.com
59
72
  executables: []
@@ -92,12 +105,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
92
105
  requirements:
93
106
  - - '>='
94
107
  - !ruby/object:Gem::Version
95
- version: '0'
108
+ version: '1.9'
96
109
  required_rubygems_version: !ruby/object:Gem::Requirement
97
110
  requirements:
98
- - - '>'
111
+ - - '>='
99
112
  - !ruby/object:Gem::Version
100
- version: 1.3.1
113
+ version: '0'
101
114
  requirements: []
102
115
  rubyforge_project:
103
116
  rubygems_version: 2.0.3