hammock 0.2.14 → 0.2.15
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +7 -0
- data/hammock.gemspec +2 -2
- data/lib/hammock/canned_scopes.rb +5 -1
- data/lib/hammock/constants.rb +1 -0
- data/lib/hammock/monkey_patches/string.rb +9 -0
- data/lib/hammock/restful_support.rb +1 -1
- data/lib/hammock/route_step.rb +2 -2
- data/lib/hammock/scope.rb +2 -2
- data/lib/hammock.rb +1 -1
- metadata +2 -2
data/History.txt
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
== 0.2.15 2009-04-15
|
2
|
+
Switched from #in? to #include? for non-literal args, since it splats into a nested array and breaks.
|
3
|
+
Moved implied verbs from RouteStep#implied_verb? to a constant.
|
4
|
+
partitioned_scope now uses an empty_scope when the resource doesn't match.
|
5
|
+
Added String#/ to wrap File.join beautifully (thanks merb).
|
6
|
+
|
7
|
+
|
1
8
|
== 0.2.14 2009-04-08
|
2
9
|
On escort(:unauthed), redirect to login for public GETs when an authed scope exists.
|
3
10
|
|
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.
|
5
|
+
s.version = "0.2.15"
|
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-04-
|
9
|
+
s.date = %q{2009-04-15}
|
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"]
|
@@ -105,7 +105,11 @@ module Hammock
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def partitioned_scope account
|
108
|
-
|
108
|
+
if account.is_a? self
|
109
|
+
lambda {|record| record.id == account.id }
|
110
|
+
else
|
111
|
+
empty_scope
|
112
|
+
end
|
109
113
|
end
|
110
114
|
|
111
115
|
def empty_scope
|
data/lib/hammock/constants.rb
CHANGED
@@ -47,6 +47,15 @@ module Hammock
|
|
47
47
|
ends_with?(str) ? self : self + str
|
48
48
|
end
|
49
49
|
|
50
|
+
# Return +self+ joined to other using File#join. This allows paths to be constructed
|
51
|
+
# with a nice syntax; for example, the following two expressions are equivalent.
|
52
|
+
#
|
53
|
+
# File.join RAILS_ROOT, 'views', controller_name, 'index.html.haml'
|
54
|
+
# RAILS_ROOT / 'views' / controller_name / 'index.html.haml'
|
55
|
+
def / other
|
56
|
+
File.join self, other
|
57
|
+
end
|
58
|
+
|
50
59
|
def possessive
|
51
60
|
"#{self}'#{'s' unless ends_with?('s')}"
|
52
61
|
end
|
@@ -137,7 +137,7 @@ module Hammock
|
|
137
137
|
end
|
138
138
|
|
139
139
|
def safe_verb_and_implication?
|
140
|
-
request.get? && !
|
140
|
+
request.get? && !Hammock::Constants::ImpliedUnsafeActions.include?(action_name.to_sym)
|
141
141
|
end
|
142
142
|
|
143
143
|
def set_editing
|
data/lib/hammock/route_step.rb
CHANGED
@@ -60,13 +60,13 @@ module Hammock
|
|
60
60
|
def delete?; :delete == http_method end
|
61
61
|
|
62
62
|
def safe?
|
63
|
-
get? && !
|
63
|
+
get? && !Hammock::Constants::ImpliedUnsafeActions.include?(verb)
|
64
64
|
end
|
65
65
|
|
66
66
|
private
|
67
67
|
|
68
68
|
def implied_verb? verb
|
69
|
-
|
69
|
+
Hammock::Constants::ImpliedVerbs.include? verb
|
70
70
|
end
|
71
71
|
|
72
72
|
def raise_unless_setup_while_trying_to task
|
data/lib/hammock/scope.rb
CHANGED
@@ -84,7 +84,7 @@ module Hammock
|
|
84
84
|
end
|
85
85
|
|
86
86
|
def current_scope
|
87
|
-
dlog "#{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?
|
@@ -92,7 +92,7 @@ module Hammock
|
|
92
92
|
else
|
93
93
|
# dlog "nest: #{current_nest_scope.clauses.inspect}"
|
94
94
|
# dlog "verb: #{current_verb_scope.clauses.inspect}"
|
95
|
-
dlog "chained in (#{resultant_scope.owner}) current_scope: #{resultant_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
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.
|
4
|
+
version: 0.2.15
|
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-04-
|
12
|
+
date: 2009-04-15 00:00:00 +10:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|