in_place_editing 1.0.0 → 1.1.0

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/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  *.gem
2
2
  .bundle
3
+ .rvmrc
3
4
  Gemfile.lock
4
5
  pkg/*
@@ -3,9 +3,9 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "in_place_editing"
6
- s.version = "1.0.0"
6
+ s.version = "1.1.0"
7
7
  s.platform = Gem::Platform::RUBY
8
- s.authors = ["David Heinemeier Hansson", "Jeremy Kemper", "Jose Fernandez", "Pawel Stradomski"]
8
+ s.authors = ["David Heinemeier Hansson", "Jeremy Kemper", "Jose Fernandez", "Pawel Stradomski, Mark Turner"]
9
9
  s.email = ["mark@amerine.net"]
10
10
  s.homepage = "https://github.com/amerine/in_place_editing"
11
11
  s.summary = %q{In Place Editing Rails Plugin}
@@ -1,28 +1,8 @@
1
- module InPlaceEditing
2
- def self.included(base)
3
- base.extend(ClassMethods)
4
- end
1
+ require File.expand_path('../in_place_editing/controller_methods', __FILE__)
2
+ require File.expand_path('../in_place_editing/helper_methods', __FILE__)
5
3
 
6
- # Example:
7
- #
8
- # # Controller
9
- # class BlogController < ApplicationController
10
- # in_place_edit_for :post, :title
11
- # end
12
- #
13
- # # View
14
- # <%= in_place_editor_field :post, 'title' %>
15
- #
16
- module ClassMethods
17
- def in_place_edit_for(object, attribute, options = {})
18
- define_method("set_#{object}_#{attribute}") do
19
- unless [:post, :put].include?(request.method) then
20
- return render(:text => 'Method not allowed', :status => 405)
21
- end
22
- @item = object.to_s.camelize.constantize.find(params[:id])
23
- @item.update_attribute(attribute, params[:value])
24
- render :text => CGI::escapeHTML(@item.send(attribute).to_s)
25
- end
26
- end
27
- end
4
+
5
+ if defined? ActionController
6
+ ActionController::Base.send :include, InPlaceEditing
7
+ ActionController::Base.helper InPlaceMacrosHelper
28
8
  end
@@ -0,0 +1,28 @@
1
+ module InPlaceEditing
2
+ def self.included(base)
3
+ base.extend(ClassMethods)
4
+ end
5
+
6
+ # Example:
7
+ #
8
+ # # Controller
9
+ # class BlogController < ApplicationController
10
+ # in_place_edit_for :post, :title
11
+ # end
12
+ #
13
+ # # View
14
+ # <%= in_place_editor_field :post, 'title' %>
15
+ #
16
+ module ClassMethods
17
+ def in_place_edit_for(object, attribute, options = {})
18
+ define_method("set_#{object}_#{attribute}") do
19
+ unless [:post, :put].include?(request.method) then
20
+ return render(:text => 'Method not allowed', :status => 405)
21
+ end
22
+ @item = object.to_s.camelize.constantize.find(params[:id])
23
+ @item.update_attribute(attribute, params[:value])
24
+ render :text => CGI::escapeHTML(@item.send(attribute).to_s)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,24 +1,28 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/test_helper")
2
2
 
3
+ class InPlaceEditingController < AbstractController::Base; end
4
+
3
5
  class InPlaceEditingTest < Test::Unit::TestCase
4
6
  include InPlaceEditing
5
7
  include InPlaceMacrosHelper
6
8
 
7
9
  include ActionView::Helpers::UrlHelper
8
10
  include ActionView::Helpers::TagHelper
11
+ include ActionView::Helpers::JavaScriptHelper
9
12
  include ActionView::Helpers::TextHelper
10
13
  include ActionView::Helpers::FormHelper
11
14
  include ActionView::Helpers::CaptureHelper
15
+ include ActionDispatch::Assertions::DomAssertions
12
16
 
13
17
  def setup
14
- @controller = Class.new do
15
- def url_for(options)
16
- url = "http://www.example.com/"
17
- url << options[:action].to_s if options and options[:action]
18
- url
19
- end
18
+ def url_for(options)
19
+ url = "http://www.example.com/"
20
+ url << options[:action].to_s if options and options[:action]
21
+ url
20
22
  end
21
- @controller = @controller.new
23
+
24
+
25
+ @controller = InPlaceEditingController.new
22
26
  @protect_against_forgery = false
23
27
  end
24
28
 
@@ -86,4 +90,4 @@ class InPlaceEditingTest < Test::Unit::TestCase
86
90
  :url => { :action => "action_to_set_value" },
87
91
  :text_between_controls => "or" )
88
92
  end
89
- end
93
+ end
@@ -3,6 +3,5 @@ $:.unshift(File.dirname(__FILE__) + '/../lib')
3
3
  require 'test/unit'
4
4
  require 'rubygems'
5
5
  require 'action_controller'
6
- require 'action_controller/assertions'
6
+ require 'action_dispatch/testing/assertions'
7
7
  require 'in_place_editing'
8
- require 'in_place_macros_helper'
metadata CHANGED
@@ -1,77 +1,60 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: in_place_editing
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 0
8
- - 0
9
- version: 1.0.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - David Heinemeier Hansson
13
9
  - Jeremy Kemper
14
10
  - Jose Fernandez
15
- - Pawel Stradomski
11
+ - Pawel Stradomski, Mark Turner
16
12
  autorequire:
17
13
  bindir: bin
18
14
  cert_chain: []
19
-
20
- date: 2011-03-07 00:00:00 -08:00
21
- default_executable:
15
+ date: 2011-08-24 00:00:00.000000000Z
22
16
  dependencies: []
23
-
24
17
  description: In Place Editing Rails Plugin
25
- email:
18
+ email:
26
19
  - mark@amerine.net
27
20
  executables: []
28
-
29
21
  extensions: []
30
-
31
22
  extra_rdoc_files: []
32
-
33
- files:
23
+ files:
34
24
  - .gitignore
35
25
  - README
36
26
  - Rakefile
37
27
  - in_place_editing.gemspec
38
28
  - init.rb
39
29
  - lib/in_place_editing.rb
40
- - lib/in_place_macros_helper.rb
30
+ - lib/in_place_editing/controller_methods.rb
31
+ - lib/in_place_editing/helper_methods.rb
41
32
  - test/in_place_editing_test.rb
42
33
  - test/test_helper.rb
43
- has_rdoc: true
44
34
  homepage: https://github.com/amerine/in_place_editing
45
35
  licenses: []
46
-
47
36
  post_install_message:
48
37
  rdoc_options: []
49
-
50
- require_paths:
38
+ require_paths:
51
39
  - lib
52
- required_ruby_version: !ruby/object:Gem::Requirement
40
+ required_ruby_version: !ruby/object:Gem::Requirement
53
41
  none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- segments:
58
- - 0
59
- version: "0"
60
- required_rubygems_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
47
  none: false
62
- requirements:
63
- - - ">="
64
- - !ruby/object:Gem::Version
65
- segments:
66
- - 0
67
- version: "0"
48
+ requirements:
49
+ - - ! '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
68
52
  requirements: []
69
-
70
53
  rubyforge_project: in_place_editing
71
- rubygems_version: 1.3.7
54
+ rubygems_version: 1.8.6
72
55
  signing_key:
73
56
  specification_version: 3
74
57
  summary: In Place Editing Rails Plugin
75
- test_files:
58
+ test_files:
76
59
  - test/in_place_editing_test.rb
77
60
  - test/test_helper.rb