texture_packer 1.1.2 → 1.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 +5 -5
- data/executables/pack_scss +41 -17
- data/lib/texture_packer/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8dc38cd32c0b72a13abfdf07a46d636efba1b851
|
4
|
+
data.tar.gz: 8dbb0c5b77dab3c9efaa3eb8c5c29ba73fb0b786
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0049b77322f41e5de83714b099b59982de5fb75334df7d8015f47d144f95851e3ef407c4b15cb758677cd399375005d9b2a772af9477012d2f2bd36a5942c067'
|
7
|
+
data.tar.gz: fb284485f416de0e4a75719f4ba705a078695eab063f70e46e6c7f6103ed922464775417c71eafba40d0f609f6d4da676910f81b75c9520297fe89f440727746
|
data/executables/pack_scss
CHANGED
@@ -34,6 +34,12 @@ def get_mixin(func, css)
|
|
34
34
|
return "@mixin #{func}{ #{css} }\n"
|
35
35
|
end
|
36
36
|
|
37
|
+
if File.exists?('packed_mobile.css') # 向下相容
|
38
|
+
exec_cmd('mv packed_mobile.css packed_m.css')
|
39
|
+
exec_cmd('mv packed_mobile.png packed_m.png')
|
40
|
+
end
|
41
|
+
$has_mobile = true if File.exists?('packed_m.css')
|
42
|
+
|
37
43
|
# ----------------------------------------------------------------
|
38
44
|
# ● 由路徑計算 class 名字
|
39
45
|
# ----------------------------------------------------------------
|
@@ -42,11 +48,12 @@ base_dir_name = File.basename(dir_name)
|
|
42
48
|
theme = base_dir_name[/[^_]+$/]
|
43
49
|
dir_without_theme = base_dir_name[0...-(theme.size + 1)]
|
44
50
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
51
|
+
output_paths_mapping = Dir['*.css'].map do |path|
|
52
|
+
name = File.basename(path, '.css')
|
53
|
+
next [name[/packed_(.*)/, 1], name]
|
54
|
+
end.to_h
|
55
|
+
|
56
|
+
content = output_paths_mapping.map{|_, path| File.read("#{path}.css") }.join
|
50
57
|
|
51
58
|
Dir['images/**/'].map{|s| s[/images\/(.*)\//, 1] }.compact.map{|s| "#{s.gsub('/', '-')}-" }.each do |path| #"images/aaa/bbb/ccc.png" => "aaa-bbb-"
|
52
59
|
content.gsub!(path, path.gsub('-', '_')) #aaa-bbb => aaa_bbb
|
@@ -83,18 +90,28 @@ loop do
|
|
83
90
|
end
|
84
91
|
# data = {selector => {nil => 'xxx', ':disabeld' => 'xxx', '[m]' => 'xxx'}}
|
85
92
|
output1 = "" #mixin的output
|
86
|
-
|
87
|
-
|
93
|
+
output_paths_mapping.map do |kind, name|
|
94
|
+
if kind == nil
|
95
|
+
output1 += get_mixin("#{base_dir_name}_sprite", "background-image: image-url('#{dir_name}.png');")
|
96
|
+
else
|
97
|
+
output1 += get_mixin("#{base_dir_name}_sprite_#{kind}", "background-image: image-url('#{dir_name}_#{kind}.png');")
|
98
|
+
end
|
99
|
+
end
|
88
100
|
output2 = "" #scss的output
|
89
101
|
output2 += "body[theme='#{theme}']{\n"
|
90
102
|
output2 += " .#{dir_without_theme}_sprite{\n"
|
91
103
|
if $has_mobile
|
92
|
-
output2 += " @include desktop{ @include #{base_dir_name}_sprite
|
93
|
-
output2 += " @include mobile{ @include #{base_dir_name}_sprite_m
|
104
|
+
output2 += " @include desktop{ @include #{base_dir_name}_sprite; }\n"
|
105
|
+
output2 += " @include mobile{ @include #{base_dir_name}_sprite_m; }\n"
|
106
|
+
elsif output_paths_mapping.size > 1
|
107
|
+
output2 += output_paths_mapping.map do |kind, name|
|
108
|
+
next " @include #{base_dir_name}_sprite;\n" if kind == nil
|
109
|
+
next " &[kind=\"#{kind}\"] { @include #{base_dir_name}_sprite_#{kind}; }\n"
|
110
|
+
end.join
|
94
111
|
else
|
95
|
-
output2 += " @include #{base_dir_name}_sprite
|
112
|
+
output2 += " @include #{base_dir_name}_sprite;\n"
|
96
113
|
end
|
97
|
-
# output2 += " &.split_mobile{ @include mobile{ @include #{base_dir_name}_sprite_m
|
114
|
+
# output2 += " &.split_mobile{ @include mobile{ @include #{base_dir_name}_sprite_m; }}\n" if $has_mobile
|
98
115
|
class CssRule
|
99
116
|
def initialize
|
100
117
|
@hash = {}
|
@@ -130,7 +147,7 @@ for selector, css_data in data
|
|
130
147
|
rules.add(prefixs, css)
|
131
148
|
}
|
132
149
|
output1 << get_mixin(func, rules.generate_css)
|
133
|
-
output2 << " &.#{selector}{ @include #{func}
|
150
|
+
output2 << " &.#{selector} { @include #{func}; }\n"
|
134
151
|
end
|
135
152
|
output2 += " }\n"
|
136
153
|
output2 += "}\n"
|
@@ -139,23 +156,30 @@ output = output0 + output1 + output2
|
|
139
156
|
# ----------------------------------------------------------------
|
140
157
|
# ● 壓縮圖片
|
141
158
|
# ----------------------------------------------------------------
|
142
|
-
|
143
|
-
exec_cmd(
|
159
|
+
output_paths_mapping.each do |_, path|
|
160
|
+
exec_cmd("pngquant #{path}.png --force")
|
161
|
+
end
|
162
|
+
|
144
163
|
write_to_file('packed.scss', output)
|
145
164
|
|
146
165
|
# ----------------------------------------------------------------
|
147
166
|
# ● 自動輸出到專案
|
148
167
|
# ----------------------------------------------------------------
|
149
168
|
if SETTING['project_dir']
|
169
|
+
css_pre_lines = ["@import './mixin.scss';"]
|
170
|
+
css_pre_lines.unshift("@import 'global_mixins';") if $has_mobile
|
171
|
+
|
150
172
|
sub_dirs = dir_name.split(File::Separator)[0...-1]
|
151
173
|
css_path = Pathname.new(SETTING['project_dir']).join('app', 'assets', 'stylesheets', 'packed_sprites', *sub_dirs, dir_without_theme)
|
152
174
|
img_path = Pathname.new(SETTING['project_dir']).join('app', 'assets', 'images', *sub_dirs)
|
153
175
|
FileUtils.mkdir_p(css_path)
|
154
176
|
FileUtils.mkdir_p(img_path)
|
155
177
|
write_to_file(css_path.join('mixin.scss'), output1)
|
156
|
-
write_to_file(css_path.join('ocean.scss'), "
|
157
|
-
|
158
|
-
|
178
|
+
write_to_file(css_path.join('ocean.scss'), "#{css_pre_lines.join("\n")}\n\n#{output2}")
|
179
|
+
output_paths_mapping.each do |_, path|
|
180
|
+
FileUtils.cp("#{path}-fs8.png", img_path.join("#{path.sub('packed', base_dir_name)}.png"))
|
181
|
+
exec_cmd("pngquant #{path}.png --force")
|
182
|
+
end
|
159
183
|
end
|
160
184
|
|
161
185
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: texture_packer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- khiav reoy
|
8
8
|
autorequire:
|
9
9
|
bindir: executables
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
74
|
version: '0'
|
75
75
|
requirements: []
|
76
76
|
rubyforge_project:
|
77
|
-
rubygems_version: 2.
|
77
|
+
rubygems_version: 2.6.14
|
78
78
|
signing_key:
|
79
79
|
specification_version: 4
|
80
80
|
summary: texture packer
|