hammock 0.2.11.2

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.
Files changed (47) hide show
  1. data/History.txt +67 -0
  2. data/LICENSE +24 -0
  3. data/Manifest.txt +46 -0
  4. data/README.rdoc +105 -0
  5. data/Rakefile +29 -0
  6. data/hammock.gemspec +43 -0
  7. data/lib/hammock/ajaxinate.rb +154 -0
  8. data/lib/hammock/callback.rb +16 -0
  9. data/lib/hammock/callbacks.rb +94 -0
  10. data/lib/hammock/canned_scopes.rb +125 -0
  11. data/lib/hammock/constants.rb +9 -0
  12. data/lib/hammock/controller_attributes.rb +52 -0
  13. data/lib/hammock/export_scope.rb +74 -0
  14. data/lib/hammock/hamlink_to.rb +47 -0
  15. data/lib/hammock/javascript_buffer.rb +63 -0
  16. data/lib/hammock/logging.rb +98 -0
  17. data/lib/hammock/model_attributes.rb +53 -0
  18. data/lib/hammock/model_logging.rb +30 -0
  19. data/lib/hammock/monkey_patches/action_pack.rb +32 -0
  20. data/lib/hammock/monkey_patches/active_record.rb +231 -0
  21. data/lib/hammock/monkey_patches/array.rb +73 -0
  22. data/lib/hammock/monkey_patches/hash.rb +57 -0
  23. data/lib/hammock/monkey_patches/logger.rb +28 -0
  24. data/lib/hammock/monkey_patches/module.rb +27 -0
  25. data/lib/hammock/monkey_patches/numeric.rb +25 -0
  26. data/lib/hammock/monkey_patches/object.rb +61 -0
  27. data/lib/hammock/monkey_patches/route_set.rb +28 -0
  28. data/lib/hammock/monkey_patches/string.rb +197 -0
  29. data/lib/hammock/overrides.rb +36 -0
  30. data/lib/hammock/resource_mapping_hooks.rb +28 -0
  31. data/lib/hammock/resource_retrieval.rb +119 -0
  32. data/lib/hammock/restful_actions.rb +172 -0
  33. data/lib/hammock/restful_rendering.rb +114 -0
  34. data/lib/hammock/restful_support.rb +186 -0
  35. data/lib/hammock/route_drawing_hooks.rb +22 -0
  36. data/lib/hammock/route_for.rb +59 -0
  37. data/lib/hammock/route_node.rb +159 -0
  38. data/lib/hammock/route_step.rb +87 -0
  39. data/lib/hammock/scope.rb +127 -0
  40. data/lib/hammock/suggest.rb +36 -0
  41. data/lib/hammock/utils.rb +42 -0
  42. data/lib/hammock.rb +29 -0
  43. data/misc/scaffold.txt +83 -0
  44. data/misc/template.rb +17 -0
  45. data/tasks/hammock_tasks.rake +5 -0
  46. data/test/hammock_test.rb +8 -0
  47. metadata +142 -0
@@ -0,0 +1,42 @@
1
+ module Hammock
2
+ module Utils
3
+ def self.included base # :nodoc:
4
+ base.send :include, Methods
5
+ base.send :extend, Methods
6
+ end
7
+
8
+ module Methods
9
+ private
10
+
11
+ require 'pathname'
12
+ def rails_root
13
+ @hammock_cached_rails_root ||= Pathname(RAILS_ROOT).realpath.to_s
14
+ end
15
+
16
+ def rails_env
17
+ ENV['RAILS_ENV'] || 'development'
18
+ end
19
+
20
+ def development?
21
+ 'development' == rails_env
22
+ end
23
+
24
+ def production?
25
+ 'production' == rails_env
26
+ end
27
+
28
+ def sqlite?
29
+ 'SQLite' == connection.adapter_name
30
+ end
31
+
32
+ def describe_call_point offset = 0
33
+ "(called from #{call_point offset + 1})"
34
+ end
35
+
36
+ def call_point offset = 0
37
+ caller[offset + 1].strip.gsub(rails_root, '').gsub(/\:in\ .*$/, '')
38
+ end
39
+
40
+ end
41
+ end
42
+ end
data/lib/hammock.rb ADDED
@@ -0,0 +1,29 @@
1
+ gem 'benhoskings-ambition'
2
+ gem 'benhoskings-ambitious-activerecord'
3
+ require 'ambition'
4
+ require 'ambition/adapters/active_record'
5
+
6
+ Dir.glob("#{File.dirname __FILE__}/hammock/**/*.rb").each {|dep|
7
+ require dep
8
+ } if defined?(RAILS_ROOT) # Loading Hammock components under 'rake package' fails.
9
+
10
+ module Hammock
11
+ VERSION = '0.2.11.2'
12
+
13
+ def self.included base # :nodoc:
14
+ Hammock.constants.map {|constant_name|
15
+ Hammock.const_get constant_name
16
+ }.select {|constant|
17
+ constant.is_a?(Module) && !constant.is_a?(Class)
18
+ }.partition {|mod|
19
+ mod.constants.include?('LoadFirst') && mod::LoadFirst
20
+ }.flatten.each {|mod|
21
+ target = mod.constants.include?('MixInto') ? mod::MixInto : base
22
+ target.send :include, mod
23
+ }
24
+ end
25
+ end
26
+
27
+ class ApplicationController < ActionController::Base
28
+ include Hammock
29
+ end
data/misc/scaffold.txt ADDED
@@ -0,0 +1,83 @@
1
+ # GET /copies
2
+ # GET /copies.xml
3
+ def index
4
+ @copies = Copy.find(:all)
5
+
6
+ respond_to do |format|
7
+ format.html # index.html.erb
8
+ format.xml { render :xml => @copies }
9
+ end
10
+ end
11
+
12
+ # GET /copies/1
13
+ # GET /copies/1.xml
14
+ def show
15
+ @copy = Copy.find(params[:id])
16
+
17
+ respond_to do |format|
18
+ format.html # show.html.erb
19
+ format.xml { render :xml => @copy }
20
+ end
21
+ end
22
+
23
+ # GET /copies/new
24
+ # GET /copies/new.xml
25
+ def new
26
+ @copy = Copy.new
27
+
28
+ respond_to do |format|
29
+ format.html # new.html.erb
30
+ format.xml { render :xml => @copy }
31
+ end
32
+ end
33
+
34
+ # GET /copies/1/edit
35
+ def edit
36
+ @copy = Copy.find(params[:id])
37
+ end
38
+
39
+ # POST /copies
40
+ # POST /copies.xml
41
+ def create
42
+ @copy = Copy.new(params[:copy])
43
+
44
+ respond_to do |format|
45
+ if @copy.save
46
+ flash[:notice] = 'Copy was successfully created.'
47
+ format.html { redirect_to(@copy) }
48
+ format.xml { render :xml => @copy, :status => :created, :location => @copy }
49
+ else
50
+ format.html { render :action => "new" }
51
+ format.xml { render :xml => @copy.errors, :status => :unprocessable_entity }
52
+ end
53
+ end
54
+ end
55
+
56
+ # PUT /copies/1
57
+ # PUT /copies/1.xml
58
+ def update
59
+ @copy = Copy.find(params[:id])
60
+
61
+ respond_to do |format|
62
+ if @copy.update_attributes(params[:copy])
63
+ flash[:notice] = 'Copy was successfully updated.'
64
+ format.html { redirect_to(@copy) }
65
+ format.xml { head :ok }
66
+ else
67
+ format.html { render :action => "edit" }
68
+ format.xml { render :xml => @copy.errors, :status => :unprocessable_entity }
69
+ end
70
+ end
71
+ end
72
+
73
+ # DELETE /copies/1
74
+ # DELETE /copies/1.xml
75
+ def destroy
76
+ @copy = Copy.find(params[:id])
77
+ @copy.destroy
78
+
79
+ respond_to do |format|
80
+ format.html { redirect_to(copies_url) }
81
+ format.xml { head :ok }
82
+ end
83
+ end
data/misc/template.rb ADDED
@@ -0,0 +1,17 @@
1
+ module Hammock
2
+ module Lol
3
+ MixInto = Lol::Lul
4
+ # LoadFirst = false
5
+
6
+ def self.included base # :nodoc:
7
+ base.send :include, InstanceMethods
8
+ base.send :extend, ClassMethods
9
+ end
10
+
11
+ module ClassMethods
12
+ end
13
+
14
+ module InstanceMethods
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,5 @@
1
+ desc "Regenerate the Manifest from the working tree"
2
+ task :git_to_manifest do
3
+ cmd = %Q(git ls-files -x '.*' > Manifest.txt)
4
+ `#{cmd}`; $? == 0
5
+ end
@@ -0,0 +1,8 @@
1
+ require 'test/unit'
2
+
3
+ class HammockTest < Test::Unit::TestCase
4
+ # Replace this with your real tests.
5
+ def test_this_plugin
6
+ flunk
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hammock
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.11.2
5
+ platform: ruby
6
+ authors:
7
+ - Ben Hoskings
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-03-24 00:00:00 +10:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rails
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: "2.2"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: benhoskings-ambitious-activerecord
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.1.3.5
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: newgem
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 1.3.0
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: hoe
47
+ type: :development
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 1.8.0
54
+ version:
55
+ description: "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!"
56
+ email:
57
+ - ben@hoskings.net
58
+ executables: []
59
+
60
+ extensions: []
61
+
62
+ extra_rdoc_files:
63
+ - History.txt
64
+ - Manifest.txt
65
+ - README.rdoc
66
+ - misc/scaffold.txt
67
+ files:
68
+ - History.txt
69
+ - LICENSE
70
+ - Manifest.txt
71
+ - README.rdoc
72
+ - Rakefile
73
+ - hammock.gemspec
74
+ - lib/hammock.rb
75
+ - lib/hammock/ajaxinate.rb
76
+ - lib/hammock/callback.rb
77
+ - lib/hammock/callbacks.rb
78
+ - lib/hammock/canned_scopes.rb
79
+ - lib/hammock/constants.rb
80
+ - lib/hammock/controller_attributes.rb
81
+ - lib/hammock/export_scope.rb
82
+ - lib/hammock/hamlink_to.rb
83
+ - lib/hammock/javascript_buffer.rb
84
+ - lib/hammock/logging.rb
85
+ - lib/hammock/model_attributes.rb
86
+ - lib/hammock/model_logging.rb
87
+ - lib/hammock/monkey_patches/action_pack.rb
88
+ - lib/hammock/monkey_patches/active_record.rb
89
+ - lib/hammock/monkey_patches/array.rb
90
+ - lib/hammock/monkey_patches/hash.rb
91
+ - lib/hammock/monkey_patches/logger.rb
92
+ - lib/hammock/monkey_patches/module.rb
93
+ - lib/hammock/monkey_patches/numeric.rb
94
+ - lib/hammock/monkey_patches/object.rb
95
+ - lib/hammock/monkey_patches/route_set.rb
96
+ - lib/hammock/monkey_patches/string.rb
97
+ - lib/hammock/overrides.rb
98
+ - lib/hammock/resource_mapping_hooks.rb
99
+ - lib/hammock/resource_retrieval.rb
100
+ - lib/hammock/restful_actions.rb
101
+ - lib/hammock/restful_rendering.rb
102
+ - lib/hammock/restful_support.rb
103
+ - lib/hammock/route_drawing_hooks.rb
104
+ - lib/hammock/route_for.rb
105
+ - lib/hammock/route_node.rb
106
+ - lib/hammock/route_step.rb
107
+ - lib/hammock/scope.rb
108
+ - lib/hammock/suggest.rb
109
+ - lib/hammock/utils.rb
110
+ - misc/scaffold.txt
111
+ - misc/template.rb
112
+ - tasks/hammock_tasks.rake
113
+ - test/hammock_test.rb
114
+ has_rdoc: true
115
+ homepage: http://github.com/benhoskings/hammock
116
+ post_install_message:
117
+ rdoc_options:
118
+ - --main
119
+ - README.rdoc
120
+ require_paths:
121
+ - lib
122
+ required_ruby_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: "0"
127
+ version:
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: "0"
133
+ version:
134
+ requirements: []
135
+
136
+ rubyforge_project: hammock
137
+ rubygems_version: 1.3.1
138
+ signing_key:
139
+ specification_version: 2
140
+ summary: Hammock is a Rails plugin that eliminates redundant code in a very RESTful manner
141
+ test_files: []
142
+