benhoskings-hammock 0.3.5 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +11 -0
- data/hammock.gemspec +3 -4
- data/lib/hammock.rb +29 -22
- data/lib/hammock/callbacks.rb +0 -1
- data/lib/hammock/constants.rb +2 -2
- data/lib/hammock/monkey_patches/active_record.rb +1 -1
- data/lib/hammock/monkey_patches/module.rb +0 -1
- data/lib/hammock/resource_mapping_hooks.rb +1 -0
- data/lib/hammock/restful_support.rb +3 -1
- data/lib/hammock/route_drawing_hooks.rb +1 -0
- data/misc/template.rb +1 -2
- metadata +3 -3
data/History.txt
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
== 0.3.7 2009-06-05
|
2
|
+
Rewrote hammock loading code to use nestable dependencies instead of the LoadFirst constant.
|
3
|
+
Replaced Hammock::Aliases with the Hammock:LambdaAlias component.
|
4
|
+
|
5
|
+
|
6
|
+
== 0.3.6 2009-06-04
|
7
|
+
Call initialize_for_load after requiring components, so Hammock::Aliases is defined.
|
8
|
+
Replaced MixInto reference with more appropriate base reference in Hammock::ActiveRecord.included.
|
9
|
+
Added exception message to model const_get error message.
|
10
|
+
|
11
|
+
|
1
12
|
== 0.3.5 2009-06-03
|
2
13
|
Converted README back to rdoc, for rubyforge rake tasks.
|
3
14
|
|
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.7"
|
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-06-
|
9
|
+
s.date = %q{2009-06-05}
|
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
|
|
@@ -20,12 +20,11 @@ It makes more sense when you see how it works though. There's a screencast comin
|
|
20
20
|
s.email = ["ben@hoskings.net"]
|
21
21
|
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.rdoc", "misc/scaffold.txt"]
|
22
22
|
s.files = ["History.txt", "LICENSE", "Manifest.txt", "README.rdoc", "Rakefile", "hammock.gemspec", "lib/hammock.rb", "lib/hammock/ajaxinate.rb", "lib/hammock/callback.rb", "lib/hammock/callbacks.rb", "lib/hammock/canned_scopes.rb", "lib/hammock/constants.rb", "lib/hammock/controller_attributes.rb", "lib/hammock/export_scope.rb", "lib/hammock/hamlink_to.rb", "lib/hammock/javascript_buffer.rb", "lib/hammock/logging.rb", "lib/hammock/model_attributes.rb", "lib/hammock/model_logging.rb", "lib/hammock/monkey_patches/action_pack.rb", "lib/hammock/monkey_patches/active_record.rb", "lib/hammock/monkey_patches/array.rb", "lib/hammock/monkey_patches/hash.rb", "lib/hammock/monkey_patches/logger.rb", "lib/hammock/monkey_patches/module.rb", "lib/hammock/monkey_patches/numeric.rb", "lib/hammock/monkey_patches/object.rb", "lib/hammock/monkey_patches/route_set.rb", "lib/hammock/monkey_patches/string.rb", "lib/hammock/overrides.rb", "lib/hammock/resource_mapping_hooks.rb", "lib/hammock/resource_retrieval.rb", "lib/hammock/restful_actions.rb", "lib/hammock/restful_rendering.rb", "lib/hammock/restful_support.rb", "lib/hammock/route_drawing_hooks.rb", "lib/hammock/route_for.rb", "lib/hammock/route_node.rb", "lib/hammock/route_step.rb", "lib/hammock/scope.rb", "lib/hammock/suggest.rb", "lib/hammock/utils.rb", "misc/scaffold.txt", "misc/template.rb", "tasks/hammock_tasks.rake", "test/hammock_test.rb"]
|
23
|
-
s.has_rdoc = true
|
24
23
|
s.homepage = %q{http://github.com/benhoskings/hammock}
|
25
24
|
s.rdoc_options = ["--main", "README.rdoc"]
|
26
25
|
s.require_paths = ["lib"]
|
27
26
|
s.rubyforge_project = %q{hammock}
|
28
|
-
s.rubygems_version = %q{1.3.
|
27
|
+
s.rubygems_version = %q{1.3.4}
|
29
28
|
s.summary = %q{Hammock is a Rails plugin that eliminates redundant code in a very RESTful manner}
|
30
29
|
|
31
30
|
if s.respond_to? :specification_version then
|
data/lib/hammock.rb
CHANGED
@@ -4,12 +4,12 @@ require 'ambition'
|
|
4
4
|
require 'ambition/adapters/active_record'
|
5
5
|
|
6
6
|
module Hammock
|
7
|
-
VERSION = '0.3.
|
7
|
+
VERSION = '0.3.7'
|
8
|
+
IncludeTarget = ActionController::Base
|
8
9
|
|
9
10
|
def self.included base # :nodoc:
|
10
|
-
puts "Loading Hammock from #{loaded_from_gem? ? 'gem' : 'plugin'}"
|
11
|
-
|
12
|
-
load_hammock_components base
|
11
|
+
puts "Loading Hammock #{Hammock::VERSION} from #{loaded_from_gem? ? 'gem' : 'plugin'}"
|
12
|
+
load_hammock_components
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.loaded_from_gem?
|
@@ -33,13 +33,9 @@ module Hammock
|
|
33
33
|
|
34
34
|
private
|
35
35
|
|
36
|
-
def self.
|
37
|
-
Hammock::Aliases.alias_lambda
|
38
|
-
end
|
39
|
-
|
40
|
-
def self.load_hammock_components base
|
36
|
+
def self.load_hammock_components
|
41
37
|
require_hammock_components
|
42
|
-
mixin_hammock_components
|
38
|
+
mixin_hammock_components
|
43
39
|
end
|
44
40
|
|
45
41
|
def self.require_hammock_components
|
@@ -48,20 +44,31 @@ module Hammock
|
|
48
44
|
}
|
49
45
|
end
|
50
46
|
|
51
|
-
def self.mixin_hammock_components
|
52
|
-
Hammock.constants.
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
47
|
+
def self.mixin_hammock_components
|
48
|
+
Hammock.constants.each &method(:mixin_hammock_component)
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.mixin_hammock_component mod
|
52
|
+
(get_constant_from(mod, :Deps) || []).each &method(:mixin_hammock_component)
|
53
|
+
do_module_mixin module_for mod
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.do_module_mixin mod
|
57
|
+
(get_constant_from(mod, :MixInto) || IncludeTarget).send :include, mod unless mod.nil?
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.module_for obj
|
61
|
+
const = obj.is_a?(Module) ? obj : const_get(obj)
|
62
|
+
const if const.is_a?(Module) && !const.is_a?(Class)
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.get_constant_from module_name, constant_name
|
66
|
+
unless (mod = module_for module_name).nil?
|
67
|
+
mod.const_get constant_name.to_s if mod.constants.include?(constant_name.to_s)
|
68
|
+
end
|
62
69
|
end
|
63
70
|
|
64
71
|
end
|
65
72
|
|
66
73
|
# This is done in init.rb when Hammock is loaded as a plugin.
|
67
|
-
|
74
|
+
Hammock::IncludeTarget.send :include, Hammock if Hammock.loaded_from_gem?
|
data/lib/hammock/callbacks.rb
CHANGED
data/lib/hammock/constants.rb
CHANGED
@@ -2,9 +2,9 @@ module Hammock
|
|
2
2
|
PleaseFileABug = "Ack, that shouldn't have happened. Please email the full stacktrace to <ben@hoskings.net>, so the problem you uncovered can be addressed. Thanks!"
|
3
3
|
|
4
4
|
module Constants
|
5
|
-
|
5
|
+
|
6
6
|
ImpliedVerbs = [:index, :create, :show, :update, :destroy]
|
7
7
|
ImpliedUnsafeActions = [:new, :edit, :destroy]
|
8
|
-
|
8
|
+
|
9
9
|
end
|
10
10
|
end
|
@@ -7,7 +7,7 @@ module Hammock
|
|
7
7
|
base.send :extend, ClassMethods # TODO maybe include in the metaclass instead of extending the class?
|
8
8
|
|
9
9
|
%w[before_undestroy after_undestroy].each {|callback_name|
|
10
|
-
|
10
|
+
base.define_callbacks callback_name
|
11
11
|
# base.send :define_method, callback_name, lambda { }
|
12
12
|
}
|
13
13
|
base.class_eval {
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Hammock
|
2
2
|
module RestfulSupport
|
3
|
+
Deps = [Callbacks]
|
4
|
+
|
3
5
|
def self.included base # :nodoc:
|
4
6
|
base.send :include, InstanceMethods
|
5
7
|
base.send :extend, ClassMethods
|
@@ -19,7 +21,7 @@ module Hammock
|
|
19
21
|
def mdl
|
20
22
|
@hammock_cached_mdl ||= Object.const_get to_s.sub('Controller', '').classify
|
21
23
|
rescue
|
22
|
-
log "
|
24
|
+
log "Error loading '#{to_s.sub('Controller', '').classify}': #{$!}."
|
23
25
|
nil
|
24
26
|
end
|
25
27
|
# The lowercase name of the model this controller operates on. For example, for +GelatinousBlobsController+, this will return "gelatinous_blob".
|
data/misc/template.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: benhoskings-hammock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.7
|
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-06-
|
12
|
+
date: 2009-06-05 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -111,7 +111,7 @@ files:
|
|
111
111
|
- misc/template.rb
|
112
112
|
- tasks/hammock_tasks.rake
|
113
113
|
- test/hammock_test.rb
|
114
|
-
has_rdoc:
|
114
|
+
has_rdoc: false
|
115
115
|
homepage: http://github.com/benhoskings/hammock
|
116
116
|
post_install_message:
|
117
117
|
rdoc_options:
|