texture_packer 1.0.0 → 1.1.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
- SHA1:
3
- metadata.gz: 64f180197b5792e32077e24720bf9e1eabc71b95
4
- data.tar.gz: 88e8d4ce8219d973af5c1a9cdfb36aed63f0db68
2
+ SHA256:
3
+ metadata.gz: c1b3743303122b6cd9693297b5701fac67078c0caa62577b6e0842cdddd61c25
4
+ data.tar.gz: a540f0a1079addab63f844d4032028ae802a38a25665478623ea0dd66357cae1
5
5
  SHA512:
6
- metadata.gz: 7fc23109a106fe632604e973424c77cddf213cbbcfc3a87cff792b0c0fec2cb2c1969a19473372199279f01cb10a7c2114c555dae0513a19371032929dc1fdff
7
- data.tar.gz: 0b488c4eb51ca48a4d01889236283f7d3eb731e300fba681ca046bedacf79efa87c9c956c414168e73ffab2bda36cc97f41b1448ccec85f2a58a03e8f71a3cb5
6
+ metadata.gz: af892d1dabe7d0688f0bec7695d863ca33c5e31e146422830c461283d78e727550d93dc54b27ffbf6f5118f596f9616d0d046e5a06c36956feea892569c087a8
7
+ data.tar.gz: fc8448ec50144df52cfdecb15e3bb9aa02536bf409ca909866f9df8038e427390b75fe19bf1d0cc37b61c1bcddc17511a716e49d5fe793f97a69c5f8163fac27
@@ -16,8 +16,12 @@ end
16
16
  SETTING = load_yaml('setting.yml')
17
17
 
18
18
  def exec_cmd(cmd)
19
- puts cmd
20
- puts `#{cmd}`
19
+ begin
20
+ puts cmd
21
+ puts `#{cmd}`
22
+ rescue => e
23
+ puts e
24
+ end
21
25
  end
22
26
 
23
27
  def write_to_file(path, content)
@@ -39,6 +43,10 @@ theme = base_dir_name[/[^_]+$/]
39
43
  dir_without_theme = base_dir_name[0...-(theme.size + 1)]
40
44
 
41
45
  content = File.read('packed.css')
46
+ if File.exists?('packed_mobile.css')
47
+ content += File.read('packed_mobile.css')
48
+ $has_mobile = true
49
+ end
42
50
 
43
51
  Dir['images/**/'].map{|s| s[/images\/(.*)\//, 1] }.compact.map{|s| "#{s.gsub('/', '-')}-" }.each do |path| #"images/aaa/bbb/ccc.png" => "aaa-bbb-"
44
52
  content.gsub!(path, path.gsub('-', '_')) #aaa-bbb => aaa_bbb
@@ -75,11 +83,13 @@ loop do
75
83
  end
76
84
  # data = {selector => {nil => 'xxx', ':disabeld' => 'xxx', '[m]' => 'xxx'}}
77
85
  output1 = "" #mixin的output
78
- output1 += get_mixin("#{base_dir_name}_sprite", "background-image: image-url('#{dir_name}.png')")
86
+ output1 += get_mixin("#{base_dir_name}_sprite", "background-image: image-url('#{dir_name}.png');")
87
+ output1 += get_mixin("#{base_dir_name}_sprite_m", "background-image: image-url('#{dir_name}_m.png');") if $has_mobile
79
88
  output2 = "" #scss的output
80
89
  output2 += "body[theme='#{theme}']{\n"
81
90
  output2 += " .#{dir_without_theme}_sprite{\n"
82
91
  output2 += " @include #{base_dir_name}_sprite();\n"
92
+ output2 += " &.split_mobile{ @include mobile{ @include #{base_dir_name}_sprite_m(); }}\n" if $has_mobile
83
93
  class CssRule
84
94
  def initialize
85
95
  @hash = {}
@@ -99,7 +109,7 @@ class CssRule
99
109
  when prefix[0] == ':'
100
110
  ["&#{prefix}, &.#{prefix[1..-1]}{ ", obj.generate_css, " }"]
101
111
  when prefix == '[m]'
102
- ["@media(max-width: $mobile_width){ ", obj.generate_css, " }"]
112
+ ["@include mobile{ ", obj.generate_css, " }"]
103
113
  else
104
114
  ["&#{prefix}{ ", obj.generate_css, " }"]
105
115
  end
@@ -125,6 +135,7 @@ output = output0 + output1 + output2
125
135
  # ● 壓縮圖片
126
136
  # ----------------------------------------------------------------
127
137
  exec_cmd('pngquant packed.png --force')
138
+ exec_cmd('pngquant packed_mobile.png --force') if $has_mobile
128
139
  write_to_file('packed.scss', output)
129
140
 
130
141
  # ----------------------------------------------------------------
@@ -139,6 +150,7 @@ if SETTING['project_dir']
139
150
  write_to_file(css_path.join('mixin.scss'), output1)
140
151
  write_to_file(css_path.join('ocean.scss'), "@import './mixin.scss';\n\n#{output2}")
141
152
  FileUtils.cp('packed-fs8.png', img_path.join(base_dir_name + '.png'))
153
+ FileUtils.cp('packed_mobile-fs8.png', img_path.join(base_dir_name + '_m.png'))
142
154
  end
143
155
 
144
156
 
@@ -1,3 +1,3 @@
1
1
  module TexturePacker
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
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.0.0
4
+ version: 1.1.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: 2018-01-11 00:00:00.000000000 Z
11
+ date: 2018-02-27 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.6.13
77
+ rubygems_version: 2.7.6
78
78
  signing_key:
79
79
  specification_version: 4
80
80
  summary: texture packer