polymer-rails 0.1.9 → 0.2.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 +22 -6
- data/app/assets/javascripts/polymer/{polymer.html.erb → polymer.html} +2 -2
- data/lib/generators/polymer/install/install_generator.rb +4 -0
- data/lib/generators/polymer/install/templates/bowerrc.json +3 -0
- data/lib/polymer-rails/component.rb +37 -0
- data/lib/polymer-rails/processors/components_processor.rb +55 -0
- data/lib/polymer-rails/railtie.rb +3 -0
- data/lib/polymer-rails/version.rb +1 -1
- data/lib/polymer-rails.rb +1 -0
- metadata +43 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f84b87114c47f492211cefef9c1f5782415d4ee1
|
4
|
+
data.tar.gz: 40edcd03135d89e01531ec02dfdccc4b6509c404
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d0f8e22cd158edc2bcb3f6d3c6605f2463ad50f59321fb2d972ee98f4fcc224f521f9677744ff847fd62a9a2730c9707cd90cd3c11df5db8dc638151f7458e7
|
7
|
+
data.tar.gz: 3c42634003742270b2151ae1f2779fa403e33113299dfda49aa7c5acd3ed9db71740dee709b92c968cebd83b22af33f1612c484c32179c914330b42b839c13d8
|
data/README.md
CHANGED
@@ -1,8 +1,20 @@
|
|
1
|
-
# Polymer
|
1
|
+
# Polymer-Rails
|
2
|
+
Want to get started with [web components](http://www.w3.org/TR/components-intro/)? Want to bring them into your Rails app? Easily build your own and use web components that are built by community in your Ruby on Rails Application. Poymer-rails helps you to do this:
|
3
|
+
|
4
|
+
1. Adds [polymer](http://polymer-project.org/) library to assets of your rails project.
|
5
|
+
|
6
|
+
2. Allows you to easily import web component with `<%= html_import_tag "my-component" %>` helper.
|
7
|
+
|
8
|
+
3. Allows you to import and package web components into assets pipeline, exactly as you would Javascript or CSS
|
9
|
+
|
10
|
+
#### Prefer using SASS or CoffeeSript?
|
11
|
+
|
12
|
+
Polymer-rails works well with compiling assets, such as CoffeeScript and Sass.
|
13
|
+
You can easily use external stylesheet or script tag references in your web component with any extension that Sprockets recognize.
|
14
|
+
Use `<link rel="stylesheet" href="application.sass">` for stylesheets and `<script src="application.coffee">` for javascripts.
|
15
|
+
This assets will be automatically compiled and required into component html file.
|
2
16
|
|
3
|
-
Adds [polymer](http://polymer-project.org/) to your rails project to help in building [web components](http://www.w3.org/TR/components-intro/).
|
4
17
|
|
5
|
-
Easily import web component with `<%= html_import_tag "my-component" %>`.
|
6
18
|
|
7
19
|
## Installation
|
8
20
|
|
@@ -45,6 +57,12 @@ Add your component to manifest file after requiring polymer:
|
|
45
57
|
|
46
58
|
And you can use your component in Rails application!
|
47
59
|
|
60
|
+
#### Polymer core/paper elements
|
61
|
+
|
62
|
+
Polymer team is working on set of core element which you can learn more about here http://www.polymer-project.org/docs/elements/core-elements.html. If you want to use them in your Rails application, checkout [polymer-core-rails](https://github.com/alchapone/polymer-core-rails) gem.
|
63
|
+
|
64
|
+
You may also be interested in Polymer paper elements, they are also available as [polymer-paper-rails](https://github.com/alchapone/polymer-paper-rails) gem.
|
65
|
+
|
48
66
|
## Example
|
49
67
|
|
50
68
|
See example Rails application here [http://polymer-rails-example.herokuapp.com/](http://polymer-rails-example.herokuapp.com/)
|
@@ -53,9 +71,7 @@ Source code can be found here [https://github.com/alchapone/polymer-rails-exampl
|
|
53
71
|
|
54
72
|
## Learn more
|
55
73
|
|
56
|
-
|
57
|
-
|
58
|
-
Also you can check out http://customelements.io/ or http://component.kitchen/ to see what components are already built by community.
|
74
|
+
You can check out http://customelements.io/ or http://component.kitchen/ to see what components are already built by community.
|
59
75
|
|
60
76
|
## Contributing
|
61
77
|
|
@@ -7,5 +7,5 @@ Code distributed by Google as part of the polymer project is also
|
|
7
7
|
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
8
8
|
-->
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
<link rel="import" href="layout.html" />
|
11
|
+
<script src="polymer.js"></script>
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Polymer
|
2
|
+
module Rails
|
3
|
+
class Component
|
4
|
+
|
5
|
+
def initialize(data)
|
6
|
+
@doc = ::Nokogiri::HTML.fragment(data)
|
7
|
+
end
|
8
|
+
|
9
|
+
def create_node(name, content)
|
10
|
+
node = ::Nokogiri::XML::Node.new(name, @doc)
|
11
|
+
node.content = content
|
12
|
+
node
|
13
|
+
end
|
14
|
+
|
15
|
+
def replace_node(node, name, content)
|
16
|
+
node.replace create_node(name, content)
|
17
|
+
end
|
18
|
+
|
19
|
+
def stylesheets
|
20
|
+
@doc.css("link[rel='stylesheet']")
|
21
|
+
end
|
22
|
+
|
23
|
+
def javascripts
|
24
|
+
@doc.css("script[src]")
|
25
|
+
end
|
26
|
+
|
27
|
+
def imports
|
28
|
+
@doc.css("link[rel='import']")
|
29
|
+
end
|
30
|
+
|
31
|
+
def stringify
|
32
|
+
@doc.inner_html
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'polymer-rails/component'
|
3
|
+
|
4
|
+
module Polymer
|
5
|
+
module Rails
|
6
|
+
class ComponentsProcessor < Sprockets::Processor
|
7
|
+
|
8
|
+
def initialize(context, data)
|
9
|
+
@context = context
|
10
|
+
@component = Component.new(data)
|
11
|
+
end
|
12
|
+
|
13
|
+
def process
|
14
|
+
inline_styles
|
15
|
+
inline_javascripts
|
16
|
+
require_imports
|
17
|
+
@component.stringify
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def require_imports
|
23
|
+
@component.imports.each do |import|
|
24
|
+
@context.require_asset component_path(import.attributes['href'].value)
|
25
|
+
import.remove
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def inline_javascripts
|
30
|
+
@component.javascripts.each do |script|
|
31
|
+
@component.replace_node(script, 'script', asset_content(script.attributes['src'].value))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def inline_styles
|
36
|
+
@component.stylesheets.each do |link|
|
37
|
+
@component.replace_node(link, 'style', asset_content(link.attributes['href'].value))
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def asset_content(file)
|
42
|
+
dir = File.dirname(@context.pathname)
|
43
|
+
path = File.absolute_path(file, dir)
|
44
|
+
@context.evaluate path
|
45
|
+
end
|
46
|
+
|
47
|
+
def component_path(file)
|
48
|
+
dir = File.dirname(@context.pathname)
|
49
|
+
dir.gsub!('/app/assets/', '/vendor/assets/') unless File.exist?(File.absolute_path(file, dir))
|
50
|
+
File.absolute_path(file, dir)
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -12,6 +12,9 @@ module Polymer
|
|
12
12
|
initializer :add_preprocessors do |app|
|
13
13
|
app.assets.register_mime_type "text/html", ".html"
|
14
14
|
app.assets.register_preprocessor "text/html", Polymer::Rails::DirectiveProcessor
|
15
|
+
app.assets.register_postprocessor 'text/html', :web do |context, data|
|
16
|
+
Polymer::Rails::ComponentsProcessor.new(context, data).process
|
17
|
+
end
|
15
18
|
end
|
16
19
|
|
17
20
|
end
|
data/lib/polymer-rails.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "polymer-rails/version"
|
2
2
|
require "polymer-rails/processors/directive_processor"
|
3
|
+
require "polymer-rails/processors/components_processor"
|
3
4
|
require "polymer-rails/helpers/asset_tag_helper"
|
4
5
|
require "polymer-rails/engine" if defined?(::Rails)
|
5
6
|
require "polymer-rails/railtie" if defined?(::Rails)
|
metadata
CHANGED
@@ -1,57 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polymer-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Chaplinsky
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 3.1.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.1.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: nokogiri
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.6.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.6.0
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- - ~>
|
45
|
+
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
47
|
version: '1.5'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- - ~>
|
52
|
+
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '1.5'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- - ~>
|
59
|
+
- - "~>"
|
46
60
|
- !ruby/object:Gem::Version
|
47
61
|
version: '0'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- - ~>
|
66
|
+
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 3.0.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 3.0.0
|
55
83
|
description: Use of web components and polymer-project in Ruby on Rails projects
|
56
84
|
email:
|
57
85
|
- alchapone@yandex.ru
|
@@ -63,15 +91,18 @@ files:
|
|
63
91
|
- Rakefile
|
64
92
|
- app/assets/javascripts/polymer/layout.html
|
65
93
|
- app/assets/javascripts/polymer/platform.js
|
66
|
-
- app/assets/javascripts/polymer/polymer.html
|
94
|
+
- app/assets/javascripts/polymer/polymer.html
|
67
95
|
- app/assets/javascripts/polymer/polymer.js
|
68
96
|
- lib/generators/polymer/component/component_generator.rb
|
69
97
|
- lib/generators/polymer/component/templates/component.html.erb
|
70
98
|
- lib/generators/polymer/install/install_generator.rb
|
71
99
|
- lib/generators/polymer/install/templates/application.html.erb
|
100
|
+
- lib/generators/polymer/install/templates/bowerrc.json
|
72
101
|
- lib/polymer-rails.rb
|
102
|
+
- lib/polymer-rails/component.rb
|
73
103
|
- lib/polymer-rails/engine.rb
|
74
104
|
- lib/polymer-rails/helpers/asset_tag_helper.rb
|
105
|
+
- lib/polymer-rails/processors/components_processor.rb
|
75
106
|
- lib/polymer-rails/processors/directive_processor.rb
|
76
107
|
- lib/polymer-rails/railtie.rb
|
77
108
|
- lib/polymer-rails/version.rb
|
@@ -85,17 +116,17 @@ require_paths:
|
|
85
116
|
- lib
|
86
117
|
required_ruby_version: !ruby/object:Gem::Requirement
|
87
118
|
requirements:
|
88
|
-
- -
|
119
|
+
- - ">="
|
89
120
|
- !ruby/object:Gem::Version
|
90
121
|
version: '0'
|
91
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
123
|
requirements:
|
93
|
-
- -
|
124
|
+
- - ">="
|
94
125
|
- !ruby/object:Gem::Version
|
95
126
|
version: '0'
|
96
127
|
requirements: []
|
97
128
|
rubyforge_project:
|
98
|
-
rubygems_version: 2.
|
129
|
+
rubygems_version: 2.2.2
|
99
130
|
signing_key:
|
100
131
|
specification_version: 4
|
101
132
|
summary: Use of web components with polymer with rails
|