js_assets 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +88 -0
- data/MIT-LICENSE +20 -0
- data/README.md +61 -0
- data/Rakefile +32 -0
- data/app/assets/javascripts/app_assets.js.erb +4 -0
- data/js_assets.gemspec +23 -0
- data/lib/js_assets/list.rb +44 -0
- data/lib/js_assets/rails/engine.rb +6 -0
- data/lib/js_assets/version.rb +3 -0
- data/lib/js_assets.rb +3 -0
- data/lib/tasks/js_assets_tasks.rake +4 -0
- metadata +86 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7ebe0fa5c9ae154f5ac53513f6359ca097fdedad
|
4
|
+
data.tar.gz: 861bea94bb12c70ed4004462c3834500453e0559
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ba50f7a1985d37176aba018027ee0f9fca599535dd2c11e17b4334d9c1cc87ff400c4811957edc82e1865b51d4b6aa1c070424a6ada9074afcd84e838d1a2591
|
7
|
+
data.tar.gz: 4297847f5897b22cd9fb1d32bb0ec6f9ea9d4b5753ac1a90555f81d816df80f80d881f8c7a10e15fc247b209bb1193d3042380abcba69f059a6b0f6c1f52fbbb
|
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
# Declare your gem's dependencies in js_assets.gemspec.
|
4
|
+
# Bundler will treat runtime dependencies like base dependencies, and
|
5
|
+
# development dependencies will be added by default to the :development group.
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
# Declare any dependencies that are still in development here instead of in
|
9
|
+
# your gemspec. These might include edge Rails or gems from your path or
|
10
|
+
# Git. Remember to move these dependencies to your gemspec before releasing
|
11
|
+
# your gem to rubygems.org.
|
12
|
+
|
13
|
+
# To use debugger
|
14
|
+
# gem 'debugger'
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
js_assets (0.0.1)
|
5
|
+
rails (~> 4.0.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actionmailer (4.0.0)
|
11
|
+
actionpack (= 4.0.0)
|
12
|
+
mail (~> 2.5.3)
|
13
|
+
actionpack (4.0.0)
|
14
|
+
activesupport (= 4.0.0)
|
15
|
+
builder (~> 3.1.0)
|
16
|
+
erubis (~> 2.7.0)
|
17
|
+
rack (~> 1.5.2)
|
18
|
+
rack-test (~> 0.6.2)
|
19
|
+
activemodel (4.0.0)
|
20
|
+
activesupport (= 4.0.0)
|
21
|
+
builder (~> 3.1.0)
|
22
|
+
activerecord (4.0.0)
|
23
|
+
activemodel (= 4.0.0)
|
24
|
+
activerecord-deprecated_finders (~> 1.0.2)
|
25
|
+
activesupport (= 4.0.0)
|
26
|
+
arel (~> 4.0.0)
|
27
|
+
activerecord-deprecated_finders (1.0.3)
|
28
|
+
activesupport (4.0.0)
|
29
|
+
i18n (~> 0.6, >= 0.6.4)
|
30
|
+
minitest (~> 4.2)
|
31
|
+
multi_json (~> 1.3)
|
32
|
+
thread_safe (~> 0.1)
|
33
|
+
tzinfo (~> 0.3.37)
|
34
|
+
arel (4.0.0)
|
35
|
+
atomic (1.1.14)
|
36
|
+
builder (3.1.4)
|
37
|
+
erubis (2.7.0)
|
38
|
+
hike (1.2.3)
|
39
|
+
i18n (0.6.5)
|
40
|
+
mail (2.5.4)
|
41
|
+
mime-types (~> 1.16)
|
42
|
+
treetop (~> 1.4.8)
|
43
|
+
mime-types (1.25)
|
44
|
+
minitest (4.7.5)
|
45
|
+
multi_json (1.8.0)
|
46
|
+
polyglot (0.3.3)
|
47
|
+
rack (1.5.2)
|
48
|
+
rack-test (0.6.2)
|
49
|
+
rack (>= 1.0)
|
50
|
+
rails (4.0.0)
|
51
|
+
actionmailer (= 4.0.0)
|
52
|
+
actionpack (= 4.0.0)
|
53
|
+
activerecord (= 4.0.0)
|
54
|
+
activesupport (= 4.0.0)
|
55
|
+
bundler (>= 1.3.0, < 2.0)
|
56
|
+
railties (= 4.0.0)
|
57
|
+
sprockets-rails (~> 2.0.0)
|
58
|
+
railties (4.0.0)
|
59
|
+
actionpack (= 4.0.0)
|
60
|
+
activesupport (= 4.0.0)
|
61
|
+
rake (>= 0.8.7)
|
62
|
+
thor (>= 0.18.1, < 2.0)
|
63
|
+
rake (10.1.0)
|
64
|
+
sprockets (2.10.0)
|
65
|
+
hike (~> 1.2)
|
66
|
+
multi_json (~> 1.0)
|
67
|
+
rack (~> 1.0)
|
68
|
+
tilt (~> 1.1, != 1.3.0)
|
69
|
+
sprockets-rails (2.0.0)
|
70
|
+
actionpack (>= 3.0)
|
71
|
+
activesupport (>= 3.0)
|
72
|
+
sprockets (~> 2.8)
|
73
|
+
sqlite3 (1.3.8)
|
74
|
+
thor (0.18.1)
|
75
|
+
thread_safe (0.1.3)
|
76
|
+
atomic
|
77
|
+
tilt (1.4.1)
|
78
|
+
treetop (1.4.15)
|
79
|
+
polyglot
|
80
|
+
polyglot (>= 0.3.1)
|
81
|
+
tzinfo (0.3.37)
|
82
|
+
|
83
|
+
PLATFORMS
|
84
|
+
ruby
|
85
|
+
|
86
|
+
DEPENDENCIES
|
87
|
+
js_assets!
|
88
|
+
sqlite3
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2013 Zaur Abasmirzoev
|
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.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# js_assets
|
2
|
+
|
3
|
+
Gem provides a helper asset_path in javascript.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add gem to your Gemfile
|
8
|
+
```ruby
|
9
|
+
gem 'js_assets'
|
10
|
+
```
|
11
|
+
And run `bundle install`.
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
In your `application.js`
|
16
|
+
```javascript
|
17
|
+
//= require app_assets
|
18
|
+
```
|
19
|
+
|
20
|
+
This directive adds the method `asset_path` in the global scope.
|
21
|
+
|
22
|
+
Get the path to the template `app/assets/javascripts/rubrics/views/index.html` in javascript:
|
23
|
+
```javascript
|
24
|
+
var path = asset_path('rubrics/views/index.html')
|
25
|
+
// the function will return for development:
|
26
|
+
// /assets/rubrics/views/index.html
|
27
|
+
// and for production
|
28
|
+
// /assets/rubrics/views/index-5eb3bb250d5300736006c8944e436e3f.html
|
29
|
+
```
|
30
|
+
|
31
|
+
## Settings
|
32
|
+
|
33
|
+
You can specify, for example in the initializer, which will be available in the helper `asset_path`, and which should be excluded.
|
34
|
+
|
35
|
+
To add a file to the list, use:
|
36
|
+
```ruby
|
37
|
+
JsAssets::List.allow << '*.png'
|
38
|
+
```
|
39
|
+
To exclude:
|
40
|
+
```ruby
|
41
|
+
JsAssets::List.exclude << '*.png'
|
42
|
+
```
|
43
|
+
Initially, the list is taken asset falling within the filter `app/config/environments/production.rb`
|
44
|
+
```ruby
|
45
|
+
config.assets.precompile += ['*.html']
|
46
|
+
```
|
47
|
+
By default:
|
48
|
+
```ruby
|
49
|
+
JsAssets::List.exclude = ["application.js"]
|
50
|
+
JsAssets::List.allow = ["*.html"]
|
51
|
+
```
|
52
|
+
|
53
|
+
Be careful! If the list of available `JsAssets::List.allow` get a file that is inserted directive `require app_assets`, recursion will occur as `sprockets` will calculate the md5-based content.
|
54
|
+
|
55
|
+
# License #
|
56
|
+
|
57
|
+
Copyright © 2013 Zaur Abasmirzoev <<zaur.kavkaz@gmail.com>>
|
58
|
+
|
59
|
+
JsAssets is distributed under an MIT-style license. See LICENSE for
|
60
|
+
details.
|
61
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
# require 'rdoc/task'
|
8
|
+
|
9
|
+
# RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
# rdoc.rdoc_dir = 'rdoc'
|
11
|
+
# rdoc.title = 'JsAssets'
|
12
|
+
# rdoc.options << '--line-numbers'
|
13
|
+
# rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
# rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
# end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
Bundler::GemHelper.install_tasks
|
21
|
+
|
22
|
+
# require 'rake/testtask'
|
23
|
+
|
24
|
+
# Rake::TestTask.new(:test) do |t|
|
25
|
+
# t.libs << 'lib'
|
26
|
+
# # t.libs << 'test'
|
27
|
+
# # t.pattern = 'test/**/*_test.rb'
|
28
|
+
# t.verbose = false
|
29
|
+
# end
|
30
|
+
|
31
|
+
|
32
|
+
# task default: :test
|
data/js_assets.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
|
3
|
+
# Maintain your gem's version:
|
4
|
+
require "js_assets/version"
|
5
|
+
|
6
|
+
# Describe your gem and declare its dependencies:
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "js_assets"
|
9
|
+
s.version = JsAssets::VERSION
|
10
|
+
s.authors = ["Zaur Abasmirzoev"]
|
11
|
+
s.email = ["zaur.kavkaz@gmail.com"]
|
12
|
+
s.license = 'MIT'
|
13
|
+
s.homepage = "https://github.com/kavkaz/js_assets"
|
14
|
+
s.summary = "Javascript helper"
|
15
|
+
s.description = "Provide asset_path helper in javascript"
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = Dir["test/**/*"]
|
19
|
+
|
20
|
+
s.add_dependency "rails", "~> 4.0.0"
|
21
|
+
|
22
|
+
s.add_development_dependency "yard"
|
23
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module JsAssets
|
2
|
+
class List
|
3
|
+
class << self
|
4
|
+
attr_accessor :exclude, :allow
|
5
|
+
|
6
|
+
@exclude = ['application.js']
|
7
|
+
@allow = ['*.html']
|
8
|
+
def self.fetch
|
9
|
+
project_assets = {}
|
10
|
+
assets_filters = ::Rails.application.config.assets.precompile
|
11
|
+
::Rails.application.assets.each_file do |filename|
|
12
|
+
if logical_path = ::Rails.application.assets.send(:logical_path_for_filename, filename, assets_filters)
|
13
|
+
next if matches_filter(@exclude, logical_path, filename)
|
14
|
+
next unless matches_filter(@allow, logical_path, filename)
|
15
|
+
project_assets[logical_path] = ::ApplicationController.helpers.asset_path(logical_path)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
return project_assets
|
19
|
+
end
|
20
|
+
|
21
|
+
protected
|
22
|
+
# from
|
23
|
+
# https://github.com/sstephenson/sprockets/blob/master/lib/sprockets/base.rb:418
|
24
|
+
def self.matches_filter(filters, logical_path, filename)
|
25
|
+
return true if filters.empty?
|
26
|
+
|
27
|
+
filters.any? do |filter|
|
28
|
+
if filter.is_a?(Regexp)
|
29
|
+
filter.match(logical_path)
|
30
|
+
elsif filter.respond_to?(:call)
|
31
|
+
if filter.arity == 1
|
32
|
+
filter.call(logical_path)
|
33
|
+
else
|
34
|
+
filter.call(logical_path, filename.to_s)
|
35
|
+
end
|
36
|
+
else
|
37
|
+
# puts filter
|
38
|
+
File.fnmatch(filter.to_s, logical_path)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/js_assets.rb
ADDED
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: js_assets
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Zaur Abasmirzoev
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: yard
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Provide asset_path helper in javascript
|
42
|
+
email:
|
43
|
+
- zaur.kavkaz@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- Gemfile.lock
|
51
|
+
- MIT-LICENSE
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- app/assets/javascripts/app_assets.js.erb
|
55
|
+
- js_assets.gemspec
|
56
|
+
- lib/js_assets.rb
|
57
|
+
- lib/js_assets/list.rb
|
58
|
+
- lib/js_assets/rails/engine.rb
|
59
|
+
- lib/js_assets/version.rb
|
60
|
+
- lib/tasks/js_assets_tasks.rake
|
61
|
+
homepage: https://github.com/kavkaz/js_assets
|
62
|
+
licenses:
|
63
|
+
- MIT
|
64
|
+
metadata: {}
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 2.0.7
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: Javascript helper
|
85
|
+
test_files: []
|
86
|
+
has_rdoc:
|