activity_engine 0.0.7 → 0.0.8
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.
- checksums.yaml +4 -4
- data/Guardfile +1 -1
- data/README.md +3 -5
- data/activity_engine.gemspec +1 -0
- data/lib/activity_engine/activity_sweeper.rb +1 -1
- data/lib/activity_engine/version.rb +1 -1
- data/lib/generators/activity_engine/register_generator.rb +2 -7
- data/spec/{models → app/models}/activity_engine/activity_spec.rb +0 -0
- data/spec/{models → app/models}/activity_engine/statistic_spec.rb +0 -0
- data/spec/features/dummy_scaffold_activity_spec.rb +22 -0
- data/spec/lib/activity_engine/activity_sweeper_spec.rb +5 -2
- data/tasks/dummy.rake +13 -12
- data/tasks/spec.rake +8 -12
- metadata +21 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9ea19bc1addf3c6339916689f55362f43462bab
|
4
|
+
data.tar.gz: e2b83cbdc64fe4784e4d07b4ec0deb812e492855
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cefb4712ced5728293d6be2f423d0712547f0dc0f9a0eb5bacde9453b715ab2becb3372a82f1f11ffcfa0a8d46ac3f08e80ea5f32011e7db458de3cd51f4499a
|
7
|
+
data.tar.gz: cc22e8b91f49cd75df775842c0a97c7a39b26c75e90c98f5fa8eabde77a6bfa195d13be0e290adca80373da51c1f4eb96ee1df60e33ff185fa65d448b7d9e92b
|
data/Guardfile
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
guard 'rspec' do
|
5
5
|
watch(%r{^spec/.+_spec\.rb$})
|
6
6
|
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
7
|
-
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
7
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/app/#{m[1]}_spec.rb" }
|
8
8
|
watch('spec/spec_helper.rb') { "spec" }
|
9
9
|
watch('spec/support/*') { "spec" }
|
10
10
|
end
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# ActivityEngine
|
2
2
|
|
3
|
+
[](https://travis-ci.org/ndlib/activity_engine)
|
4
|
+
|
3
5
|
A mountable Rails engine for both recording activity and displaying activity on
|
4
6
|
a persisted object.
|
5
7
|
|
@@ -23,7 +25,7 @@ To record activity, register a class and method via a Rails generator.
|
|
23
25
|
|
24
26
|
$ rails g activity_engine:register <ClassName> <MethodName> <Subject>
|
25
27
|
|
26
|
-
Or by hand in a config/
|
28
|
+
Or by hand in a config/post_initializers/activity_engine_config.rb
|
27
29
|
|
28
30
|
ActivityEngine.register('<ClassName>', '<MethodName>') do |activity,context|
|
29
31
|
activity.subject = context.<subject>
|
@@ -33,7 +35,3 @@ Or by hand in a config/initializers/activity_engine_config.rb
|
|
33
35
|
end
|
34
36
|
|
35
37
|
Then, whenever the ClassName#MethodName is invoke an activity will be recorded.
|
36
|
-
|
37
|
-
## TODO
|
38
|
-
|
39
|
-
* Provide a means for retrieving an object's activities
|
data/activity_engine.gemspec
CHANGED
@@ -29,7 +29,7 @@ module ActivityEngine
|
|
29
29
|
self.records_processed << record
|
30
30
|
ActivityEngine::Activity.new.tap {|activity|
|
31
31
|
activity.subject = record
|
32
|
-
activity.user = current_user
|
32
|
+
activity.user = current_user if respond_to?(:current_user)
|
33
33
|
activity.activity_type = "#{controller_name}##{action_name}"
|
34
34
|
}.save!
|
35
35
|
end
|
@@ -6,17 +6,12 @@ module ActivityEngine
|
|
6
6
|
desc "Creates a ActivityEngine initializer."
|
7
7
|
argument :class_name, type: :string
|
8
8
|
argument :method_name, type: :string
|
9
|
-
argument :subject_method, type: :string
|
10
9
|
|
11
10
|
def copy_initializer
|
12
11
|
generate('activity_engine:install')
|
13
12
|
text = [
|
14
|
-
"ActivityEngine.
|
15
|
-
"
|
16
|
-
" activity.current_user = context.current_user",
|
17
|
-
" activity.activity_type = '#{class_name}##{method_name}'",
|
18
|
-
"# activity.message = 'Specify a custom message if applicable'",
|
19
|
-
"end",
|
13
|
+
"ActivityEngine.register_models('#{class_name}')",
|
14
|
+
"ActivityEngine.register_controller('#{class_name.pluralize}Controller', '#{method_name}')",
|
20
15
|
"",
|
21
16
|
""
|
22
17
|
].join("\n")
|
File without changes
|
File without changes
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# NOTE: These specs are very much tied into the output of the
|
4
|
+
# `rake dummy:scaffold` commands. A change in those means a likely
|
5
|
+
# change in the behavior.
|
6
|
+
describe 'DummyScaffoldActivity', type: :feature do
|
7
|
+
|
8
|
+
it 'when I do a registered activity it is recorded' do
|
9
|
+
expect {
|
10
|
+
visit('/watches/new')
|
11
|
+
click_button("Create Watch")
|
12
|
+
}.to change{ActivityEngine::Activity.count}.by(1)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'when I do a non-registered activity it is not recorded' do
|
16
|
+
expect {
|
17
|
+
visit('/invisibles/new')
|
18
|
+
click_button("Create Invisible")
|
19
|
+
}.to_not change{ActivityEngine::Activity.count}
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -12,13 +12,16 @@ describe ActivityEngine::ActivitySweeper do
|
|
12
12
|
|
13
13
|
describe '#observe' do
|
14
14
|
it 'should allow multiple registrations' do
|
15
|
+
# Registered via the dummy spec
|
16
|
+
expect(TestSweeper.observed_classes).to eq([Watch])
|
17
|
+
|
15
18
|
expect {
|
16
19
|
TestSweeper.observe(:book)
|
17
|
-
}.to change{TestSweeper.observed_classes}.from([]).to([Book])
|
20
|
+
}.to change{TestSweeper.observed_classes}.from([Watch]).to([Watch, Book])
|
18
21
|
|
19
22
|
expect {
|
20
23
|
TestSweeper.observe(:animal)
|
21
|
-
}.to change{TestSweeper.observed_classes}.from([Book]).to([Book, Animal])
|
24
|
+
}.to change{TestSweeper.observed_classes}.from([Watch,Book]).to([Watch,Book, Animal])
|
22
25
|
end
|
23
26
|
end
|
24
27
|
end
|
data/tasks/dummy.rake
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
namespace :dummy do
|
2
2
|
desc "Generate a Rails dummy for ActivityEngine tests"
|
3
|
-
task :generate => [:init, :new_app, :install, :migrate]
|
3
|
+
task :generate => [:init, :new_app, :install, :scaffold, :migrate]
|
4
4
|
|
5
5
|
desc 'Remove dummy application'
|
6
6
|
task :remove => :init do
|
@@ -13,7 +13,7 @@ namespace :dummy do
|
|
13
13
|
task :regenerate => [:remove, :generate]
|
14
14
|
|
15
15
|
|
16
|
-
task :new_app => [:init
|
16
|
+
task :new_app => [:init] do
|
17
17
|
# Cribbed from https://gist.github.com/stas/4131823
|
18
18
|
require 'rails'
|
19
19
|
require 'activity_engine'
|
@@ -48,12 +48,20 @@ namespace :dummy do
|
|
48
48
|
)
|
49
49
|
end
|
50
50
|
|
51
|
+
task :scaffold => [:init, :new_app, :install] do
|
52
|
+
system("rails generate scaffold Watch --controller-specs false --view-specs false --routing-specs false")
|
53
|
+
system("rails generate scaffold Gear --controller-specs false --view-specs false --routing-specs false")
|
54
|
+
system("rails generate scaffold Invisible --controller-specs false --view-specs false --routing-specs false")
|
55
|
+
|
56
|
+
require 'generators/activity_engine/register_generator'
|
57
|
+
system("rails generate activity_engine:register Watch create")
|
58
|
+
system("rm -rf #{File.join(DUMMY_ROOT,'spec')}")
|
59
|
+
end
|
60
|
+
|
51
61
|
task :install => [:init, :new_app] do
|
52
62
|
puts "Installing ActivityEngine"
|
53
63
|
require 'generators/activity_engine/install_generator'
|
54
|
-
|
55
|
-
%W(. --force )
|
56
|
-
)
|
64
|
+
system("rails generate activity_engine:install --force")
|
57
65
|
end
|
58
66
|
task :migrate => :init do
|
59
67
|
puts "Running activity_engine migrations"
|
@@ -66,11 +74,4 @@ namespace :dummy do
|
|
66
74
|
DUMMY_ROOT = File.expand_path("../../spec/dummy", __FILE__).freeze
|
67
75
|
end
|
68
76
|
|
69
|
-
task :guard => [:init] do
|
70
|
-
if File.exist?(File.join(DUMMY_ROOT, 'Rakefile'))
|
71
|
-
$stderr.puts "Dummy rakefile already exists"
|
72
|
-
exit!(-1)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
77
|
end
|
data/tasks/spec.rake
CHANGED
@@ -1,16 +1,12 @@
|
|
1
|
-
task :spec do
|
2
|
-
APP_RAKEFILE = File.expand_path("../../spec/dummy/Rakefile", __FILE__)
|
3
|
-
load 'rails/tasks/engine.rake'
|
1
|
+
task :spec => ['dummy:regenerate'] do
|
4
2
|
require 'rails'
|
5
3
|
require 'rspec/core/rake_task'
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
RSpec::Core::RakeTask.new(:__spec) do |t|
|
13
|
-
t.pattern = "./spec/**/*_spec.rb"
|
4
|
+
RSpec::Core::RakeTask.new(:rspec) do |t|
|
5
|
+
t.pattern = '../**/*_spec.rb'
|
6
|
+
# Because we are running in the context of the dummy app, we need to
|
7
|
+
# make sure that spec_helper.rb is somewhere in the load path.
|
8
|
+
# Thus the "-I ../"
|
9
|
+
t.rspec_opts = "--colour -I ../"
|
14
10
|
end
|
15
|
-
Rake::Task['
|
11
|
+
Rake::Task['rspec'].invoke
|
16
12
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activity_engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Friesen
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: capybara
|
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'
|
55
69
|
description: ActivityEngine - a mountable Rails engine for activity streams
|
56
70
|
email:
|
57
71
|
- jeremy.n.friesen@gmail.com
|
@@ -93,13 +107,14 @@ files:
|
|
93
107
|
- lib/generators/activity_engine/templates/insert_into_application_config.rb
|
94
108
|
- lib/tasks/activity_engine_tasks.rake
|
95
109
|
- script/rails
|
110
|
+
- spec/app/models/activity_engine/activity_spec.rb
|
111
|
+
- spec/app/models/activity_engine/statistic_spec.rb
|
112
|
+
- spec/features/dummy_scaffold_activity_spec.rb
|
96
113
|
- spec/lib/activity_engine/activity_builder_spec.rb
|
97
114
|
- spec/lib/activity_engine/activity_data_structure_spec.rb
|
98
115
|
- spec/lib/activity_engine/activity_sweeper_spec.rb
|
99
116
|
- spec/lib/activity_engine/context_builder_spec.rb
|
100
117
|
- spec/lib/activity_engine_spec.rb
|
101
|
-
- spec/models/activity_engine/activity_spec.rb
|
102
|
-
- spec/models/activity_engine/statistic_spec.rb
|
103
118
|
- spec/spec_helper.rb
|
104
119
|
- spec/spec_patch.rb
|
105
120
|
- spec/support/persistence_layer.rb
|
@@ -130,13 +145,14 @@ signing_key:
|
|
130
145
|
specification_version: 4
|
131
146
|
summary: ActivityEngine - a mountable Rails engine for activity streams
|
132
147
|
test_files:
|
148
|
+
- spec/app/models/activity_engine/activity_spec.rb
|
149
|
+
- spec/app/models/activity_engine/statistic_spec.rb
|
150
|
+
- spec/features/dummy_scaffold_activity_spec.rb
|
133
151
|
- spec/lib/activity_engine/activity_builder_spec.rb
|
134
152
|
- spec/lib/activity_engine/activity_data_structure_spec.rb
|
135
153
|
- spec/lib/activity_engine/activity_sweeper_spec.rb
|
136
154
|
- spec/lib/activity_engine/context_builder_spec.rb
|
137
155
|
- spec/lib/activity_engine_spec.rb
|
138
|
-
- spec/models/activity_engine/activity_spec.rb
|
139
|
-
- spec/models/activity_engine/statistic_spec.rb
|
140
156
|
- spec/spec_helper.rb
|
141
157
|
- spec/spec_patch.rb
|
142
158
|
- spec/support/persistence_layer.rb
|