serviceworker-rails 0.5.4 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +4 -3
- data/gemfiles/rails_3.gemfile +2 -3
- data/gemfiles/rails_4.gemfile +2 -3
- data/gemfiles/rails_5.gemfile +2 -3
- data/lib/generators/serviceworker/install_generator.rb +15 -2
- data/lib/generators/serviceworker/templates/offline.html +1 -1
- data/lib/serviceworker/rails/handler.rb +19 -1
- data/lib/serviceworker/rails/version.rb +1 -1
- data/serviceworker-rails.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e58a2ae3f4679e8cd32a024d0114d5a924a174a
|
4
|
+
data.tar.gz: 474f2390c03df7be5efb55d7f173b40dd863c259
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b212fcdba3d949901fb95462fda9472e9c27d241542c7303949d87eff1183e0c492c77596d01ddb70e41bb86f30e4eecd717a2403bb4edfea6da52724eb78d95
|
7
|
+
data.tar.gz: 331f5ea58dbd378e481397ff48219a80e113aff428c904a93044f6b68cf613fa7f00c9530776397a87b8fde6bfffbba78431c9ea5ba701b8cb32face5a1b2b0d
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/rossta/serviceworker-rails.svg?branch=master)](https://travis-ci.org/rossta/serviceworker-rails)
|
4
4
|
[![Code Climate](https://codeclimate.com/github/rossta/serviceworker-rails/badges/gpa.svg)](https://codeclimate.com/github/rossta/serviceworker-rails)
|
5
|
-
[![Coverage Status](https://coveralls.io/repos/github/rossta/serviceworker-rails/badge.svg?branch=master)](https://coveralls.io/github/rossta/serviceworker-rails?branch=master)
|
6
5
|
|
7
6
|
Turn your Rails app into a Progressive Web App. Use [Service Worker](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API) with the Rails asset pipeline.
|
8
7
|
|
@@ -100,9 +99,11 @@ Create a JavaScript file called `app/assets/javascripts/serviceworker.js.erb`:
|
|
100
99
|
// app/assets/javascripts/serviceworker.js.erb
|
101
100
|
console.log('[Service Worker] Hello world!');
|
102
101
|
|
102
|
+
var CACHE_NAME = 'v1-cached-assets'
|
103
|
+
|
103
104
|
function onInstall(event) {
|
104
105
|
event.waitUntil(
|
105
|
-
caches.open(
|
106
|
+
caches.open(CACHE_NAME).then(function prefill(cache) {
|
106
107
|
return cache.addAll([
|
107
108
|
'<%= asset_path "application.js" %>',
|
108
109
|
'<%= asset_path "application.css" %>',
|
@@ -239,7 +240,7 @@ function onFetch(event) {
|
|
239
240
|
// See https://jakearchibald.com/2014/offline-cookbook/#on-network-response for more examples
|
240
241
|
}
|
241
242
|
|
242
|
-
self.addEventListener('
|
243
|
+
self.addEventListener('fetch', onFetch);
|
243
244
|
```
|
244
245
|
|
245
246
|
## Configuration
|
data/gemfiles/rails_3.gemfile
CHANGED
@@ -6,11 +6,10 @@ gem "rails", "~> 3.2"
|
|
6
6
|
gem "test-unit", "~> 3.0"
|
7
7
|
|
8
8
|
group :development, :test do
|
9
|
-
gem "
|
9
|
+
gem "guard", :require => false
|
10
|
+
gem "guard-minitest", :require => false
|
10
11
|
gem "pry"
|
11
12
|
gem "pry-byebug", :platforms => [:mri]
|
12
|
-
gem "guard"
|
13
|
-
gem "guard-minitest"
|
14
13
|
end
|
15
14
|
|
16
15
|
gemspec :path => "../"
|
data/gemfiles/rails_4.gemfile
CHANGED
@@ -5,11 +5,10 @@ source "https://rubygems.org"
|
|
5
5
|
gem "rails", "~> 4.2"
|
6
6
|
|
7
7
|
group :development, :test do
|
8
|
-
gem "
|
8
|
+
gem "guard", :require => false
|
9
|
+
gem "guard-minitest", :require => false
|
9
10
|
gem "pry"
|
10
11
|
gem "pry-byebug", :platforms => [:mri]
|
11
|
-
gem "guard"
|
12
|
-
gem "guard-minitest"
|
13
12
|
end
|
14
13
|
|
15
14
|
gemspec :path => "../"
|
data/gemfiles/rails_5.gemfile
CHANGED
@@ -5,11 +5,10 @@ source "https://rubygems.org"
|
|
5
5
|
gem "rails", "~> 5.0"
|
6
6
|
|
7
7
|
group :development, :test do
|
8
|
-
gem "
|
8
|
+
gem "guard", :require => false
|
9
|
+
gem "guard-minitest", :require => false
|
9
10
|
gem "pry"
|
10
11
|
gem "pry-byebug", :platforms => [:mri]
|
11
|
-
gem "guard"
|
12
|
-
gem "guard-minitest"
|
13
12
|
end
|
14
13
|
|
15
14
|
gemspec :path => "../"
|
@@ -31,9 +31,14 @@ module Serviceworker
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def update_application_layout
|
34
|
+
layout = detect_layout
|
34
35
|
snippet = %(<link rel="manifest" href="/manifest.json" />)
|
35
36
|
snippet << %(\n<meta name="apple-mobile-web-app-capable" content="yes">)
|
36
|
-
|
37
|
+
unless layout
|
38
|
+
conditional_warn "Could not locate application layout. To insert manifest tags manually, use:\n\n#{snippet}\n"
|
39
|
+
return
|
40
|
+
end
|
41
|
+
insert_into_file layout, snippet, before: "</head>\n"
|
37
42
|
end
|
38
43
|
|
39
44
|
def add_offline_html
|
@@ -55,7 +60,7 @@ module Serviceworker
|
|
55
60
|
end
|
56
61
|
|
57
62
|
def detect_layout
|
58
|
-
layouts = %w[.html.erb .html.haml .html.slim].map do |ext|
|
63
|
+
layouts = %w[.html.erb .html.haml .html.slim .erb .haml .slim].map do |ext|
|
59
64
|
layouts_dir("application#{ext}")
|
60
65
|
end
|
61
66
|
layouts.find { |layout| File.exist?(layout) }
|
@@ -80,6 +85,14 @@ module Serviceworker
|
|
80
85
|
def join(*paths)
|
81
86
|
File.expand_path(File.join(*paths), destination_root)
|
82
87
|
end
|
88
|
+
|
89
|
+
def conditional_warn(warning)
|
90
|
+
silenced? or warn warning
|
91
|
+
end
|
92
|
+
|
93
|
+
def silenced?
|
94
|
+
ENV["RAILS_ENV"] == "test"
|
95
|
+
end
|
83
96
|
end
|
84
97
|
end
|
85
98
|
end
|
@@ -29,7 +29,25 @@ module ServiceWorker
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def asset_path(path)
|
32
|
-
|
32
|
+
if controller_helpers.respond_to?(:compute_asset_path)
|
33
|
+
controller_helpers.compute_asset_path(path)
|
34
|
+
else
|
35
|
+
logical_asset_path(path)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def controller_helpers
|
40
|
+
::ActionController::Base.helpers
|
41
|
+
end
|
42
|
+
|
43
|
+
def logical_asset_path(path)
|
44
|
+
asset_path = controller_helpers.asset_path(path)
|
45
|
+
uri = URI.parse(asset_path)
|
46
|
+
uri.host = nil
|
47
|
+
uri.scheme = nil
|
48
|
+
uri.to_s
|
49
|
+
rescue URI::InvalidURIError
|
50
|
+
asset_path
|
33
51
|
end
|
34
52
|
end
|
35
53
|
end
|
data/serviceworker-rails.gemspec
CHANGED
@@ -29,5 +29,5 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_development_dependency "rubocop", "0.46.0"
|
30
30
|
spec.add_development_dependency "rails"
|
31
31
|
spec.add_development_dependency "appraisal", "~> 2.1.0"
|
32
|
-
spec.add_development_dependency "
|
32
|
+
spec.add_development_dependency "simplecov"
|
33
33
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ross Kaffenberger
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -137,7 +137,7 @@ dependencies:
|
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: 2.1.0
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
140
|
+
name: simplecov
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
143
|
- - ">="
|
@@ -229,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
229
229
|
version: '0'
|
230
230
|
requirements: []
|
231
231
|
rubyforge_project:
|
232
|
-
rubygems_version: 2.5.
|
232
|
+
rubygems_version: 2.5.2
|
233
233
|
signing_key:
|
234
234
|
specification_version: 4
|
235
235
|
summary: ServiceWorker for Rails 3+
|