polymer-rails 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +6 -6
- data/lib/generators/polymer/component/component_generator.rb +9 -2
- data/lib/generators/polymer/component/templates/component.css.erb +3 -0
- data/lib/generators/polymer/component/templates/component.html.erb +3 -9
- data/lib/generators/polymer/component/templates/component.js.erb +3 -0
- data/lib/polymer-rails/processors/components_processor.rb +16 -7
- data/lib/polymer-rails/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eef638cd7e83a08318fd6df97fe5826a3bb4a84e
|
4
|
+
data.tar.gz: 6b7a005ea359b3e380e0580d9ca0c64029901e31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17cc9af4f73200621d3fed91a29a70febdea309c4b54c102a0567a366f2690445880d1830d4debe866bc091e1f697d3136812e15b73cfa2f4c1ee363788777d9
|
7
|
+
data.tar.gz: 6ae629accb1778e8998c3479af457f15eb12800b925a2c2f89b026001eb7b2501a09be394ba5407b0e63a523e8e801a151d8198fa69067e6553007d683af5874
|
data/README.md
CHANGED
@@ -10,9 +10,9 @@ Want to get started with [web components](http://www.w3.org/wiki/WebComponents/
|
|
10
10
|
#### Prefer using SASS or CoffeeSript?
|
11
11
|
|
12
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
|
14
|
-
Use `<link rel="stylesheet" href="application.sass">` for stylesheets and `<script src="application.coffee">` for javascripts.
|
13
|
+
You can easily use external stylesheet or script tag references in your web component `<link rel="stylesheet" href="application.css">` for stylesheets and `<script src="application.js">` for javascripts.
|
15
14
|
This assets will be automatically compiled and required into component html file.
|
15
|
+
* Note that if you're using sass or coffe precompilation, assets are required to use '.css.sass' and '.js.coffee' extensions.*
|
16
16
|
|
17
17
|
|
18
18
|
|
@@ -36,7 +36,7 @@ Or install it yourself as:
|
|
36
36
|
|
37
37
|
$ rails g polymer:install
|
38
38
|
|
39
|
-
- This generator adds `//= require polymer/
|
39
|
+
- This generator adds `//= require polymer/webcomponents` into `application.js` manifest file
|
40
40
|
- Creates `app/assets/components` and `application.html` manifest file where you can include all your components.
|
41
41
|
- Creates `vendor/assets/components` directory for third-party web components.
|
42
42
|
|
@@ -47,12 +47,12 @@ to import web components manifest to your app.
|
|
47
47
|
|
48
48
|
$ rails g polymer:component <component-name>
|
49
49
|
|
50
|
-
This generates new `<component-name>` component directory and
|
50
|
+
This generates new `<component-name>` component directory and `.html`, `.css`, `.js` files of the same name under `app/assets/components` folder.
|
51
51
|
|
52
|
-
Add your component to manifest file after requiring
|
52
|
+
Add your component to manifest file after requiring webcomponents:
|
53
53
|
|
54
54
|
//
|
55
|
-
//= require polymer/
|
55
|
+
//= require polymer/webcomponents
|
56
56
|
//= require component-name/component-name
|
57
57
|
|
58
58
|
And you can use your component in Rails application!
|
@@ -4,13 +4,20 @@ module Polymer
|
|
4
4
|
source_root File.expand_path('../templates', __FILE__)
|
5
5
|
|
6
6
|
def create_component_dir
|
7
|
-
empty_directory "app/assets/components/#{
|
7
|
+
empty_directory "app/assets/components/#{component_name}"
|
8
8
|
end
|
9
9
|
|
10
10
|
def copy_component_template
|
11
|
-
template "component.html.erb", "app/assets/components/#{
|
11
|
+
template "component.html.erb", "app/assets/components/#{component_name}/#{component_name}.html"
|
12
|
+
template "component.js.erb", "app/assets/components/#{component_name}/#{component_name}.js"
|
13
|
+
template "component.css.erb", "app/assets/components/#{component_name}/#{component_name}.css"
|
12
14
|
end
|
13
15
|
|
16
|
+
private
|
17
|
+
|
18
|
+
def component_name
|
19
|
+
name.gsub('_', '-').downcase
|
20
|
+
end
|
14
21
|
end
|
15
22
|
end
|
16
23
|
end
|
@@ -1,15 +1,9 @@
|
|
1
|
-
<polymer-element name="<%=
|
1
|
+
<polymer-element name="<%= component_name %>">
|
2
2
|
<template>
|
3
|
-
<
|
4
|
-
:host {
|
5
|
-
display: block;
|
6
|
-
}
|
7
|
-
</style>
|
3
|
+
<link rel="stylesheet" href="<%= component_name %>.css" />
|
8
4
|
|
9
5
|
<h2><%= file_name.capitalize.gsub('_', ' ') %></h2>
|
10
6
|
</template>
|
11
7
|
|
12
|
-
<script
|
13
|
-
Polymer('<%= name %>');
|
14
|
-
</script>
|
8
|
+
<script src="<%= component_name %>.js"></script>
|
15
9
|
</polymer-element>
|
@@ -20,7 +20,7 @@ module Polymer
|
|
20
20
|
|
21
21
|
def require_imports
|
22
22
|
@component.imports.each do |import|
|
23
|
-
@context.require_asset
|
23
|
+
@context.require_asset absolute_asset_path(import.attributes['href'].value)
|
24
24
|
import.remove
|
25
25
|
end
|
26
26
|
end
|
@@ -38,19 +38,28 @@ module Polymer
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def asset_content(file)
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
asset_path = absolute_asset_path(file)
|
42
|
+
asset = find_asset(asset_path)
|
43
|
+
unless asset.blank?
|
44
|
+
@context.depend_on_asset asset_path
|
45
|
+
asset.to_s
|
46
|
+
else
|
47
|
+
nil
|
48
|
+
end
|
44
49
|
end
|
45
50
|
|
46
|
-
def
|
51
|
+
def absolute_asset_path(file)
|
47
52
|
search_file = file.sub(/^(\.\.\/)+/, '/').sub(/^\/*/, '')
|
48
53
|
::Rails.application.assets.paths.each do |path|
|
49
54
|
file_list = Dir.glob( "#{File.absolute_path search_file, path }*")
|
50
55
|
return file_list.first unless file_list.blank?
|
51
56
|
end
|
52
|
-
|
53
|
-
return
|
57
|
+
components = Dir.glob("#{File.absolute_path file, File.dirname(@context.pathname)}*")
|
58
|
+
return components.blank? ? nil : components.first
|
59
|
+
end
|
60
|
+
|
61
|
+
def find_asset(asset_path)
|
62
|
+
::Rails.application.assets.find_asset(asset_path)
|
54
63
|
end
|
55
64
|
|
56
65
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polymer-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
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-
|
11
|
+
date: 2014-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -108,7 +108,9 @@ files:
|
|
108
108
|
- app/assets/javascripts/polymer/polymer.js
|
109
109
|
- app/assets/javascripts/polymer/webcomponents.js
|
110
110
|
- lib/generators/polymer/component/component_generator.rb
|
111
|
+
- lib/generators/polymer/component/templates/component.css.erb
|
111
112
|
- lib/generators/polymer/component/templates/component.html.erb
|
113
|
+
- lib/generators/polymer/component/templates/component.js.erb
|
112
114
|
- lib/generators/polymer/install/install_generator.rb
|
113
115
|
- lib/generators/polymer/install/templates/application.html.erb
|
114
116
|
- lib/generators/polymer/install/templates/bowerrc.json
|