linner 0.1.5 → 0.2.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 +4 -4
- data/lib/linner.rb +30 -32
- data/lib/linner/environment.rb +6 -4
- data/lib/linner/helper.rb +7 -7
- data/lib/linner/version.rb +1 -1
- data/spec/linner/helper_spec.rb +4 -4
- data/vendor/config.default.yml +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 234c003d2a8de857346b8001b7d76f4e0e2dc1d3
|
4
|
+
data.tar.gz: 5f67d62fd866da6717fa56f619be7a8613a1c859
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a78076faccfb160445dbe5c3846ba796e787c36a46c0f699f72890e0837dee3ca62f237dd0d83c00772d0eb06fe5b648dd456021c70cdce85ba5c27519726d91
|
7
|
+
data.tar.gz: 2324de42bd8f6ab2fbb82a7a98b54e71fe61f20958edc4c2e798bebfe089dae86fd729c35c6813c873c607f5942703344ecfb7ef670fd19c1a59d4f271de91e8
|
data/lib/linner.rb
CHANGED
@@ -25,48 +25,46 @@ module Linner
|
|
25
25
|
|
26
26
|
def perform(compile: false)
|
27
27
|
environment.files.each do |config|
|
28
|
-
|
29
|
-
|
28
|
+
concat(config, compile)
|
29
|
+
copy(config)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
private
|
34
|
-
def concat(config)
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
34
|
+
def concat(config, compile)
|
35
|
+
config["concat"].map do |dest, regex|
|
36
|
+
matches = Dir.glob(regex).uniq.order_by(before:config["order"]["before"], after:config["order"]["after"])
|
37
|
+
dest = Asset.new(File.join environment.public_folder, dest)
|
38
|
+
dest.content = ""
|
39
|
+
cached = matches.select do |path|
|
40
|
+
mtime = File.mtime(path).to_i
|
41
|
+
mtime == cache[path] ? false : cache[path] = mtime
|
42
|
+
end
|
43
|
+
next if cached.empty?
|
44
|
+
matches.each do |m|
|
45
|
+
asset = Asset.new(m)
|
46
|
+
content = asset.content
|
47
|
+
if asset.wrappable?
|
48
|
+
content = asset.wrap
|
47
49
|
end
|
48
|
-
|
49
|
-
end
|
50
|
+
dest.content << content
|
51
|
+
end
|
52
|
+
dest.compress if compile
|
53
|
+
dest.write
|
50
54
|
end
|
51
|
-
assets
|
52
55
|
end
|
53
56
|
|
54
57
|
def copy(config)
|
55
58
|
config["copy"].each do |dest, regex|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
dest_path = File.join(environment.public_folder, dest, logical_path)
|
66
|
-
FileUtils.mkdir_p File.dirname(dest_path)
|
67
|
-
FileUtils.cp_r path, dest_path
|
68
|
-
end
|
69
|
-
end.join
|
59
|
+
Dir.glob(regex).each do |path|
|
60
|
+
mtime = File.mtime(path).to_i
|
61
|
+
next if cache[path] == mtime
|
62
|
+
cache[path] = mtime
|
63
|
+
logical_path = Asset.new(path).logical_path
|
64
|
+
dest_path = File.join(environment.public_folder, dest, logical_path)
|
65
|
+
FileUtils.mkdir_p File.dirname(dest_path)
|
66
|
+
FileUtils.cp_r path, dest_path
|
67
|
+
end
|
70
68
|
end
|
71
69
|
end
|
72
70
|
end
|
data/lib/linner/environment.rb
CHANGED
@@ -15,10 +15,12 @@ module Linner
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
def notification
|
19
|
+
@env["notification"]
|
20
|
+
end
|
21
|
+
|
22
|
+
def wrapper
|
23
|
+
@env["modules"]["wrapper"]
|
22
24
|
end
|
23
25
|
|
24
26
|
def files
|
data/lib/linner/helper.rb
CHANGED
@@ -7,15 +7,15 @@ module Linner
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
module
|
11
|
-
def
|
12
|
-
|
13
|
-
|
10
|
+
module Order
|
11
|
+
def order_by(before:[], after:[])
|
12
|
+
order_by_before(self, before)
|
13
|
+
order_by_after(self, after)
|
14
14
|
self
|
15
15
|
end
|
16
16
|
|
17
17
|
private
|
18
|
-
def
|
18
|
+
def order_by_before(list, before)
|
19
19
|
before.reverse.each do |f|
|
20
20
|
if i = list.index {|x| x =~ /#{f}/i}
|
21
21
|
list.unshift list.delete_at i
|
@@ -23,7 +23,7 @@ module Linner
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
def
|
26
|
+
def order_by_after(list, after)
|
27
27
|
after.reverse.each do |f|
|
28
28
|
if i = list.index {|x| x =~ /#{f}/i}
|
29
29
|
list.push list.delete_at i
|
@@ -38,5 +38,5 @@ class Hash
|
|
38
38
|
end
|
39
39
|
|
40
40
|
class Array
|
41
|
-
include Linner::
|
41
|
+
include Linner::Order
|
42
42
|
end
|
data/lib/linner/version.rb
CHANGED
data/spec/linner/helper_spec.rb
CHANGED
@@ -7,21 +7,21 @@ describe Array do
|
|
7
7
|
|
8
8
|
describe :sort do
|
9
9
|
it "won't change when before and after are empty array" do
|
10
|
-
@array.
|
10
|
+
@array.order_by(before:[], after:[]).should be_equal @array
|
11
11
|
end
|
12
12
|
|
13
13
|
it "will change by before items" do
|
14
|
-
@array.
|
14
|
+
@array.order_by(before:["jquery.js", "vendor.js"], after:[])
|
15
15
|
@array.should =~ %w[jquery.js vendor.js app.js bootstrap.css reset.css]
|
16
16
|
end
|
17
17
|
|
18
18
|
it "will change by after items" do
|
19
|
-
@array.
|
19
|
+
@array.order_by(before:[], after:["reset.css", "bootstrap.css"])
|
20
20
|
@array.should =~ %w[app.js jquery.js vendor.js reset.css bootstrap.css]
|
21
21
|
end
|
22
22
|
|
23
23
|
it "will change by before and after items" do
|
24
|
-
@array.
|
24
|
+
@array.order_by(before:["jquery.js", "vendor.js"], after:["reset.css", "bootstrap.css"])
|
25
25
|
@array.should =~ %w[jquery.js vendor.js app.js reset.css bootstrap.css]
|
26
26
|
end
|
27
27
|
end
|
data/vendor/config.default.yml
CHANGED
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.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Saito
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|