ember-rails-assets 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7bac61bf99ea7c2845897a37a2a6bcbfc22e5af5
4
+ data.tar.gz: 41773a8a23d3afc3bd6d841136bf400a8daf00ed
5
+ SHA512:
6
+ metadata.gz: c4b4865be52f8cb1aa08560f553fffdaacca3fd69e8e085b8a6a68b618fb8fcbb192778fd502891af8dca70ea9910530a7e0e69301dabae12659ad9b6028c9e5
7
+ data.tar.gz: c378a3c6c9e041ea77317ae365f69106303fa4207bce0b91b851074671422cdab4656080a5b310fe4c441b3bb4aa66d64574ef59abf0febb1860f69d5a293b30
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ember-rails-assets.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Micah Geisel
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Ember::Rails::Assets
2
+
3
+ `asset-path` helper for ember-rails, including digest!
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'ember-rails-assets'
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ Ember: Require `ember-rails-assets` anywhere, then use the `asset-path` helper in your template:
16
+
17
+ ```javascript
18
+ // app/assets/javascripts/templates/application.hbs
19
+ //= require ember-rails-assets
20
+ <img src={{asset-path "dogs/chihuahua"}} />
21
+ ```
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( https://github.com/[my-github-username]/ember-rails-assets/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,4 @@
1
+ Ember.Handlebars.registerHelper "asset-path", (name) ->
2
+ path = window.ASSETS.path(name)
3
+ new Ember.Handlebars.SafeString(path)
4
+
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ember/rails/assets/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ember-rails-assets"
8
+ spec.version = Ember::Rails::Assets::VERSION
9
+ spec.authors = ["Micah Geisel"]
10
+ spec.email = ["micah@botandrose.com"]
11
+ spec.summary = %q{asset-path helper for ember-rails, including digest!}
12
+ spec.description = %q{asset-path helper for ember-rails, including digest!}
13
+ spec.homepage = "https://github.com/botandrose/ember-rails-assets"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
@@ -0,0 +1,20 @@
1
+ require "ember/rails/assets/helper"
2
+ require "ember/rails/assets/middleware"
3
+ require "ember/rails/assets/version"
4
+
5
+ module Ember
6
+ module Rails
7
+ module Assets
8
+ class Engine < ::Rails::Engine
9
+ initializer "ember-rails-assets.helper" do |app|
10
+ ApplicationController.helper Ember::Rails::Assets::Helper
11
+ end
12
+
13
+ initializer "ember-rails-assets.middleware" do |app|
14
+ config.app_middleware.use Ember::Rails::Assets::Middleware
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+
@@ -0,0 +1,16 @@
1
+ require "ember/rails/assets/javascript"
2
+
3
+ module Ember
4
+ module Rails
5
+ module Assets
6
+ module Helper
7
+ def assets_javascript_tag key
8
+ javascript_tag do
9
+ raw Javascript.new(key, assets_manifest.path).render
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+
@@ -0,0 +1,32 @@
1
+ require "json"
2
+ require "active_support/core_ext"
3
+
4
+ module Ember
5
+ module Rails
6
+ module Assets
7
+ class Javascript < Struct.new(:key, :assets_manifest_path)
8
+ def render
9
+ <<-JS.strip_heredoc
10
+ window.#{key} = {
11
+ prefix: "/assets/",
12
+ path: function(name) {
13
+ return this.prefix + (this.assets[name] || name);
14
+ },
15
+ assets: #{JSON.dump(assets)}
16
+ };
17
+ JS
18
+ end
19
+
20
+ private
21
+
22
+ def assets
23
+ json = File.read(assets_manifest_path)
24
+ JSON.load(json)["assets"]
25
+ rescue Errno::ENOENT
26
+ {}
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+
@@ -0,0 +1,36 @@
1
+ require "ember/rails/assets/javascript"
2
+
3
+ module Ember
4
+ module Rails
5
+ module Assets
6
+ class Middleware < Struct.new(:app)
7
+ def call env
8
+ @status, @headers, @body = app.call(env)
9
+ return [@status, @headers, @body] unless html?
10
+
11
+ response = Rack::Response.new([], @status, @headers)
12
+ @body.each do |fragment|
13
+ response.write inject(fragment)
14
+ end
15
+ @body.close if @body.respond_to?(:close)
16
+
17
+ response.finish
18
+ end
19
+
20
+ private
21
+
22
+ def html?
23
+ @headers["Content-Type"] =~ /html/
24
+ end
25
+
26
+ def inject response
27
+ key = "ASSETS"
28
+ path = ActionView::Base.assets_manifest.path
29
+ markup = Javascript.new(key, path).render
30
+ response.gsub(%r{</head>}, "<script>#{markup}</script></head>")
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+
@@ -0,0 +1,7 @@
1
+ module Ember
2
+ module Rails
3
+ module Assets
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ember-rails-assets
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Micah Geisel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: asset-path helper for ember-rails, including digest!
42
+ email:
43
+ - micah@botandrose.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - app/assets/javascripts/ember-rails-assets.js.coffee
54
+ - ember-rails-assets.gemspec
55
+ - lib/ember/rails/assets.rb
56
+ - lib/ember/rails/assets/helper.rb
57
+ - lib/ember/rails/assets/javascript.rb
58
+ - lib/ember/rails/assets/middleware.rb
59
+ - lib/ember/rails/assets/version.rb
60
+ homepage: https://github.com/botandrose/ember-rails-assets
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.2.2
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: asset-path helper for ember-rails, including digest!
84
+ test_files: []