fine_print 1.1.1 → 1.2.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: 737d9043df423544d60771c30e22ef71811bcb4b
4
- data.tar.gz: 6e54249ed44c5178b6fe8ea17d6518680cf5436b
3
+ metadata.gz: 0ad3cdb6cc83d91c8ad70a79abd35a43159d3f99
4
+ data.tar.gz: 1aa4cc47c9501d5fd816b6d5eddee4d71a4dbd52
5
5
  SHA512:
6
- metadata.gz: 268d93027f2008ebadafed4b5dd735235b3506fa0bb7813af8be63dc727e3178ae25c09c885d92d03b7290bc9298bbb4e62116998db17c0d4df76c0cc1f716ef
7
- data.tar.gz: 3f1c3ccdf8fcdb31522c61cf524c5b979f566ad80d75a0c4d703c4ae3a6889bafc79084613533e256388ad110739a2902f0de34236527ce25b079d22ba5b3d25
6
+ metadata.gz: 52bc3cdc2a6f0250b716f2401171ad06afc52dc6c34b8e0873037b71d60deb757b976d60310cdd95d9bf8c3be462a7fde7edfea24be698c8dc4372304950a2fe
7
+ data.tar.gz: 54bbdde67d20c2795eac3679f43a00af2d3aad288add521ea908da2924a1c7a147b34674fb344171a75d1e761ce9dc7fd292b0efdefe201de805da8f06f62762
@@ -8,7 +8,7 @@ module FinePrint
8
8
  protected
9
9
 
10
10
  def verify_admin
11
- user = send FinePrint.current_user_method
11
+ user = FinePrint.current_user_proc.call(self)
12
12
  FinePrint.raise_unless_admin(user)
13
13
  end
14
14
  end
@@ -1,15 +1,15 @@
1
1
  module FinePrint
2
2
  class ApplicationController < ActionController::Base
3
- before_filter :verify_admin!
3
+ before_filter :verify_admin
4
4
 
5
5
  rescue_from FinePrint::SecurityTransgression,
6
6
  :with => lambda { redirect_to FinePrint.redirect_path }
7
7
 
8
8
  protected
9
9
 
10
- def verify_admin!
11
- user = send FinePrint.current_user_method
12
- FinePrint.raise_unless_admin!(user)
10
+ def verify_admin
11
+ user = send FinePrint.current_user_proc.call(self)
12
+ FinePrint.raise_unless_admin(user)
13
13
  end
14
14
  end
15
15
  end
@@ -3,22 +3,22 @@
3
3
  FinePrint.configure do |config|
4
4
  # Engine Configuration
5
5
 
6
- # Name of the ApplicationController helper method that returns the current user.
7
- # Default: 'current_user'
8
- config.current_user_method = 'current_user'
6
+ # Proc called with controller as argument that returns the current user.
7
+ # Default: lambda { |controller| controller.current_user }
8
+ config.current_user_proc = lambda { |controller| controller.current_user }
9
9
 
10
- # Proc called with user as argument that should return true if and only if the user is an admin.
10
+ # Proc called with user as argument that returns true iif the user is an admin.
11
11
  # Admins can create and edit agreements and terminate accepted agreements.
12
12
  # Default: lambda { |user| false } (no admins)
13
13
  config.user_admin_proc = lambda { |user| false }
14
14
 
15
- # Proc that returns true if and only if the provided user is logged in.
15
+ # Proc called with user as argument that returns true iif the user is logged in.
16
16
  # In many systems, a non-logged-in user is represented by nil.
17
17
  # However, some systems use something like an AnonymousUser class to represent this state.
18
18
  # This proc is mostly used to help the developer realize that they should only be asking
19
19
  # signed in users to sign contracts; without this, developers would get a cryptic SQL error.
20
- # Default: lambda { |user| !user.nil? }
21
- config.user_signed_in_proc = lambda { |user| !user.nil? }
20
+ # Default: lambda { |user| user }
21
+ config.user_signed_in_proc = lambda { |user| user }
22
22
 
23
23
  # Path to redirect users to when an error occurs (e.g. permission denied on admin pages).
24
24
  # Default: '/'
@@ -3,34 +3,34 @@
3
3
  FinePrint.configure do |config|
4
4
  # Engine Configuration
5
5
 
6
- # Name of the ApplicationController helper method that returns the current user
6
+ # Proc called with controller as argument that returns the current user.
7
7
  # Default: 'current_user'
8
- config.current_user_method = 'current_user'
8
+ config.current_user_proc = lambda { |controller| controller.current_user }
9
9
 
10
- # Proc called with user as argument that should return true if and only if the user is an admin
11
- # Admins can create and edit agreements and terminate accepted agreements
10
+ # Proc called with user as argument that returns true iif the user is an admin.
11
+ # Admins can create and edit agreements and terminate accepted agreements.
12
12
  # Default: lambda { |user| false } (no admins)
13
13
  config.user_admin_proc = lambda { |user| false }
14
14
 
15
- # Proc that returns true if and only if the provided user is logged in
16
- # In many systems, a non-logged-in user is represented by nil
17
- # However, some systems use something like an AnonymousUser class to represent this state
15
+ # Proc called with user as argument that returns true iif the user is logged in.
16
+ # In many systems, a non-logged-in user is represented by nil.
17
+ # However, some systems use something like an AnonymousUser class to represent this state.
18
18
  # This proc is mostly used to help the developer realize that they should only be asking
19
- # signed in users to sign contracts; without this, developers would get a cryptic SQL error
20
- # Default: lambda { |user| !user.nil? }
21
- config.user_signed_in_proc = lambda { |user| !user.nil? }
19
+ # signed in users to sign contracts; without this, developers would get a cryptic SQL error.
20
+ # Default: lambda { |user| user }
21
+ config.user_signed_in_proc = lambda { |user| user }
22
22
 
23
- # Path to redirect users to when an error occurs (e.g. permission denied on admin pages)
23
+ # Path to redirect users to when an error occurs (e.g. permission denied on admin pages).
24
24
  # Default: '/'
25
25
  config.redirect_path = '/'
26
26
 
27
27
  # Signature (fine_print_get_signatures) Configuration
28
28
 
29
- # Path to redirect users to when they need to agree to contract(s)
30
- # A list of contract names that must be agreed to will be available in the 'contracts' parameter
29
+ # Path to redirect users to when they need to agree to contract(s).
30
+ # A list of contract names that must be agreed to will be available in the 'contracts' parameter.
31
31
  # Your code doesn't have to deal with all of them at once, e.g. you can get
32
32
  # the user to agree to the first one and then they'll just eventually be
33
- # redirected back to this page with the remaining contract names
33
+ # redirected back to this page with the remaining contract names.
34
34
  # Default: '/'
35
35
  config.pose_contracts_path = '/'
36
36
  end
@@ -35,7 +35,7 @@ module FinePrint
35
35
  # Bail if nothing to do
36
36
  return true if contract_names.blank?
37
37
 
38
- user = send FinePrint.current_user_method
38
+ user = FinePrint.current_user_proc.call(self)
39
39
  FinePrint.raise_unless_signed_in(user)
40
40
 
41
41
  unsigned_contract_names =
@@ -35,7 +35,7 @@ module FinePrint
35
35
  # Bail if nothing to do
36
36
  return true if contract_names.blank?
37
37
 
38
- user = send FinePrint.current_user_method
38
+ user = send FinePrint.current_user_proc.call(self)
39
39
  FinePrint.raise_unless_signed_in(user)
40
40
 
41
41
  unsigned_contract_names =
@@ -54,6 +54,8 @@ module FinePrint
54
54
  # See the README
55
55
  def fine_print_skip_signatures(*args)
56
56
  options = args.last.is_a?(Hash) ? args.pop : {}
57
+
58
+ # Convert all names to string
57
59
  names = args.flatten.collect{|n| n.to_s}
58
60
 
59
61
  class_eval do
@@ -1,3 +1,3 @@
1
1
  module FinePrint
2
- VERSION = '1.1.1'
2
+ VERSION = '1.2.0'
3
3
  end
@@ -1,3 +1,3 @@
1
1
  module FinePrint
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1'
3
3
  end
data/lib/fine_print.rb CHANGED
@@ -7,7 +7,7 @@ module FinePrint
7
7
 
8
8
  # Can be set in initializer only
9
9
  ENGINE_OPTIONS = [
10
- :current_user_method,
10
+ :current_user_proc,
11
11
  :user_admin_proc,
12
12
  :user_signed_in_proc,
13
13
  :pose_contracts_path,
data/lib/fine_print.rb~ CHANGED
@@ -38,7 +38,7 @@ module FinePrint
38
38
  ref
39
39
  when Integer
40
40
  Contract.find(ref)
41
- when String
41
+ when String, Symbol
42
42
  Contract.where(:name => ref.to_s).published.first
43
43
  end
44
44
  end
@@ -3,22 +3,22 @@
3
3
  FinePrint.configure do |config|
4
4
  # Engine Configuration
5
5
 
6
- # Name of the ApplicationController helper method that returns the current user.
7
- # Default: 'current_user'
8
- config.current_user_method = 'current_user'
6
+ # Proc called with controller as argument that returns the current user.
7
+ # Default: lambda { |controller| controller.current_user }
8
+ config.current_user_proc = lambda { |controller| controller.current_user }
9
9
 
10
- # Proc called with user as argument that should return true if and only if the user is an admin.
10
+ # Proc called with user as argument that returns true iif the user is an admin.
11
11
  # Admins can create and edit agreements and terminate accepted agreements.
12
12
  # Default: lambda { |user| false } (no admins)
13
13
  config.user_admin_proc = lambda { |user| user.is_admin }
14
14
 
15
- # Proc that returns true if and only if the provided user is logged in.
15
+ # Proc called with user as argument that returns true iif the user is logged in.
16
16
  # In many systems, a non-logged-in user is represented by nil.
17
17
  # However, some systems use something like an AnonymousUser class to represent this state.
18
18
  # This proc is mostly used to help the developer realize that they should only be asking
19
19
  # signed in users to sign contracts; without this, developers would get a cryptic SQL error.
20
- # Default: lambda { |user| !user.nil? }
21
- config.user_signed_in_proc = lambda { |user| !user.nil? }
20
+ # Default: lambda { |user| user }
21
+ config.user_signed_in_proc = lambda { |user| user }
22
22
 
23
23
  # Path to redirect users to when an error occurs (e.g. permission denied on admin pages).
24
24
  # Default: '/'
@@ -10,7 +10,7 @@ FinePrint.configure do |config|
10
10
  # Proc called with user as argument that should return true if and only if the user is an admin.
11
11
  # Admins can create and edit agreements and terminate accepted agreements.
12
12
  # Default: lambda { |user| false } (no admins)
13
- config.user_admin_proc = lambda { |user| false }
13
+ config.user_admin_proc = lambda { |user| user.is_admin }
14
14
 
15
15
  # Proc that returns true if and only if the provided user is logged in.
16
16
  # In many systems, a non-logged-in user is represented by nil.
Binary file
@@ -1771,3 +1771,17 @@ Connecting to database specified by database.yml
1771
1771
   (4.2ms) CREATE INDEX "index_fine_print_signatures_on_contract_id" ON "fine_print_signatures" ("contract_id")
1772
1772
   (4.2ms) CREATE UNIQUE INDEX "index_fine_print_s_on_u_id_and_u_type_and_c_id" ON "fine_print_signatures" ("user_id", "user_type", "contract_id")
1773
1773
   (0.1ms) SELECT version FROM "schema_migrations"
1774
+ Connecting to database specified by database.yml
1775
+ Connecting to database specified by database.yml
1776
+  (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
1777
+  (0.1ms) select sqlite_version(*)
1778
+  (13.4ms) DROP TABLE "dummy_users"
1779
+  (5.7ms) CREATE TABLE "dummy_users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "is_admin" boolean DEFAULT 'f' NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
1780
+  (4.6ms) DROP TABLE "fine_print_contracts"
1781
+  (4.4ms) CREATE TABLE "fine_print_contracts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255) NOT NULL, "version" integer, "title" varchar(255) NOT NULL, "content" text NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
1782
+  (4.3ms) CREATE UNIQUE INDEX "index_fine_print_contracts_on_name_and_version" ON "fine_print_contracts" ("name", "version")
1783
+  (4.5ms) DROP TABLE "fine_print_signatures"
1784
+  (4.5ms) CREATE TABLE "fine_print_signatures" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "contract_id" integer NOT NULL, "user_id" integer NOT NULL, "user_type" varchar(255) NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
1785
+  (4.4ms) CREATE INDEX "index_fine_print_signatures_on_contract_id" ON "fine_print_signatures" ("contract_id")
1786
+  (3.8ms) CREATE UNIQUE INDEX "index_fine_print_s_on_u_id_and_u_type_and_c_id" ON "fine_print_signatures" ("user_id", "user_type", "contract_id")
1787
+  (0.1ms) SELECT version FROM "schema_migrations"