jquery-rest-rails 1.0.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.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jquery-rest-rails.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 bokmann
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,41 @@
1
+ # Jquery::Rest::Rails
2
+
3
+ a simple asset gem bundling of the javascript from:
4
+
5
+ https://github.com/lyconic/jquery.rest
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'jquery-rest-rails'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install jquery-rest-rails
20
+
21
+ ## Usage
22
+
23
+ See the usage instructions for the original javascript. This gem file just makes it so you aren't copying around unversioned resources.
24
+
25
+ ## Versioning
26
+
27
+ The original jquery.rest javascript is unversioned. I shudder to think how many people just copied that file into some public/javascripts directory on their project, and are now unable to track if they should upgrade, what upgrades might solve (or introduce), etc.
28
+
29
+ So solve that, I'm going to version this gem as closely as I can determine to the intent of Semantic Versioning (http://www.semver.org), tracing each version of the gem back to the github sha1 hash of the jquery.rest.js file from which it came. If this helps you solve a problem someday, you can buy me a scotch.
30
+
31
+
32
+ Version 1.0.0 - 50360072aae439afe82f699352c8d7dceae703b8
33
+
34
+
35
+ ## Contributing
36
+
37
+ 1. Fork it
38
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
39
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
40
+ 4. Push to the branch (`git push origin my-new-feature`)
41
+ 5. Create new Pull Request
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/jquery-rest-rails/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["bokmann"]
6
+ gem.email = ["dbock@codesherpas.com"]
7
+ gem.description = %q{jquery.rest is a little bit of javascript for giving you crud verbs good for talking to rails controllers. Since I hate unversioned resources, I'm making it an asset gem.}
8
+ gem.summary = %q{A simple asset pipeline bundling of the rest jquery plugin.}
9
+ gem.homepage = ""
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "jquery-rest-rails"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Jquery::Rest::Rails::VERSION
17
+
18
+ gem.add_development_dependency "rake"
19
+ end
@@ -0,0 +1,10 @@
1
+ require "jquery-rest-rails/version"
2
+
3
+ module Jquery
4
+ module Rest
5
+ module Rails
6
+ class Engine < ::Rails::Engine
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ module Jquery
2
+ module Rest
3
+ module Rails
4
+ VERSION = "1.0.0"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,177 @@
1
+ /*
2
+ * Copyright (c) 2011 Lyconic, LLC.
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ * THE SOFTWARE.
21
+ */
22
+
23
+ (function($){
24
+
25
+ var _ajax = $.ajax, trim;
26
+
27
+ // support JS < 1.8.1
28
+ trim = String.prototype.trim || function () {
29
+ return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
30
+ }
31
+
32
+ // Will only use method override if $.restSetup.useMethodOverride is set to true
33
+ // Change the values of this global object if your method parameter is different.
34
+ $.restSetup = {
35
+ methodParam: '_method',
36
+ useMethodOverride: false,
37
+ verbs: {
38
+ create: 'POST',
39
+ update: 'PUT',
40
+ destroy: 'DELETE'
41
+ }
42
+ };
43
+
44
+ // collect csrf param & token from meta tags if they haven't already been set
45
+ $(document).ready(function(){
46
+ $.restSetup.csrfParam = $.restSetup.csrfParam || $('meta[name=csrf-param]').attr('content');
47
+ $.restSetup.csrfToken = $.restSetup.csrfToken || $('meta[name=csrf-token]').attr('content');
48
+ });
49
+
50
+ function collect_options (url, data, success, error) {
51
+ var options = { dataType: 'json' };
52
+ if (arguments.length === 1 && typeof arguments[0] !== "string") {
53
+ options = $.extend(options, url);
54
+ if ("url" in options)
55
+ if ("data" in options) {
56
+ fill_url(options.url, options.data);
57
+ }
58
+ } else {
59
+ // shift arguments if data argument was omitted
60
+ if ($.isFunction(data)) {
61
+ error = success;
62
+ success = data;
63
+ data = null;
64
+ }
65
+
66
+ url = fill_url(url, data);
67
+
68
+ options = $.extend(options, {
69
+ url: url,
70
+ data: data,
71
+ success: function (data, text, xhr) {
72
+ if (success) success.call(options.context || options, data, get_headers(xhr), xhr);
73
+ },
74
+ error: function (xhr) {
75
+ if (error) error.call(options.context || options, xhr, get_headers(xhr));
76
+ }
77
+ });
78
+ }
79
+ return options;
80
+ }
81
+
82
+ function fill_url (url, data) {
83
+ var key, u, val;
84
+ for (key in data) {
85
+ val = data[key];
86
+ u = url.replace('{'+key+'}', val);
87
+ if (u != url) {
88
+ url = u;
89
+ delete data[key];
90
+ }
91
+ }
92
+ return url;
93
+ }
94
+
95
+ function get_headers(xhr) {
96
+ // trim the headers because IE likes to include the blank line between the headers
97
+ // and the content as part of the headers
98
+ var headers = {}, stringHeaders = trim.call(xhr.getAllResponseHeaders());
99
+ $.each(stringHeaders.split("\n"), function (i, header) {
100
+ if (header.length) {
101
+ var matches = header.match(/^([\w\-]+):(.*)/);
102
+ if (matches.length === 3) headers[ matches[1] ] = trim.call(matches[2]);
103
+ }
104
+ });
105
+ xhr.responseHeaders = headers;
106
+ return headers;
107
+ }
108
+
109
+ $.ajax = function (settings) {
110
+ var csrfParam = new RegExp("(" + $.restSetup.csrfParam + "=)", "i"),
111
+ userBeforeSend = settings.beforeSend,
112
+ methodOverride;
113
+
114
+ if (typeof settings.data !== "string")
115
+ if (settings.data != null) {
116
+ settings.data = $.param(settings.data);
117
+ }
118
+
119
+ settings.data = settings.data || "";
120
+ if ($.restSetup.csrfParam && $.restSetup.csrfToken)
121
+ if (!/^(get)$/i.test(settings.type))
122
+ if (!csrfParam.test(settings.data)) {
123
+ settings.data += (settings.data ? "&" : "") + $.restSetup.csrfParam + '=' + $.restSetup.csrfToken;
124
+ }
125
+
126
+ if ($.restSetup.useMethodOverride)
127
+ if (!/^(get|post)$/i.test(settings.type)) {
128
+ methodOverride = settings.type.toUpperCase();
129
+ settings.data += (settings.data ? "&" : "") + $.restSetup.methodParam + '=' + settings.type.toLowerCase();
130
+ settings.type = "POST";
131
+ }
132
+
133
+ settings.beforeSend = function (xhr, ajaxSettings) {
134
+ var context = settings.context || settings,
135
+ contentType = settings.contentType,
136
+ resourceContentType = /.*\.(json|xml)/i.exec(settings.url);
137
+
138
+ if (!contentType) contentType = $.restSetup.contentType;
139
+ if (!contentType && resourceContentType) {
140
+ contentType = 'application/' + resourceContentType[1].toLowerCase();
141
+ }
142
+ if (settings.contentType != contentType) $.extend(settings, { contentType: contentType });
143
+
144
+ if ( methodOverride ) xhr.setRequestHeader('X-HTTP-Method-Override', methodOverride);
145
+
146
+ if ( $.isFunction(userBeforeSend) ) userBeforeSend.call(context, xhr, ajaxSettings);
147
+ }
148
+
149
+ return _ajax.call(this, settings);
150
+ }
151
+
152
+ $.read = function () {
153
+ var options = collect_options.apply(this, arguments);
154
+ options.type = 'GET';
155
+ return $.ajax(options);
156
+ }
157
+
158
+ $.create = function () {
159
+ var options = collect_options.apply(this, arguments);
160
+ options.type = $.restSetup.verbs.create;
161
+ return $.ajax(options);
162
+ }
163
+
164
+ $.update = function () {
165
+ var options = collect_options.apply(this, arguments);
166
+ options.type = $.restSetup.verbs.update;
167
+ return $.ajax(options);
168
+ }
169
+
170
+ $.destroy = function () {
171
+ var options = collect_options.apply(this, arguments);
172
+ options.type = $.restSetup.verbs.destroy;
173
+ return $.ajax(options);
174
+ }
175
+
176
+ })(jQuery);
177
+
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jquery-rest-rails
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - bokmann
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-03-19 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ type: :development
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ hash: 3
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ name: rake
32
+ version_requirements: *id001
33
+ prerelease: false
34
+ description: jquery.rest is a little bit of javascript for giving you crud verbs good for talking to rails controllers. Since I hate unversioned resources, I'm making it an asset gem.
35
+ email:
36
+ - dbock@codesherpas.com
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files: []
42
+
43
+ files:
44
+ - .gitignore
45
+ - Gemfile
46
+ - LICENSE
47
+ - README.md
48
+ - Rakefile
49
+ - jquery-rest-rails.gemspec
50
+ - lib/jquery-rest-rails.rb
51
+ - lib/jquery-rest-rails/version.rb
52
+ - vendor/assets/javascripts/jquery.rest.js
53
+ homepage: ""
54
+ licenses: []
55
+
56
+ post_install_message:
57
+ rdoc_options: []
58
+
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ hash: 3
67
+ segments:
68
+ - 0
69
+ version: "0"
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ hash: 3
76
+ segments:
77
+ - 0
78
+ version: "0"
79
+ requirements: []
80
+
81
+ rubyforge_project:
82
+ rubygems_version: 1.8.10
83
+ signing_key:
84
+ specification_version: 3
85
+ summary: A simple asset pipeline bundling of the rest jquery plugin.
86
+ test_files: []
87
+