sprockets-source-url 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.
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/README.md +23 -0
- data/Rakefile +19 -0
- data/examples/application.js +3 -0
- data/examples/example.js +7 -0
- data/examples/index.html +4 -0
- data/examples/modules/element.js +1 -0
- data/examples/modules/event.js +1 -0
- data/examples/modules/group.js +1 -0
- data/examples/modules/models/another.js +1 -0
- data/examples/modules/program.js +5 -0
- data/examples/modules/user.js +4 -0
- data/lib/sprockets/source_url.rb +24 -0
- data/sprockets-source.gemspec +23 -0
- metadata +71 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# Sprockets Source URL
|
2
|
+
|
3
|
+
Source URLs are awesome little 'meta comments' that the browser can use for finding the names of scripts. For example:
|
4
|
+
|
5
|
+
//@ sourceURL=my/script/name
|
6
|
+
|
7
|
+
This means that instead of seeing one compiled file in Chrome's inspector, like this:
|
8
|
+
|
9
|
+

|
10
|
+
|
11
|
+
You see your whole directory tree:
|
12
|
+
|
13
|
+

|
14
|
+
|
15
|
+
So much easier to navigate! The alternative to this is to spit out multiple script tags into the page.
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
Just require `sprockets/source_url` in development.
|
20
|
+
|
21
|
+
## @sourceURL
|
22
|
+
|
23
|
+
Both Chrome and Firefox have `@sourceURL` support. For more information, please see this [excellent post on the subject](http://pmuellr.blogspot.com/2009/06/debugger-friendly.html).
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'sprockets'
|
3
|
+
require 'sprockets/source_url'
|
4
|
+
require 'rake/testtask'
|
5
|
+
|
6
|
+
task :example do
|
7
|
+
env = Sprockets::Environment.new(File.expand_path('..', __FILE__))
|
8
|
+
env.append_path 'examples/'
|
9
|
+
|
10
|
+
target = File.expand_path('../examples/example.js', __FILE__)
|
11
|
+
env['application.js'].write_to target
|
12
|
+
end
|
13
|
+
|
14
|
+
task :default => :test
|
15
|
+
|
16
|
+
Rake::TestTask.new do |t|
|
17
|
+
t.libs << "test"
|
18
|
+
t.warning = true
|
19
|
+
end
|
data/examples/example.js
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
eval("var element = 1;\n" + "\n//@ sourceURL=/modules/element");
|
2
|
+
eval("var event = 1;\n" + "\n//@ sourceURL=/modules/event");
|
3
|
+
eval("var group = 1;\n" + "\n//@ sourceURL=/modules/group");
|
4
|
+
eval("var another = 1;\n" + "\n//@ sourceURL=/modules/models/another");
|
5
|
+
eval("window.program = function(){\n alert('Long live the Programs!');\n\n throw new Error('Here is a stack trace');\n};\n" + "\n//@ sourceURL=/modules/program");
|
6
|
+
eval("window.user = function(){\n alert('Long live the Users');\n window.program();\n};\n" + "\n//@ sourceURL=/modules/user");
|
7
|
+
eval("\nvar self = 'application.js';\n" + "\n//@ sourceURL=/application");
|
data/examples/index.html
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
var element = 1;
|
@@ -0,0 +1 @@
|
|
1
|
+
var event = 1;
|
@@ -0,0 +1 @@
|
|
1
|
+
var group = 1;
|
@@ -0,0 +1 @@
|
|
1
|
+
var another = 1;
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'sprockets'
|
2
|
+
require 'tilt'
|
3
|
+
|
4
|
+
module Sprockets
|
5
|
+
class SourceURL < Tilt::Template
|
6
|
+
self.default_mime_type = 'application/javascript'
|
7
|
+
|
8
|
+
def prepare
|
9
|
+
end
|
10
|
+
|
11
|
+
def evaluate(scope, locals, &block)
|
12
|
+
code = ''
|
13
|
+
code << 'eval('
|
14
|
+
code << data.inspect
|
15
|
+
code << " + \"\\n//@ sourceURL=/#{scope.logical_path}\""
|
16
|
+
code << ");\n"
|
17
|
+
code
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
if defined?(register_postprocessor)
|
22
|
+
register_postprocessor 'application/javascript', SourceURL
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "sprockets-source-url"
|
6
|
+
s.version = '0.0.1'
|
7
|
+
s.authors = ["Alex MacCaw"]
|
8
|
+
s.email = ["info@eribium.org"]
|
9
|
+
s.homepage = ""
|
10
|
+
s.summary = %q{Adds SourceURL support to Sprockets}
|
11
|
+
s.description = s.summary
|
12
|
+
|
13
|
+
s.rubyforge_project = "sprockets-source-url"
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
|
20
|
+
# specify any dependencies here; for example:
|
21
|
+
# s.add_development_dependency "rspec"
|
22
|
+
s.add_runtime_dependency "sprockets", "~>2.4.0"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sprockets-source-url
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Alex MacCaw
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-23 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: sprockets
|
16
|
+
requirement: &70304890717080 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.4.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70304890717080
|
25
|
+
description: Adds SourceURL support to Sprockets
|
26
|
+
email:
|
27
|
+
- info@eribium.org
|
28
|
+
executables: []
|
29
|
+
extensions: []
|
30
|
+
extra_rdoc_files: []
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- Gemfile
|
34
|
+
- README.md
|
35
|
+
- Rakefile
|
36
|
+
- examples/application.js
|
37
|
+
- examples/example.js
|
38
|
+
- examples/index.html
|
39
|
+
- examples/modules/element.js
|
40
|
+
- examples/modules/event.js
|
41
|
+
- examples/modules/group.js
|
42
|
+
- examples/modules/models/another.js
|
43
|
+
- examples/modules/program.js
|
44
|
+
- examples/modules/user.js
|
45
|
+
- lib/sprockets/source_url.rb
|
46
|
+
- sprockets-source.gemspec
|
47
|
+
homepage: ''
|
48
|
+
licenses: []
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ! '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
requirements: []
|
66
|
+
rubyforge_project: sprockets-source-url
|
67
|
+
rubygems_version: 1.8.15
|
68
|
+
signing_key:
|
69
|
+
specification_version: 3
|
70
|
+
summary: Adds SourceURL support to Sprockets
|
71
|
+
test_files: []
|