satchel 0.0.1 → 0.0.2

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: f65129ed73d372a2b29b8c7bdabdf65f21616502
4
- data.tar.gz: baa20abc0389eb97ef188b676c70073049931fed
3
+ metadata.gz: e58681014e253497e9642f2c4c8e91061ede86bb
4
+ data.tar.gz: 3133bb65293a8948260731a24df60f989f835e39
5
5
  SHA512:
6
- metadata.gz: 2a947c6b478508e3d46f076b64b32e3cdce44c8830760f15e7347fccdb52855746047cbe0c30bddf9bc1c7e3c0d725881d6adde0e4f489a6a8441c1634a4e08d
7
- data.tar.gz: 9d937162e3a863a63752c7ab7d286048e7ff4f4061d2cba53cec58bb34f5f22f31bd3208abf44e7a24596069900bf62bfeacbf0667b0a3a9e725f002129f4491
6
+ metadata.gz: 46e3ceb68cec34a77ceb26068c83ecaeacd40d84d6281be1f25877d8c2a6f140c67e9e00dcfbdb3f0d3ecf1713ebab51acdbeae861290bdea0a555ec4ccc761b
7
+ data.tar.gz: 0e9ddfc8541a8e7dc28d90eb658798efbb96aa4543fc9b8d0ffb33dce70210ea91cf66657c62b19628173906abb1f7257deed6d4f296a5bd105848b8d32a4e28
data/.gitignore CHANGED
@@ -6,4 +6,5 @@ spec/dummy/log/*.log
6
6
  spec/dummy/tmp/
7
7
  spec/dummy/.sass-cache
8
8
  Gemfile.lock
9
- tmp/*
9
+ tmp/*
10
+ coverage/
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
@@ -0,0 +1,6 @@
1
+ # Satchel.register('PagesController', 'show') do |activity,context|
2
+ # activity.subject = context.page
3
+ # activity.user = context.current_user
4
+ # activity.activity_type = 'pages#show'
5
+ # activity.message = "A particulare message?"
6
+ # end
@@ -1,3 +1,3 @@
1
1
  module Satchel
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -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.1
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