jquery-cookie-rails 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +62 -0
- data/LICENSE +21 -0
- data/README.md +49 -0
- data/jquery-cookie-rails.gemspec +25 -0
- data/lib/generators/jquery-cookie-rails/install/install_generator.rb +36 -0
- data/lib/jquery-cookie-rails.rb +1 -0
- data/lib/jquery-cookie-rails/rails.rb +2 -0
- data/lib/jquery-cookie-rails/rails/engine.rb +6 -0
- data/lib/jquery-cookie-rails/rails/version.rb +6 -0
- data/vendor/assets/javascripts/jquery.cookie.js +47 -0
- metadata +94 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
inflection-js-rails (0.1.0)
|
5
|
+
railties (>= 3.2.0, < 5.0)
|
6
|
+
thor (~> 0.14)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionpack (3.2.3)
|
12
|
+
activemodel (= 3.2.3)
|
13
|
+
activesupport (= 3.2.3)
|
14
|
+
builder (~> 3.0.0)
|
15
|
+
erubis (~> 2.7.0)
|
16
|
+
journey (~> 1.0.1)
|
17
|
+
rack (~> 1.4.0)
|
18
|
+
rack-cache (~> 1.2)
|
19
|
+
rack-test (~> 0.6.1)
|
20
|
+
sprockets (~> 2.1.2)
|
21
|
+
activemodel (3.2.3)
|
22
|
+
activesupport (= 3.2.3)
|
23
|
+
builder (~> 3.0.0)
|
24
|
+
activesupport (3.2.3)
|
25
|
+
i18n (~> 0.6)
|
26
|
+
multi_json (~> 1.0)
|
27
|
+
builder (3.0.0)
|
28
|
+
erubis (2.7.0)
|
29
|
+
hike (1.2.1)
|
30
|
+
i18n (0.6.0)
|
31
|
+
journey (1.0.3)
|
32
|
+
json (1.6.6)
|
33
|
+
multi_json (1.2.0)
|
34
|
+
rack (1.4.1)
|
35
|
+
rack-cache (1.2)
|
36
|
+
rack (>= 0.4)
|
37
|
+
rack-ssl (1.3.2)
|
38
|
+
rack
|
39
|
+
rack-test (0.6.1)
|
40
|
+
rack (>= 1.0)
|
41
|
+
railties (3.2.3)
|
42
|
+
actionpack (= 3.2.3)
|
43
|
+
activesupport (= 3.2.3)
|
44
|
+
rack-ssl (~> 1.3.2)
|
45
|
+
rake (>= 0.8.7)
|
46
|
+
rdoc (~> 3.4)
|
47
|
+
thor (~> 0.14.6)
|
48
|
+
rake (0.9.2.2)
|
49
|
+
rdoc (3.12)
|
50
|
+
json (~> 1.4)
|
51
|
+
sprockets (2.1.2)
|
52
|
+
hike (~> 1.2)
|
53
|
+
rack (~> 1.0)
|
54
|
+
tilt (~> 1.1, != 1.3.0)
|
55
|
+
thor (0.14.6)
|
56
|
+
tilt (1.3.3)
|
57
|
+
|
58
|
+
PLATFORMS
|
59
|
+
ruby
|
60
|
+
|
61
|
+
DEPENDENCIES
|
62
|
+
inflection-js-rails!
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2012 Ryan Scott Lewis
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# jquery-cookie-rails
|
2
|
+
|
3
|
+
Adds [jquery-cookie](https://github.com/carhartl/jquery-cookie) to the Rails 3 asset pipeline.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
In your Gemfile, add the following lines:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem :assets do
|
11
|
+
gem 'jquery-cookie-rails'
|
12
|
+
end
|
13
|
+
```
|
14
|
+
|
15
|
+
Now run `bundle install`.
|
16
|
+
|
17
|
+
### Rails 3.0
|
18
|
+
|
19
|
+
This gem adds a single generator to Rails 3, `jquery-cookie:install`.
|
20
|
+
|
21
|
+
Running the generator will copy over the assets to your assets to your public directory.
|
22
|
+
|
23
|
+
### Rails 3.1 or greater
|
24
|
+
|
25
|
+
For Rails 3.1 and greater, the files will be added to the asset pipeline and available for you to use.
|
26
|
+
|
27
|
+
Simply the following to `app/assets/javascripts/application.js` after jQuery:
|
28
|
+
|
29
|
+
//= require jquery
|
30
|
+
//= require jquery.cookie`.
|
31
|
+
|
32
|
+
## Props
|
33
|
+
|
34
|
+
I didn't write any of the Javascript included within jquery.cookie.
|
35
|
+
All props goto [Klaus Hartl](http://github.com/carhartl).
|
36
|
+
|
37
|
+
## Contributing
|
38
|
+
|
39
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
40
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
41
|
+
* Fork the project
|
42
|
+
* Start a feature/bugfix branch
|
43
|
+
* Commit and push until you are happy with your contribution
|
44
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
45
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
46
|
+
|
47
|
+
## Copyright
|
48
|
+
|
49
|
+
Copyright (c) 2012 Ryan Scott Lewis. See LICENSE for details.
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
APP_NAME = File.basename(__FILE__, '.gemspec')
|
3
|
+
|
4
|
+
require File.expand_path("../lib/#{APP_NAME}/rails/version", __FILE__)
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = APP_NAME
|
8
|
+
s.version = JqueryCookie::Rails::VERSION
|
9
|
+
s.platform = Gem::Platform::RUBY
|
10
|
+
s.authors = ["Ryan Scott Lewis"]
|
11
|
+
s.email = ["c00lryguy@gmail.com"]
|
12
|
+
s.homepage = "http://rubygems.org/gems/#{APP_NAME}"
|
13
|
+
s.summary = "Use jquery-cookie with Rails 3"
|
14
|
+
s.description = "This gem provides jquery-cookie assets for your Rails 3 application."
|
15
|
+
|
16
|
+
s.required_rubygems_version = ">= 1.3.6"
|
17
|
+
|
18
|
+
s.add_dependency "railties", ">= 3.2.0", "< 5.0"
|
19
|
+
s.add_dependency "thor", "~> 0.14"
|
20
|
+
s.add_dependency "jquery-rails", "~> 2.0"
|
21
|
+
|
22
|
+
s.files = `git ls-files`.split("\n")
|
23
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
24
|
+
s.require_path = 'lib'
|
25
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'rails'
|
2
|
+
|
3
|
+
# Supply generator for Rails 3.0.x or if asset pipeline is not enabled
|
4
|
+
if ::Rails.version < "3.1" || !::Rails.application.config.assets.enabled
|
5
|
+
module JqueryCookie
|
6
|
+
module Generators
|
7
|
+
class InstallGenerator < ::Rails::Generators::Base
|
8
|
+
|
9
|
+
desc "This generator installs jquery-cookie #{JqueryCookie::Rails::JS_VERSION}"
|
10
|
+
source_root File.expand_path('../../../../../vendor/assets', __FILE__)
|
11
|
+
|
12
|
+
def copy_files
|
13
|
+
say_status("copying", "jquery-cookie (#{JqueryCookie::Rails::JS_VERSION})", :green)
|
14
|
+
copy_file "javascripts/jquery.cookie.js", "public/javascripts/jquery.cookie.js"
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
else
|
21
|
+
module JqueryCookie
|
22
|
+
module Generators
|
23
|
+
class InstallGenerator < ::Rails::Generators::Base
|
24
|
+
desc "Just show instructions so people will know what to do when mistakenly using generator for Rails 3.1 apps"
|
25
|
+
|
26
|
+
def do_nothing
|
27
|
+
say_status("deprecated", "You are using Rails 3.1 or the asset pipeline enabled, so this generator is not needed.")
|
28
|
+
say_status("", "The necessary files are already in your asset pipeline.")
|
29
|
+
say_status("", "Just add `//= require jquery.cookie` to your app/assets/javascripts/application.js")
|
30
|
+
say_status("", "If you do not want the asset pipeline enabled, you may turn it off in application.rb and re-run this generator.")
|
31
|
+
# ok, nothing
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'jquery-cookie-rails/rails'
|
@@ -0,0 +1,47 @@
|
|
1
|
+
/*!
|
2
|
+
* jQuery Cookie Plugin
|
3
|
+
* https://github.com/carhartl/jquery-cookie
|
4
|
+
*
|
5
|
+
* Copyright 2011, Klaus Hartl
|
6
|
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
7
|
+
* http://www.opensource.org/licenses/mit-license.php
|
8
|
+
* http://www.opensource.org/licenses/GPL-2.0
|
9
|
+
*/
|
10
|
+
(function($) {
|
11
|
+
$.cookie = function(key, value, options) {
|
12
|
+
|
13
|
+
// key and at least value given, set cookie...
|
14
|
+
if (arguments.length > 1 && (!/Object/.test(Object.prototype.toString.call(value)) || value === null || value === undefined)) {
|
15
|
+
options = $.extend({}, options);
|
16
|
+
|
17
|
+
if (value === null || value === undefined) {
|
18
|
+
options.expires = -1;
|
19
|
+
}
|
20
|
+
|
21
|
+
if (typeof options.expires === 'number') {
|
22
|
+
var days = options.expires, t = options.expires = new Date();
|
23
|
+
t.setDate(t.getDate() + days);
|
24
|
+
}
|
25
|
+
|
26
|
+
value = String(value);
|
27
|
+
|
28
|
+
return (document.cookie = [
|
29
|
+
encodeURIComponent(key), '=', options.raw ? value : encodeURIComponent(value),
|
30
|
+
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
|
31
|
+
options.path ? '; path=' + options.path : '',
|
32
|
+
options.domain ? '; domain=' + options.domain : '',
|
33
|
+
options.secure ? '; secure' : ''
|
34
|
+
].join(''));
|
35
|
+
}
|
36
|
+
|
37
|
+
// key and possibly options given, get cookie...
|
38
|
+
options = value || {};
|
39
|
+
var decode = options.raw ? function(s) { return s; } : decodeURIComponent;
|
40
|
+
|
41
|
+
var pairs = document.cookie.split('; ');
|
42
|
+
for (var i = 0, pair; pair = pairs[i] && pairs[i].split('='); i++) {
|
43
|
+
if (decode(pair[0]) === key) return decode(pair[1] || ''); // IE saves cookies with empty string as "c; ", e.g. without "=" as opposed to EOMB, thus pair[1] may be undefined
|
44
|
+
}
|
45
|
+
return null;
|
46
|
+
};
|
47
|
+
})(jQuery);
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jquery-cookie-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ryan Scott Lewis
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-21 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: railties
|
16
|
+
requirement: &70264675494560 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.2.0
|
22
|
+
- - <
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: '5.0'
|
25
|
+
type: :runtime
|
26
|
+
prerelease: false
|
27
|
+
version_requirements: *70264675494560
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: thor
|
30
|
+
requirement: &70264675492140 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ~>
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0.14'
|
36
|
+
type: :runtime
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: *70264675492140
|
39
|
+
- !ruby/object:Gem::Dependency
|
40
|
+
name: jquery-rails
|
41
|
+
requirement: &70264675490560 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '2.0'
|
47
|
+
type: :runtime
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: *70264675490560
|
50
|
+
description: This gem provides jquery-cookie assets for your Rails 3 application.
|
51
|
+
email:
|
52
|
+
- c00lryguy@gmail.com
|
53
|
+
executables: []
|
54
|
+
extensions: []
|
55
|
+
extra_rdoc_files: []
|
56
|
+
files:
|
57
|
+
- .gitignore
|
58
|
+
- Gemfile
|
59
|
+
- Gemfile.lock
|
60
|
+
- LICENSE
|
61
|
+
- README.md
|
62
|
+
- jquery-cookie-rails.gemspec
|
63
|
+
- lib/generators/jquery-cookie-rails/install/install_generator.rb
|
64
|
+
- lib/jquery-cookie-rails.rb
|
65
|
+
- lib/jquery-cookie-rails/rails.rb
|
66
|
+
- lib/jquery-cookie-rails/rails/engine.rb
|
67
|
+
- lib/jquery-cookie-rails/rails/version.rb
|
68
|
+
- vendor/assets/javascripts/jquery.cookie.js
|
69
|
+
homepage: http://rubygems.org/gems/jquery-cookie-rails
|
70
|
+
licenses: []
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
77
|
+
requirements:
|
78
|
+
- - ! '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 1.3.6
|
87
|
+
requirements: []
|
88
|
+
rubyforge_project:
|
89
|
+
rubygems_version: 1.8.10
|
90
|
+
signing_key:
|
91
|
+
specification_version: 3
|
92
|
+
summary: Use jquery-cookie with Rails 3
|
93
|
+
test_files: []
|
94
|
+
has_rdoc:
|