paper_trail-rails 0.3.0 → 0.4.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
  SHA256:
3
- metadata.gz: c131d41ac82f9058ed9bfbf6bbb0ec4c41d81bb0831213354a8a489d13ab02fa
4
- data.tar.gz: ad5bc11f3012ff9155c6891a4cdd5b55a424c505aaa6872f38a4a9bae2a0e776
3
+ metadata.gz: 46c7ec10c6ff25dde513b4bbc0201aa897d8d6dab53eb68403704c687ba67050
4
+ data.tar.gz: 75825da982f15ad55fec3e28bd233d2553f4b80f70c5ec37e5f2ce64d0730bd2
5
5
  SHA512:
6
- metadata.gz: ecf6879903c63aeca60556f75877f4bf709022a7953975610c732bb13819e4f0939e19f3c220b8aad562c1d6516c900b90b12b71666a4284d7b4dfc32c9c5309
7
- data.tar.gz: d8956bd5abfe35a712cfec8f24df52319e1d3cbbb9a06162eab2582c4dcba0f05f2f422a9d7b7d4c8ddf62e09103c08111a046ff83f11f0ddf3a249ef0ab7336
6
+ metadata.gz: e2e4b492d8a3015449bedfe712c97a66d30fa3157a4b62a45d6e65d91c89044adc5ad384b8fe3258ad1ca9a8b306f764c8ffac9fd327ff5bca9d794b8a7b4235
7
+ data.tar.gz: d5878b0446630d09ade880658c9b8a4cedfca0c79c3af55d420d989a852f6f8acd5f28b8dca313aae79d433d040113a05e2e4e4648c9bdc77172fa281d212864
@@ -1,3 +1,10 @@
1
+ ## 0.4.0 (2020-04-23)
2
+ - Allow user to be selected by index in addition to id
3
+ - Add config.select_user_inspect
4
+ - Fix: Remove .default_order which may not be defined. Included as config example instead.
5
+ - Fix: Replace respond.id with respond_to?(:id)
6
+ - Fix: Should use require_user rather than require_reason
7
+
1
8
  ## 0.3.0 (2019-09-16)
2
9
  - Fix: When running db:migrate:redo, command got recorded as "rails db:migrate:redo VERSION=2019…"
3
10
  instead of as "rails db:migrate: MigrationName (up)" as intended.
data/Readme.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # PaperTrail::Rails
2
2
 
3
3
  [![Gem Version][1]][2]
4
+ [![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](https://rdoc.info/github/TylerRick/paper_trail-rails/master)
4
5
 
5
6
  An extension to [PaperTrail](https://github.com/paper-trail-gem/paper_trail)
6
7
  that adds some useful automatic integrations with Rails:
@@ -4,18 +4,22 @@ module PaperTrail
4
4
  def initialize
5
5
  config = self
6
6
 
7
+ #config.user_model = User
7
8
  config.select_user_filter = :itself
9
+ config.select_user_inspect = :inspect
8
10
  config.select_user_other_allowed_values = ['system', 'admin']
9
11
  config.source_location_filter = ->(line) { !line.match /paper_trail/ }
10
12
  end
11
13
 
12
14
  # Filter proc to use to show a list of users in select_user helper. For example:
13
- # ->(users) { users.admins) }
15
+ # ->(users) { users.admins.default_order }
14
16
  # or
15
- # ->(users) { users.none) }
17
+ # ->(users) { users.none }
16
18
  # Can be also be a symbol or anything that responds to to_proc.
17
19
  attr_accessor :select_user_filter
18
20
 
21
+ attr_accessor :select_user_inspect
22
+
19
23
  attr_accessor :select_user_other_allowed_values
20
24
 
21
25
  attr_accessor :source_location_filter
@@ -73,10 +73,10 @@ module PaperTrail
73
73
  user = config.console.user_for_test.(User.all)
74
74
  else
75
75
  puts "Before you make any changes... We need to know who is making the changes, to store in the PaperTrail version history."
76
- user = PaperTrail::Rails.select_user(required: config.console.require_reason)
76
+ user = PaperTrail::Rails.select_user(required: config.console.require_user)
77
77
  puts "Thank you, #{user}! Have a wonderful time!" if user
78
78
  end
79
- user.respond.id
79
+ user.respond_to?(:id) ? user.id : user
80
80
  end
81
81
  )
82
82
 
@@ -4,11 +4,15 @@ module PaperTrail
4
4
  module Rails
5
5
  module General
6
6
  class << self
7
- def select_user(filter: :itself, other_allowed_values: [], prompt: 'Please enter a User id', required: true)
7
+ def select_user(filter: :itself, other_allowed_values: [], prompt: '"Please enter the index of one of the users above, or a valid User id', required: true)
8
+ config = PaperTrail::Rails.config
9
+
10
+ user_options = nil
8
11
  User.logger.silence do
9
- puts 'id. user'
10
- filter.to_proc.(User.all).default_order.each do |user|
11
- puts "%4s. %s" % [user.id, user.inspect]
12
+ puts 'index. user'
13
+ user_options = filter.to_proc.(User.all)
14
+ user_options.each.with_index do |user, i|
15
+ puts "%2s. %s" % [i + 1, user.inspect]
12
16
  end
13
17
  end
14
18
 
@@ -20,7 +24,11 @@ module PaperTrail
20
24
  when *other_allowed_values
21
25
  user = input
22
26
  else
23
- user = User.find(input) rescue nil
27
+ if (i = Integer(input) rescue nil)
28
+ user = user_options[i - 1] || (User.find(input) rescue nil)
29
+ else # allow for non-numeric ids like uuids
30
+ user = User.find(input) rescue nil
31
+ end
24
32
  end
25
33
  break unless required
26
34
  end
@@ -1,7 +1,7 @@
1
1
  module PaperTrail
2
2
  module Rails
3
3
  def self.version
4
- "0.3.0"
4
+ "0.4.0"
5
5
  end
6
6
  end
7
7
  end
@@ -30,6 +30,6 @@ Gem::Specification.new do |spec|
30
30
  spec.add_dependency "rails"
31
31
 
32
32
  spec.add_development_dependency "bundler", "~> 2.0"
33
- spec.add_development_dependency "rake", "~> 10.0"
33
+ spec.add_development_dependency 'rake', '>= 12.3.3'
34
34
  spec.add_development_dependency "rspec", "~> 3.0"
35
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paper_trail-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Rick
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-16 00:00:00.000000000 Z
11
+ date: 2020-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: paper_trail
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '10.0'
61
+ version: 12.3.3
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '10.0'
68
+ version: 12.3.3
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement