sprockets-umodule 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4a34c71c2402af977c4d275588332de7dbe530dd
4
+ data.tar.gz: a3f7a0701325d4b5d8d4342de84bd4560647e674
5
+ SHA512:
6
+ metadata.gz: da56b89e33c79812e5c255318d7fe2347ad2f0802ded82c9e4c620fb213e6f084fe40f71e7ce7008ea5afe8caf0835cc467a05439a8d750a0ac10f68aebbbb33
7
+ data.tar.gz: f881d1af7ac14dd7160bbde4060098b13e24142a00d3303e4897113fc06adb43b3ac6fff966f966067d9c6cb454320ea98b1d680afa720a90ad39e2643f1aadc
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ Gemfile.lock
3
+ .rbenv-version
4
+ .ruby-version
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'pry'
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Loic Nageleisen
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.mdown ADDED
@@ -0,0 +1,11 @@
1
+ # sprockets-umodule
2
+
3
+ [umodule-js](https://github.com/lloeki/umodule-js) integration with Sprockets
4
+
5
+ ## Goal
6
+
7
+ Save you from the boilerplate of writing module wrapping.
8
+
9
+ ## Usage
10
+
11
+ Add sprockets-umodule to your Gemfile. Name your module files with .umodule.
@@ -0,0 +1,7 @@
1
+ (function () {
2
+ define = require('module').define;
3
+
4
+ define('<%= module_name %>', function (exports, require, module) {
5
+ <%= source %>
6
+ });
7
+ })();
@@ -0,0 +1,5 @@
1
+ module Sprockets
2
+ module Umodule
3
+ VERSION = '1.0.0'
4
+ end
5
+ end
@@ -0,0 +1,47 @@
1
+ require 'tilt'
2
+
3
+ module Sprockets
4
+ module Umodule
5
+ class Wrapper < Tilt::Template
6
+ @wrapper_template = File.read(File.join(File.dirname(__FILE__), 'umodule.js.erb'))
7
+
8
+ class << self
9
+ attr_reader :wrapper_template
10
+
11
+ def engine_initialized?
12
+ defined?(ERB)
13
+ end
14
+ end
15
+
16
+ def initialize_engine
17
+ require 'erb'
18
+ end
19
+
20
+ def prepare
21
+ @erb = ERB.new(wrapper_template)
22
+ end
23
+
24
+ def evaluate(context, locals, &block)
25
+ bind(@erb).render(context.logical_path, data)
26
+ end
27
+
28
+ private
29
+
30
+ def wrapper_template
31
+ self.class.wrapper_template
32
+ end
33
+
34
+ def bind(erb)
35
+ Class.new do
36
+ def initialize(erb)
37
+ @erb = erb
38
+ end
39
+
40
+ def render(module_name, source)
41
+ @erb.result(binding)
42
+ end
43
+ end.new(erb)
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,15 @@
1
+ require 'sprockets/umodule/version'
2
+ require 'sprockets/umodule/wrapper'
3
+ require 'sprockets/engines'
4
+
5
+ module Sprockets
6
+ module Umodule
7
+ class << self
8
+ attr_accessor :options
9
+ end
10
+
11
+ @options = {}
12
+ end
13
+
14
+ register_engine '.umodule', Umodule::Wrapper
15
+ end
@@ -0,0 +1 @@
1
+ require 'sprockets/umodule'
@@ -0,0 +1,13 @@
1
+ require 'sprockets'
2
+ require 'sprockets-umodule'
3
+ require 'sprockets-helpers'
4
+ require 'construct'
5
+ require 'pry'
6
+
7
+ # Requires supporting files with custom matchers and macros, etc,
8
+ # in ./support/ and its subdirectories.
9
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
10
+
11
+ RSpec.configure do |config|
12
+ config.include Construct::Helpers
13
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.configure do |c|
4
+ c.filter_run_excluding broken: true
5
+ c.filter_run_excluding todo: true
6
+ end
7
+
8
+ describe Sprockets::Umodule do
9
+ before :each do
10
+ @root = create_construct
11
+ @assets = @root.directory 'assets'
12
+ @env = Sprockets::Environment.new @root.to_s
13
+ @env.append_path @assets.to_s
14
+ end
15
+
16
+ after :each do
17
+ @root.destroy!
18
+ end
19
+
20
+ it 'processes umodule js files' do
21
+ @assets.file 'foo.js.umodule', %Q[bar = function () { "bar" };\n]
22
+ asset = @env['foo.js']
23
+ asset.to_s.should eq <<-SOURCE
24
+ (function () {
25
+ define = require('module').define;
26
+
27
+ define('foo', function (exports, require, module) {
28
+ bar = function () { "bar" };
29
+
30
+ });
31
+ })();
32
+ SOURCE
33
+ end
34
+
35
+ it 'sets the module name with the directory' do
36
+ @assets.file 'sub/foo.js.umodule', %Q[bar = function () { "bar" };\n]
37
+ asset = @env['sub/foo.js']
38
+ asset.to_s.should include %q[define('sub/foo',]
39
+ end
40
+
41
+ it 'indents the module contents prettily'
42
+ it 'works with coffeescript'
43
+
44
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+ require 'sprockets/umodule/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'sprockets-umodule'
7
+ s.version = Sprockets::Umodule::VERSION
8
+ s.authors = ['Loic Nageleisen']
9
+ s.email = ['loic.nageleisen@gmail.com']
10
+ s.homepage = 'http://github.com/lloeki/sprockets-umodule'
11
+ s.summary = %q{uModule wrapping for the Sprockets asset pipeline.}
12
+ s.description = %q{uModule wrapping for the Sprockets asset pipeline.}
13
+ s.files = `git ls-files`.split("\n")
14
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
+ s.executables = `git ls-files -- bin/*`.split("\n")
16
+ .map { |f| File.basename(f) }
17
+ s.require_paths = ['lib']
18
+ s.add_dependency 'umodule-source'
19
+ s.add_dependency 'tilt', '~> 1.1'
20
+ s.add_development_dependency 'sprockets-helpers', '~> 0.6'
21
+ s.add_development_dependency 'rspec', '~> 2.6'
22
+ s.add_development_dependency 'test-construct', '~> 1.2'
23
+ s.add_development_dependency 'rake'
24
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sprockets-umodule
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Loic Nageleisen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: umodule-source
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: tilt
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sprockets-helpers
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '0.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '0.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.6'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '2.6'
69
+ - !ruby/object:Gem::Dependency
70
+ name: test-construct
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '1.2'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '1.2'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: uModule wrapping for the Sprockets asset pipeline.
98
+ email:
99
+ - loic.nageleisen@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - .gitignore
105
+ - Gemfile
106
+ - LICENSE
107
+ - README.mdown
108
+ - lib/sprockets-umodule.rb
109
+ - lib/sprockets/umodule.rb
110
+ - lib/sprockets/umodule/umodule.js.erb
111
+ - lib/sprockets/umodule/version.rb
112
+ - lib/sprockets/umodule/wrapper.rb
113
+ - spec/spec_helper.rb
114
+ - spec/sprockets-umodule_spec.rb
115
+ - sprockets-umodule.gemspec
116
+ homepage: http://github.com/lloeki/sprockets-umodule
117
+ licenses: []
118
+ metadata: {}
119
+ post_install_message:
120
+ rdoc_options: []
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ requirements: []
134
+ rubyforge_project:
135
+ rubygems_version: 2.0.3
136
+ signing_key:
137
+ specification_version: 4
138
+ summary: uModule wrapping for the Sprockets asset pipeline.
139
+ test_files:
140
+ - spec/spec_helper.rb
141
+ - spec/sprockets-umodule_spec.rb
142
+ has_rdoc: