jeditable-rails 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ # jeditable-rails gem
2
+ ## 0.1.1
3
+
4
+ * Added support for the same attribute on multiple records on the same page.
5
+ * Execute jQuery in self executing function (to keep it from colliding with other libs)
6
+
7
+ ## 0.1.0 - Initial release
data/Gemfile CHANGED
@@ -6,7 +6,7 @@ source "http://rubygems.org"
6
6
  # Add dependencies to develop your gem here.
7
7
  # Include everything needed to run rake, tests, features, etc.
8
8
  group :development do
9
- gem "shoulda", ">= 0"
9
+ gem "rspec", "~> 2.3.0"
10
10
  gem "bundler", "~> 1.0.0"
11
11
  gem "jeweler", "~> 1.5.2"
12
12
  gem "rcov", ">= 0"
@@ -1,6 +1,7 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
+ diff-lcs (1.1.2)
4
5
  git (1.2.5)
5
6
  jeweler (1.5.2)
6
7
  bundler (~> 1.0.0)
@@ -8,7 +9,14 @@ GEM
8
9
  rake
9
10
  rake (0.8.7)
10
11
  rcov (0.9.9)
11
- shoulda (2.11.3)
12
+ rspec (2.3.0)
13
+ rspec-core (~> 2.3.0)
14
+ rspec-expectations (~> 2.3.0)
15
+ rspec-mocks (~> 2.3.0)
16
+ rspec-core (2.3.0)
17
+ rspec-expectations (2.3.0)
18
+ diff-lcs (~> 1.1.2)
19
+ rspec-mocks (2.3.0)
12
20
 
13
21
  PLATFORMS
14
22
  ruby
@@ -17,4 +25,4 @@ DEPENDENCIES
17
25
  bundler (~> 1.0.0)
18
26
  jeweler (~> 1.5.2)
19
27
  rcov
20
- shoulda
28
+ rspec (~> 2.3.0)
data/Rakefile CHANGED
@@ -26,21 +26,18 @@ Jeweler::Tasks.new do |gem|
26
26
  end
27
27
  Jeweler::RubygemsDotOrgTasks.new
28
28
 
29
- require 'rake/testtask'
30
- Rake::TestTask.new(:test) do |test|
31
- test.libs << 'lib' << 'test'
32
- test.pattern = 'test/**/test_*.rb'
33
- test.verbose = true
29
+ require 'rspec/core'
30
+ require 'rspec/core/rake_task'
31
+ RSpec::Core::RakeTask.new(:spec) do |spec|
32
+ spec.pattern = FileList['spec/**/*_spec.rb']
34
33
  end
35
34
 
36
- require 'rcov/rcovtask'
37
- Rcov::RcovTask.new do |test|
38
- test.libs << 'test'
39
- test.pattern = 'test/**/test_*.rb'
40
- test.verbose = true
35
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
36
+ spec.pattern = 'spec/**/*_spec.rb'
37
+ spec.rcov = true
41
38
  end
42
39
 
43
- task :default => :test
40
+ task :default => :spec
44
41
 
45
42
  require 'rake/rdoctask'
46
43
  Rake::RDocTask.new do |rdoc|
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{jeditable-rails}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Aidan Feldman"]
12
- s.date = %q{2011-02-02}
12
+ s.date = %q{2011-02-17}
13
13
  s.description = %q{An edit-in-place gem that uses the JEditable jQuery plugin to post updates to the server via AJAX.}
14
14
  s.email = %q{aidan.feldman@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
+ "CHANGELOG.markdown",
21
22
  "Gemfile",
22
23
  "Gemfile.lock",
23
24
  "LICENSE.txt",
@@ -28,35 +29,35 @@ Gem::Specification.new do |s|
28
29
  "lib/jeditable-rails.rb",
29
30
  "lib/jeditable-rails/base.rb",
30
31
  "lib/jeditable-rails/helpers/jeditable_helper.rb",
31
- "test/helper.rb",
32
- "test/test_jeditable-rails.rb"
32
+ "spec/jeditable-rails_spec.rb",
33
+ "spec/spec_helper.rb"
33
34
  ]
34
35
  s.homepage = %q{http://github.com/afeld/jeditable-rails}
35
36
  s.licenses = ["MIT"]
36
37
  s.require_paths = ["lib"]
37
- s.rubygems_version = %q{1.4.2}
38
+ s.rubygems_version = %q{1.5.0}
38
39
  s.summary = %q{An edit-in-place gem for Rails 3}
39
40
  s.test_files = [
40
- "test/helper.rb",
41
- "test/test_jeditable-rails.rb"
41
+ "spec/jeditable-rails_spec.rb",
42
+ "spec/spec_helper.rb"
42
43
  ]
43
44
 
44
45
  if s.respond_to? :specification_version then
45
46
  s.specification_version = 3
46
47
 
47
48
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
48
- s.add_development_dependency(%q<shoulda>, [">= 0"])
49
+ s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
49
50
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
50
51
  s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
51
52
  s.add_development_dependency(%q<rcov>, [">= 0"])
52
53
  else
53
- s.add_dependency(%q<shoulda>, [">= 0"])
54
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
54
55
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
55
56
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
56
57
  s.add_dependency(%q<rcov>, [">= 0"])
57
58
  end
58
59
  else
59
- s.add_dependency(%q<shoulda>, [">= 0"])
60
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
60
61
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
61
62
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
62
63
  s.add_dependency(%q<rcov>, [">= 0"])
@@ -3,39 +3,17 @@ module JeditableHelper
3
3
  # will be created. Otherwise, the value of the property of the object is
4
4
  # returned. See #editable_field for options.
5
5
  def editable_field_if(condition, object, property, options={})
6
- value = object.send property
7
6
  if condition
8
- name = "#{object.class.to_s.underscore}[#{property}]"
9
- update_url = options.delete(:update_url) || url_for(object)
10
- args = {:method => 'PUT', :name => name}.merge(options)
11
- %{
12
- <span class="editable" data-name="#{name}">#{value}</span>
13
- <script type="text/javascript">
14
- $(function(){
15
- var args = {data: function(value, settings) {
16
- // Unescape HTML
17
- var retval = value
18
- .replace(/&amp;/gi, '&')
19
- .replace(/&gt;/gi, '>')
20
- .replace(/&lt;/gi, '<')
21
- .replace(/&quot;/gi, "\\\"");
22
- return retval;
23
- }};
24
- $.extend(args, #{args.to_json});
25
- $(".editable[data-name='#{name}']").editable("#{update_url}", args);
26
- });
27
- </script>
28
- }.html_safe
7
+ editable_field(object, property, options)
29
8
  else
30
- value
9
+ object.send property
31
10
  end
32
11
  end
33
-
12
+
34
13
  # Creates an editable span for the given property of the given object.
35
- # When clicked, the
36
- #
14
+ #
37
15
  # === Options
38
- #
16
+ #
39
17
  # [:method]
40
18
  # Specify the HTTP method to use: <tt>'PUT'</tt> or <tt>'POST'</tt>.
41
19
  # [:name]
@@ -43,6 +21,30 @@ module JeditableHelper
43
21
  # [:update_url]
44
22
  # The URL to submit the form to. Defaults to <tt>url_for(object)</tt>.
45
23
  def editable_field(object, property, options={})
46
- editable_field_if(true, object, property, options={})
24
+ name = "#{object.class.to_s.underscore}[#{property}]"
25
+ value = object.send property
26
+ update_url = options.delete(:update_url) || url_for(object)
27
+ args = {:method => 'PUT', :name => name}.merge(options)
28
+ %{
29
+ <span class="editable" data-id="#{object.id}" data-name="#{name}">#{value}</span>
30
+ <script type="text/javascript">
31
+ (function( $ ){
32
+ $(function(){
33
+ var args = {data: function(value, settings) {
34
+ // Unescape HTML
35
+ var retval = value
36
+ .replace(/&amp;/gi, '&')
37
+ .replace(/&gt;/gi, '>')
38
+ .replace(/&lt;/gi, '<')
39
+ .replace(/&quot;/gi, "\\\"");
40
+ return retval;
41
+ }};
42
+ $.extend(args, #{args.to_json});
43
+ $(".editable[data-id='#{object.id}'][data-name='#{name}']").editable("#{update_url}", args);
44
+ });
45
+ })( jQuery );
46
+ </script>
47
+ }.html_safe
47
48
  end
48
49
  end
50
+
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "JeditableRails" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'jeditable-rails'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jeditable-rails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Aidan Feldman
@@ -15,28 +15,28 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-02 00:00:00 -05:00
18
+ date: 2011-02-17 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- prerelease: false
23
- name: shoulda
24
22
  type: :development
25
- version_requirements: &id001 !ruby/object:Gem::Requirement
23
+ requirement: &id001 !ruby/object:Gem::Requirement
26
24
  none: false
27
25
  requirements:
28
- - - ">="
26
+ - - ~>
29
27
  - !ruby/object:Gem::Version
30
28
  hash: 3
31
29
  segments:
30
+ - 2
31
+ - 3
32
32
  - 0
33
- version: "0"
34
- requirement: *id001
35
- - !ruby/object:Gem::Dependency
33
+ version: 2.3.0
34
+ name: rspec
35
+ version_requirements: *id001
36
36
  prerelease: false
37
- name: bundler
37
+ - !ruby/object:Gem::Dependency
38
38
  type: :development
39
- version_requirements: &id002 !ruby/object:Gem::Requirement
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -47,12 +47,12 @@ dependencies:
47
47
  - 0
48
48
  - 0
49
49
  version: 1.0.0
50
- requirement: *id002
51
- - !ruby/object:Gem::Dependency
50
+ name: bundler
51
+ version_requirements: *id002
52
52
  prerelease: false
53
- name: jeweler
53
+ - !ruby/object:Gem::Dependency
54
54
  type: :development
55
- version_requirements: &id003 !ruby/object:Gem::Requirement
55
+ requirement: &id003 !ruby/object:Gem::Requirement
56
56
  none: false
57
57
  requirements:
58
58
  - - ~>
@@ -63,12 +63,12 @@ dependencies:
63
63
  - 5
64
64
  - 2
65
65
  version: 1.5.2
66
- requirement: *id003
67
- - !ruby/object:Gem::Dependency
66
+ name: jeweler
67
+ version_requirements: *id003
68
68
  prerelease: false
69
- name: rcov
69
+ - !ruby/object:Gem::Dependency
70
70
  type: :development
71
- version_requirements: &id004 !ruby/object:Gem::Requirement
71
+ requirement: &id004 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ">="
@@ -77,7 +77,9 @@ dependencies:
77
77
  segments:
78
78
  - 0
79
79
  version: "0"
80
- requirement: *id004
80
+ name: rcov
81
+ version_requirements: *id004
82
+ prerelease: false
81
83
  description: An edit-in-place gem that uses the JEditable jQuery plugin to post updates to the server via AJAX.
82
84
  email: aidan.feldman@gmail.com
83
85
  executables: []
@@ -89,6 +91,7 @@ extra_rdoc_files:
89
91
  - README.rdoc
90
92
  files:
91
93
  - .document
94
+ - CHANGELOG.markdown
92
95
  - Gemfile
93
96
  - Gemfile.lock
94
97
  - LICENSE.txt
@@ -99,8 +102,8 @@ files:
99
102
  - lib/jeditable-rails.rb
100
103
  - lib/jeditable-rails/base.rb
101
104
  - lib/jeditable-rails/helpers/jeditable_helper.rb
102
- - test/helper.rb
103
- - test/test_jeditable-rails.rb
105
+ - spec/jeditable-rails_spec.rb
106
+ - spec/spec_helper.rb
104
107
  has_rdoc: true
105
108
  homepage: http://github.com/afeld/jeditable-rails
106
109
  licenses:
@@ -131,10 +134,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
134
  requirements: []
132
135
 
133
136
  rubyforge_project:
134
- rubygems_version: 1.4.2
137
+ rubygems_version: 1.5.0
135
138
  signing_key:
136
139
  specification_version: 3
137
140
  summary: An edit-in-place gem for Rails 3
138
141
  test_files:
139
- - test/helper.rb
140
- - test/test_jeditable-rails.rb
142
+ - spec/jeditable-rails_spec.rb
143
+ - spec/spec_helper.rb
@@ -1,18 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- begin
4
- Bundler.setup(:default, :development)
5
- rescue Bundler::BundlerError => e
6
- $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
8
- exit e.status_code
9
- end
10
- require 'test/unit'
11
- require 'shoulda'
12
-
13
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
- $LOAD_PATH.unshift(File.dirname(__FILE__))
15
- require 'jeditable-rails'
16
-
17
- class Test::Unit::TestCase
18
- end
@@ -1,7 +0,0 @@
1
- require 'helper'
2
-
3
- class TestJeditableRails < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
6
- end
7
- end