rake-sprockets 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +111 -0
- data/Rakefile +2 -0
- data/lib/rake/sprockets/ey_string.rb +16 -0
- data/lib/rake/sprockets/version.rb +5 -0
- data/lib/rake/sprockets.rb +80 -0
- data/lib/tasks/sprockets.rake +11 -0
- data/rake-sprockets.gemspec +25 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cbc0e66462dcca1c3f125c1f5f09412e81f8b204
|
4
|
+
data.tar.gz: a72fe026a808ce9edfb41c26bd4107f985754c20
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9522a496e26314de9f8f8e3aa90f742f375337b7d326ebd31671bba5790d2129f9ee0acef179ebe07fe690e4c7fdceec7059a2459b78a47129578b3fb62151d4
|
7
|
+
data.tar.gz: 513a2ccaeb16fb8cfb3cc2cc19951284a59a795ce8b230f99033c24a629d34ec4c290527adf41d485bb18b5779bcebf8e793b946109b80939245aca56c6280fd
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 myobie
|
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,111 @@
|
|
1
|
+
# Rake::Sprockets
|
2
|
+
|
3
|
+
Very easy defaults for using sprockets through rake.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'rake-asset-pipeline'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install rake-asset-pipeline
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
The default expected folder structure is:
|
24
|
+
|
25
|
+
assets/
|
26
|
+
js/app.js
|
27
|
+
css/app.css
|
28
|
+
public/
|
29
|
+
|
30
|
+
Build the assets with:
|
31
|
+
|
32
|
+
```sh
|
33
|
+
$ rake build
|
34
|
+
```
|
35
|
+
|
36
|
+
This will produce the following new files:
|
37
|
+
|
38
|
+
public/assets/js/app.js
|
39
|
+
public/assets/css/app.css
|
40
|
+
|
41
|
+
### Override defaults
|
42
|
+
|
43
|
+
These are the settings that can be overriden in your `Rakefile`:
|
44
|
+
|
45
|
+
#### Project root
|
46
|
+
|
47
|
+
The default is `Dir.pwd`.
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
Rake::Sprockets.root = Pathname.new __dir__
|
51
|
+
```
|
52
|
+
|
53
|
+
#### logger
|
54
|
+
|
55
|
+
The default is `$stdout`.
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
Rake::Sprockets.logger = Logger.new("log/output.log")
|
59
|
+
```
|
60
|
+
|
61
|
+
#### env
|
62
|
+
|
63
|
+
`#env` is set to `RAKE_ENV` or defaults to development.
|
64
|
+
|
65
|
+
`#env` is fancy and can answer queries:
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
Rake::Sprockets.env.production?
|
69
|
+
```
|
70
|
+
|
71
|
+
Override from the shell:
|
72
|
+
|
73
|
+
```sh
|
74
|
+
$ RAKE_ENV=production rake build
|
75
|
+
```
|
76
|
+
|
77
|
+
#### precompile list
|
78
|
+
|
79
|
+
The default is to only compile `app.js` and `app.css`. You can add more
|
80
|
+
files:
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
Rake::Sprockets.precompile += ["other.css", "cray.js"]
|
84
|
+
```
|
85
|
+
|
86
|
+
#### asset directories
|
87
|
+
|
88
|
+
The default asset directories are `assets/js` and `assets/css`. You can
|
89
|
+
change or add more:
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
Rake::Sprockets.asset_paths = ["stylesheets", "javascripts"] # "assets/" is prepended
|
93
|
+
```
|
94
|
+
|
95
|
+
#### compression
|
96
|
+
|
97
|
+
In production compression is used if it's setup. You need to supply the
|
98
|
+
js and css compressors (there are no defaults):
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
Rake::Sprockets.css_compressor = :sass
|
102
|
+
Rake::Sprockets.js_compressor = :uglify
|
103
|
+
```
|
104
|
+
|
105
|
+
## Contributing
|
106
|
+
|
107
|
+
1. Fork it ( https://github.com/myobie/rake-sprockets/fork )
|
108
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
109
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
110
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
111
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'rake/sprockets/version'
|
2
|
+
require 'rake/sprockets/ey_string'
|
3
|
+
load 'tasks/sprockets.rake'
|
4
|
+
|
5
|
+
require 'logger'
|
6
|
+
require 'pathname'
|
7
|
+
require 'sprockets'
|
8
|
+
|
9
|
+
module Rake
|
10
|
+
module Sprockets
|
11
|
+
class << self
|
12
|
+
attr_accessor :root, :logger, :precompile, :asset_paths, :js_compressor, :css_compressor
|
13
|
+
|
14
|
+
def root
|
15
|
+
@root ||= Pathname.new Dir.pwd
|
16
|
+
end
|
17
|
+
|
18
|
+
def env
|
19
|
+
@env ||= ENV.fetch("RAKE_ENV", "development").ey?
|
20
|
+
end
|
21
|
+
|
22
|
+
def logger
|
23
|
+
Logger.new $stdout
|
24
|
+
end
|
25
|
+
|
26
|
+
def precompile
|
27
|
+
@precompile ||= ["app.js", "app.css"]
|
28
|
+
end
|
29
|
+
|
30
|
+
def asset_paths
|
31
|
+
@asset_paths ||= ["css", "js"]
|
32
|
+
end
|
33
|
+
|
34
|
+
def public
|
35
|
+
root.join "public"
|
36
|
+
end
|
37
|
+
|
38
|
+
def assets
|
39
|
+
root.join "assets"
|
40
|
+
end
|
41
|
+
|
42
|
+
def public_assets
|
43
|
+
public.join("assets")
|
44
|
+
end
|
45
|
+
|
46
|
+
def sprockets
|
47
|
+
@sprockets ||= create_sprockets_env
|
48
|
+
end
|
49
|
+
|
50
|
+
def create_sprockets_env
|
51
|
+
::Sprockets::Environment.new(root) do |s_env|
|
52
|
+
s_env.logger = logger
|
53
|
+
|
54
|
+
if env.production?
|
55
|
+
s_env.js_compressor = js_compressor if js_compressor
|
56
|
+
s_env.css_compressor = css_compressor if css_compressor
|
57
|
+
end
|
58
|
+
end.tap do |s|
|
59
|
+
asset_paths.each do |path|
|
60
|
+
s.append_path assets.join(path)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def compile
|
66
|
+
precompile.each do |file|
|
67
|
+
assets = sprockets.find_asset file
|
68
|
+
prefix, basename = assets.pathname.to_s.split("/")[-2..-1]
|
69
|
+
public_assets.join(prefix).mkpath
|
70
|
+
filename = public_assets.join prefix, basename
|
71
|
+
assets.write_to filename
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def clean
|
76
|
+
public_assets.rmtree
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rake/sprockets/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rake-sprockets"
|
8
|
+
spec.version = Rake::Sprockets::VERSION
|
9
|
+
spec.authors = ["myobie"]
|
10
|
+
spec.email = ["me@nathanherald.com"]
|
11
|
+
spec.summary = %q{Good defaults for using sprockets through rake}
|
12
|
+
spec.description = %q{Build your assets with rake build.}
|
13
|
+
spec.homepage = ""
|
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
|
+
|
23
|
+
spec.add_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_dependency "sprockets", "~> 2.12"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rake-sprockets
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- myobie
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-12 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: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sprockets
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.12'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.12'
|
55
|
+
description: Build your assets with rake build.
|
56
|
+
email:
|
57
|
+
- me@nathanherald.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- lib/rake/sprockets.rb
|
68
|
+
- lib/rake/sprockets/ey_string.rb
|
69
|
+
- lib/rake/sprockets/version.rb
|
70
|
+
- lib/tasks/sprockets.rake
|
71
|
+
- rake-sprockets.gemspec
|
72
|
+
homepage: ''
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.2.2
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Good defaults for using sprockets through rake
|
96
|
+
test_files: []
|