hammock 0.2.12.1 → 0.2.13

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,10 @@
1
+ == 0.2.13 2009-04-07
2
+ Use update_attributes instead of adjust in #find_or_create_with.
3
+ Added optional statuses handling to #ajaxinate.
4
+ Moved semicolons from call to declaration of response_action in #ajaxinate.
5
+ Avoid specifying the request format as an empty string.
6
+
7
+
1
8
  == 0.2.12.1 2009-04-01
2
9
  Changed #log to #dlog for unmatched scope logging and related chatter.
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.12.1"
5
+ s.version = "0.2.13"
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-01}
9
+ s.date = %q{2009-04-07}
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"]
@@ -37,7 +37,7 @@ module Hammock
37
37
  link_class = link_class_for route.verb, record, attribute
38
38
 
39
39
  link_params[:_method] = route.http_method
40
- link_params[:format] = opts[:format].to_s
40
+ link_params[:format] = opts[:format].to_s unless opts[:format].blank?
41
41
 
42
42
  form_elements_hash = if route.get?
43
43
  '{ }'
@@ -49,14 +49,21 @@ module Hammock
49
49
 
50
50
  response_action = case link_params[:format].to_s
51
51
  when 'js'
52
- "eval(response)"
52
+ "eval(response);"
53
53
  else
54
- "jQuery('.#{opts[:target] || link_class + '_target'}').before(response).remove()"
54
+ "jQuery('.#{opts[:target] || link_class + '_target'}').before(response).remove();"
55
55
  end
56
56
 
57
57
  # TODO check the response code in the callback, and replace :after with :success and :failure.
58
58
  js = %Q{
59
59
  jQuery('.#{link_class}').#{opts[:on] || 'click'}(function() {
60
+ var obj = null;
61
+
62
+ if (#{opts[:spinner] ? 'true' : 'false'}) {
63
+ obj = jQuery(this).parents('.#{record.base_model}:first').find('.statuses');
64
+ obj.find('.spinner').animate({opacity: 'show'}, 100);
65
+ }
66
+
60
67
  /*if (#{attribute.blank? ? 'false' : 'true'} && (jQuery('.#{link_class}_target .original_value').html() == jQuery('.#{link_class}_target .modify input').val())) {
61
68
  eval("#{clean_snippet opts[:skipped]}");
62
69
  } else*/ if (false == eval("#{clean_snippet opts[:before]}")) {
@@ -70,8 +77,14 @@ module Hammock
70
77
  #{link_params.to_flattened_json},
71
78
  #{forgery_key_json(route.http_method)}
72
79
  ),
73
- function(response) {
74
- #{response_action};
80
+ function(response, textStatus) {
81
+ #{response_action}
82
+ if ('success' == textStatus) {
83
+ if (obj) {
84
+ obj.children('.spinner').hide()
85
+ .siblings('.success').show().fadeOut(4000);
86
+ }
87
+ }
75
88
  eval("#{clean_snippet opts[:after]}");
76
89
  }
77
90
  );
@@ -89,7 +89,7 @@ module Hammock
89
89
  def find_or_create_with(find_attributes, create_attributes = {}, adjust_attributes = false)
90
90
  if record = find_or_new_with(find_attributes, create_attributes)
91
91
  log "Create failed. #{record.errors.inspect}", :skip => 1 if record.new_record? && !record.save
92
- log "Adjust failed. #{record.errors.inspect}", :skip => 1 if adjust_attributes && !record.adjust(create_attributes)
92
+ log "Adjust failed. #{record.errors.inspect}", :skip => 1 if adjust_attributes && !record.update_attributes(create_attributes)
93
93
  record
94
94
  end
95
95
  end
data/lib/hammock.rb CHANGED
@@ -4,7 +4,7 @@ require 'ambition'
4
4
  require 'ambition/adapters/active_record'
5
5
 
6
6
  module Hammock
7
- VERSION = '0.2.12.1'
7
+ VERSION = '0.2.13'
8
8
 
9
9
  def self.included base # :nodoc:
10
10
  puts "Loading Hammock from #{loaded_from_gem? ? 'gem' : 'plugin'}"
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.12.1
4
+ version: 0.2.13
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-01 00:00:00 +10:00
12
+ date: 2009-04-07 00:00:00 +10:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency