hammock 0.3.6 → 0.3.7

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,8 @@
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
+
1
6
  == 0.3.6 2009-06-04
2
7
  Call initialize_for_load after requiring components, so Hammock::Aliases is defined.
3
8
  Replaced MixInto reference with more appropriate base reference in Hammock::ActiveRecord.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.3.6"
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-04}
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
 
@@ -1,6 +1,5 @@
1
1
  module Hammock
2
2
  module Callbacks
3
- LoadFirst = true
4
3
 
5
4
  def self.included base # :nodoc:
6
5
  base.send :include, InstanceMethods
@@ -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
@@ -1,7 +1,6 @@
1
1
  module Hammock
2
2
  module ModulePatches
3
3
  MixInto = Module
4
- LoadFirst = true
5
4
 
6
5
  def self.included base # :nodoc:
7
6
  base.send :include, InstanceMethods
@@ -1,6 +1,7 @@
1
1
  module Hammock
2
2
  module ResourceMappingHooks
3
3
  MixInto = ActionController::Resources
4
+ Deps = [ModulePatches]
4
5
 
5
6
  def self.included base # :nodoc:
6
7
  base.send :include, Methods
@@ -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
@@ -1,6 +1,7 @@
1
1
  module Hammock
2
2
  module RouteDrawingHooks
3
3
  MixInto = ActionController::Routing::RouteSet
4
+ Deps = [ModulePatches]
4
5
 
5
6
  def self.included base # :nodoc:
6
7
  base.send :include, Methods
data/lib/hammock.rb CHANGED
@@ -4,11 +4,12 @@ require 'ambition'
4
4
  require 'ambition/adapters/active_record'
5
5
 
6
6
  module Hammock
7
- VERSION = '0.3.6'
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
- load_hammock_components base
11
+ puts "Loading Hammock #{Hammock::VERSION} from #{loaded_from_gem? ? 'gem' : 'plugin'}"
12
+ load_hammock_components
12
13
  end
13
14
 
14
15
  def self.loaded_from_gem?
@@ -32,14 +33,9 @@ module Hammock
32
33
 
33
34
  private
34
35
 
35
- def self.initialize_for_load
36
- Hammock::Aliases.alias_lambda
37
- end
38
-
39
- def self.load_hammock_components base
36
+ def self.load_hammock_components
40
37
  require_hammock_components
41
- initialize_for_load
42
- mixin_hammock_components base
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 base
52
- Hammock.constants.map {|constant_name|
53
- Hammock.const_get constant_name
54
- }.select {|constant|
55
- constant.is_a?(Module) && !constant.is_a?(Class)
56
- }.partition {|mod|
57
- mod.constants.include?('LoadFirst') && mod::LoadFirst
58
- }.flatten.each {|mod|
59
- target = mod.constants.include?('MixInto') ? mod::MixInto : base
60
- target.send :include, mod
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
- ActionController::Base.send :include, Hammock if Hammock.loaded_from_gem?
74
+ Hammock::IncludeTarget.send :include, Hammock if Hammock.loaded_from_gem?
data/misc/template.rb CHANGED
@@ -1,8 +1,7 @@
1
1
  module Hammock
2
2
  module Lol
3
3
  MixInto = Lol::Lul
4
- # LoadFirst = false
5
-
4
+
6
5
  def self.included base # :nodoc:
7
6
  base.send :include, InstanceMethods
8
7
  base.send :extend, ClassMethods
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.6
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-04 00:00:00 +10:00
12
+ date: 2009-06-05 00:00:00 +10:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency