serviceworker-rails 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/CHANGELOG.md +16 -0
- data/Gemfile +2 -4
- data/README.md +5 -3
- data/bin/_guard-core +1 -0
- data/bin/guard +1 -0
- data/lib/generators/serviceworker/templates/serviceworker.js +64 -53
- data/lib/serviceworker/rails/version.rb +1 -1
- data/lib/serviceworker/route.rb +1 -0
- data/serviceworker-rails.gemspec +2 -1
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31552ed751cd1b86fdd2c30a11e4ecb131e4e947
|
4
|
+
data.tar.gz: 9afb5f219f579eef75b06f99d69bbacfa67fc8c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 335912fa3a5c4910004163a289e863467cde8eb5a5d96b9bade63287abd4e1c244944741a599c2c7f56c106d442b83eb7b8671916f7bdb61a6120316ea719588
|
7
|
+
data.tar.gz: f7ec9e6be9ad4dc3cf67f96dbbf14d1fc2c6345c59ba4eddf1d11575b9ac2cf30dec32a6314cbc565b69997b7526b76b4ef66b3b4bbc6616d2d5879b873c1d54
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
### 0.5.2 - 2017-01-07
|
2
|
+
|
3
|
+
* enhancements
|
4
|
+
* Enable generated serviceworker.js with improved fetch logic
|
5
|
+
* bug fixes
|
6
|
+
* Omit application.js from generated serviceworker.js to prevent circular
|
7
|
+
sprockets requires
|
8
|
+
|
9
|
+
### 0.5.1 - 2016-11-17
|
10
|
+
|
11
|
+
* enhancements
|
12
|
+
* Add support for Rails 3
|
13
|
+
* bug fixes
|
14
|
+
* Fix syntax error in generated serviceworker.js
|
15
|
+
* Remove duplicate line in generated manifest.json (@brandonhilkert)
|
16
|
+
|
1
17
|
### 0.5.0 - 2016-11-10
|
2
18
|
|
3
19
|
* enhancements
|
data/Gemfile
CHANGED
@@ -4,12 +4,10 @@ source "https://rubygems.org"
|
|
4
4
|
gemspec
|
5
5
|
|
6
6
|
group :development, :test do
|
7
|
-
gem "rubocop", "0.39.0"
|
8
|
-
|
9
7
|
unless ENV["TRAVIS"]
|
8
|
+
gem "guard", require: false
|
9
|
+
gem "guard-minitest", require: false
|
10
10
|
gem "pry"
|
11
11
|
gem "pry-byebug", platforms: [:mri]
|
12
|
-
gem "guard"
|
13
|
-
gem "guard-minitest"
|
14
12
|
end
|
15
13
|
end
|
data/README.md
CHANGED
@@ -81,6 +81,8 @@ It will also make the following modifications to existing files:
|
|
81
81
|
* Injects tags into the `head` of `app/views/layouts/application.html.erb` for
|
82
82
|
linking to the web app manifest
|
83
83
|
|
84
|
+
**NOTE** Given that Service Worker operates in a separate browser thread, outside the context of your web pages, you don't want to include `serviceworker.js` script in your `application.js`. So if you have a line like `require_tree .` in your `application.js` file, you'll either need to move your `serviceworker.js` to another location or replace `require_tree` with something more explicit.
|
85
|
+
|
84
86
|
To learn more about each of the changes or to perform the set up yourself, check
|
85
87
|
out the manual setup section below.
|
86
88
|
|
@@ -157,7 +159,7 @@ if (navigator.serviceWorker) {
|
|
157
159
|
|
158
160
|
You may also want to create a `manifest.json` file to make your web app installable.
|
159
161
|
|
160
|
-
```
|
162
|
+
```javascript
|
161
163
|
// app/assets/javascripts/manifest.json
|
162
164
|
{
|
163
165
|
"name": "My Progressive Rails App",
|
@@ -224,7 +226,7 @@ function onFetch(event) {
|
|
224
226
|
if (request.method !== 'GET') { return; }
|
225
227
|
|
226
228
|
event.respondWith(
|
227
|
-
fetch(request)
|
229
|
+
fetch(request) // first, the network
|
228
230
|
.catch(function fallback() {
|
229
231
|
caches.match(request).then(function(response) { // then, the cache
|
230
232
|
response || caches.match("/offline.html"); // then, /offline cache
|
@@ -287,7 +289,7 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
287
289
|
|
288
290
|
## Contributing
|
289
291
|
|
290
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
292
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/rossta/serviceworker-rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
291
293
|
|
292
294
|
## License
|
293
295
|
|
data/bin/_guard-core
CHANGED
data/bin/guard
CHANGED
@@ -1,53 +1,64 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
//
|
11
|
-
//
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
//
|
30
|
-
//
|
31
|
-
//
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
//
|
42
|
-
|
43
|
-
|
44
|
-
//
|
45
|
-
|
46
|
-
//
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
//
|
52
|
-
|
53
|
-
|
1
|
+
var CACHE_VERSION = 'v1'
|
2
|
+
var CACHE_NAME = 'sw-cache-' + CACHE_VERSION;
|
3
|
+
|
4
|
+
function onInstall(event) {
|
5
|
+
console.log('[Serviceworker]', "Installing!", event);
|
6
|
+
event.waitUntil(
|
7
|
+
caches.open(CACHE_NAME).then(function prefill(cache) {
|
8
|
+
return cache.addAll([
|
9
|
+
|
10
|
+
// make sure serviceworker.js is not required by application.js
|
11
|
+
// if you want to reference application.js from here
|
12
|
+
'<%%#= asset_path "application.js" %>',
|
13
|
+
|
14
|
+
'<%%= asset_path "application.css" %>',
|
15
|
+
|
16
|
+
'/offline.html',
|
17
|
+
|
18
|
+
]);
|
19
|
+
})
|
20
|
+
);
|
21
|
+
}
|
22
|
+
|
23
|
+
function onActivate(event) {
|
24
|
+
console.log('[Serviceworker]', "Activating!", event);
|
25
|
+
event.waitUntil(
|
26
|
+
caches.keys().then(function(cacheNames) {
|
27
|
+
return Promise.all(
|
28
|
+
cacheNames.filter(function(cacheName) {
|
29
|
+
// Return true if you want to remove this cache,
|
30
|
+
// but remember that caches are shared across
|
31
|
+
// the whole origin
|
32
|
+
return key.indexOf(CACHE_VERSION) !== 0;
|
33
|
+
}).map(function(cacheName) {
|
34
|
+
return caches.delete(cacheName);
|
35
|
+
})
|
36
|
+
);
|
37
|
+
})
|
38
|
+
);
|
39
|
+
}
|
40
|
+
|
41
|
+
// Borrowed from https://github.com/TalAter/UpUp
|
42
|
+
function onFetch(event) {
|
43
|
+
event.respondWith(
|
44
|
+
// try to return untouched request from network first
|
45
|
+
fetch(event.request).catch(function() {
|
46
|
+
// if it fails, try to return request from the cache
|
47
|
+
return caches.match(event.request).then(function(response) {
|
48
|
+
if (response) {
|
49
|
+
return response;
|
50
|
+
}
|
51
|
+
// if not found in cache, return default offline content for navigate requests
|
52
|
+
if (event.request.mode === 'navigate' ||
|
53
|
+
(event.request.method === 'GET' && event.request.headers.get('accept').includes('text/html'))) {
|
54
|
+
console.log('[Serviceworker]', "Fetching offline content", event);
|
55
|
+
return caches.match('/offline.html');
|
56
|
+
}
|
57
|
+
})
|
58
|
+
})
|
59
|
+
);
|
60
|
+
}
|
61
|
+
|
62
|
+
self.addEventListener('install', onInstall);
|
63
|
+
self.addEventListener('activate', onActivate);
|
64
|
+
self.addEventListener('fetch', onFetch);
|
data/lib/serviceworker/route.rb
CHANGED
data/serviceworker-rails.gemspec
CHANGED
@@ -23,9 +23,10 @@ Gem::Specification.new do |spec|
|
|
23
23
|
|
24
24
|
spec.add_development_dependency "sprockets-rails"
|
25
25
|
spec.add_development_dependency "bundler", "~> 1.11"
|
26
|
-
spec.add_development_dependency "rake", "~>
|
26
|
+
spec.add_development_dependency "rake", "~> 11.0"
|
27
27
|
spec.add_development_dependency "minitest", "~> 5.0"
|
28
28
|
spec.add_development_dependency "rack-test"
|
29
|
+
spec.add_development_dependency "rubocop", "0.46.0"
|
29
30
|
spec.add_development_dependency "rails"
|
30
31
|
spec.add_development_dependency "appraisal", "~> 2.1.0"
|
31
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serviceworker-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ross Kaffenberger
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '11.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '11.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: minitest
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.46.0
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.46.0
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: rails
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -201,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
201
215
|
version: '0'
|
202
216
|
requirements: []
|
203
217
|
rubyforge_project:
|
204
|
-
rubygems_version: 2.5.
|
218
|
+
rubygems_version: 2.5.1
|
205
219
|
signing_key:
|
206
220
|
specification_version: 4
|
207
221
|
summary: ServiceWorker for Rails 3+
|