emblem-sprockets 0.1.0

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.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in emblem-rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 A. Speller
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
+ # Emblem::Sprockets
2
+
3
+ Integrate [Emblem.js](https://github.com/machty/emblem.js) with sprockets
4
+
5
+ ## Installation
6
+
7
+ Add `gem 'emblem-sprockets'` to your application's Gemfile :
8
+
9
+ gem 'emblem-sprockets'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Tell emblem-sprockets about your sprockets environment:
16
+
17
+ Emblem::Sprockets.integrate sprockets_environment
18
+
19
+ Now any templates ending in `.emblem` will be compiled as
20
+ Ember-Handlebars templates. If you need to compile your Emblem templates
21
+ with vanilla Handlebars, use the `.raw.emblem` extension.
22
+
23
+ ## Upgrading to the latest Emblem
24
+
25
+ This gem is only responsible for integrating Emblem.js with Sprockets. Any
26
+ updates to the Emblem language itself can be pulled in via
27
+
28
+ $ bundle update emblem-source
29
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'emblem/sprockets/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "emblem-sprockets"
8
+ gem.version = Emblem::Sprockets::VERSION
9
+ gem.authors = ["Alex Speller", "Alex Matchneer", "Micah Geisel"]
10
+ gem.email = ["micah@botandrose.com"]
11
+ gem.description = %q{Use emblem.js with sprockets - see https://github.com/machty/emblem.js}
12
+ gem.summary = %q{Use emblem.js with sprockets}
13
+ gem.homepage = "http://github.com/botandrose/emblem-sprockets"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ gem.add_dependency "barber-emblem"
20
+ end
@@ -0,0 +1 @@
1
+ require "emblem/sprockets"
@@ -0,0 +1,11 @@
1
+ require 'emblem/sprockets/version'
2
+ require 'emblem/sprockets/integration'
3
+ require 'barber/precompiler'
4
+
5
+ module Emblem
6
+ module Sprockets
7
+ def self.integrate sprockets
8
+ Integration.integrate sprockets
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ require 'emblem/sprockets/template'
2
+
3
+ module Emblem
4
+ module Sprockets
5
+ module Integration
6
+ def self.integrate sprockets
7
+ sprockets.register_engine '.emblem', Emblem::Sprockets::Template
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,54 @@
1
+ require 'sprockets'
2
+ require 'sprockets/engines'
3
+ require 'barber-emblem'
4
+
5
+ module Emblem
6
+ module Sprockets
7
+ class Template < Tilt::Template
8
+ def self.default_mime_type
9
+ 'application/javascript'
10
+ end
11
+
12
+ def prepare; end
13
+
14
+ def evaluate(scope, locals, &block)
15
+ target = template_target(scope)
16
+
17
+ template = data
18
+
19
+ if raw?(scope)
20
+ template = precompile_emblem(template)
21
+ else
22
+ template = precompile_ember_emblem(template)
23
+ end
24
+
25
+ "#{target} = #{template}\n"
26
+ end
27
+
28
+
29
+ private
30
+
31
+ def raw?(scope)
32
+ scope.pathname.to_s =~ /\.raw\.(emblem)/
33
+ end
34
+
35
+ def template_target(scope)
36
+ "Ember.TEMPLATES[#{template_path(scope.logical_path).inspect}]"
37
+ end
38
+
39
+ def precompile_emblem(string)
40
+ Barber::Emblem::FilePrecompiler.call(string)
41
+ end
42
+
43
+ def precompile_ember_emblem(string)
44
+ Barber::Emblem::EmberFilePrecompiler.call(string)
45
+ end
46
+
47
+ def template_path(path)
48
+ path = path.split('/')
49
+ path.shift # drop initial "templates/" prefix
50
+ path.join('/')
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,5 @@
1
+ module Emblem
2
+ module Sprockets
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: emblem-sprockets
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.0
6
+ platform: ruby
7
+ authors:
8
+ - Alex Speller
9
+ - Alex Matchneer
10
+ - Micah Geisel
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+ date: 2013-04-18 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ prerelease: false
18
+ type: :runtime
19
+ name: barber-emblem
20
+ version_requirements: !ruby/object:Gem::Requirement
21
+ none: false
22
+ requirements:
23
+ - - ! '>='
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
26
+ requirement: !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ! '>='
30
+ - !ruby/object:Gem::Version
31
+ version: '0'
32
+ description: Use emblem.js with sprockets - see https://github.com/machty/emblem.js
33
+ email:
34
+ - micah@botandrose.com
35
+ executables: []
36
+ extensions: []
37
+ extra_rdoc_files: []
38
+ files:
39
+ - .gitignore
40
+ - Gemfile
41
+ - LICENSE.txt
42
+ - README.md
43
+ - Rakefile
44
+ - emblem-sprockets.gemspec
45
+ - lib/emblem-sprockets.rb
46
+ - lib/emblem/sprockets.rb
47
+ - lib/emblem/sprockets/integration.rb
48
+ - lib/emblem/sprockets/template.rb
49
+ - lib/emblem/sprockets/version.rb
50
+ homepage: http://github.com/botandrose/emblem-sprockets
51
+ licenses: []
52
+ post_install_message:
53
+ rdoc_options: []
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubyforge_project:
70
+ rubygems_version: 1.8.25
71
+ signing_key:
72
+ specification_version: 3
73
+ summary: Use emblem.js with sprockets
74
+ test_files: []