hammock 0.2.12 → 0.2.12.1

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.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.2.12.1 2009-04-01
2
+ Changed #log to #dlog for unmatched scope logging and related chatter.
3
+
4
+
1
5
  == 0.2.12 2009-03-31
2
6
  Added loading message.
3
7
  Moved require for hammock components within Hammock.included.
data/hammock.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{hammock}
5
- s.version = "0.2.12"
5
+ s.version = "0.2.12.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Ben Hoskings"]
9
- s.date = %q{2009-03-31}
9
+ s.date = %q{2009-04-01}
10
10
  s.description = %q{Hammock is a Rails plugin that eliminates redundant code in a very RESTful manner. It does this in lots in lots of different places, but in one manner: it encourages specification in place of implementation. Hammock enforces RESTful resource access by abstracting actions away from the controller in favour of a clean, model-like callback system. Hammock tackles the hard and soft sides of security at once with a scoping security system on your models. Specify who can verb what resources under what conditions once, and everything else - the actual security, link generation, index filtering - just happens. Hammock inspects your routes and resources to generate a routing tree for each resource. Parent resources in a nested route are handled transparently at every point - record retrieval, creation, and linking. It makes more sense when you see how it works though, so check out the screencast!}
11
11
  s.email = ["ben@hoskings.net"]
12
12
  s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.rdoc", "misc/scaffold.txt"]
data/lib/hammock/scope.rb CHANGED
@@ -27,13 +27,13 @@ module Hammock
27
27
  raise "The verb at #{call_point} must be supplied as a Symbol." unless verb.nil? || verb.is_a?(Symbol)
28
28
  route = route_for verb, resource
29
29
  if route.safe? && !resource.indexable_by(current_user)
30
- log "#{requester_name} can't index #{resource.name.pluralize}. #{describe_call_point 4}"
30
+ dlog "#{requester_name} can't index #{resource.name.pluralize}. #{describe_call_point 4}"
31
31
  :not_found
32
32
  elsif !route.safe? && !make_createable(resource)
33
- log "#{requester_name} can't #{verb} #{resource.name.pluralize}. #{describe_call_point 4}"
33
+ dlog "#{requester_name} can't #{verb} #{resource.name.pluralize}. #{describe_call_point 4}"
34
34
  :read_only
35
35
  else
36
- # log "#{requester_name} can #{verb} #{resource.name.pluralize}."
36
+ # dlog "#{requester_name} can #{verb} #{resource.name.pluralize}."
37
37
  :ok
38
38
  end
39
39
  end
@@ -43,20 +43,20 @@ module Hammock
43
43
  route = route_for verb, record
44
44
  if route.verb.in?(:save, :create) && record.new_record?
45
45
  if !record.createable_by?(current_user)
46
- log "#{requester_name} can't create a #{record.class} with #{record.attributes.inspect}. #{describe_call_point 4}"
46
+ dlog "#{requester_name} can't create a #{record.class} with #{record.attributes.inspect}. #{describe_call_point 4}"
47
47
  :unauthed
48
48
  else
49
49
  :ok
50
50
  end
51
51
  else
52
52
  if !record.readable_by?(current_user)
53
- log "#{requester_name} can't see #{record.class}<#{record.id}>. #{describe_call_point 4}"
53
+ dlog "#{requester_name} can't see #{record.class}<#{record.id}>. #{describe_call_point 4}"
54
54
  :not_found
55
55
  elsif !route.safe? && !record.writeable_by?(current_user)
56
- log "#{requester_name} can't #{verb} #{record.class}<#{record.id}>. #{describe_call_point 4}"
56
+ dlog "#{requester_name} can't #{verb} #{record.class}<#{record.id}>. #{describe_call_point 4}"
57
57
  :read_only
58
58
  else
59
- # log "#{requester_name} can #{verb} #{record.class}<#{record.id}>."
59
+ # dlog "#{requester_name} can #{verb} #{record.class}<#{record.id}>."
60
60
  :ok
61
61
  end
62
62
  end
@@ -64,13 +64,13 @@ module Hammock
64
64
 
65
65
  def current_verb_scope
66
66
  if current_user && (scope_name = account_verb_scope?)
67
- # log "got an account_verb_scope #{scope_name}."
67
+ # dlog "got an account_verb_scope #{scope_name}."
68
68
  mdl.send scope_name, current_user
69
69
  elsif !(scope_name = public_verb_scope?)
70
70
  log "No #{current_user.nil? ? 'public' : 'account'} #{scope_name_for_action} scope available for #{mdl}.#{' May be available after login.' if account_verb_scope?}"
71
71
  nil
72
72
  else
73
- # log "got a #{scope_name} public_verb_scope."
73
+ # dlog "got a #{scope_name} public_verb_scope."
74
74
  mdl.send scope_name
75
75
  end
76
76
  end
@@ -84,15 +84,15 @@ module Hammock
84
84
  end
85
85
 
86
86
  def current_scope
87
- log "#{current_hammock_resource.mdl}, #{current_hammock_resource.ancestry.map(&:mdl).inspect}"
87
+ dlog "#{current_hammock_resource.mdl}, #{current_hammock_resource.ancestry.map(&:mdl).inspect}"
88
88
  if (verb_scope = current_verb_scope).nil?
89
89
  nil
90
90
  elsif (resultant_scope = verb_scope.within(current_nest_scope, current_hammock_resource.routing_parent)).nil?
91
91
  nil
92
92
  else
93
- # puts "nest: #{current_nest_scope.clauses.inspect}"
94
- # puts "verb: #{current_verb_scope.clauses.inspect}"
95
- puts "chained in (#{resultant_scope.owner}) current_scope: #{resultant_scope.clauses.inspect}"
93
+ # dlog "nest: #{current_nest_scope.clauses.inspect}"
94
+ # dlog "verb: #{current_verb_scope.clauses.inspect}"
95
+ dlog "chained in (#{resultant_scope.owner}) current_scope: #{resultant_scope.clauses.inspect}"
96
96
  resultant_scope = resultant_scope.chain(custom_scope) unless custom_scope.nil?
97
97
  resultant_scope.sort_by &mdl.sorter
98
98
  end
data/lib/hammock.rb CHANGED
@@ -4,7 +4,7 @@ require 'ambition'
4
4
  require 'ambition/adapters/active_record'
5
5
 
6
6
  module Hammock
7
- VERSION = '0.2.12'
7
+ VERSION = '0.2.12.1'
8
8
 
9
9
  def self.included base # :nodoc:
10
10
  puts "Loading Hammock from #{loaded_from_gem? ? 'gem' : 'plugin'}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hammock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.12
4
+ version: 0.2.12.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Hoskings
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-31 00:00:00 +10:00
12
+ date: 2009-04-01 00:00:00 +10:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency