linner 0.9.1 → 0.10.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f0bd139ca78130131ca3cc2c5bdf8b46f88ff4b8
4
- data.tar.gz: 282a2aff6ff90978dd47c241592911226216829f
3
+ metadata.gz: da0b05dc72a9e2993d4c6c1f12c27311e622ba20
4
+ data.tar.gz: 75ac9e76a25aa4d7fdbf27c82ece3bbc3f29028a
5
5
  SHA512:
6
- metadata.gz: f889e7634447fe5f4f1b7e1747d88189bb59ae4ce45388d1026e56469ca40c1756f3c3ba9c815e56e6d24fa394885236e376fec9a225099d4adea219ee01de49
7
- data.tar.gz: 43e91e47a4c8615b0660b43238c59d9e8be44c5e2f47f69e58b2d2e398104a8a82523debbb8981a9817638b018bc8830c9784f35ee78e83e581fa72de4bee9c8
6
+ metadata.gz: 8c2421a77a255f1d4b5e15e8ed263ea6bf2ed7d478808697c4ec858aabdb435f9bbe203c8a9b1bad6df6b67dedcf81305cddff625f5ab3d722d346a25db3a5dd
7
+ data.tar.gz: 60a194ab95ce596151b82646f429628b8b80fe0176d0e8a6da02524694683427900d63826b2cf5cd68d8f0190973bdab2b0e96d85720df41bbaf253c61fb2a78
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ v0.10.0
2
+ - introducing new directive `compile` and `context` to compile files
3
+
1
4
  v0.9.1
2
5
  - add .yml .yaml and .txt to Tilt templates
3
6
 
@@ -51,12 +51,16 @@ the default configuration defines four groups: `scripts`, `styles`, `images` and
51
51
 
52
52
  `copy` defines copy strategy of files in Linner. The `Dir.glob` of `value` will be copy to `key` folder.
53
53
 
54
+ `compile` defines compile strategy of files in Linner. The `Dir.glob` of `value` will be compile to `key` folder.
55
+
54
56
  `precompile` defines precompile strategy of javascript templates for Linner. The `Dir.glob` of `value` will be concat to `key`.
55
57
 
56
58
  `sprite` defines sprite strategy of images for Linner. The `Dir.glob` of `value` will be sprite to `key`.
57
59
 
58
60
  `tar` defines archive strategy of files in Linner. The `Dir.glob` of `value` will be archive to `key` file.
59
61
 
62
+ `context` defines the context of the `compile` files, and the value will pass to the render function.
63
+
60
64
  `order` defines the order of this group files, and It's very useful when you `concat` your files. for example:
61
65
 
62
66
  ```yaml
@@ -102,6 +102,7 @@ module Linner
102
102
  end
103
103
  env.groups.each do |config|
104
104
  copy(config) if config["copy"]
105
+ compile(config) if config["compile"]
105
106
  concat(config) if config["concat"]
106
107
  end
107
108
  env.groups.each do |config|
@@ -122,6 +123,17 @@ module Linner
122
123
 
123
124
  def copy(config)
124
125
  config["copy"].each do |dest, pattern|
126
+ Dir.glob(pattern).each do |path|
127
+ asset = Asset.new(path)
128
+ dest_path = File.join(env.public_folder, dest, asset.logical_path)
129
+ FileUtils.mkdir_p File.dirname(dest_path)
130
+ FileUtils.cp_r path, dest_path
131
+ end
132
+ end
133
+ end
134
+
135
+ def compile(config)
136
+ config["compile"].each do |dest, pattern|
125
137
  Dir.glob(pattern).each do |path|
126
138
  next if not cache.miss?(dest, path)
127
139
  asset = Asset.new(path)
@@ -129,8 +141,18 @@ module Linner
129
141
  if asset.javascript? or asset.stylesheet?
130
142
  asset.content
131
143
  asset.compress if compile?
132
- dest_path = dest_path.sub(/[^.]+\z/,"js") if asset.javascript?
133
- dest_path = dest_path.sub(/[^.]+\z/,"css") if asset.stylesheet?
144
+ dest_path = dest_path.sub(/[^.]+\z/, "js") if asset.javascript?
145
+ dest_path = dest_path.sub(/[^.]+\z/, "css") if asset.stylesheet?
146
+ asset.path = dest_path
147
+ asset.write
148
+ elsif asset.eruby?
149
+ base, ext = path.split(".")
150
+ dest_path = if ext == "erb"
151
+ dest_path.sub(/[.]+\z/, "html")
152
+ else
153
+ dest_path.gsub(File.basename(dest_path), File.basename(dest_path, File.extname(dest_path)))
154
+ end
155
+ asset.content(config["context"])
134
156
  asset.path = dest_path
135
157
  asset.write
136
158
  else
@@ -36,10 +36,10 @@ module Linner
36
36
  File.rename path, digest_path
37
37
  end
38
38
 
39
- def content
39
+ def content(context = nil)
40
40
  return @content if @content
41
41
  source = begin
42
- File.exist?(path) ? Tilt.new(path, :default_encoding => "UTF-8").render : ""
42
+ File.exist?(path) ? Tilt.new(path, :default_encoding => "UTF-8").render(nil, context) : ""
43
43
  rescue RuntimeError
44
44
  File.read(path, mode: "rb")
45
45
  rescue => e
@@ -76,6 +76,10 @@ module Linner
76
76
  Tilt[path] and Tilt[path].default_mime_type == "text/template"
77
77
  end
78
78
 
79
+ def eruby?
80
+ Tilt[path] and Tilt[path].default_mime_type = "application/x-eruby"
81
+ end
82
+
79
83
  def wrappable?
80
84
  !!(self.javascript? and !Linner.env.modules_ignored.include?(@path) or self.template?)
81
85
  end
@@ -49,6 +49,8 @@ module Tilt
49
49
  end
50
50
  end
51
51
 
52
+ ERBTemplate.default_mime_type = "application/x-eruby"
53
+
52
54
  register PlainTemplate, "txt"
53
55
  register CSSTemplate, "css"
54
56
  register JavascriptTemplate, "js"
@@ -1,3 +1,3 @@
1
1
  module Linner
2
- VERSION = "0.9.1"
2
+ VERSION = "0.10.0"
3
3
  end
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency "thor", "~> 0.18"
22
- spec.add_dependency "tilt", "~> 1.4"
22
+ spec.add_dependency "tilt", "~> 2.0"
23
23
  spec.add_dependency "reel", "~> 0.5.0"
24
24
  spec.add_dependency "listen", "~> 1.3"
25
25
  spec.add_dependency "uglifier", "~> 2.5.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Saito
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-23 00:00:00.000000000 Z
11
+ date: 2015-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.4'
33
+ version: '2.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.4'
40
+ version: '2.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: reel
43
43
  requirement: !ruby/object:Gem::Requirement