Module: Linner
- Extended by:
- Linner
- Included in:
- Linner
- Defined in:
- lib/linner.rb,
lib/linner/asset.rb,
lib/linner/cache.rb,
lib/linner/helper.rb,
lib/linner/sprite.rb,
lib/linner/archive.rb,
lib/linner/bundler.rb,
lib/linner/command.rb,
lib/linner/reactor.rb,
lib/linner/version.rb,
lib/linner/wrapper.rb,
lib/linner/notifier.rb,
lib/linner/compressor.rb,
lib/linner/environment.rb
Defined Under Namespace
Modules: HashRecursiveMerge, Order, Wrapper
Classes: Archive, Asset, Bundler, Cache, Command, Compressor, Environment, ImageProxy, Notifier, Reactor, Sprite
Constant Summary
collapse
- VERSION =
"1.0.0"
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#compile=(value) ⇒ Object
Sets the attribute compile
19
20
21
|
# File 'lib/linner.rb', line 19
def compile=(value)
@compile = value
end
|
#env ⇒ Object
Returns the value of attribute env.
19
20
21
|
# File 'lib/linner.rb', line 19
def env
@env
end
|
#strict ⇒ Object
Returns the value of attribute strict.
19
20
21
|
# File 'lib/linner.rb', line 19
def strict
@strict
end
|
Instance Method Details
#cache ⇒ Object
35
36
37
|
# File 'lib/linner.rb', line 35
def cache
@cache ||= Cache.new
end
|
#compile? ⇒ Boolean
90
91
92
|
# File 'lib/linner.rb', line 90
def compile?
@compile
end
|
#config_file ⇒ Object
25
26
27
28
29
|
# File 'lib/linner.rb', line 25
def config_file
linner_file = root.join("Linnerfile")
config_file = root.join("config.yml")
File.exist?(linner_file) ? linner_file : config_file
end
|
#manifest ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/linner.rb', line 39
def manifest
@manifest ||= begin
hash = {}
copy_assets = []
concat_assets = []
template_assets = []
sprite_assets = []
cdn = env.revision["cdn"] || ""
prefix = env.revision["prefix"] || ""
env.groups.each do |config|
concat_assets << config["concat"].keys if config["concat"]
template_assets << config["template"].keys if config["template"]
sprite_assets << config["sprite"].keys if config["sprite"]
config["copy"].each do |dest, pattern|
copy_assets << Dir.glob(pattern).map do |path|
logical_path = Asset.new(path).logical_path
dest_path = File.join(dest, logical_path)
end
end if config["copy"]
end
sprite_assets.flatten.each do |dest|
name = File.basename(dest).sub /[^.]+\z/, "png"
dest = File.join env.sprites["path"], name
asset = Asset.new(File.join env.public_folder, dest)
hash[prefix + dest] = cdn + prefix + asset.relative_digest_path
asset.revision!
(concat_assets + copy_assets).flatten.each do |file|
path = File.join env.public_folder, file
next unless Asset.new(path).stylesheet?
url = env.sprites["url"] || env.sprites["path"]
puts = File.read(path).gsub(File.join(url, File.basename(dest)), File.join(cdn, url, File.basename(asset.relative_digest_path)))
File.open(path, "w") { |file| file << puts }
end
end
(concat_assets + template_assets + copy_assets).flatten.each do |dest|
asset = Asset.new(File.join env.public_folder, dest)
next unless asset.revable?
hash[prefix + dest] = cdn + prefix + asset.relative_digest_path
asset.revision!
end
hash
end
end
|
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
# File 'lib/linner.rb', line 98
def perform(*asset)
env.groups.each do |config|
precompile(config) if config["precompile"]
sprite(config) if config["sprite"]
end
env.groups.each do |config|
copy(config) if config["copy"]
compile(config) if config["compile"]
concat(config) if config["concat"]
end
env.groups.each do |config|
tar(config) if config["tar"]
end
revision if compile? and env.revision
end
|
#root ⇒ Object
21
22
23
|
# File 'lib/linner.rb', line 21
def root
@root ||= Pathname('.').realpath
end
|
#strict? ⇒ Boolean
94
95
96
|
# File 'lib/linner.rb', line 94
def strict?
@strict
end
|