rack-lodash 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/Gemfile +21 -0
- data/LICENCE.txt +22 -0
- data/README.md +66 -0
- data/Rakefile +73 -0
- data/examples/config.rb +108 -0
- data/examples/config.ru +10 -0
- data/lib/rack/lodash.rb +113 -0
- data/lib/rack/lodash/version.rb +14 -0
- data/rack-lodash.gemspec +25 -0
- data/spec/rack_lodash_spec.rb +105 -0
- data/spec/spec_helper.rb +26 -0
- data/spec/support/shared/all_pages.rb +14 -0
- data/vendor/assets/javascript/libs/lodash/1.3.1/lodash.min.js +48 -0
- metadata +119 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 27de30b415fcd1dd0eb47e6c90984a682f99f783
|
4
|
+
data.tar.gz: 554897d26abf5322eb92a5a37462c19f42e0278d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 65348a5ee1780ae4e42d7ebd437f28dfb455a09391064f5ab37610e6ff7b787da0eae3b3c2924a4bc24ed7d60ccb686c225824be488bd587cd65107c868ae47e
|
7
|
+
data.tar.gz: 86d69e6e5181683e60aca81b3fccb94b902ef6f1082c089b3aa1b235cab9b1385117eb3b1cb57526e1983d4eb9025dee3973da3c38f6d27cd77c6144f54facec
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in rack-lodash.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
group :development do
|
7
|
+
gem "wirble"
|
8
|
+
gem "yard"
|
9
|
+
end
|
10
|
+
|
11
|
+
group :examples do
|
12
|
+
gem "sinatra"
|
13
|
+
gem "haml"
|
14
|
+
end
|
15
|
+
|
16
|
+
group :test do
|
17
|
+
gem "rspec"
|
18
|
+
gem "rack-test"
|
19
|
+
gem "simplecov"
|
20
|
+
gem "timecop"
|
21
|
+
end
|
data/LICENCE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Iain Barnett
|
2
|
+
|
3
|
+
MIT Licence
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# Rack::Lodash #
|
2
|
+
|
3
|
+
[Lo-dash](http://lodash.com/) CDN script tags and fallback in one neat package. Current version is for Lo-dash v#{Rack::Lodash::LODASH_VERSION}
|
4
|
+
|
5
|
+
## Why? ##
|
6
|
+
|
7
|
+
Because then I don't have to worry about versioning or fallback.
|
8
|
+
|
9
|
+
## Installation ##
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
gem 'rack-lodash'
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or even better:
|
20
|
+
|
21
|
+
$ bundle install --binstubs --path vendor
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
$ gem install rack-lodash -r
|
26
|
+
|
27
|
+
## Usage ##
|
28
|
+
|
29
|
+
In your rackup file or Sinatra class (or wherever you like to set up Rack middleware…)
|
30
|
+
|
31
|
+
use Rack::Lodash
|
32
|
+
|
33
|
+
Then wherever you need the script loaded (like in a layout file):
|
34
|
+
|
35
|
+
Rack::Lodash.cdn( env )
|
36
|
+
|
37
|
+
That's it. There are more options, check the docs.
|
38
|
+
|
39
|
+
|
40
|
+
### Version numbers ###
|
41
|
+
|
42
|
+
This library uses [semver](http://semver.org/) to version the **library**. That means the library version is ***not*** an indicator of quality but a way to manage changes. The version of Lo-Dash can be found in the lib/rack/lodash/version.rb file, or via the {Rack::Lodash::LODASH_VERSION} constant.
|
43
|
+
|
44
|
+
On top of that, version numbers will also change when new releases of Lo-Dash are supported.
|
45
|
+
|
46
|
+
* If Lo-Dash makes a major version jump, then this library will make a ***minor*** jump. That is because the API for the library has not really changed, but it is *possibly* a change that will break things.
|
47
|
+
* If Lo-Dash makes a minor version jump, then so will this library, for the same reason as above.
|
48
|
+
* I doubt point releases will be followed, but if so, it will also precipitate a minor jump in this library's version number. That's because even though Lo-Dash feel it's a point release, I'm not them, my responsibility is to users of this library and I'll take the cautious approach of making it a minor version number change.
|
49
|
+
|
50
|
+
As an example, if the current library version was 1.0.0 and Lo-Dash was at 2.0.0 and I made a change that I felt was major and breaking (to the Ruby library), I'd bump Rack::Lodash's version to 2.0.0. That the version numbers match between Rack::Lodash and the Lo-Dash script is of no significance, it's just coincidental.
|
51
|
+
If then Lo-Dash went to v2.1.0 and I decided to support that, I'd make the changes and bump Rack::Lodash's version to 2.1.0. That the version numbers match between Rack::Lodash and the Lo-Dash script is of no significance, it's just coincidental.
|
52
|
+
If then I made a minor change to the library's API that could be breaking I'd bump it to 2.2.0.
|
53
|
+
If I then added some more instructions I'd bump Rack::Lodash's version to 2.2.1.
|
54
|
+
If then Lo-Dash released version 3.0.0, I'd add it to the library, and bump Rack::Lodash's version to 2.3.0.
|
55
|
+
|
56
|
+
Only one version of Lo-Dash will be supported at a time. This is because the fallback script is shipped with the gem and I'd like to keep it as light as possible. It's also a headache to have more than one.
|
57
|
+
|
58
|
+
So basically, if you want to use a specific version of Lo-Dash, look for the library version that supports it via the {Rack::Lodash::LODASH_VERSION} constant. Don't rely on the version numbers of *this* library to tell you anything other than compatibility between versions of this library.
|
59
|
+
|
60
|
+
## Contributing
|
61
|
+
|
62
|
+
1. Fork it
|
63
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
64
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
65
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
66
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
|
4
|
+
desc "(Re-) generate documentation and place it in the docs/ dir. Open the index.html file in there to read it."
|
5
|
+
task :docs => [:"docs:environment", :"docs:yard"]
|
6
|
+
namespace :docs do
|
7
|
+
|
8
|
+
task :environment do
|
9
|
+
ENV["RACK_ENV"] = "documentation"
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'yard'
|
13
|
+
|
14
|
+
YARD::Rake::YardocTask.new :yard do |t|
|
15
|
+
t.files = ['lib/**/*.rb', 'app/*.rb', 'spec/**/*.rb']
|
16
|
+
t.options = ['-odocs/'] # optional
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
task :default => "spec"
|
22
|
+
|
23
|
+
task :spec => :"spec:run"
|
24
|
+
task :rspec => :spec
|
25
|
+
namespace :spec do
|
26
|
+
task :environment do
|
27
|
+
ENV["RACK_ENV"] = "test"
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "Run specs"
|
31
|
+
task :run, [:any_args] => :"spec:environment" do |t,args|
|
32
|
+
warn "Entering spec task."
|
33
|
+
any_args = args[:any_args] || ""
|
34
|
+
cmd = "bin/rspec #{any_args}"
|
35
|
+
warn cmd
|
36
|
+
system cmd
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
namespace :examples do
|
42
|
+
|
43
|
+
desc "Run the examples."
|
44
|
+
task :run do
|
45
|
+
exec "bundle exec rackup examples/config.ru"
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
namespace :cdn do
|
52
|
+
require 'open3'
|
53
|
+
desc "An availability check, for sanity"
|
54
|
+
task :check do
|
55
|
+
require_relative './lib/rack/lodash.rb'
|
56
|
+
Rack::Lodash::CDN.constants.each do |const|
|
57
|
+
url = "#{Rack::Lodash::CDN.const_get(const)}"
|
58
|
+
url = "http:#{url}" unless url.start_with? "http"
|
59
|
+
cmd = "curl -I #{url}"
|
60
|
+
puts cmd
|
61
|
+
puts catch(:status) {
|
62
|
+
Open3.popen3(cmd) do |_,stdout,_|
|
63
|
+
line = stdout.gets
|
64
|
+
throw :status, "Nothing for #{const}" if line.nil?
|
65
|
+
puts line.match("HTTP/1.1 404 Not Found") ?
|
66
|
+
"FAILED: #{const}" :
|
67
|
+
"PASSED: #{const}"
|
68
|
+
end
|
69
|
+
}
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
data/examples/config.rb
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'sinatra/base'
|
2
|
+
require 'haml'
|
3
|
+
require 'rack/lodash'
|
4
|
+
|
5
|
+
class App < Sinatra::Base
|
6
|
+
|
7
|
+
enable :inline_templates
|
8
|
+
use Rack::Lodash
|
9
|
+
|
10
|
+
get "/" do
|
11
|
+
output = <<STR
|
12
|
+
!!!
|
13
|
+
%body
|
14
|
+
%ul
|
15
|
+
%li
|
16
|
+
%a{ href: "/jsdelivr-cdn"} jsdelivr-cdn
|
17
|
+
%li
|
18
|
+
%a{ href: "/cloudflare-cdn"} cloudflare-cdn
|
19
|
+
%li
|
20
|
+
%a{ href: "/unspecified-cdn"} unspecified-cdn
|
21
|
+
%li
|
22
|
+
%a{ href: "/specified-via-use"} specified-via-use
|
23
|
+
STR
|
24
|
+
haml output
|
25
|
+
end
|
26
|
+
|
27
|
+
get "/jsdelivr-cdn" do
|
28
|
+
haml :index, :layout => :jsdelivr
|
29
|
+
end
|
30
|
+
|
31
|
+
get "/cloudflare-cdn" do
|
32
|
+
haml :index, :layout => :cloudflare
|
33
|
+
end
|
34
|
+
|
35
|
+
get "/unspecified-cdn" do
|
36
|
+
haml :index, :layout => :unspecified
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
# This is probably the one I'd use.
|
42
|
+
class App2 < Sinatra::Base
|
43
|
+
|
44
|
+
enable :inline_templates
|
45
|
+
use Rack::Lodash, :organisation => :jsdelivr
|
46
|
+
|
47
|
+
get "/" do
|
48
|
+
haml :index, :layout => :specified_via_use
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
__END__
|
53
|
+
|
54
|
+
@@jsdelivr
|
55
|
+
!!!
|
56
|
+
%head
|
57
|
+
= Rack::Lodash.cdn( env, :organisation => :jsdelivr )
|
58
|
+
%body
|
59
|
+
= yield
|
60
|
+
|
61
|
+
@@cloudflare
|
62
|
+
!!!
|
63
|
+
%head
|
64
|
+
= Rack::Lodash.cdn( env, :organisation => :cloudflare )
|
65
|
+
%body
|
66
|
+
= yield
|
67
|
+
|
68
|
+
@@unspecified
|
69
|
+
!!!
|
70
|
+
%head
|
71
|
+
= Rack::Lodash.cdn(env)
|
72
|
+
%body
|
73
|
+
= yield
|
74
|
+
|
75
|
+
@@specified_via_use
|
76
|
+
!!!
|
77
|
+
%head
|
78
|
+
= Rack::Lodash.cdn(env)
|
79
|
+
%body
|
80
|
+
= yield
|
81
|
+
|
82
|
+
@@index
|
83
|
+
|
84
|
+
%pre#example
|
85
|
+
:plain
|
86
|
+
var stooges = [
|
87
|
+
{ 'name': 'curly',
|
88
|
+
'quotes': ['Oh, a wise guy, eh?', 'Poifect!']
|
89
|
+
},
|
90
|
+
{ 'name': 'moe',
|
91
|
+
'quotes': ['Spread out!', 'You knucklehead!']
|
92
|
+
}
|
93
|
+
];
|
94
|
+
|
95
|
+
document.getElementById("placeholder").textContent= "<p>" + _.flatten(stooges, 'quotes') + "</p>";
|
96
|
+
|
97
|
+
#placeholder
|
98
|
+
:javascript
|
99
|
+
var stooges = [
|
100
|
+
{ 'name': 'curly',
|
101
|
+
'quotes': ['Oh, a wise guy, eh?', 'Poifect!']
|
102
|
+
},
|
103
|
+
{ 'name': 'moe',
|
104
|
+
'quotes': ['Spread out!', 'You knucklehead!']
|
105
|
+
}
|
106
|
+
];
|
107
|
+
|
108
|
+
document.getElementById("placeholder").textContent= "<p>" + _.flatten(stooges, 'quotes') + "</p>";
|
data/examples/config.ru
ADDED
data/lib/rack/lodash.rb
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
require "rack/lodash/version"
|
2
|
+
require "rack/jquery/helpers"
|
3
|
+
|
4
|
+
module Rack
|
5
|
+
class Lodash
|
6
|
+
include Rack::JQuery::Helpers # for caching
|
7
|
+
|
8
|
+
# Namespaced CDNs for convenience.
|
9
|
+
module CDN
|
10
|
+
|
11
|
+
# Script tags for the Media Temple CDN
|
12
|
+
CLOUDFLARE = "//cdnjs.cloudflare.com/ajax/libs/lodash.js/#{LODASH_VERSION}/lodash.min.js"
|
13
|
+
|
14
|
+
# Script tags for the jsDelivr CDN
|
15
|
+
JSDELIVR = "//cdn.jsdelivr.net/lodash/#{LODASH_VERSION}/lodash.backbone.min.js"
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
# The file name to use for the fallback route.
|
20
|
+
LODASH_FILE_NAME = "lodash-#{LODASH_VERSION}.min.js"
|
21
|
+
|
22
|
+
|
23
|
+
# This javascript checks if the Lodash object has loaded. If not, that most likely means the CDN is unreachable, so it uses the local minified Lodash.
|
24
|
+
FALLBACK = <<STR
|
25
|
+
<script type="text/javascript">
|
26
|
+
if (typeof _ == 'undefined') {
|
27
|
+
document.write(unescape("%3Cscript src='/js/#{LODASH_FILE_NAME}' type='text/javascript'%3E%3C/script%3E"))
|
28
|
+
};
|
29
|
+
</script>
|
30
|
+
STR
|
31
|
+
|
32
|
+
|
33
|
+
# @param [Hash] env The rack env.
|
34
|
+
# @param [Hash] opts Extra options.
|
35
|
+
# @options opts [Symbol] :organisation Choose which CDN to use, either :cloudflare or :jsdelivr. The default is :cloudflare. If an organisation was set via the Rack env this will override it.
|
36
|
+
# @return [String] The HTML script tags to get the CDN.
|
37
|
+
def self.cdn( env, opts={} )
|
38
|
+
organisation = opts[:organisation] ||
|
39
|
+
(env["rack.lodash"] && env["rack.lodash"]["organisation"]) ||
|
40
|
+
Rack::Lodash::DEFAULT_ORGANISATION
|
41
|
+
|
42
|
+
script = case organisation
|
43
|
+
when :cloudflare then CDN::CLOUDFLARE
|
44
|
+
when :jsdelivr then CDN::JSDELIVR
|
45
|
+
else CDN::CLOUDFLARE
|
46
|
+
end
|
47
|
+
"<script src='#{script}'></script>\n#{FALLBACK}"
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
# The default CDN to use.
|
52
|
+
DEFAULT_ORGANISATION = :cloudflare
|
53
|
+
|
54
|
+
|
55
|
+
# Default options hash for the middleware.
|
56
|
+
DEFAULT_OPTIONS = {
|
57
|
+
:http_path => "/js",
|
58
|
+
:organisation => DEFAULT_ORGANISATION
|
59
|
+
}
|
60
|
+
|
61
|
+
|
62
|
+
# @param [#call] app
|
63
|
+
# @param [Hash] options
|
64
|
+
# @option options [String] :http_path If you wish the Lodash fallback route to be "/js/lodash-1.3.1.min.js" (or whichever version this is at) then do nothing, that's the default. If you want the path to be "/assets/javascripts/lodash-1.3.1.min.js" then pass in `:http_path => "/assets/javascripts".
|
65
|
+
# @option options [Symbol] :organisation Choose which CDN to use, either :cloudflare or :jsdelivr. The default is :cloudflare.
|
66
|
+
# @example
|
67
|
+
# # The default:
|
68
|
+
# use Rack::Lodash
|
69
|
+
#
|
70
|
+
# # With a different route to the fallback:
|
71
|
+
# use Rack::Lodash, :http_path => "/assets/js"
|
72
|
+
#
|
73
|
+
# # With the CDN specified via the use statement
|
74
|
+
# use Rack::Lodash, :organisation => :jsdelivr
|
75
|
+
def initialize( app, options={} )
|
76
|
+
@app, @options = app, DEFAULT_OPTIONS.merge(options)
|
77
|
+
@http_path_to_lodash = ::File.join @options[:http_path], LODASH_FILE_NAME
|
78
|
+
@organisation = @options[:organisation]
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
# @param [Hash] env Rack request environment hash.
|
83
|
+
def call( env )
|
84
|
+
dup._call env
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
# For thread safety
|
89
|
+
# @param (see #call)
|
90
|
+
def _call( env )
|
91
|
+
env.merge! "rack.lodash" => {"organisation" => @organisation}
|
92
|
+
|
93
|
+
request = Rack::Request.new(env.dup)
|
94
|
+
if request.path_info == @http_path_to_lodash
|
95
|
+
response = Rack::Response.new
|
96
|
+
# for caching
|
97
|
+
response.headers.merge! caching_headers( LODASH_FILE_NAME, LODASH_VERSION_DATE)
|
98
|
+
|
99
|
+
# There's no need to test if the IF_MODIFIED_SINCE against the release date because the header will only be passed if the file was previously accessed by the requester, and the file is never updated. If it is updated then it is accessed by a different path.
|
100
|
+
if request.env['HTTP_IF_MODIFIED_SINCE']
|
101
|
+
response.status = 304
|
102
|
+
else
|
103
|
+
response.status = 200
|
104
|
+
response.write ::File.read( ::File.expand_path "../../../vendor/assets/javascript/libs/lodash/#{LODASH_VERSION}/lodash.min.js", __FILE__)
|
105
|
+
end
|
106
|
+
response.finish
|
107
|
+
else
|
108
|
+
@app.call(env)
|
109
|
+
end
|
110
|
+
end # call
|
111
|
+
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Rack
|
2
|
+
class Lodash
|
3
|
+
|
4
|
+
# The version of this library.
|
5
|
+
VERSION = "0.0.1"
|
6
|
+
|
7
|
+
# The version of Lo-dash it supports
|
8
|
+
LODASH_VERSION = "1.3.1"
|
9
|
+
|
10
|
+
# This is the release date of the Lo-dash file, it makes an easy "Last-Modified" date for setting the headers around caching.
|
11
|
+
# @todo remember to change Last-Modified with each release!
|
12
|
+
LODASH_VERSION_DATE = "Wed, 12 Jun 2013 15:54:39 +0100"
|
13
|
+
end
|
14
|
+
end
|
data/rack-lodash.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rack/lodash/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rack-lodash"
|
8
|
+
spec.version = Rack::Lodash::VERSION
|
9
|
+
spec.authors = ["Iain Barnett"]
|
10
|
+
spec.email = ["iainspeed@gmail.com"]
|
11
|
+
spec.description = %q{Lo-dash CDN script tags and fallback in one neat package. Current version is for Lo-dash v#{Rack::Lodash::LODASH_VERSION}}
|
12
|
+
spec.summary = %q{The description says it all.}
|
13
|
+
spec.homepage = "https://github.com/yb66/rack-jquery"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/).reject{|x| x.start_with?("vendor") && !x.include?(Rack::Lodash::LODASH_VERSION) }
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
spec.add_dependency("rack")
|
21
|
+
spec.add_dependency("rack-jquery-helpers")
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require_relative "../lib/rack/lodash.rb"
|
5
|
+
|
6
|
+
describe "The class methods" do
|
7
|
+
let(:env) {
|
8
|
+
{}
|
9
|
+
}
|
10
|
+
subject { Rack::Lodash.cdn env, opts }
|
11
|
+
context "Given an argument" do
|
12
|
+
context "of nil (the default)" do
|
13
|
+
let(:opts) { {} }
|
14
|
+
it { should == "<script src='#{Rack::Lodash::CDN::CLOUDFLARE}'></script>\n#{Rack::Lodash::FALLBACK}" }
|
15
|
+
end
|
16
|
+
context "of :jsdelivr" do
|
17
|
+
let(:opts) { {organisation: :jsdelivr} }
|
18
|
+
it { should == "<script src='#{Rack::Lodash::CDN::JSDELIVR}'></script>\n#{Rack::Lodash::FALLBACK}" }
|
19
|
+
end
|
20
|
+
context "of :cloudflare" do
|
21
|
+
let(:opts) { {organisation: :cloudflare} }
|
22
|
+
it { should == "<script src='#{Rack::Lodash::CDN::CLOUDFLARE}'></script>\n#{Rack::Lodash::FALLBACK}" }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "Inserting the CDN" do
|
28
|
+
include_context "All routes"
|
29
|
+
context "Check the examples run at all" do
|
30
|
+
before do
|
31
|
+
get "/"
|
32
|
+
end
|
33
|
+
it_should_behave_like "Any route"
|
34
|
+
end
|
35
|
+
context "jsDelivr CDN" do
|
36
|
+
before do
|
37
|
+
get "/jsdelivr-cdn"
|
38
|
+
end
|
39
|
+
it_should_behave_like "Any route"
|
40
|
+
subject { last_response.body }
|
41
|
+
let(:expected) { Rack::Lodash::CDN::JSDELIVR }
|
42
|
+
it { should include expected }
|
43
|
+
end
|
44
|
+
context "Unspecified CDN" do
|
45
|
+
before do
|
46
|
+
get "/unspecified-cdn"
|
47
|
+
end
|
48
|
+
it_should_behave_like "Any route"
|
49
|
+
subject { last_response.body }
|
50
|
+
let(:expected) { Rack::Lodash::CDN::CLOUDFLARE }
|
51
|
+
it { should include expected }
|
52
|
+
end
|
53
|
+
context "Cloudflare CDN" do
|
54
|
+
before do
|
55
|
+
get "/cloudflare-cdn"
|
56
|
+
end
|
57
|
+
it_should_behave_like "Any route"
|
58
|
+
subject { last_response.body }
|
59
|
+
let(:expected) { Rack::Lodash::CDN::CLOUDFLARE }
|
60
|
+
it { should include expected }
|
61
|
+
end
|
62
|
+
context "Specified CDN via the use statement" do
|
63
|
+
let(:app){ App2 }
|
64
|
+
before do
|
65
|
+
get "/"
|
66
|
+
end
|
67
|
+
it_should_behave_like "Any route"
|
68
|
+
subject { last_response.body }
|
69
|
+
let(:expected) { Rack::Lodash::CDN::JSDELIVR }
|
70
|
+
it { should include expected }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
require 'timecop'
|
76
|
+
require 'time'
|
77
|
+
|
78
|
+
describe "Serving the fallback lodash" do
|
79
|
+
include_context "All routes"
|
80
|
+
before do
|
81
|
+
get "/js/lodash-#{Rack::Lodash::LODASH_VERSION}.min.js"
|
82
|
+
end
|
83
|
+
it_should_behave_like "Any route"
|
84
|
+
subject { last_response.body }
|
85
|
+
let(:expected) { s = <<STR
|
86
|
+
/**
|
87
|
+
* @license
|
88
|
+
* Lo-Dash #{Rack::Lodash::LODASH_VERSION}
|
89
|
+
STR
|
90
|
+
s.strip
|
91
|
+
}
|
92
|
+
it { should start_with expected }
|
93
|
+
|
94
|
+
context "Re requests" do
|
95
|
+
before do
|
96
|
+
at_start = Time.parse(Rack::Lodash::LODASH_VERSION_DATE) + 60 * 60 * 24 * 180
|
97
|
+
Timecop.freeze at_start
|
98
|
+
get "/js/lodash-#{Rack::Lodash::LODASH_VERSION}.min.js"
|
99
|
+
Timecop.travel Time.now + 86400 # add a day
|
100
|
+
get "/js/lodash-#{Rack::Lodash::LODASH_VERSION}.min.js", {}, {"HTTP_IF_MODIFIED_SINCE" => Rack::Utils.rfc2109(at_start) }
|
101
|
+
end
|
102
|
+
subject { last_response }
|
103
|
+
its(:status) { should == 304 }
|
104
|
+
end
|
105
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'rspec'
|
4
|
+
Spec_dir = File.expand_path( File.dirname __FILE__ )
|
5
|
+
|
6
|
+
|
7
|
+
# code coverage
|
8
|
+
require 'simplecov'
|
9
|
+
SimpleCov.start do
|
10
|
+
add_filter "/vendor/"
|
11
|
+
add_filter "/bin/"
|
12
|
+
add_filter "/spec/"
|
13
|
+
end
|
14
|
+
|
15
|
+
require "rack/test"
|
16
|
+
ENV['RACK_ENV'] ||= 'test'
|
17
|
+
ENV["EXPECT_WITH"] ||= "racktest"
|
18
|
+
|
19
|
+
|
20
|
+
Dir[ File.join( Spec_dir, "/support/**/*.rb")].each do |f|
|
21
|
+
require f
|
22
|
+
end
|
23
|
+
|
24
|
+
RSpec.configure do |config|
|
25
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
26
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
config_path = File.expand_path '../../../examples/config.rb', File.dirname(__FILE__)
|
4
|
+
require_relative config_path
|
5
|
+
|
6
|
+
shared_context "All routes" do
|
7
|
+
include Rack::Test::Methods
|
8
|
+
let(:app){ App }
|
9
|
+
end
|
10
|
+
|
11
|
+
shared_examples_for "Any route" do
|
12
|
+
subject { last_response }
|
13
|
+
it { should be_ok }
|
14
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
/**
|
2
|
+
* @license
|
3
|
+
* Lo-Dash 1.3.1 (Custom Build) lodash.com/license
|
4
|
+
* Build: `lodash modern -o ./dist/lodash.js`
|
5
|
+
* Underscore.js 1.4.4 underscorejs.org/LICENSE
|
6
|
+
*/
|
7
|
+
;!function(n){function t(n,t,e){e=(e||0)-1;for(var r=n.length;++e<r;)if(n[e]===t)return e;return-1}function e(n,e){var r=typeof e;if(n=n.k,"boolean"==r||e==h)return n[e];"number"!=r&&"string"!=r&&(r="object");var u="number"==r?e:j+e;return n=n[r]||(n[r]={}),"object"==r?n[u]&&-1<t(n[u],e)?0:-1:n[u]?0:-1}function r(n){var t=this.k,e=typeof n;if("boolean"==e||n==h)t[n]=y;else{"number"!=e&&"string"!=e&&(e="object");var r="number"==e?n:j+n,u=t[e]||(t[e]={});"object"==e?(u[r]||(u[r]=[])).push(n)==this.b.length&&(t[e]=b):u[r]=y
|
8
|
+
}}function u(n){return n.charCodeAt(0)}function a(n,t){var e=n.m,r=t.m;if(n=n.l,t=t.l,n!==t){if(n>t||typeof n=="undefined")return 1;if(n<t||typeof t=="undefined")return-1}return e<r?-1:1}function o(n){var t=-1,e=n.length,u=l();u["false"]=u["null"]=u["true"]=u.undefined=b;var a=l();for(a.b=n,a.k=u,a.push=r;++t<e;)a.push(n[t]);return u.object===false?(p(a),h):a}function i(n){return"\\"+Q[n]}function f(){return m.pop()||[]}function l(){return d.pop()||{b:h,k:h,l:h,"false":b,m:0,leading:b,maxWait:0,"null":b,number:h,object:h,push:h,string:h,trailing:b,"true":b,undefined:b,n:h}
|
9
|
+
}function c(n){n.length=0,m.length<C&&m.push(n)}function p(n){var t=n.k;t&&p(t),n.b=n.k=n.l=n.object=n.number=n.string=n.n=h,d.length<C&&d.push(n)}function s(n,t,e){t||(t=0),typeof e=="undefined"&&(e=n?n.length:0);var r=-1;e=e-t||0;for(var u=Array(0>e?0:e);++r<e;)u[r]=n[t+r];return u}function v(r){function m(n){if(!n||ve.call(n)!=V)return b;var t=n.valueOf,e=typeof t=="function"&&(e=fe(t))&&fe(e);return e?n==e||fe(n)==e:it(n)}function d(n,t,e){if(!n||!L[typeof n])return n;t=t&&typeof e=="undefined"?t:tt.createCallback(t,e);
|
10
|
+
for(var r=-1,u=L[typeof n]&&Se(n),a=u?u.length:0;++r<a&&(e=u[r],!(t(n[e],e,n)===false)););return n}function C(n,t,e){var r;if(!n||!L[typeof n])return n;t=t&&typeof e=="undefined"?t:tt.createCallback(t,e);for(r in n)if(t(n[r],r,n)===false)break;return n}function Q(n,t,e){var r,u=n,a=u;if(!u)return a;for(var o=arguments,i=0,f=typeof e=="number"?2:o.length;++i<f;)if((u=o[i])&&L[typeof u])for(var l=-1,c=L[typeof u]&&Se(u),p=c?c.length:0;++l<p;)r=c[l],"undefined"==typeof a[r]&&(a[r]=u[r]);return a}function X(n,t,e){var r,u=n,a=u;
|
11
|
+
if(!u)return a;var o=arguments,i=0,f=typeof e=="number"?2:o.length;if(3<f&&"function"==typeof o[f-2])var l=tt.createCallback(o[--f-1],o[f--],2);else 2<f&&"function"==typeof o[f-1]&&(l=o[--f]);for(;++i<f;)if((u=o[i])&&L[typeof u])for(var c=-1,p=L[typeof u]&&Se(u),s=p?p.length:0;++c<s;)r=p[c],a[r]=l?l(a[r],u[r]):u[r];return a}function Z(n){var t,e=[];if(!n||!L[typeof n])return e;for(t in n)le.call(n,t)&&e.push(t);return e}function tt(n){return n&&typeof n=="object"&&!Ee(n)&&le.call(n,"__wrapped__")?n:new et(n)
|
12
|
+
}function et(n){this.__wrapped__=n}function rt(n,t,e,r){function u(){var r=arguments,l=o?this:t;return a||(n=t[i]),e.length&&(r=r.length?(r=Ce.call(r),f?r.concat(e):e.concat(r)):e),this instanceof u?(l=gt(n.prototype)?ye(n.prototype):{},r=n.apply(l,r),gt(r)?r:l):n.apply(l,r)}var a=vt(n),o=!e,i=t;if(o){var f=r;e=t}else if(!a){if(!r)throw new Yt;t=n}return u}function ut(n){return Ie[n]}function at(){var n=(n=tt.indexOf)===$t?t:n;return n}function ot(n){return function(t,e,r,u){return typeof e!="boolean"&&e!=h&&(u=r,r=u&&u[e]===t?g:e,e=b),r!=h&&(r=tt.createCallback(r,u)),n(t,e,r,u)
|
13
|
+
}}function it(n){var t,e;return n&&ve.call(n)==V&&(t=n.constructor,!vt(t)||t instanceof t)?(C(n,function(n,t){e=t}),e===g||le.call(n,e)):b}function ft(n){return Ae[n]}function lt(n,t,e,r,u,a){var o=n;if(typeof t!="boolean"&&t!=h&&(r=e,e=t,t=b),typeof e=="function"){if(e=typeof r=="undefined"?e:tt.createCallback(e,r,1),o=e(o),typeof o!="undefined")return o;o=n}if(r=gt(o)){var i=ve.call(o);if(!J[i])return o;var l=Ee(o)}if(!r||!t)return r?l?s(o):X({},o):o;switch(r=xe[i],i){case P:case K:return new r(+o);
|
14
|
+
case U:case H:return new r(o);case G:return r(o.source,A.exec(o))}i=!u,u||(u=f()),a||(a=f());for(var p=u.length;p--;)if(u[p]==n)return a[p];return o=l?r(o.length):{},l&&(le.call(n,"index")&&(o.index=n.index),le.call(n,"input")&&(o.input=n.input)),u.push(n),a.push(o),(l?wt:d)(n,function(n,r){o[r]=lt(n,t,e,g,u,a)}),i&&(c(u),c(a)),o}function ct(n){var t=[];return C(n,function(n,e){vt(n)&&t.push(e)}),t.sort()}function pt(n){for(var t=-1,e=Se(n),r=e.length,u={};++t<r;){var a=e[t];u[n[a]]=a}return u}function st(n,t,e,r,u,a){var o=e===k;
|
15
|
+
if(typeof e=="function"&&!o){e=tt.createCallback(e,r,2);var i=e(n,t);if(typeof i!="undefined")return!!i}if(n===t)return 0!==n||1/n==1/t;var l=typeof n,p=typeof t;if(n===n&&(!n||"function"!=l&&"object"!=l)&&(!t||"function"!=p&&"object"!=p))return b;if(n==h||t==h)return n===t;if(p=ve.call(n),l=ve.call(t),p==z&&(p=V),l==z&&(l=V),p!=l)return b;switch(p){case P:case K:return+n==+t;case U:return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case G:case H:return n==Xt(t)}if(l=p==W,!l){if(le.call(n,"__wrapped__")||le.call(t,"__wrapped__"))return st(n.__wrapped__||n,t.__wrapped__||t,e,r,u,a);
|
16
|
+
if(p!=V)return b;var p=n.constructor,s=t.constructor;if(p!=s&&(!vt(p)||!(p instanceof p&&vt(s)&&s instanceof s)))return b}for(s=!u,u||(u=f()),a||(a=f()),p=u.length;p--;)if(u[p]==n)return a[p]==t;var v=0,i=y;if(u.push(n),a.push(t),l){if(p=n.length,v=t.length,i=v==n.length,!i&&!o)return i;for(;v--;)if(l=p,s=t[v],o)for(;l--&&!(i=st(n[l],s,e,r,u,a)););else if(!(i=st(n[v],s,e,r,u,a)))break;return i}return C(t,function(t,o,f){return le.call(f,o)?(v++,i=le.call(n,o)&&st(n[o],t,e,r,u,a)):void 0}),i&&!o&&C(n,function(n,t,e){return le.call(e,t)?i=-1<--v:void 0
|
17
|
+
}),s&&(c(u),c(a)),i}function vt(n){return typeof n=="function"}function gt(n){return!(!n||!L[typeof n])}function yt(n){return typeof n=="number"||ve.call(n)==U}function ht(n){return typeof n=="string"||ve.call(n)==H}function bt(n,t,e){var r=arguments,u=0,a=2;if(!gt(n))return n;if(e===k)var o=r[3],i=r[4],l=r[5];else{var p=y,i=f(),l=f();typeof e!="number"&&(a=r.length),3<a&&"function"==typeof r[a-2]?o=tt.createCallback(r[--a-1],r[a--],2):2<a&&"function"==typeof r[a-1]&&(o=r[--a])}for(;++u<a;)(Ee(r[u])?wt:d)(r[u],function(t,e){var r,u,a=t,f=n[e];
|
18
|
+
if(t&&((u=Ee(t))||m(t))){for(a=i.length;a--;)if(r=i[a]==t){f=l[a];break}if(!r){var c;o&&(a=o(f,t),c=typeof a!="undefined")&&(f=a),c||(f=u?Ee(f)?f:[]:m(f)?f:{}),i.push(t),l.push(f),c||(f=bt(f,t,k,o,i,l))}}else o&&(a=o(f,t),typeof a=="undefined"&&(a=t)),typeof a!="undefined"&&(f=a);n[e]=f});return p&&(c(i),c(l)),n}function mt(n){for(var t=-1,e=Se(n),r=e.length,u=Mt(r);++t<r;)u[t]=n[e[t]];return u}function dt(n,t,e){var r=-1,u=at(),a=n?n.length:0,o=b;return e=(0>e?_e(0,a+e):e)||0,a&&typeof a=="number"?o=-1<(ht(n)?n.indexOf(t,e):u(n,t,e)):d(n,function(n){return++r<e?void 0:!(o=n===t)
|
19
|
+
}),o}function _t(n,t,e){var r=y;t=tt.createCallback(t,e),e=-1;var u=n?n.length:0;if(typeof u=="number")for(;++e<u&&(r=!!t(n[e],e,n)););else d(n,function(n,e,u){return r=!!t(n,e,u)});return r}function kt(n,t,e){var r=[];t=tt.createCallback(t,e),e=-1;var u=n?n.length:0;if(typeof u=="number")for(;++e<u;){var a=n[e];t(a,e,n)&&r.push(a)}else d(n,function(n,e,u){t(n,e,u)&&r.push(n)});return r}function jt(n,t,e){t=tt.createCallback(t,e),e=-1;var r=n?n.length:0;if(typeof r!="number"){var u;return d(n,function(n,e,r){return t(n,e,r)?(u=n,b):void 0
|
20
|
+
}),u}for(;++e<r;){var a=n[e];if(t(a,e,n))return a}}function wt(n,t,e){var r=-1,u=n?n.length:0;if(t=t&&typeof e=="undefined"?t:tt.createCallback(t,e),typeof u=="number")for(;++r<u&&t(n[r],r,n)!==false;);else d(n,t);return n}function Ct(n,t,e){var r=-1,u=n?n.length:0;if(t=tt.createCallback(t,e),typeof u=="number")for(var a=Mt(u);++r<u;)a[r]=t(n[r],r,n);else a=[],d(n,function(n,e,u){a[++r]=t(n,e,u)});return a}function xt(n,t,e){var r=-1/0,a=r;if(!t&&Ee(n)){e=-1;for(var o=n.length;++e<o;){var i=n[e];i>a&&(a=i)
|
21
|
+
}}else t=!t&&ht(n)?u:tt.createCallback(t,e),wt(n,function(n,e,u){e=t(n,e,u),e>r&&(r=e,a=n)});return a}function Ot(n,t){var e=-1,r=n?n.length:0;if(typeof r=="number")for(var u=Mt(r);++e<r;)u[e]=n[e][t];return u||Ct(n,t)}function Et(n,t,e,r){if(!n)return e;var u=3>arguments.length;t=tt.createCallback(t,r,4);var a=-1,o=n.length;if(typeof o=="number")for(u&&(e=n[++a]);++a<o;)e=t(e,n[a],a,n);else d(n,function(n,r,a){e=u?(u=b,n):t(e,n,r,a)});return e}function St(n,t,e,r){var u=n?n.length:0,a=3>arguments.length;
|
22
|
+
if(typeof u!="number")var o=Se(n),u=o.length;return t=tt.createCallback(t,r,4),wt(n,function(r,i,f){i=o?o[--u]:--u,e=a?(a=b,n[i]):t(e,n[i],i,f)}),e}function It(n,t,e){var r;t=tt.createCallback(t,e),e=-1;var u=n?n.length:0;if(typeof u=="number")for(;++e<u&&!(r=t(n[e],e,n)););else d(n,function(n,e,u){return!(r=t(n,e,u))});return!!r}function At(n){var r=-1,u=at(),a=n?n.length:0,i=ae.apply(Zt,Ce.call(arguments,1)),f=[],l=a>=w&&u===t;if(l){var c=o(i);c?(u=e,i=c):l=b}for(;++r<a;)c=n[r],0>u(i,c)&&f.push(c);
|
23
|
+
return l&&p(i),f}function Nt(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&t!=h){var a=-1;for(t=tt.createCallback(t,e);++a<u&&t(n[a],a,n);)r++}else if(r=t,r==h||e)return n[0];return s(n,0,ke(_e(0,r),u))}}function $t(n,e,r){if(typeof r=="number"){var u=n?n.length:0;r=0>r?_e(0,u+r):r||0}else if(r)return r=Ft(n,e),n[r]===e?r:-1;return n?t(n,e,r):-1}function Bt(n,t,e){if(typeof t!="number"&&t!=h){var r=0,u=-1,a=n?n.length:0;for(t=tt.createCallback(t,e);++u<a&&t(n[u],u,n);)r++}else r=t==h||e?1:_e(0,t);
|
24
|
+
return s(n,r)}function Ft(n,t,e,r){var u=0,a=n?n.length:u;for(e=e?tt.createCallback(e,r,1):Wt,t=e(t);u<a;)r=u+a>>>1,e(n[r])<t?u=r+1:a=r;return u}function Rt(n){for(var t=-1,e=n?xt(Ot(n,"length")):0,r=Mt(0>e?0:e);++t<e;)r[t]=Ot(n,t);return r}function Tt(n,t){for(var e=-1,r=n?n.length:0,u={};++e<r;){var a=n[e];t?u[a]=t[e]:u[a[0]]=a[1]}return u}function qt(n,t){return Oe.fastBind||ge&&2<arguments.length?ge.call.apply(ge,arguments):rt(n,t,Ce.call(arguments,2))}function Dt(n,t,e){function r(){ue(s),ue(v),l=0,s=v=h
|
25
|
+
}function u(){var t=g&&(!m||1<l);r(),t&&(p!==false&&(c=new Vt),i=n.apply(f,o))}function a(){r(),(g||p!==t)&&(c=new Vt,i=n.apply(f,o))}var o,i,f,l=0,c=0,p=b,s=h,v=h,g=y;if(t=_e(0,t||0),e===y)var m=y,g=b;else gt(e)&&(m=e.leading,p="maxWait"in e&&_e(t,e.maxWait||0),g="trailing"in e?e.trailing:g);return function(){if(o=arguments,f=this,l++,ue(v),p===false)m&&2>l&&(i=n.apply(f,o));else{var e=new Vt;!s&&!m&&(c=e);var r=p-(e-c);0<r?s||(s=se(a,r)):(ue(s),s=h,c=e,i=n.apply(f,o))}return t!==p&&(v=se(u,t)),i}}function zt(n){var t=Ce.call(arguments,1);
|
26
|
+
return se(function(){n.apply(g,t)},1)}function Wt(n){return n}function Pt(n){wt(ct(n),function(t){var e=tt[t]=n[t];tt.prototype[t]=function(){var n=this.__wrapped__,t=[n];return ce.apply(t,arguments),t=e.apply(tt,t),n&&typeof n=="object"&&n===t?this:new et(t)}})}function Kt(){return this.__wrapped__}r=r?nt.defaults(n.Object(),r,nt.pick(n,D)):n;var Mt=r.Array,Ut=r.Boolean,Vt=r.Date,Gt=r.Function,Ht=r.Math,Jt=r.Number,Lt=r.Object,Qt=r.RegExp,Xt=r.String,Yt=r.TypeError,Zt=[],ne=Lt.prototype,te=r._,ee=Qt("^"+Xt(ne.valueOf).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),re=Ht.ceil,ue=r.clearTimeout,ae=Zt.concat,oe=Ht.floor,ie=Gt.prototype.toString,fe=ee.test(fe=Lt.getPrototypeOf)&&fe,le=ne.hasOwnProperty,ce=Zt.push,pe=r.setImmediate,se=r.setTimeout,ve=ne.toString,ge=ee.test(ge=ve.bind)&&ge,ye=ee.test(ye=Lt.create)&&ye,he=ee.test(he=Mt.isArray)&&he,be=r.isFinite,me=r.isNaN,de=ee.test(de=Lt.keys)&&de,_e=Ht.max,ke=Ht.min,je=r.parseInt,we=Ht.random,Ce=Zt.slice,Ht=ee.test(r.attachEvent),Ht=ge&&!/\n|true/.test(ge+Ht),xe={};
|
27
|
+
xe[W]=Mt,xe[P]=Ut,xe[K]=Vt,xe[M]=Gt,xe[V]=Lt,xe[U]=Jt,xe[G]=Qt,xe[H]=Xt,et.prototype=tt.prototype;var Oe=tt.support={};Oe.fastBind=ge&&!Ht,tt.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:N,variable:"",imports:{_:tt}};var Ee=he,Se=de?function(n){return gt(n)?de(n):[]}:Z,Ie={"&":"&","<":"<",">":">",'"':""","'":"'"},Ae=pt(Ie),Ut=ot(function $e(n,t,e){for(var r=-1,u=n?n.length:0,a=[];++r<u;){var o=n[r];e&&(o=e(o,r,n)),Ee(o)?ce.apply(a,t?o:$e(o)):a.push(o)
|
28
|
+
}return a}),Ne=ot(function(n,r,u){var a=-1,i=at(),l=n?n.length:0,s=[],v=!r&&l>=w&&i===t,g=u||v?f():s;if(v){var y=o(g);y?(i=e,g=y):(v=b,g=u?g:(c(g),s))}for(;++a<l;){var y=n[a],h=u?u(y,a,n):y;(r?!a||g[g.length-1]!==h:0>i(g,h))&&((u||v)&&g.push(h),s.push(y))}return v?(c(g.b),p(g)):u&&c(g),s});return Ht&&Y&&typeof pe=="function"&&(zt=qt(pe,r)),pe=8==je(B+"08")?je:function(n,t){return je(ht(n)?n.replace(F,""):n,t||0)},tt.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0
|
29
|
+
}},tt.assign=X,tt.at=function(n){for(var t=-1,e=ae.apply(Zt,Ce.call(arguments,1)),r=e.length,u=Mt(r);++t<r;)u[t]=n[e[t]];return u},tt.bind=qt,tt.bindAll=function(n){for(var t=1<arguments.length?ae.apply(Zt,Ce.call(arguments,1)):ct(n),e=-1,r=t.length;++e<r;){var u=t[e];n[u]=qt(n[u],n)}return n},tt.bindKey=function(n,t){return rt(n,t,Ce.call(arguments,2),k)},tt.compact=function(n){for(var t=-1,e=n?n.length:0,r=[];++t<e;){var u=n[t];u&&r.push(u)}return r},tt.compose=function(){var n=arguments;return function(){for(var t=arguments,e=n.length;e--;)t=[n[e].apply(this,t)];
|
30
|
+
return t[0]}},tt.countBy=function(n,t,e){var r={};return t=tt.createCallback(t,e),wt(n,function(n,e,u){e=Xt(t(n,e,u)),le.call(r,e)?r[e]++:r[e]=1}),r},tt.createCallback=function(n,t,e){if(n==h)return Wt;var r=typeof n;if("function"!=r){if("object"!=r)return function(t){return t[n]};var u=Se(n);return function(t){for(var e=u.length,r=b;e--&&(r=st(t[u[e]],n[u[e]],k)););return r}}return typeof t=="undefined"||$&&!$.test(ie.call(n))?n:1===e?function(e){return n.call(t,e)}:2===e?function(e,r){return n.call(t,e,r)
|
31
|
+
}:4===e?function(e,r,u,a){return n.call(t,e,r,u,a)}:function(e,r,u){return n.call(t,e,r,u)}},tt.debounce=Dt,tt.defaults=Q,tt.defer=zt,tt.delay=function(n,t){var e=Ce.call(arguments,2);return se(function(){n.apply(g,e)},t)},tt.difference=At,tt.filter=kt,tt.flatten=Ut,tt.forEach=wt,tt.forIn=C,tt.forOwn=d,tt.functions=ct,tt.groupBy=function(n,t,e){var r={};return t=tt.createCallback(t,e),wt(n,function(n,e,u){e=Xt(t(n,e,u)),(le.call(r,e)?r[e]:r[e]=[]).push(n)}),r},tt.initial=function(n,t,e){if(!n)return[];
|
32
|
+
var r=0,u=n.length;if(typeof t!="number"&&t!=h){var a=u;for(t=tt.createCallback(t,e);a--&&t(n[a],a,n);)r++}else r=t==h||e?1:t||r;return s(n,0,ke(_e(0,u-r),u))},tt.intersection=function(n){for(var r=arguments,u=r.length,a=-1,i=f(),l=-1,s=at(),v=n?n.length:0,g=[],y=f();++a<u;){var h=r[a];i[a]=s===t&&(h?h.length:0)>=w&&o(a?r[a]:y)}n:for(;++l<v;){var b=i[0],h=n[l];if(0>(b?e(b,h):s(y,h))){for(a=u,(b||y).push(h);--a;)if(b=i[a],0>(b?e(b,h):s(r[a],h)))continue n;g.push(h)}}for(;u--;)(b=i[u])&&p(b);return c(i),c(y),g
|
33
|
+
},tt.invert=pt,tt.invoke=function(n,t){var e=Ce.call(arguments,2),r=-1,u=typeof t=="function",a=n?n.length:0,o=Mt(typeof a=="number"?a:0);return wt(n,function(n){o[++r]=(u?t:n[t]).apply(n,e)}),o},tt.keys=Se,tt.map=Ct,tt.max=xt,tt.memoize=function(n,t){function e(){var r=e.cache,u=j+(t?t.apply(this,arguments):arguments[0]);return le.call(r,u)?r[u]:r[u]=n.apply(this,arguments)}return e.cache={},e},tt.merge=bt,tt.min=function(n,t,e){var r=1/0,a=r;if(!t&&Ee(n)){e=-1;for(var o=n.length;++e<o;){var i=n[e];
|
34
|
+
i<a&&(a=i)}}else t=!t&&ht(n)?u:tt.createCallback(t,e),wt(n,function(n,e,u){e=t(n,e,u),e<r&&(r=e,a=n)});return a},tt.omit=function(n,t,e){var r=at(),u=typeof t=="function",a={};if(u)t=tt.createCallback(t,e);else var o=ae.apply(Zt,Ce.call(arguments,1));return C(n,function(n,e,i){(u?!t(n,e,i):0>r(o,e))&&(a[e]=n)}),a},tt.once=function(n){var t,e;return function(){return t?e:(t=y,e=n.apply(this,arguments),n=h,e)}},tt.pairs=function(n){for(var t=-1,e=Se(n),r=e.length,u=Mt(r);++t<r;){var a=e[t];u[t]=[a,n[a]]
|
35
|
+
}return u},tt.partial=function(n){return rt(n,Ce.call(arguments,1))},tt.partialRight=function(n){return rt(n,Ce.call(arguments,1),h,k)},tt.pick=function(n,t,e){var r={};if(typeof t!="function")for(var u=-1,a=ae.apply(Zt,Ce.call(arguments,1)),o=gt(n)?a.length:0;++u<o;){var i=a[u];i in n&&(r[i]=n[i])}else t=tt.createCallback(t,e),C(n,function(n,e,u){t(n,e,u)&&(r[e]=n)});return r},tt.pluck=Ot,tt.range=function(n,t,e){n=+n||0,e=+e||1,t==h&&(t=n,n=0);var r=-1;t=_e(0,re((t-n)/e));for(var u=Mt(t);++r<t;)u[r]=n,n+=e;
|
36
|
+
return u},tt.reject=function(n,t,e){return t=tt.createCallback(t,e),kt(n,function(n,e,r){return!t(n,e,r)})},tt.rest=Bt,tt.shuffle=function(n){var t=-1,e=n?n.length:0,r=Mt(typeof e=="number"?e:0);return wt(n,function(n){var e=oe(we()*(++t+1));r[t]=r[e],r[e]=n}),r},tt.sortBy=function(n,t,e){var r=-1,u=n?n.length:0,o=Mt(typeof u=="number"?u:0);for(t=tt.createCallback(t,e),wt(n,function(n,e,u){var a=o[++r]=l();a.l=t(n,e,u),a.m=r,a.n=n}),u=o.length,o.sort(a);u--;)n=o[u],o[u]=n.n,p(n);return o},tt.tap=function(n,t){return t(n),n
|
37
|
+
},tt.throttle=function(n,t,e){var r=y,u=y;return e===false?r=b:gt(e)&&(r="leading"in e?e.leading:r,u="trailing"in e?e.trailing:u),e=l(),e.leading=r,e.maxWait=t,e.trailing=u,n=Dt(n,t,e),p(e),n},tt.times=function(n,t,e){n=-1<(n=+n)?n:0;var r=-1,u=Mt(n);for(t=tt.createCallback(t,e,1);++r<n;)u[r]=t(r);return u},tt.toArray=function(n){return n&&typeof n.length=="number"?s(n):mt(n)},tt.transform=function(n,t,e,r){var u=Ee(n);return t=tt.createCallback(t,r,4),e==h&&(u?e=[]:(r=n&&n.constructor,e=gt(r&&r.prototype)?ye(r&&r.prototype):{})),(u?wt:d)(n,function(n,r,u){return t(e,n,r,u)
|
38
|
+
}),e},tt.union=function(n){return Ee(n)||(arguments[0]=n?Ce.call(n):Zt),Ne(ae.apply(Zt,arguments))},tt.uniq=Ne,tt.unzip=Rt,tt.values=mt,tt.where=kt,tt.without=function(n){return At(n,Ce.call(arguments,1))},tt.wrap=function(n,t){return function(){var e=[n];return ce.apply(e,arguments),t.apply(this,e)}},tt.zip=function(n){return n?Rt(arguments):[]},tt.zipObject=Tt,tt.collect=Ct,tt.drop=Bt,tt.each=wt,tt.extend=X,tt.methods=ct,tt.object=Tt,tt.select=kt,tt.tail=Bt,tt.unique=Ne,Pt(tt),tt.chain=tt,tt.prototype.chain=function(){return this
|
39
|
+
},tt.clone=lt,tt.cloneDeep=function(n,t,e){return lt(n,y,t,e)},tt.contains=dt,tt.escape=function(n){return n==h?"":Xt(n).replace(T,ut)},tt.every=_t,tt.find=jt,tt.findIndex=function(n,t,e){var r=-1,u=n?n.length:0;for(t=tt.createCallback(t,e);++r<u;)if(t(n[r],r,n))return r;return-1},tt.findKey=function(n,t,e){var r;return t=tt.createCallback(t,e),d(n,function(n,e,u){return t(n,e,u)?(r=e,b):void 0}),r},tt.has=function(n,t){return n?le.call(n,t):b},tt.identity=Wt,tt.indexOf=$t,tt.isArguments=function(n){return ve.call(n)==z
|
40
|
+
},tt.isArray=Ee,tt.isBoolean=function(n){return n===y||n===false||ve.call(n)==P},tt.isDate=function(n){return n?typeof n=="object"&&ve.call(n)==K:b},tt.isElement=function(n){return n?1===n.nodeType:b},tt.isEmpty=function(n){var t=y;if(!n)return t;var e=ve.call(n),r=n.length;return e==W||e==H||e==z||e==V&&typeof r=="number"&&vt(n.splice)?!r:(d(n,function(){return t=b}),t)},tt.isEqual=st,tt.isFinite=function(n){return be(n)&&!me(parseFloat(n))},tt.isFunction=vt,tt.isNaN=function(n){return yt(n)&&n!=+n
|
41
|
+
},tt.isNull=function(n){return n===h},tt.isNumber=yt,tt.isObject=gt,tt.isPlainObject=m,tt.isRegExp=function(n){return n?typeof n=="object"&&ve.call(n)==G:b},tt.isString=ht,tt.isUndefined=function(n){return typeof n=="undefined"},tt.lastIndexOf=function(n,t,e){var r=n?n.length:0;for(typeof e=="number"&&(r=(0>e?_e(0,r+e):ke(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},tt.mixin=Pt,tt.noConflict=function(){return r._=te,this},tt.parseInt=pe,tt.random=function(n,t){n==h&&t==h&&(t=1),n=+n||0,t==h?(t=n,n=0):t=+t||0;
|
42
|
+
var e=we();return n%1||t%1?n+ke(e*(t-n+parseFloat("1e-"+((e+"").length-1))),t):n+oe(e*(t-n+1))},tt.reduce=Et,tt.reduceRight=St,tt.result=function(n,t){var e=n?n[t]:g;return vt(e)?n[t]():e},tt.runInContext=v,tt.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Se(n).length},tt.some=It,tt.sortedIndex=Ft,tt.template=function(n,t,e){var r=tt.templateSettings;n||(n=""),e=Q({},e,r);var u,a=Q({},e.imports,r.imports),r=Se(a),a=mt(a),o=0,f=e.interpolate||R,l="__p+='",f=Qt((e.escape||R).source+"|"+f.source+"|"+(f===N?I:R).source+"|"+(e.evaluate||R).source+"|$","g");
|
43
|
+
n.replace(f,function(t,e,r,a,f,c){return r||(r=a),l+=n.slice(o,c).replace(q,i),e&&(l+="'+__e("+e+")+'"),f&&(u=y,l+="';"+f+";__p+='"),r&&(l+="'+((__t=("+r+"))==null?'':__t)+'"),o=c+t.length,t}),l+="';\n",f=e=e.variable,f||(e="obj",l="with("+e+"){"+l+"}"),l=(u?l.replace(x,""):l).replace(O,"$1").replace(E,"$1;"),l="function("+e+"){"+(f?"":e+"||("+e+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}";try{var c=Gt(r,"return "+l).apply(g,a)
|
44
|
+
}catch(p){throw p.source=l,p}return t?c(t):(c.source=l,c)},tt.unescape=function(n){return n==h?"":Xt(n).replace(S,ft)},tt.uniqueId=function(n){var t=++_;return Xt(n==h?"":n)+t},tt.all=_t,tt.any=It,tt.detect=jt,tt.findWhere=jt,tt.foldl=Et,tt.foldr=St,tt.include=dt,tt.inject=Et,d(tt,function(n,t){tt.prototype[t]||(tt.prototype[t]=function(){var t=[this.__wrapped__];return ce.apply(t,arguments),n.apply(tt,t)})}),tt.first=Nt,tt.last=function(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&t!=h){var a=u;
|
45
|
+
for(t=tt.createCallback(t,e);a--&&t(n[a],a,n);)r++}else if(r=t,r==h||e)return n[u-1];return s(n,_e(0,u-r))}},tt.take=Nt,tt.head=Nt,d(tt,function(n,t){tt.prototype[t]||(tt.prototype[t]=function(t,e){var r=n(this.__wrapped__,t,e);return t==h||e&&typeof t!="function"?r:new et(r)})}),tt.VERSION="1.3.1",tt.prototype.toString=function(){return Xt(this.__wrapped__)},tt.prototype.value=Kt,tt.prototype.valueOf=Kt,wt(["join","pop","shift"],function(n){var t=Zt[n];tt.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)
|
46
|
+
}}),wt(["push","reverse","sort","unshift"],function(n){var t=Zt[n];tt.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),wt(["concat","slice","splice"],function(n){var t=Zt[n];tt.prototype[n]=function(){return new et(t.apply(this.__wrapped__,arguments))}}),tt}var g,y=!0,h=null,b=!1,m=[],d=[],_=0,k={},j=+new Date+"",w=75,C=40,x=/\b__p\+='';/g,O=/\b(__p\+=)''\+/g,E=/(__e\(.*?\)|\b__t\))\+'';/g,S=/&(?:amp|lt|gt|quot|#39);/g,I=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,A=/\w*$/,N=/<%=([\s\S]+?)%>/g,$=($=/\bthis\b/)&&$.test(v)&&$,B=" \t\x0B\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",F=RegExp("^["+B+"]*0+(?=.$)"),R=/($^)/,T=/[&<>"']/g,q=/['\n\r\t\u2028\u2029\\]/g,D="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),z="[object Arguments]",W="[object Array]",P="[object Boolean]",K="[object Date]",M="[object Function]",U="[object Number]",V="[object Object]",G="[object RegExp]",H="[object String]",J={};
|
47
|
+
J[M]=b,J[z]=J[W]=J[P]=J[K]=J[U]=J[V]=J[G]=J[H]=y;var L={"boolean":b,"function":y,object:y,number:b,string:b,undefined:b},Q={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},X=L[typeof exports]&&exports,Y=L[typeof module]&&module&&module.exports==X&&module,Z=L[typeof global]&&global;!Z||Z.global!==Z&&Z.window!==Z||(n=Z);var nt=v();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=nt, define(function(){return nt})):X&&!X.nodeType?Y?(Y.exports=nt)._=nt:X._=nt:n._=nt
|
48
|
+
}(this);
|
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rack-lodash
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Iain Barnett
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rack
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rack-jquery-helpers
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Lo-dash CDN script tags and fallback in one neat package. Current version
|
70
|
+
is for Lo-dash v#{Rack::Lodash::LODASH_VERSION}
|
71
|
+
email:
|
72
|
+
- iainspeed@gmail.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- .gitignore
|
78
|
+
- .rspec
|
79
|
+
- Gemfile
|
80
|
+
- LICENCE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- examples/config.rb
|
84
|
+
- examples/config.ru
|
85
|
+
- lib/rack/lodash.rb
|
86
|
+
- lib/rack/lodash/version.rb
|
87
|
+
- rack-lodash.gemspec
|
88
|
+
- spec/rack_lodash_spec.rb
|
89
|
+
- spec/spec_helper.rb
|
90
|
+
- spec/support/shared/all_pages.rb
|
91
|
+
- vendor/assets/javascript/libs/lodash/1.3.1/lodash.min.js
|
92
|
+
homepage: https://github.com/yb66/rack-jquery
|
93
|
+
licenses:
|
94
|
+
- MIT
|
95
|
+
metadata: {}
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - '>='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
requirements: []
|
111
|
+
rubyforge_project:
|
112
|
+
rubygems_version: 2.0.3
|
113
|
+
signing_key:
|
114
|
+
specification_version: 4
|
115
|
+
summary: The description says it all.
|
116
|
+
test_files:
|
117
|
+
- spec/rack_lodash_spec.rb
|
118
|
+
- spec/spec_helper.rb
|
119
|
+
- spec/support/shared/all_pages.rb
|