slim-grunt-helpers 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 20e8513107759c51072567f6a9bf8eaac947daf0
4
- data.tar.gz: 189e753cea3c2c6cb8f8dc54c938ab10befa81f4
3
+ metadata.gz: d566aa9db2ec0e20872d9d84f75b8c828d544774
4
+ data.tar.gz: a61fb1704ca4ad4a3e322d31cdc6888813739040
5
5
  SHA512:
6
- metadata.gz: 198b4fa59667f2a76f7a96153e56631757fdc07e13c500ecc9236a5566dc61cb20ce86af68920d2aa4a3ecaa8eee648dab2591ff577b0febd1a8ec06e83bbe76
7
- data.tar.gz: 76d7483c61447ce79c5789c5dd7d22e1899b39e215a37701f7ff8acf2491bc2b3d9bbac7472697bc3334d580e318a54ee9fff7137019ccfa1c5686d5b3f21d4f
6
+ metadata.gz: e779274082e12e0ad0f2f748f2264f308bd150a04b3b5316b86ade8e1fb41b4f9b48b4947f4869bec7f4ca9e5b2b71286beedecd6c4b7b5bd53de3ab5bd1e92f
7
+ data.tar.gz: 09d78f7bd69ba051f3a1e1b5d7824b3a771fce06a9247f271bb0c098d2346ca998b20e5a812141fab3f0e307b75c378b40abaf316dab7d45a7b0771b0b980ad4
data/README.md CHANGED
@@ -50,9 +50,10 @@ there which are boring to type directly in Slim. The usage is simple:
50
50
  == sg_usemin_css('application.css', alt: '.tmp') do |usemin|
51
51
  - usemin << 'styles/bootstrap.css'
52
52
  - usemin.add 'styles/main.css', 'data-customattr' => 'customdata'
53
+ - usemin.include 'styles/secondary.css', 'data-customattr' => 'customdata'
53
54
  ```
54
55
 
55
- **Note:** You can either use **&lt;&lt;** or `add`, I prefer the first one but if you want use two params,
56
+ **Note:** You can either use **&lt;&lt;**, `add` or `include`, I prefer the first one but if you want use two params,
56
57
  the only way to do it is in this way:
57
58
  ```ruby
58
59
  - usemin.<<('param1', 'data-customattr' => 'customdata')
@@ -73,6 +74,15 @@ hash of options which are appended as attributes to the link tag. Notice that on
73
74
  `rel="stylesheet"` is automatically appended (and can be overwritten by specifying a `rel` key in options).
74
75
  Additionally, notice that attributes with `nil` or `false` as value are not set (so you can remove `rel`), while those with `true` are set but without value and without `=""`.
75
76
 
77
+ ## usemin.require and usemin.require_tree
78
+ `require` allows to include files only if they are not already included. Uses same params as `include`.
79
+ `require_tree` instead, require an entire directory tree, using [Dir glob](http://ruby-doc.org/core-1.9.3/Dir.html#method-c-glob) pattern. It accepts the following parameters:
80
+
81
+ - `root_path` which is the path will be used as base directory (and **omitted in tags**)
82
+ - `pattern` which is the pattern accepted by [Dir glob](http://ruby-doc.org/core-1.9.3/Dir.html#method-c-glob), used to search files
83
+ - `relative` which if it's true, ensures file path won't start with `/` when printed in html
84
+ - `options` which are directly passed to `require`
85
+
76
86
  ## Contributing
77
87
 
78
88
  1. Fork it
@@ -1,3 +1,5 @@
1
+ require 'pathname'
2
+
1
3
  module SlimGruntHelpers
2
4
 
3
5
  module Models
@@ -28,12 +30,18 @@ module SlimGruntHelpers
28
30
  BASE_OPTIONS
29
31
  end
30
32
 
31
- def require_tree(root_path, pattern, options={})
32
- Dir[root_path.join(pattern)].reject do |file|
33
+ def require_tree(root_path, pattern, relative=false, options={})
34
+ unless root_path.respond_to? :join
35
+ root_path = Pathname.new(root_path.to_s)
36
+ end
37
+
38
+ Dir[root_path.join(pattern).to_s].reject do |file|
33
39
  File.directory? file
34
40
  end.each do |file|
35
- file_name = file.to_s
36
- file_name["#{ root_path }/"] = ''
41
+ file_name = file.to_s
42
+ real_root_path = root_path.to_s
43
+ real_root_path += '/' if relative
44
+ file_name[real_root_path] = ''
37
45
 
38
46
  self.require file_name, options
39
47
  end
@@ -1,3 +1,3 @@
1
1
  module SlimGruntHelpers
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slim-grunt-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fire-Dragon-DoL