polyfillrb 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -6
- data/lib/polyfill.js +11 -0
- data/lib/polyfillrb/rails/railtie.rb +14 -0
- data/lib/polyfillrb/rails/view_helper.rb +1 -1
- data/lib/polyfillrb/version.rb +1 -1
- data/lib/polyfillrb.rb +2 -57
- data/polyfillrb.gemspec +0 -1
- metadata +3 -4
- data/bin/polyfillrb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83b52ea541bf7e5477966fac05ba3a4d330f8e20
|
4
|
+
data.tar.gz: 89bb0281f93563920c8045c9ca3f1c97c71f8e22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4dba32c66efc3ff13f2ef3e7d6ff5c548da9a4655bcae4bcc6b04b84cfabcd4b5d7d8d0c86e9f9d7d6a54e0e6edef3fb990b1dde847996f1b3aa307684b2713d
|
7
|
+
data.tar.gz: 0bdb15103e6cf9b009cd44d8970397f6751d3425f969aa871596579994ae8e2c027283725936efe9d5084c66190f3b0c1cf11253ff129199c1d228e9442b0e2d
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Polyfillrb
|
1
|
+
# Polyfillrb [![Code Climate](https://codeclimate.com/github/blainekasten/polyfillrb/badges/gpa.svg)](https://codeclimate.com/github/blainekasten/polyfillrb)
|
2
2
|
|
3
3
|
A simple ruby wrapper for the phenominal [Polyfill.io Service by FTLabs](https://cdn.polyfill.io/v1/docs/) for Rails applications.
|
4
4
|
|
@@ -24,15 +24,11 @@ The library provides a simple view helper to load in the polyfills. Simply in an
|
|
24
24
|
|
25
25
|
### Installing
|
26
26
|
|
27
|
-
Add the gem to your Gemfile: `gem "polyfillrb", "~>1.
|
27
|
+
Add the gem to your Gemfile: `gem "polyfillrb", "~>1.1.0"`
|
28
28
|
|
29
|
-
Then you must run the command to build the polyfills. simply run:
|
30
|
-
|
31
|
-
%> polyfillrb init
|
32
29
|
|
33
30
|
### Future Plans
|
34
31
|
|
35
32
|
* Cache polyfills to avoid node IO calls (especially in production)
|
36
33
|
* Ensure we are doing the most performant javascript executions.
|
37
|
-
* Remove the need to run `polyfillrb init` on install. It'd be best if it could all be bundled up, but that has some issues to resolve in itself.
|
38
34
|
|
data/lib/polyfill.js
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var args = process.argv.slice(3);
|
4
|
+
|
5
|
+
process.stdout.write((function(uaString, minify){
|
6
|
+
return require(__dirname + '/polyfill-service/lib').getPolyfillString({
|
7
|
+
uaString: uaString,
|
8
|
+
minify: !!minify,
|
9
|
+
features: { default: { flags: [] } }
|
10
|
+
});
|
11
|
+
})(args[0], args[1]));
|
@@ -10,6 +10,20 @@ module Polyfillrb
|
|
10
10
|
include ::Polyfillrb::Rails::ViewHelper
|
11
11
|
end
|
12
12
|
end
|
13
|
+
|
14
|
+
# Preload the application with polyfills
|
15
|
+
initializer "polyfillrb.configure_rails_initialization" do |app|
|
16
|
+
|
17
|
+
# clone polyfill
|
18
|
+
::Rails.logger.info "Gathering Polyfill Library..."
|
19
|
+
%x( cd #{Polyfillrb::PROJECT_DIRECTORY} && git clone git@github.com:Financial-Times/polyfill-service.git )
|
20
|
+
|
21
|
+
# build the npm locals
|
22
|
+
::Rails.logger.info "Buidling Polyfills...\n this may take a minute"
|
23
|
+
%x( cd #{Polyfillrb::PROJECT_DIRECTORY}/polyfill-service && [ -d "node_modules" ] || npm install && grunt buildsources )
|
24
|
+
|
25
|
+
end
|
26
|
+
|
13
27
|
end
|
14
28
|
end
|
15
29
|
end
|
data/lib/polyfillrb/version.rb
CHANGED
data/lib/polyfillrb.rb
CHANGED
@@ -1,66 +1,11 @@
|
|
1
|
-
require 'polyfillrb/rails'
|
1
|
+
require 'polyfillrb/rails' if defined?(Rails)
|
2
2
|
|
3
3
|
module Polyfillrb
|
4
4
|
|
5
5
|
PROJECT_DIRECTORY = File.expand_path(File.dirname(__FILE__))
|
6
6
|
|
7
7
|
def self.get_polyfills(ua, minify=false)
|
8
|
-
|
9
|
-
# we console.log the results of the polyfillService so that we
|
10
|
-
# can read them from the IO instance.
|
11
|
-
#
|
12
|
-
# This feels kind of hacky, so in the future we can look into
|
13
|
-
# better ways to inject JS into this.
|
14
|
-
jscode = <<-JS
|
15
|
-
console.log(
|
16
|
-
require('#{PROJECT_DIRECTORY}/polyfill-service/lib').getPolyfillString({
|
17
|
-
uaString: '#{ua}',
|
18
|
-
minify: #{minify},
|
19
|
-
features: { default: { flags: [] } }
|
20
|
-
})
|
21
|
-
);
|
22
|
-
JS
|
23
|
-
|
24
|
-
# pump into a node runner
|
25
|
-
i = IO.popen('node', 'r+')
|
26
|
-
i.write(jscode)
|
27
|
-
i.close_write
|
28
|
-
|
29
|
-
# return the results
|
30
|
-
return i.read
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
#
|
35
|
-
# loads the javascript for the application
|
36
|
-
def self.init
|
37
|
-
# check for node and npm
|
38
|
-
|
39
|
-
|
40
|
-
# clone polyfill
|
41
|
-
puts "-- Cloning Polyfill js\n"
|
42
|
-
#%x( cd #{PROJECT_DIRECTORY} && git clone --branch v1.2.0 git@github.com:Financial-Times/polyfill-service.git )
|
43
|
-
%x( cd #{PROJECT_DIRECTORY} && git clone git@github.com:Financial-Times/polyfill-service.git )
|
44
|
-
|
45
|
-
# build the npm locals
|
46
|
-
puts "\n-- Grabbing dependencies\n"
|
47
|
-
%x( cd #{PROJECT_DIRECTORY}/polyfill-service && npm install )
|
48
|
-
|
49
|
-
# build the polyfills
|
50
|
-
#puts "\n-- Building polyfills\n"
|
51
|
-
#%x( cd #{PROJECT_DIRECTORY}/polyfill-service && grunt build )
|
52
|
-
end
|
53
|
-
|
54
|
-
def self.build
|
55
|
-
|
56
|
-
puts "-- Building polyfills \n"
|
57
|
-
%x( cd #{PROJECT_DIRECTORY}/polyfill-service && grunt buildsources )
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
|
-
|
62
|
-
def self.method_missing(method, blah, bleh)
|
63
|
-
puts "Polyfillrb does not support the action '#{method}'"
|
8
|
+
return %x( node #{PROJECT_DIRECTORY}/polyfill.js -p "#{ua}" #{minify})
|
64
9
|
end
|
65
10
|
|
66
11
|
end
|
data/polyfillrb.gemspec
CHANGED
@@ -13,7 +13,6 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.license = "MIT"
|
14
14
|
|
15
15
|
spec.files = `git ls-files -z`.split("\x0")
|
16
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
16
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
17
|
spec.require_paths = ["lib"]
|
19
18
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polyfillrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Blaine Kasten
|
@@ -27,8 +27,7 @@ dependencies:
|
|
27
27
|
description: Provides user agent specific polyfills to the browser easily in ruby
|
28
28
|
email:
|
29
29
|
- blainekasten@gmail.com
|
30
|
-
executables:
|
31
|
-
- polyfillrb
|
30
|
+
executables: []
|
32
31
|
extensions: []
|
33
32
|
extra_rdoc_files: []
|
34
33
|
files:
|
@@ -36,7 +35,7 @@ files:
|
|
36
35
|
- Gemfile
|
37
36
|
- README.md
|
38
37
|
- Rakefile
|
39
|
-
-
|
38
|
+
- lib/polyfill.js
|
40
39
|
- lib/polyfillrb.rb
|
41
40
|
- lib/polyfillrb/rails.rb
|
42
41
|
- lib/polyfillrb/rails/railtie.rb
|