transcript 0.1.0 → 0.2.0

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: 9b20d6d6f59ef113036dddfa9739d4fc16dc10b0
4
- data.tar.gz: ea8aa8e46168e4dbddaa027f2820f6e83e7373ec
3
+ metadata.gz: 9e04f6c3c1dd6ca723c39b456a26e7b130e843fc
4
+ data.tar.gz: c7cd0d7476473cfe66ca443e5b40254fc53e366e
5
5
  SHA512:
6
- metadata.gz: c58484693521b8da900784752ba56c334b7141d2af4163ce68b345b4010457fd43450eb2a9d307754dda9dc23ebafda1a7ec173d1a82999a360a4800778e66a0
7
- data.tar.gz: 931079903ab30d12e4a52d9701120e22613d2dbe51a7be57764582d34b64df65b2b3f5f319e1af6c98976216ab8a8d6ff5f3620fc32a1c0faeb7c86c7d6fb2c8
6
+ metadata.gz: d63d943fb6cbaa5cd3f681788111f028407813b0aed8cbfac2e8510b6b998826967304f33c5119ee8858c2d50b5d1c7ff1736380fb880129e338e86a3b036f54
7
+ data.tar.gz: 58d11b15a2e01ffd08b7a55b240cb12b1e5a86cff8e45cc9990541c2b395001e4fc13809e9e9fba59c9dd36d59c232f84d2ccc4599373baa3c93ba40ddb644fc
data/Gemfile.lock CHANGED
@@ -1,45 +1,45 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- transcript (0.1.0)
5
- rails (~> 5.0)
4
+ transcript (0.2.0)
5
+ rails (~> 5.0.4)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actioncable (5.0.0.1)
11
- actionpack (= 5.0.0.1)
12
- nio4r (~> 1.2)
10
+ actioncable (5.0.4)
11
+ actionpack (= 5.0.4)
12
+ nio4r (>= 1.2, < 3.0)
13
13
  websocket-driver (~> 0.6.1)
14
- actionmailer (5.0.0.1)
15
- actionpack (= 5.0.0.1)
16
- actionview (= 5.0.0.1)
17
- activejob (= 5.0.0.1)
14
+ actionmailer (5.0.4)
15
+ actionpack (= 5.0.4)
16
+ actionview (= 5.0.4)
17
+ activejob (= 5.0.4)
18
18
  mail (~> 2.5, >= 2.5.4)
19
19
  rails-dom-testing (~> 2.0)
20
- actionpack (5.0.0.1)
21
- actionview (= 5.0.0.1)
22
- activesupport (= 5.0.0.1)
20
+ actionpack (5.0.4)
21
+ actionview (= 5.0.4)
22
+ activesupport (= 5.0.4)
23
23
  rack (~> 2.0)
24
24
  rack-test (~> 0.6.3)
25
25
  rails-dom-testing (~> 2.0)
26
26
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
- actionview (5.0.0.1)
28
- activesupport (= 5.0.0.1)
27
+ actionview (5.0.4)
28
+ activesupport (= 5.0.4)
29
29
  builder (~> 3.1)
30
30
  erubis (~> 2.7.0)
31
31
  rails-dom-testing (~> 2.0)
32
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
33
- activejob (5.0.0.1)
34
- activesupport (= 5.0.0.1)
32
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
33
+ activejob (5.0.4)
34
+ activesupport (= 5.0.4)
35
35
  globalid (>= 0.3.6)
36
- activemodel (5.0.0.1)
37
- activesupport (= 5.0.0.1)
38
- activerecord (5.0.0.1)
39
- activemodel (= 5.0.0.1)
40
- activesupport (= 5.0.0.1)
36
+ activemodel (5.0.4)
37
+ activesupport (= 5.0.4)
38
+ activerecord (5.0.4)
39
+ activemodel (= 5.0.4)
40
+ activesupport (= 5.0.4)
41
41
  arel (~> 7.0)
42
- activesupport (5.0.0.1)
42
+ activesupport (5.0.4)
43
43
  concurrent-ruby (~> 1.0, >= 1.0.2)
44
44
  i18n (~> 0.7)
45
45
  minitest (~> 5.1)
@@ -48,11 +48,11 @@ GEM
48
48
  activesupport (>= 3.0)
49
49
  railties (>= 3.0)
50
50
  rspec-rails (>= 2.2)
51
- arel (7.1.1)
52
- builder (3.2.2)
51
+ arel (7.1.4)
52
+ builder (3.2.3)
53
53
  codeclimate-test-reporter (0.6.0)
54
54
  simplecov (>= 0.7.1, < 1.0.0)
55
- concurrent-ruby (1.0.2)
55
+ concurrent-ruby (1.0.5)
56
56
  diff-lcs (1.2.5)
57
57
  docile (1.1.5)
58
58
  erubis (2.7.0)
@@ -61,48 +61,46 @@ GEM
61
61
  factory_girl_rails (4.7.0)
62
62
  factory_girl (~> 4.7.0)
63
63
  railties (>= 3.0.0)
64
- globalid (0.3.7)
65
- activesupport (>= 4.1.0)
66
- i18n (0.7.0)
64
+ globalid (0.4.0)
65
+ activesupport (>= 4.2.0)
66
+ i18n (0.8.6)
67
67
  json (2.0.1)
68
68
  loofah (2.0.3)
69
69
  nokogiri (>= 1.5.9)
70
- mail (2.6.4)
70
+ mail (2.6.6)
71
71
  mime-types (>= 1.16, < 4)
72
72
  method_source (0.8.2)
73
73
  mime-types (3.1)
74
74
  mime-types-data (~> 3.2015)
75
75
  mime-types-data (3.2016.0521)
76
- mini_portile2 (2.1.0)
77
- minitest (5.9.0)
78
- nio4r (1.2.1)
79
- nokogiri (1.6.8)
80
- mini_portile2 (~> 2.1.0)
81
- pkg-config (~> 1.1.7)
82
- pkg-config (1.1.7)
83
- rack (2.0.1)
76
+ mini_portile2 (2.2.0)
77
+ minitest (5.10.2)
78
+ nio4r (2.1.0)
79
+ nokogiri (1.8.0)
80
+ mini_portile2 (~> 2.2.0)
81
+ rack (2.0.3)
84
82
  rack-test (0.6.3)
85
83
  rack (>= 1.0)
86
- rails (5.0.0.1)
87
- actioncable (= 5.0.0.1)
88
- actionmailer (= 5.0.0.1)
89
- actionpack (= 5.0.0.1)
90
- actionview (= 5.0.0.1)
91
- activejob (= 5.0.0.1)
92
- activemodel (= 5.0.0.1)
93
- activerecord (= 5.0.0.1)
94
- activesupport (= 5.0.0.1)
84
+ rails (5.0.4)
85
+ actioncable (= 5.0.4)
86
+ actionmailer (= 5.0.4)
87
+ actionpack (= 5.0.4)
88
+ actionview (= 5.0.4)
89
+ activejob (= 5.0.4)
90
+ activemodel (= 5.0.4)
91
+ activerecord (= 5.0.4)
92
+ activesupport (= 5.0.4)
95
93
  bundler (>= 1.3.0, < 2.0)
96
- railties (= 5.0.0.1)
94
+ railties (= 5.0.4)
97
95
  sprockets-rails (>= 2.0.0)
98
- rails-dom-testing (2.0.1)
99
- activesupport (>= 4.2.0, < 6.0)
100
- nokogiri (~> 1.6.0)
96
+ rails-dom-testing (2.0.3)
97
+ activesupport (>= 4.2.0)
98
+ nokogiri (>= 1.6)
101
99
  rails-html-sanitizer (1.0.3)
102
100
  loofah (~> 2.0)
103
- railties (5.0.0.1)
104
- actionpack (= 5.0.0.1)
105
- activesupport (= 5.0.0.1)
101
+ railties (5.0.4)
102
+ actionpack (= 5.0.4)
103
+ activesupport (= 5.0.4)
106
104
  method_source
107
105
  rake (>= 0.8.7)
108
106
  thor (>= 0.18.1, < 2.0)
@@ -135,19 +133,19 @@ GEM
135
133
  json (>= 1.8, < 3)
136
134
  simplecov-html (~> 0.10.0)
137
135
  simplecov-html (0.10.0)
138
- sprockets (3.7.0)
136
+ sprockets (3.7.1)
139
137
  concurrent-ruby (~> 1.0)
140
138
  rack (> 1, < 3)
141
- sprockets-rails (3.1.1)
139
+ sprockets-rails (3.2.0)
142
140
  actionpack (>= 4.0)
143
141
  activesupport (>= 4.0)
144
142
  sprockets (>= 3.0.0)
145
143
  sqlite3 (1.3.11)
146
- thor (0.19.1)
147
- thread_safe (0.3.5)
148
- tzinfo (1.2.2)
144
+ thor (0.19.4)
145
+ thread_safe (0.3.6)
146
+ tzinfo (1.2.3)
149
147
  thread_safe (~> 0.1)
150
- websocket-driver (0.6.4)
148
+ websocket-driver (0.6.5)
151
149
  websocket-extensions (>= 0.1.0)
152
150
  websocket-extensions (0.1.2)
153
151
 
@@ -167,4 +165,4 @@ DEPENDENCIES
167
165
  transcript!
168
166
 
169
167
  BUNDLED WITH
170
- 1.12.5
168
+ 1.15.1
data/README.md CHANGED
@@ -22,14 +22,14 @@ gem 'transcript'
22
22
 
23
23
  And then execute:
24
24
 
25
- ```sh
26
- $ bundle
25
+ ```bash
26
+ bundle
27
27
  ```
28
28
 
29
29
  Next, run the generator to install:
30
30
 
31
- ```sh
32
- $ rails generate transcript:install NAME
31
+ ```bash
32
+ rails generate transcript:install NAME
33
33
  ```
34
34
 
35
35
  This generates a Transcript model, which can be called anything, and an initializer, specifying some configuration.
@@ -65,7 +65,7 @@ This interface sets up relationships to the log. To get a list of all the entrie
65
65
  The receiver, similar to the actor, can be any individual model, and as many models as required. To add a new receiver, include the concern:
66
66
 
67
67
  ```ruby
68
- class Post < ActiveRecord::Post
68
+ class Post < ActiveRecord::Base
69
69
  include Transcript::Receiver
70
70
  end
71
71
  ```
@@ -124,7 +124,8 @@ end
124
124
 
125
125
  Now, in any action, make a call to the helper. The method expects an object representing the actor and the object that is being acted upon. You can optionally pass a custom action name as a third argument as a string representing the verb (e.g. `create`, `delete`, or `export`). If no custom action is provided Transcript will infer from the controller action it's being called in.
126
126
 
127
- **Implied action:**
127
+ #### Implied action
128
+
128
129
  ```ruby
129
130
  def create
130
131
  audit_action current_user, @comment
@@ -132,7 +133,8 @@ def create
132
133
  end
133
134
  ```
134
135
 
135
- **Custom action:**
136
+ #### Custom action
137
+
136
138
  ```ruby
137
139
  def send_password_reset
138
140
  audit_action current_user, @user, "password_reset"
@@ -140,6 +142,16 @@ def send_password_reset
140
142
  end
141
143
  ```
142
144
 
145
+ ### Background Job
146
+
147
+ Transcript includes an ActiveJob class to create audit entries in the background. However, it can also be run in synchronous mode where entries are created inline. This is handled with a configuration value, which by default is set to synchronous mode.
148
+
149
+ ```ruby
150
+ Transcript.configure do |config|
151
+ config.create_mode = :asynchronous # use backgrounding or :synchronous for inline
152
+ end
153
+ ```
154
+
143
155
  ## Known Issues
144
156
 
145
157
  ### UUIDs
@@ -163,7 +175,7 @@ end
163
175
 
164
176
  ## Contributing
165
177
 
166
- Bug reports and pull requests are welcome on GitHub at https://github.com/newaperio/transcript. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
178
+ Bug reports and pull requests are welcome on [GitHub](https://github.com/newaperio/transcript). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
167
179
 
168
180
  ## License
169
181
 
@@ -1,3 +1,3 @@
1
1
  Transcript.configure do |config|
2
- config.audit_model = <%= class_name %>
2
+ config.audit_model = '<%= class_name %>'
3
3
  end
@@ -7,7 +7,7 @@ module Transcript
7
7
  included do
8
8
  has_many :audit_entries_by,
9
9
  as: :actor,
10
- class_name: Transcript.configuration.audit_model
10
+ class_name: Transcript.configuration.audit_model.to_s
11
11
  end
12
12
  end
13
13
  end
@@ -1,5 +1,27 @@
1
1
  module Transcript
2
2
  class Configuration
3
+ CREATE_MODES = [:asynchronous, :synchronous]
4
+
5
+ class UnsupportedCreateMode < StandardError; end
6
+
3
7
  attr_accessor :audit_model
8
+ attr_reader :create_mode
9
+
10
+ def initialize
11
+ @create_mode = :synchronous
12
+ end
13
+
14
+ def create_mode=(mode)
15
+ mode = mode.to_sym
16
+
17
+ raise UnsupportedCreateMode unless CREATE_MODES.include?(mode)
18
+ @create_mode = mode
19
+ ensure
20
+ @create_mode = :synchronous if @create_mode.nil?
21
+ end
22
+
23
+ def job_method
24
+ create_mode.to_sym == :asynchronous ? :perform_later : :perform_now
25
+ end
4
26
  end
5
27
  end
@@ -5,7 +5,10 @@ module Transcript
5
5
  extend ActiveSupport::Concern
6
6
 
7
7
  def audit_action(actor, receiver, action = action_name)
8
- Transcript::Job.perform_later(actor, receiver, action)
8
+ Transcript::Job.send(
9
+ Transcript.configuration.job_method,
10
+ actor, receiver, action
11
+ )
9
12
  end
10
13
  end
11
14
  end
@@ -1,3 +1,3 @@
1
1
  module Transcript
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,3 +1,4 @@
1
1
  Transcript.configure do |config|
2
2
  config.audit_model = AuditEntry
3
+ config.create_mode = :asynchronous
3
4
  end
@@ -37,7 +37,7 @@ RSpec.describe Transcript::InstallGenerator, type: :generator do
37
37
 
38
38
  expect(initializer).to exist
39
39
  expect(initializer).to have_correct_syntax
40
- expect(initializer).to contain("config.audit_model = AuditLog")
40
+ expect(initializer).to contain("config.audit_model = 'AuditLog'")
41
41
  end
42
42
 
43
43
  it "includes the controller concern in ApplicationController" do
@@ -1,7 +1,32 @@
1
1
  RSpec.describe Transcript::Configuration do
2
2
  it "accepts a custom audit model" do
3
- Transcript.configure { |config| config.audit_model = AuditEntry }
3
+ config = Transcript::Configuration.new
4
+ config.audit_model = AuditEntry
4
5
 
5
- expect(Transcript.configuration.audit_model).to eq AuditEntry
6
+ expect(config.audit_model).to eq AuditEntry
7
+ end
8
+
9
+ it "has a default create mode" do
10
+ config = Transcript::Configuration.new
11
+
12
+ expect(config.create_mode).to eq :synchronous
13
+ expect(config.job_method).to eq :perform_now
14
+ end
15
+
16
+ it "accepts a create mode option" do
17
+ config = Transcript::Configuration.new
18
+ config.create_mode = :asynchronous
19
+
20
+ expect(config.create_mode).to eq :asynchronous
21
+ expect(config.job_method).to eq :perform_later
22
+ end
23
+
24
+ it "raises an error if unsupported create mode is given" do
25
+ config = Transcript::Configuration.new
26
+
27
+ expect { config.create_mode = :foo }.to raise_error(
28
+ Transcript::Configuration::UnsupportedCreateMode
29
+ )
30
+ expect(config.create_mode).to eq :synchronous
6
31
  end
7
32
  end
data/transcript.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.add_development_dependency "shoulda-matchers", "~> 3.1"
12
12
  spec.add_development_dependency "simplecov", "~> 0.12"
13
13
  spec.add_development_dependency "sqlite3", "~> 1.3"
14
- spec.add_runtime_dependency "rails", "~> 5.0"
14
+ spec.add_runtime_dependency "rails", "~> 5.0.4"
15
15
  spec.authors = ["Logan Leger", "NewAperio"]
16
16
  spec.description = <<-DESC
17
17
  Transcript is a simple audit library. It provides a clean interface for
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transcript
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Logan Leger
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-08-23 00:00:00.000000000 Z
12
+ date: 2017-07-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ammeter
@@ -143,14 +143,14 @@ dependencies:
143
143
  requirements:
144
144
  - - "~>"
145
145
  - !ruby/object:Gem::Version
146
- version: '5.0'
146
+ version: 5.0.4
147
147
  type: :runtime
148
148
  prerelease: false
149
149
  version_requirements: !ruby/object:Gem::Requirement
150
150
  requirements:
151
151
  - - "~>"
152
152
  - !ruby/object:Gem::Version
153
- version: '5.0'
153
+ version: 5.0.4
154
154
  description: |
155
155
  Transcript is a simple audit library. It provides a clean interface for
156
156
  recording changes to a given record, including metadata about the change itself.
@@ -291,7 +291,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
291
291
  version: '0'
292
292
  requirements: []
293
293
  rubyforge_project:
294
- rubygems_version: 2.5.1
294
+ rubygems_version: 2.6.11
295
295
  signing_key:
296
296
  specification_version: 4
297
297
  summary: Simple ActiveRecord auditing.