cuba-assets 0.0.5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +33 -1
- data/cuba-assets.gemspec +1 -1
- data/lib/cuba/assets.rb +8 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d54c3d4baebdd2a310acffa44a50486d9cb47607
|
4
|
+
data.tar.gz: bff41d88b31e7007f66d2343492bf6721246b445
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6fbf9475c455c564c411f4a619653fe9188c677ab4cebc70c8878bd04129a1b6060142f8057d02eda96ac871be1db20904f589d45fa14e20928f1d983ed08f6
|
7
|
+
data.tar.gz: 15ba5cc070a814a94d6a0394e6b7021f8b5116d62e0e1a3d483ac98ffb5d23f9f3df4bac60e4350ba59e468ea75ac46e0a551e02182eed3fab500a98c58fbbd6
|
data/README.md
CHANGED
@@ -18,9 +18,41 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
$ gem install cuba-assets
|
20
20
|
|
21
|
+
## Why Cuba::Assets?
|
22
|
+
|
23
|
+
Adding Sprockets to Cuba isn't a hard task. It only takes a little boilerplate to get it set up.
|
24
|
+
This gem just takes that boilerplate out of sight.
|
25
|
+
|
21
26
|
## Usage
|
22
27
|
|
23
|
-
|
28
|
+
The first order of business is requiring the plugin and making it available.
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
require "cuba/assets"
|
32
|
+
Cuba.plugin Cuba::Assets
|
33
|
+
```
|
34
|
+
|
35
|
+
This assumes that you have the following directories in place:
|
36
|
+
|
37
|
+
- `<assets_dir>/javascripts`
|
38
|
+
- `<assets_dir>/styles`
|
39
|
+
- `<assets_dir>/fonts`
|
40
|
+
- `<assets_dir>/images`
|
41
|
+
|
42
|
+
Where `<assets_dir>` is, by default: `<app_dir>/assets`
|
43
|
+
|
44
|
+
With that in place, you can now use the `asset` helper, passing the desired asset's path.
|
45
|
+
This will return an instance of `Sprockets::BundledAsset`.
|
46
|
+
|
47
|
+
## Configurations
|
48
|
+
|
49
|
+
### Changing the assets directory
|
50
|
+
|
51
|
+
To change the assets directory, just set it on the `settings` hash.
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
Cuba.settings[:assets][:js_compressor] = nil
|
55
|
+
```
|
24
56
|
|
25
57
|
## Contributing
|
26
58
|
|
data/cuba-assets.gemspec
CHANGED
data/lib/cuba/assets.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
require "pathname"
|
2
2
|
require "sprockets"
|
3
3
|
|
4
|
-
Cuba.settings[:
|
4
|
+
Cuba.settings[:assets] = {}
|
5
5
|
|
6
|
-
Cuba.settings[:
|
7
|
-
|
6
|
+
Cuba.settings[:assets][:assets_dir] = "assets/"
|
7
|
+
|
8
|
+
Cuba.settings[:assets][:js_compressor] = :uglify
|
9
|
+
Cuba.settings[:assets][:css_compressor] = :scss
|
8
10
|
module Cuba::Assets
|
9
11
|
def asset(path)
|
10
12
|
environment[path]
|
@@ -26,13 +28,13 @@ module Cuba::Assets
|
|
26
28
|
environment.append_path "#{assets_dir}/fonts"
|
27
29
|
environment.append_path "#{assets_dir}/images"
|
28
30
|
|
29
|
-
environment.js_compressor = Cuba.settings[:js_compressor]
|
30
|
-
environment.css_compressor = Cuba.settings[:css_compressor]
|
31
|
+
environment.js_compressor = Cuba.settings[:assets][:js_compressor]
|
32
|
+
environment.css_compressor = Cuba.settings[:assets][:css_compressor]
|
31
33
|
|
32
34
|
environment
|
33
35
|
end
|
34
36
|
|
35
37
|
def assets_dir
|
36
|
-
@assets_dir ||= Pathname(Cuba.settings[:assets_dir]).expand_path.to_s
|
38
|
+
@assets_dir ||= Pathname(Cuba.settings[:assets][:assets_dir]).expand_path.to_s
|
37
39
|
end
|
38
40
|
end
|