pry-auditlog 0.2.1 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3ee50ac939176aede2e4955cd623aa70ea86ec6
4
- data.tar.gz: af43359a9d894b87042f90f1360f88072b5800c7
3
+ metadata.gz: 035c74c0fdf31df8ae21d8bac8b19d845e7fc8d8
4
+ data.tar.gz: 0740c1a1c39bea29a3c6cf7f246c0f77c3d0fa9a
5
5
  SHA512:
6
- metadata.gz: 6a5e2842283b10f2c17296f2c4738d7f9648807b077cee2ddc7e9c280a9d1e2b48ce1bef3918ccdf659fea1c59e74f50ba5ececb4ae9fe68188e145350a6ac59
7
- data.tar.gz: 3c34344d5112ca2f2c0358a7c1f6e3fbcb5a6db34404e0d08e9bb2858cfcd3b16c2fd344b2761bf0335f323ac391dfa48af4a3031e61097a93c58ad1cf639ffb
6
+ metadata.gz: b75e8f845ca663f6924da9c05ff93f5bf464b533c29fdc472256b7081d9c7571dded1d2e2e798c9832f19c3c2f32671bbbd082d357509c597aad4cc327aec4c9
7
+ data.tar.gz: 609716ddfae232cc18e3b64eb97de38b155991c12e56d260220c5952744a9a928cab6bd7f9cfe6d02f1027558ea9a2de5bba4b79820d59a8d345167435fa48d6
data/.rubocop.yml ADDED
@@ -0,0 +1,23 @@
1
+ MethodLength:
2
+ Max: 50
3
+
4
+ LineLength:
5
+ Max: 160
6
+
7
+ AbcSize:
8
+ Max: 75
9
+
10
+ FileName:
11
+ Enabled: false
12
+
13
+ PerceivedComplexity:
14
+ Enabled: false
15
+
16
+ CyclomaticComplexity:
17
+ Enabled: false
18
+
19
+ Style/Documentation:
20
+ Enabled: false
21
+
22
+ Style/CaseEquality:
23
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ cache:
3
+ - bundler
4
+ install:
5
+ - bundle install
6
+ rvm:
7
+ - 2.2.2
8
+ script:
9
+ - bundle exec rake test
data/Gemfile CHANGED
@@ -1,8 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in pry-auditlog.gemspec
4
3
  gemspec
5
-
6
- group :development do
7
- gem 'rubocop'
8
- end
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 Cozy Services Ltd.
1
+ Copyright (c) 2014-2015 Matt Greensmith and Cozy Services Ltd.
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # PryAuditlog
2
2
 
3
+ [![Build Status](https://travis-ci.org/mgreensmith/pry-auditlog.svg)](https://travis-ci.org/mgreensmith/pry-auditlog)
4
+ [![Gem Version](https://badge.fury.io/rb/pry-auditlog.svg)](http://badge.fury.io/rb/pry-auditlog)
5
+
3
6
  PryAuditlog is a plugin for the [Pry](http://pry.github.com) REPL that enables logging of any combination of Pry input and output to a configured audit log file.
4
7
 
5
8
  It modifies the `read` method of the REPL class to read input statements to Pry, and it inserts itself into the `output` mechanism to scrape a copy of all emitted data. It also redirects `$stdout` and `$stderr` during the Pry session in order to capture all output emitted from any `puts` or similar statements.
@@ -18,19 +21,21 @@ Set appropriate config values and then require the plugin in your `.pryrc` or an
18
21
 
19
22
  ```
20
23
  # The auditlog must be explicitly enabled
21
- Pry.config.auditlog_enabled = true # default: false
24
+ Pry.config.auditlog_enabled = true # default: false
22
25
 
23
- # Optional path to audit log destination
24
- Pry.config.auditlog_file = '/path/to/file' # default: '/dev/null'
26
+ # Path to audit log destination and optional file mode
27
+ Pry.config.auditlog_file = '/path/to/file' # default: '/dev/null'
28
+ Pry.config.auditlog_file_mode = 0644 # default: 0600
25
29
 
26
30
  # We log both input and output by default
27
- Pry.config.auditlog_log_input = false # default: true
28
- Pry.config.auditlog_log_output = false # default: true
31
+ Pry.config.auditlog_log_input = false # default: true
32
+ Pry.config.auditlog_log_output = false # default: true
29
33
 
30
34
  # Set all config values *before* requiring the plugin
31
35
  require 'pry-auditlog'
32
36
  ```
33
37
 
34
- ### Author
38
+ ## Copyright
35
39
 
36
- Matt Greensmith for [Cozy](http://www.cozy.co)
40
+ Copyright (c) 2014-2015 Matt Greensmith and Cozy Services Ltd. See [LICENSE.txt](LICENSE.txt) for
41
+ further details.
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ task default: %w(test)
4
+
5
+ task :test do
6
+ sh 'rubocop'
7
+ end
data/bin/example.rb ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'pry'
4
+
5
+ Pry.config.auditlog_enabled = true
6
+ Pry.config.auditlog_file = '~/pry_audit.log'
7
+ require 'pry-auditlog'
8
+
9
+ Pry.start
data/lib/ext/pry/repl.rb CHANGED
@@ -44,7 +44,7 @@ class Pry
44
44
 
45
45
  # send the prompt and log line to our logger.
46
46
  if Pry.config.auditlog_log_input
47
- PryAuditlog::Logger.set_prompt(current_prompt)
47
+ PryAuditlog::Logger.prompt = current_prompt
48
48
  PryAuditlog::Logger.log('I', indented_val)
49
49
  end
50
50
 
data/lib/pry-auditlog.rb CHANGED
@@ -3,6 +3,7 @@ require 'pry-auditlog/version'
3
3
 
4
4
  Pry.config.auditlog_enabled = false unless defined?(Pry.config.auditlog_enabled)
5
5
  Pry.config.auditlog_file = '/dev/null' unless defined?(Pry.config.auditlog_file)
6
+ Pry.config.auditlog_file_mode = 0600 unless defined?(Pry.config.auditlog_file_mode)
6
7
  Pry.config.auditlog_log_input = true unless defined?(Pry.config.auditlog_log_input)
7
8
  Pry.config.auditlog_log_output = true unless defined?(Pry.config.auditlog_log_output)
8
9
 
@@ -17,14 +18,14 @@ if Pry.config.auditlog_enabled
17
18
 
18
19
  Pry.config.original_output = Pry.config.output
19
20
  Pry.config.output = PryAuditlog::Output.new
20
- Pry.config.output._set_original_output(Pry.config.original_output)
21
+ Pry.config.output._original_output = Pry.config.original_output
21
22
  end
22
23
 
23
24
  local_hooks = Pry::Hooks.new
24
25
 
25
26
  local_hooks.add_hook(:before_session, :prepare_auditlog) do
26
27
  $stdout = $stderr = Pry.config.output if Pry.config.auditlog_log_output
27
- PryAuditlog::Logger.set_session_token(Time.now.to_i)
28
+ PryAuditlog::Logger.session_token = Time.now.to_i
28
29
  PryAuditlog::Logger.log('AUDIT LOG', 'Pry session started')
29
30
  end
30
31
 
@@ -1,29 +1,25 @@
1
1
  module PryAuditlog
2
2
  class Logger
3
- @@current_prompt = ''
4
- @@session_token = ''
5
- begin
6
- if Pry.config.auditlog_file
7
- @@audit_file = File.open(Pry.config.auditlog_file, 'a', 0600).tap { |f| f.sync = true }
8
- else
9
- @@audit_file = false
10
- end
11
- rescue Errno::EACCES, Errno::ENOENT
12
- @@audit_file = false
3
+ class << self
4
+ attr_accessor :audit_file, :prompt, :session_token
13
5
  end
14
6
 
15
- def self.set_session_token(token)
16
- @@session_token = token
17
- end
7
+ @prompt = ''
8
+ @session_token = ''
18
9
 
19
- def self.set_prompt(current_prompt)
20
- @@current_prompt = current_prompt
10
+ begin
11
+ if Pry.config.auditlog_file
12
+ @audit_file = File.open(File.expand_path(Pry.config.auditlog_file), 'a', Pry.config.auditlog_file_mode).tap { |f| f.sync = true }
13
+ end
14
+ rescue Errno::EACCES, Errno::ENOENT => e
15
+ Pry.output.print "Failed to open audit log file, audit logging is disabled: #{e.message}\n"
16
+ @audit_file = nil
21
17
  end
22
18
 
23
19
  def self.log(type, line)
24
- line = "#{@@current_prompt}#{line}" if type == 'I'
25
- log_line = "[#{Time.now.to_s}][#{@@session_token}][#{type}] #{line}"
26
- @@audit_file.puts log_line if @@audit_file && !line.strip.empty?
20
+ line = "#{@prompt}#{line}" if type == 'I'
21
+ log_line = "[#{Time.now}][#{@session_token}][#{type}] #{line}"
22
+ @audit_file.puts log_line if @audit_file && !line.strip.empty?
27
23
  end
28
24
  end
29
25
  end
@@ -1,14 +1,12 @@
1
1
  module PryAuditlog
2
2
  class Output < StringIO
3
- def _set_original_output(orig)
4
- @original_output = orig
5
- end
3
+ attr_accessor :_original_output
6
4
 
7
5
  def print(line)
8
6
  PryAuditlog::Logger.log('O', line)
9
- @original_output.print(line)
7
+ @_original_output.print(line)
10
8
  end
11
- alias << print
12
- alias write print
9
+ alias_method :<<, :print
10
+ alias_method :write, :print
13
11
  end
14
12
  end
@@ -1,3 +1,3 @@
1
1
  module PryAuditlog
2
- VERSION = '0.2.1'
2
+ VERSION = '0.3.0'
3
3
  end
data/pry-auditlog.gemspec CHANGED
@@ -6,14 +6,18 @@ require 'pry-auditlog/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'pry-auditlog'
8
8
  spec.version = PryAuditlog::VERSION
9
- spec.authors = ['Cozy Services Ltd.', 'Matt Greensmith']
10
- spec.email = ['opensource@cozy.co']
11
- spec.summary = %q{Adds audit log capability to Pry}
12
- spec.description = %q{PryAuditlog is a plugin for the Pry REPL that enables logging of any combination of Pry input and output to a configured audit log file.}
13
- spec.homepage = 'http://github.com/cozyco/pry-auditlog'
9
+ spec.authors = ['Matt Greensmith', 'Cozy Services Ltd.']
10
+ spec.email = ['matt@mattgreensmith.net', 'opensource@cozy.co']
11
+ spec.summary = 'Adds audit log capability to Pry'
12
+ spec.description = 'PryAuditlog is a plugin for the Pry REPL that enables logging of any combination of Pry input and output to a configured audit file.'
13
+ spec.homepage = 'http://github.com/mgreensmith/pry-auditlog'
14
14
  spec.license = 'MIT'
15
15
  spec.files = `git ls-files -z`.split("\x0")
16
16
  spec.require_paths = ['lib']
17
17
 
18
18
  spec.add_dependency 'pry', '~> 0.10'
19
+
20
+ spec.add_development_dependency 'bundler', '~> 1.6'
21
+ spec.add_development_dependency 'rake'
22
+ spec.add_development_dependency 'rubocop'
19
23
  end
metadata CHANGED
@@ -1,49 +1,96 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pry-auditlog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
- - Cozy Services Ltd.
8
7
  - Matt Greensmith
8
+ - Cozy Services Ltd.
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-07-07 00:00:00.000000000 Z
12
+ date: 2015-06-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pry
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ~>
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
20
  version: '0.10'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ~>
25
+ - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0.10'
28
+ - !ruby/object:Gem::Dependency
29
+ name: bundler
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '1.6'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '1.6'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rake
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rubocop
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
28
70
  description: PryAuditlog is a plugin for the Pry REPL that enables logging of any
29
- combination of Pry input and output to a configured audit log file.
71
+ combination of Pry input and output to a configured audit file.
30
72
  email:
73
+ - matt@mattgreensmith.net
31
74
  - opensource@cozy.co
32
75
  executables: []
33
76
  extensions: []
34
77
  extra_rdoc_files: []
35
78
  files:
36
- - .gitignore
79
+ - ".gitignore"
80
+ - ".rubocop.yml"
81
+ - ".travis.yml"
37
82
  - Gemfile
38
83
  - LICENSE.txt
39
84
  - README.md
85
+ - Rakefile
86
+ - bin/example.rb
40
87
  - lib/ext/pry/repl.rb
41
88
  - lib/pry-auditlog.rb
42
89
  - lib/pry-auditlog/logger.rb
43
90
  - lib/pry-auditlog/output.rb
44
91
  - lib/pry-auditlog/version.rb
45
92
  - pry-auditlog.gemspec
46
- homepage: http://github.com/cozyco/pry-auditlog
93
+ homepage: http://github.com/mgreensmith/pry-auditlog
47
94
  licenses:
48
95
  - MIT
49
96
  metadata: {}
@@ -53,17 +100,17 @@ require_paths:
53
100
  - lib
54
101
  required_ruby_version: !ruby/object:Gem::Requirement
55
102
  requirements:
56
- - - '>='
103
+ - - ">="
57
104
  - !ruby/object:Gem::Version
58
105
  version: '0'
59
106
  required_rubygems_version: !ruby/object:Gem::Requirement
60
107
  requirements:
61
- - - '>='
108
+ - - ">="
62
109
  - !ruby/object:Gem::Version
63
110
  version: '0'
64
111
  requirements: []
65
112
  rubyforge_project:
66
- rubygems_version: 2.0.14
113
+ rubygems_version: 2.4.5
67
114
  signing_key:
68
115
  specification_version: 4
69
116
  summary: Adds audit log capability to Pry