hammock 0.3.10.4 → 0.3.11
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 +8 -0
- data/hammock.gemspec +3 -3
- data/lib/hammock/callbacks.rb +11 -9
- data/lib/hammock/logging.rb +1 -1
- data/lib/hammock/monkey_patches/string.rb +5 -1
- data/lib/hammock/restful_actions.rb +4 -1
- data/lib/hammock/route_node.rb +0 -8
- data/lib/hammock.rb +1 -1
- metadata +3 -3
data/History.txt
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
== 0.3.11 2009-08-19
|
|
2
|
+
Removed some old debug logging.
|
|
3
|
+
Added String#quote_for_shell.
|
|
4
|
+
Added &=' to the name-part of the String#valid_email? regex.
|
|
5
|
+
Added after[_failed]_find_on_create callback definitions, and calls within #find_record_on_create.
|
|
6
|
+
Renamed Account to User in log message.
|
|
7
|
+
|
|
8
|
+
|
|
1
9
|
== 0.3.10.4 2009-07-29
|
|
2
10
|
Temporary fix: re-fetch records in find_record_on_create to avoid readonly errors.
|
|
3
11
|
|
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.3.
|
|
5
|
+
s.version = "0.3.11"
|
|
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-
|
|
9
|
+
s.date = %q{2009-08-19}
|
|
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.
|
|
11
11
|
|
|
12
12
|
|
|
@@ -24,7 +24,7 @@ It makes more sense when you see how it works though. There's a screencast comin
|
|
|
24
24
|
s.rdoc_options = ["--main", "README.rdoc"]
|
|
25
25
|
s.require_paths = ["lib"]
|
|
26
26
|
s.rubyforge_project = %q{hammock}
|
|
27
|
-
s.rubygems_version = %q{1.3.
|
|
27
|
+
s.rubygems_version = %q{1.3.5}
|
|
28
28
|
s.summary = %q{Hammock is a Rails plugin that eliminates redundant code in a very RESTful manner}
|
|
29
29
|
|
|
30
30
|
if s.respond_to? :specification_version then
|
data/lib/hammock/callbacks.rb
CHANGED
|
@@ -9,18 +9,20 @@ module Hammock
|
|
|
9
9
|
include ActiveSupport::Callbacks
|
|
10
10
|
|
|
11
11
|
define_hammock_callbacks *%w[
|
|
12
|
-
before_find
|
|
12
|
+
before_find during_find after_failed_find
|
|
13
|
+
after_find_on_create
|
|
14
|
+
after_failed_find_on_create
|
|
13
15
|
|
|
14
|
-
before_index
|
|
15
|
-
before_modify
|
|
16
|
+
before_index before_show
|
|
17
|
+
before_modify before_new before_edit
|
|
16
18
|
|
|
17
|
-
before_save
|
|
18
|
-
before_create
|
|
19
|
-
before_update
|
|
20
|
-
before_destroy
|
|
21
|
-
before_undestroy
|
|
19
|
+
before_save after_save after_failed_save
|
|
20
|
+
before_create after_create after_failed_create
|
|
21
|
+
before_update after_update after_failed_update
|
|
22
|
+
before_destroy after_destroy
|
|
23
|
+
before_undestroy after_undestroy
|
|
22
24
|
|
|
23
|
-
before_suggest
|
|
25
|
+
before_suggest after_suggest
|
|
24
26
|
]
|
|
25
27
|
}
|
|
26
28
|
end
|
data/lib/hammock/logging.rb
CHANGED
|
@@ -18,7 +18,7 @@ module Hammock
|
|
|
18
18
|
request.remote_ip.colorize('green'),
|
|
19
19
|
(@current_site.subdomain unless @current_site.nil?),
|
|
20
20
|
(request.session_options[:id].nil? ? 'nil' : ('...' + request.session_options[:id][-8, 8])),
|
|
21
|
-
(current_user.nil? ? "unauthed" : "
|
|
21
|
+
(current_user.nil? ? "unauthed" : "User<#{current_user.id}> #{current_user.name}").colorize('green'),
|
|
22
22
|
response.status,
|
|
23
23
|
log_hit_request_info,
|
|
24
24
|
log_hit_route_info
|
|
@@ -60,6 +60,10 @@ module Hammock
|
|
|
60
60
|
"#{self}'#{'s' unless ends_with?('s')}"
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
+
def quote_for_shell
|
|
64
|
+
%Q{"#{gsub('"', '\"')}"}
|
|
65
|
+
end
|
|
66
|
+
|
|
63
67
|
# TODO any more to add?
|
|
64
68
|
NamePrefixes = %w[de den la von].freeze
|
|
65
69
|
|
|
@@ -133,7 +137,7 @@ module Hammock
|
|
|
133
137
|
|
|
134
138
|
# Returns true if the string represents a valid email address.
|
|
135
139
|
def valid_email?
|
|
136
|
-
/^([a-z0-9
|
|
140
|
+
/^([a-z0-9\-\+\=\&\'\_\.]{2,})\@([a-z0-9\-]+\.)*([a-z0-9\-]{2,}\.)([a-z0-9\-]{2,})$/ =~ self
|
|
137
141
|
end
|
|
138
142
|
|
|
139
143
|
def clean_email!
|
|
@@ -131,8 +131,11 @@ module Hammock
|
|
|
131
131
|
if findable_on_create?
|
|
132
132
|
if record = mdl.ambition_context.within(current_nest_scope).find(:first, :conditions => params_for(mdl.symbolize))
|
|
133
133
|
log "Suitable #{record.class}<#{record.id}> already exists."
|
|
134
|
-
assign_entity mdl.resource.find record.id
|
|
134
|
+
returning assign_entity mdl.resource.find record.id do
|
|
135
|
+
callback :after_find_on_create
|
|
136
|
+
end
|
|
135
137
|
else
|
|
138
|
+
callback :after_failed_find_on_create
|
|
136
139
|
log "Couldn't find a suitable #{mdl}, proceeding with creation."
|
|
137
140
|
end
|
|
138
141
|
end
|
data/lib/hammock/route_node.rb
CHANGED
|
@@ -92,9 +92,7 @@ module Hammock
|
|
|
92
92
|
|
|
93
93
|
def nesting_scope_segment_for params
|
|
94
94
|
raise "The root of the route map isn't associated with a resource." if root?
|
|
95
|
-
puts "is this undefined? #{resource.accessible_attributes_on_create.inspect}"
|
|
96
95
|
value = params.delete resource.param_key
|
|
97
|
-
puts "resource.select {|r| r.#{resource.routing_attribute} == value }"
|
|
98
96
|
eval "resource.select {|r| r.#{resource.routing_attribute} == value }"
|
|
99
97
|
end
|
|
100
98
|
|
|
@@ -103,7 +101,6 @@ module Hammock
|
|
|
103
101
|
end
|
|
104
102
|
|
|
105
103
|
def add entity, options, path_steps = nil
|
|
106
|
-
# puts "add(#{entity.inspect}, #{options.inspect}, #{path_steps.inspect})"
|
|
107
104
|
if path_steps.nil?
|
|
108
105
|
path_steps = (options[:path_prefix] || '').split('/').squash.discard {|i| i.starts_with? ':' }.map(&:to_sym)
|
|
109
106
|
add entity, options, path_steps
|
|
@@ -134,19 +131,14 @@ module Hammock
|
|
|
134
131
|
end
|
|
135
132
|
|
|
136
133
|
def determine_routing_parent
|
|
137
|
-
# puts "\ndetermine_routing_parent: #{mdl}:"
|
|
138
134
|
if parent.nil? || parent.resource.nil?
|
|
139
135
|
# puts "Resource for #{mdl} has either no parent or no resource - not nestable."
|
|
140
136
|
nil
|
|
141
137
|
else
|
|
142
|
-
# puts "reflections: #{resource.reflections.keys.inspect}"
|
|
143
138
|
scannable_reflections = resource.nestable_reflections
|
|
144
|
-
# puts "scannable reflections: #{scannable_reflections.keys.inspect}"
|
|
145
139
|
valid_reflections = scannable_reflections.selekt {|k,v|
|
|
146
|
-
# puts "#{v.klass}<#{v.object_id}> == #{parent.resource}<#{parent.resource.object_id}> #=> #{v.klass == parent.resource}"
|
|
147
140
|
v.klass == parent.resource
|
|
148
141
|
}
|
|
149
|
-
# puts "valid reflections: #{valid_reflections.keys.inspect}"
|
|
150
142
|
|
|
151
143
|
if valid_reflections.keys.length < 1
|
|
152
144
|
raise "The routing table specifies that #{mdl} is nested within #{parent.mdl}, but there is no ActiveRecord association linking #{resource} to #{parent.resource}. Example: 'belongs_to :#{parent.resource.base_model}' in the #{resource} model."
|
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.3.
|
|
4
|
+
version: 0.3.11
|
|
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-
|
|
12
|
+
date: 2009-08-19 00:00:00 +10:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
@@ -139,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
139
139
|
requirements: []
|
|
140
140
|
|
|
141
141
|
rubyforge_project: hammock
|
|
142
|
-
rubygems_version: 1.3.
|
|
142
|
+
rubygems_version: 1.3.5
|
|
143
143
|
signing_key:
|
|
144
144
|
specification_version: 3
|
|
145
145
|
summary: Hammock is a Rails plugin that eliminates redundant code in a very RESTful manner
|