on_the_spot 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -2,5 +2,4 @@ rvm:
2
2
  - 1.8.7
3
3
  - 1.9.2
4
4
  - rbx
5
- - ree
6
- - jruby
5
+ - ree
data/README.markdown CHANGED
@@ -1,5 +1,7 @@
1
1
  # on_the_spot
2
2
 
3
+ [![Build Status](http://travis-ci.org/nathanvda/on_the_spot.png)](http://travis-ci.org/nathanvda/on_the_spot)
4
+
3
5
  On-the-spot is a Rails3 compliant unobtrusive javascript in-place-editing plugin, using jEditable, and depends on jQuery.
4
6
 
5
7
  ## Installation
@@ -7,12 +9,30 @@ On-the-spot is a Rails3 compliant unobtrusive javascript in-place-editing plugin
7
9
  Inside your `Gemfile` add the following:
8
10
 
9
11
  gem "on_the_spot"
12
+
13
+ ### Rails 3.1
14
+
15
+ Add the following to application.js so it compiles to the asset_pipeline
16
+
17
+ //= require on_the_spot
18
+
19
+ ### Rails 3.0.x
10
20
 
11
21
  Run the installation task:
12
22
 
13
23
  rails g on_the_spot:install
14
24
 
15
- Inside your `routes.rb` you need to provide the following route:
25
+ Inside your `application.html.haml` you will need to add below the default javascripts:
26
+
27
+ = javascript_include_tag :on_the_spot
28
+
29
+ or using erb, you write
30
+
31
+ <%= javascript_include_tag :on_the_spot %>
32
+
33
+ ### Routes (for all Rails 3 versions)
34
+
35
+ Inside your `routes.rb` you need to provide the following route :
16
36
 
17
37
  resources :posts do
18
38
  collection do
@@ -23,13 +43,6 @@ Inside your `routes.rb` you need to provide the following route:
23
43
  You need to do this for each controller that uses the on-the-spot editing.
24
44
  For the moment i do not know of any better solution, but i am always open for suggestions!
25
45
 
26
- Inside your `application.html.haml` you will need to add below the default javascripts:
27
-
28
- = javascript_include_tag :on_the_spot
29
-
30
- or using erb, you write
31
-
32
- <%= javascript_include_tag :on_the_spot %>
33
46
 
34
47
  That is all you need to do to start using it!
35
48
 
data/Rakefile CHANGED
@@ -27,12 +27,6 @@ RSpec::Core::RakeTask.new(:spec)
27
27
  task :default => :spec
28
28
 
29
29
 
30
- desc "Run all specs with rcov"
31
- RSpec::Core::RakeTask.new("test_cov") do |t|
32
- t.rcov = true
33
- t.rcov_opts = %w{--rails --include views -Ispec --exclude gems\/,spec\/,features\/,seeds\/}
34
- end
35
-
36
30
  require 'rake/rdoctask'
37
31
  Rake::RDocTask.new do |rdoc|
38
32
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.13
1
+ 0.0.14
@@ -1,63 +1,7 @@
1
- $(document).ready(function() {
2
-
3
- $(".on_the_spot_editing").mouseover(function() {
4
- $(this).css('background-color', '#EEF2A0');
5
- });
6
- $(".on_the_spot_editing").mouseout(function() {
7
- $(this).css('background-color', 'inherit');
8
- });
9
- $('.on_the_spot_editing').each(initializeOnTheSpot);
10
-
11
- });
12
-
13
- function initializeOnTheSpot(n){
14
- var el = $(this),
15
- auth_token = el.attr('data-auth'),
16
- data_url = el.attr('data-url'),
17
- ok_text = el.attr('data-ok') || 'OK',
18
- cancel_text = el.attr('data-cancel') || 'Cancel',
19
- tooltip_text = el.attr('data-tooltip') || 'Click to edit ...',
20
- edit_type = el.attr('data-edittype'),
21
- select_data = el.attr('data-select'),
22
- rows = el.attr('data-rows'),
23
- columns = el.attr('data-columns'),
24
- load_url = el.attr('data-loadurl'),
25
- selected = el.attr('data-selected'),
26
- callback = el.attr('data-callback');
27
-
28
- var options = {
29
- tooltip: tooltip_text,
30
- placeholder: tooltip_text,
31
- cancel: cancel_text,
32
- submit: ok_text,
33
- select: selected,
34
- onerror: function (settings, original, xhr) {
35
- original.reset();
36
- //just show the error-msg for now
37
- alert(xhr.responseText);
38
- },
39
- submitdata: {
40
- authenticity_token: auth_token,
41
- _method: 'put'
42
- },
43
- callback: new Function("value", "settings", "return "+callback+"(this, value, settings);")
44
- };
45
- if (edit_type != null) {
46
- options.type = edit_type;
47
- }
48
- if (edit_type == 'select') {
49
- if (select_data != null) {
50
- options.data = select_data;
51
- options.submitdata['select_array'] = select_data;
52
- }
53
- if (load_url != null) {
54
- options.loadurl = load_url;
55
- }
56
- }
57
- else if (edit_type == 'textarea') {
58
- options.rows = rows;
59
- options.cols = columns;
60
- }
61
-
62
- el.editable(data_url, options)
63
- }
1
+ // This is the manifest file for rails 3.1
2
+ //
3
+ // now you can use just write
4
+ // javascript_include_tag :on_the_spot
5
+ //
6
+ //= require jquery.jeditable.mini.js
7
+ //= require on_the_spot_code
@@ -0,0 +1,63 @@
1
+ $(document).ready(function() {
2
+
3
+ $(".on_the_spot_editing").mouseover(function() {
4
+ $(this).css('background-color', '#EEF2A0');
5
+ });
6
+ $(".on_the_spot_editing").mouseout(function() {
7
+ $(this).css('background-color', 'inherit');
8
+ });
9
+ $('.on_the_spot_editing').each(initializeOnTheSpot);
10
+
11
+ });
12
+
13
+ function initializeOnTheSpot(n){
14
+ var el = $(this),
15
+ auth_token = el.attr('data-auth'),
16
+ data_url = el.attr('data-url'),
17
+ ok_text = el.attr('data-ok') || 'OK',
18
+ cancel_text = el.attr('data-cancel') || 'Cancel',
19
+ tooltip_text = el.attr('data-tooltip') || 'Click to edit ...',
20
+ edit_type = el.attr('data-edittype'),
21
+ select_data = el.attr('data-select'),
22
+ rows = el.attr('data-rows'),
23
+ columns = el.attr('data-columns'),
24
+ load_url = el.attr('data-loadurl'),
25
+ selected = el.attr('data-selected'),
26
+ callback = el.attr('data-callback');
27
+
28
+ var options = {
29
+ tooltip: tooltip_text,
30
+ placeholder: tooltip_text,
31
+ cancel: cancel_text,
32
+ submit: ok_text,
33
+ select: selected,
34
+ onerror: function (settings, original, xhr) {
35
+ original.reset();
36
+ //just show the error-msg for now
37
+ alert(xhr.responseText);
38
+ },
39
+ submitdata: {
40
+ authenticity_token: auth_token,
41
+ _method: 'put'
42
+ },
43
+ callback: callback ? new Function("value", "settings", "return "+callback+"(this, value, settings);") : null
44
+ };
45
+ if (edit_type != null) {
46
+ options.type = edit_type;
47
+ }
48
+ if (edit_type == 'select') {
49
+ if (select_data != null) {
50
+ options.data = select_data;
51
+ options.submitdata['select_array'] = select_data;
52
+ }
53
+ if (load_url != null) {
54
+ options.loadurl = load_url;
55
+ }
56
+ }
57
+ else if (edit_type == 'textarea') {
58
+ options.rows = rows;
59
+ options.cols = columns;
60
+ }
61
+
62
+ el.editable(data_url, options)
63
+ }
data/lib/on_the_spot.rb CHANGED
@@ -5,7 +5,7 @@ module OnTheSpot
5
5
  class Engine < ::Rails::Engine
6
6
 
7
7
  config.before_initialize do
8
- config.action_view.javascript_expansions[:on_the_spot] = %w(jquery.jeditable.mini.js on_the_spot)
8
+ config.action_view.javascript_expansions[:on_the_spot] = %w(jquery.jeditable.mini.js on_the_spot_code)
9
9
  end
10
10
 
11
11
  # configure our plugin on boot. other extension points such
data/on_the_spot.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{on_the_spot}
8
- s.version = "0.0.13"
8
+ s.version = "0.0.14"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Nathan Van der Auwera"]
12
- s.date = %q{2011-07-24}
12
+ s.date = %q{2011-09-13}
13
13
  s.description = %q{Unobtrusive in place editing, using jEditable; only works in Rails 3}
14
14
  s.email = %q{nathan@dixis.com}
15
15
  s.extra_rdoc_files = [
@@ -29,6 +29,7 @@ Gem::Specification.new do |s|
29
29
  "VERSION",
30
30
  "app/assets/javascripts/jquery.jeditable.mini.js",
31
31
  "app/assets/javascripts/on_the_spot.js",
32
+ "app/assets/javascripts/on_the_spot_code.js",
32
33
  "lib/generators/on_the_spot/install/install_generator.rb",
33
34
  "lib/generators/on_the_spot/install/templates/jquery.jeditable.mini.js",
34
35
  "lib/generators/on_the_spot/install/templates/on_the_spot.en.yml",
@@ -39,6 +40,7 @@ Gem::Specification.new do |s|
39
40
  "spec/dummy/Rakefile",
40
41
  "spec/dummy/app/controllers/application_controller.rb",
41
42
  "spec/dummy/app/helpers/application_helper.rb",
43
+ "spec/dummy/app/models/post.rb",
42
44
  "spec/dummy/app/views/layouts/application.html.erb",
43
45
  "spec/dummy/config.ru",
44
46
  "spec/dummy/config/application.rb",
@@ -55,6 +57,8 @@ Gem::Specification.new do |s|
55
57
  "spec/dummy/config/initializers/session_store.rb",
56
58
  "spec/dummy/config/locales/en.yml",
57
59
  "spec/dummy/config/routes.rb",
60
+ "spec/dummy/db/migrate/20110724190901_create_posts.rb",
61
+ "spec/dummy/db/schema.rb",
58
62
  "spec/dummy/public/404.html",
59
63
  "spec/dummy/public/422.html",
60
64
  "spec/dummy/public/500.html",
@@ -0,0 +1,2 @@
1
+ class Post < ActiveRecord::Base
2
+ end
@@ -0,0 +1,14 @@
1
+ class CreatePosts < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :posts do |t|
4
+ t.string :title
5
+ t.string :content
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+
11
+ def self.down
12
+ drop_table :posts
13
+ end
14
+ end
@@ -0,0 +1,22 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # Note that this schema.rb definition is the authoritative source for your
6
+ # database schema. If you need to create the application database on another
7
+ # system, you should be using db:schema:load, not running all the migrations
8
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
10
+ #
11
+ # It's strongly recommended to check this file into your version control system.
12
+
13
+ ActiveRecord::Schema.define(:version => 20110724190901) do
14
+
15
+ create_table "posts", :force => true do |t|
16
+ t.string "title"
17
+ t.string "content"
18
+ t.datetime "created_at"
19
+ t.datetime "updated_at"
20
+ end
21
+
22
+ end
@@ -1,16 +1,21 @@
1
1
  require 'spec_helper'
2
+
3
+
2
4
  require 'generator_spec/test_case'
3
5
  require 'generators/on_the_spot/install/install_generator'
4
6
 
7
+ require 'rspec/mocks'
8
+
5
9
  describe OnTheSpot::Generators::InstallGenerator do
6
10
  include GeneratorSpec::TestCase
7
11
 
8
12
  destination File.expand_path("../../tmp", __FILE__)
9
13
 
14
+
10
15
  context "in rails 3.0" do
11
16
  context "with no arguments" do
12
- before(:all) do
13
- ::Rails.stub(:version) { '3.0.8' }
17
+ before(:each) do
18
+ Rails.stub(:version) { '3.0.8' }
14
19
  prepare_destination
15
20
  run_generator
16
21
  end
@@ -32,8 +37,8 @@ describe OnTheSpot::Generators::InstallGenerator do
32
37
 
33
38
  context "in rails 3.1" do
34
39
  context "with no arguments" do
35
- before(:all) do
36
- ::Rails.stub(:version) { '3.1.0' }
40
+ before(:each) do
41
+ Rails.stub(:version) { '3.1.0' }
37
42
  prepare_destination
38
43
  run_generator
39
44
  end
data/spec/spec_helper.rb CHANGED
@@ -4,8 +4,11 @@ ENV["RAILS_ENV"] = "test"
4
4
  require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
5
  require "rails/test_help"
6
6
  require "rspec/rails"
7
+ require "rspec/mocks"
7
8
  require 'simplecov'
8
9
 
10
+ SimpleCov.start 'rails'
11
+
9
12
  ActionMailer::Base.delivery_method = :test
10
13
  ActionMailer::Base.perform_deliveries = true
11
14
  ActionMailer::Base.default_url_options[:host] = "test.com"
@@ -26,8 +29,8 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
26
29
  RSpec.configure do |config|
27
30
  # Remove this line if you don't want RSpec's should and should_not
28
31
  # methods or matchers
29
- require 'rspec/expectations'
30
- config.include RSpec::Matchers
32
+ #require 'rspec/expectations'
33
+ #config.include RSpec::Matchers
31
34
 
32
35
  # == Mock Framework
33
36
  config.mock_with :rspec
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: on_the_spot
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 13
10
- version: 0.0.13
9
+ - 14
10
+ version: 0.0.14
11
11
  platform: ruby
12
12
  authors:
13
13
  - Nathan Van der Auwera
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-24 00:00:00 +02:00
18
+ date: 2011-09-13 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -89,6 +89,7 @@ files:
89
89
  - VERSION
90
90
  - app/assets/javascripts/jquery.jeditable.mini.js
91
91
  - app/assets/javascripts/on_the_spot.js
92
+ - app/assets/javascripts/on_the_spot_code.js
92
93
  - lib/generators/on_the_spot/install/install_generator.rb
93
94
  - lib/generators/on_the_spot/install/templates/jquery.jeditable.mini.js
94
95
  - lib/generators/on_the_spot/install/templates/on_the_spot.en.yml
@@ -99,6 +100,7 @@ files:
99
100
  - spec/dummy/Rakefile
100
101
  - spec/dummy/app/controllers/application_controller.rb
101
102
  - spec/dummy/app/helpers/application_helper.rb
103
+ - spec/dummy/app/models/post.rb
102
104
  - spec/dummy/app/views/layouts/application.html.erb
103
105
  - spec/dummy/config.ru
104
106
  - spec/dummy/config/application.rb
@@ -115,6 +117,8 @@ files:
115
117
  - spec/dummy/config/initializers/session_store.rb
116
118
  - spec/dummy/config/locales/en.yml
117
119
  - spec/dummy/config/routes.rb
120
+ - spec/dummy/db/migrate/20110724190901_create_posts.rb
121
+ - spec/dummy/db/schema.rb
118
122
  - spec/dummy/public/404.html
119
123
  - spec/dummy/public/422.html
120
124
  - spec/dummy/public/500.html