satchel 0.0.1 → 0.0.2
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/.gitignore +2 -1
- data/README.md +35 -0
- data/lib/generators/satchel/install_generator.rb +19 -0
- data/lib/generators/satchel/register_generator.rb +28 -0
- data/lib/generators/satchel/templates/satchel_config.rb +6 -0
- data/lib/satchel/version.rb +1 -1
- data/spec/spec_helper.rb +9 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e58681014e253497e9642f2c4c8e91061ede86bb
|
4
|
+
data.tar.gz: 3133bb65293a8948260731a24df60f989f835e39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46e3ceb68cec34a77ceb26068c83ecaeacd40d84d6281be1f25877d8c2a6f140c67e9e00dcfbdb3f0d3ecf1713ebab51acdbeae861290bdea0a555ec4ccc761b
|
7
|
+
data.tar.gz: 0e9ddfc8541a8e7dc28d90eb658798efbb96aa4543fc9b8d0ffb33dce70210ea91cf66657c62b19628173906abb1f7257deed6d4f296a5bd105848b8d32a4e28
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -2,3 +2,38 @@
|
|
2
2
|
|
3
3
|
A mountable Rails engine for both recording activity and displaying activity on
|
4
4
|
a persisted object.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem 'satchel'
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Then run:
|
17
|
+
|
18
|
+
$ rails g satchel:install
|
19
|
+
|
20
|
+
## Register a Method
|
21
|
+
|
22
|
+
To record activity, register a class and method via a Rails generator.
|
23
|
+
|
24
|
+
$ rails g satchel:register <ClassName> <MethodName> <Subject>
|
25
|
+
|
26
|
+
Or by hand in a config/initializers/satchel_config.rb
|
27
|
+
|
28
|
+
Satchel.register('<ClassName>', '<MethodName>') do |activity,context|
|
29
|
+
activity.subject = context.<subject>
|
30
|
+
activity.user = context.current_user
|
31
|
+
activity.activity_type = "an arbitrary type"
|
32
|
+
activity.message = "A particulare message?"
|
33
|
+
end
|
34
|
+
|
35
|
+
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
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Satchel
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path("../templates", __FILE__)
|
5
|
+
|
6
|
+
desc "Creates a Satchel initializer."
|
7
|
+
|
8
|
+
def copy_initializer
|
9
|
+
template "satchel_config.rb", "config/initializers/satchel_config.rb"
|
10
|
+
end
|
11
|
+
|
12
|
+
def run_migrations
|
13
|
+
rake('satchel:install:migrations')
|
14
|
+
rake('db:migrate')
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Satchel
|
2
|
+
module Generators
|
3
|
+
class RegisterGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path("../templates", __FILE__)
|
5
|
+
|
6
|
+
desc "Creates a Satchel initializer."
|
7
|
+
argument :class_name, type: :string
|
8
|
+
argument :method_name, type: :string
|
9
|
+
argument :subject_method, type: :string
|
10
|
+
|
11
|
+
def copy_initializer
|
12
|
+
generate('satchel:install')
|
13
|
+
text = [
|
14
|
+
"Satchel.register('#{class_name}', '#{method_name}') do |activity, context|",
|
15
|
+
" activity.subject = context.#{subject_method}",
|
16
|
+
" activity.user = context.current_user",
|
17
|
+
" activity.activity_type = '#{class_name}##{method_name}'",
|
18
|
+
"# activity.message = 'Specify a custom message if applicable'",
|
19
|
+
"end",
|
20
|
+
"",
|
21
|
+
""
|
22
|
+
].join("\n")
|
23
|
+
|
24
|
+
inject_into_file('config/initializers/satchel_config.rb', text, before: /\A.*Satchel.register/)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/satchel/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
ENV["RAILS_ENV"] ||= 'test'
|
2
2
|
|
3
|
+
if ENV['COVERAGE']
|
4
|
+
require 'simplecov'
|
5
|
+
SimpleCov.command_name "spec"
|
6
|
+
SimpleCov.start 'rails' do
|
7
|
+
add_filter '/spec'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
|
3
12
|
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
4
13
|
require File.expand_path('../spec_patch', __FILE__)
|
5
14
|
require "rails/test_help"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: satchel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Friesen
|
@@ -76,6 +76,9 @@ files:
|
|
76
76
|
- app/views/layouts/satchel/application.html.erb
|
77
77
|
- config/routes.rb
|
78
78
|
- db/migrate/20130722162331_create_satchel_activities.rb
|
79
|
+
- lib/generators/satchel/install_generator.rb
|
80
|
+
- lib/generators/satchel/register_generator.rb
|
81
|
+
- lib/generators/satchel/templates/satchel_config.rb
|
79
82
|
- lib/satchel.rb
|
80
83
|
- lib/satchel/activity_builder.rb
|
81
84
|
- lib/satchel/activity_data_structure.rb
|