XCUtils 0.0.1 → 0.1.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/bin/xcatlasify +8 -0
- data/lib/XCUtils/version.rb +1 -1
- data/lib/XCUtils/xcutils_patcher.rb +48 -0
- data/lib/XCUtils/xcutils_resizer.rb +9 -11
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d383fb1e0decd52a70e80bc201b7b940ee909112
|
4
|
+
data.tar.gz: e27f5c934576c8be7a7c51fa789e79a34a0159b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99c936628e070d0f9862be890964e3ea4acc440ee9dd1e0893b16afd3e1db1055c228378a76b20014e40350f87372106fbf5152bc811887f974595fce1210cc3
|
7
|
+
data.tar.gz: d4d559ebeb98413108f5cf196e8c791eda6faf23e3319b64b2a2375551e2762bfabe029e938279eae47d6cff06efeb55556d10ad2c20e009a3b80026b593720d
|
data/bin/xcatlasify
CHANGED
@@ -5,6 +5,7 @@ require 'rubygems'
|
|
5
5
|
|
6
6
|
require "thor"
|
7
7
|
require_relative "../lib/XCUtils/xcutils_resizer"
|
8
|
+
require_relative "../lib/XCUtils/xcutils_patcher"
|
8
9
|
|
9
10
|
class XCAtlasify < Thor
|
10
11
|
|
@@ -27,6 +28,13 @@ class XCAtlasify < Thor
|
|
27
28
|
XCUtils::XCUtilsSorter.start
|
28
29
|
end
|
29
30
|
|
31
|
+
desc "patch [patch-vrs, base-atlas]", "This patches the current 'resize' result (directory structure) to the latest version"
|
32
|
+
def patch(vrs, base)
|
33
|
+
validate_support
|
34
|
+
ARGV.shift
|
35
|
+
XCUtils::XCUtilsPatcher.start
|
36
|
+
end
|
37
|
+
|
30
38
|
private
|
31
39
|
def validate_support
|
32
40
|
# check if the action is valid...
|
data/lib/XCUtils/version.rb
CHANGED
@@ -0,0 +1,48 @@
|
|
1
|
+
require "thor"
|
2
|
+
require 'fileutils'
|
3
|
+
require 'debugger'
|
4
|
+
|
5
|
+
module XCUtils
|
6
|
+
class XCUtilsPatcher < Thor::Group
|
7
|
+
include Thor::Actions
|
8
|
+
|
9
|
+
argument :version
|
10
|
+
argument :base
|
11
|
+
|
12
|
+
|
13
|
+
def rename_and_move
|
14
|
+
say_status "Patching", "version #{version}", :yellow
|
15
|
+
|
16
|
+
unless version.eql? "0.0.1"
|
17
|
+
say_status "Warning", "No patch for this version...", :red
|
18
|
+
abort
|
19
|
+
end
|
20
|
+
|
21
|
+
unless Dir.exists?("#{base}.atlas")
|
22
|
+
say_status "Warning", "The base atlas does not exist, make sure you are within the correct directoy", :red
|
23
|
+
abort
|
24
|
+
end
|
25
|
+
|
26
|
+
checkSuffix = ["~ipad", "@2x~ipad", "@2x"]
|
27
|
+
|
28
|
+
checkSuffix.each do |suffix|
|
29
|
+
dir_suffix = "#{base}#{suffix}.atlas"
|
30
|
+
|
31
|
+
say_status "Patching", "#{dir_suffix}", :yellow
|
32
|
+
Dir["#{dir_suffix}/*.png"].each do |f|
|
33
|
+
filename = File.basename(f, File.extname(f))
|
34
|
+
unless filename.eql? ("filename#{suffix}")
|
35
|
+
dir = File.dirname(f)
|
36
|
+
new_filename = "#{base}.atlas/#{filename}#{suffix}.png"
|
37
|
+
say_status "Moving", "#{f} :: #{new_filename}", :green
|
38
|
+
File.rename(f, new_filename)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
say_status "Deleting", "#{dir_suffix}", :yellow
|
42
|
+
FileUtils.rm_rf(dir_suffix)
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
@@ -15,9 +15,6 @@ module XCUtils
|
|
15
15
|
name = File.basename target
|
16
16
|
Dir.mkdir(target) unless Dir.exists?(target)
|
17
17
|
Dir.mkdir(File.join(target,"#{name}.atlas")) unless Dir.exists?(File.join(target,"#{name}.atlas"))
|
18
|
-
Dir.mkdir(File.join(target,"#{name}@2x.atlas")) unless Dir.exists?(File.join(target,"#{name}@2x.atlas"))
|
19
|
-
Dir.mkdir(File.join(target,"#{name}~ipad.atlas")) unless Dir.exists?(File.join(target,"#{name}~ipad.atlas"))
|
20
|
-
Dir.mkdir(File.join(target,"#{name}@2x~ipad.atlas")) unless Dir.exists?(File.join(target,"#{name}@2x~ipad.atlas"))
|
21
18
|
end
|
22
19
|
|
23
20
|
def write_rename_images_to_dir
|
@@ -28,6 +25,7 @@ module XCUtils
|
|
28
25
|
if f.include?("@2x") && f.include?("~ipad")
|
29
26
|
|
30
27
|
fn = f.gsub("@2x","").gsub("~ipad","")
|
28
|
+
fn = File.basename(fn,File.extname(fn))
|
31
29
|
|
32
30
|
# load image
|
33
31
|
img = Magick::Image.read(File.join(source,f)).first
|
@@ -43,22 +41,22 @@ module XCUtils
|
|
43
41
|
img = img.extent(nWidth, nHeight)
|
44
42
|
|
45
43
|
# create ipad retina version
|
46
|
-
say_status "create ipad retina version", "#{
|
47
|
-
img.write(File.join(target,"#{name}@2x
|
44
|
+
say_status "create ipad retina version", "#{fn}@2x~ipad", :yellow
|
45
|
+
img.write(File.join(target,"#{name}.atlas","#{fn}@2x–ipad.png"))
|
48
46
|
|
49
47
|
# create ipad non retina version
|
50
|
-
say_status "create ipad non retina version", "#{
|
48
|
+
say_status "create ipad non retina version", "#{fn}~ipad", :yellow
|
51
49
|
img.minify!
|
52
|
-
img.write(File.join(target,"#{name}
|
50
|
+
img.write(File.join(target,"#{name}.atlas","#{fn}~ipad.png"))
|
53
51
|
|
54
52
|
# create iphone retina version - identical to ipad non retina version
|
55
|
-
say_status "create iphone retina version - identical to ipad non retina version", "#{
|
56
|
-
img.write(File.join(target,"#{name}
|
53
|
+
say_status "create iphone retina version - identical to ipad non retina version", "#{fn}@2x", :yellow
|
54
|
+
img.write(File.join(target,"#{name}.atlas","#{fn}@2x.png"))
|
57
55
|
|
58
56
|
# create iphone non retina version
|
59
|
-
say_status "create iphone non retina version", "#{
|
57
|
+
say_status "create iphone non retina version", "#{fn}", :yellow
|
60
58
|
img.minify!
|
61
|
-
img.write(File.join(target,"#{name}.atlas",fn))
|
59
|
+
img.write(File.join(target,"#{name}.atlas","#{fn}.png"))
|
62
60
|
end
|
63
61
|
end
|
64
62
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: XCUtils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin Müller
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-08-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -109,6 +109,7 @@ extra_rdoc_files: []
|
|
109
109
|
files:
|
110
110
|
- bin/xcatlasify
|
111
111
|
- lib/XCUtils/version.rb
|
112
|
+
- lib/XCUtils/xcutils_patcher.rb
|
112
113
|
- lib/XCUtils/xcutils_resizer.rb
|
113
114
|
- lib/XCUtils/xcutils_sorter.rb
|
114
115
|
homepage: https://github.com/elchbenny/XCUtils
|
@@ -131,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
132
|
version: '0'
|
132
133
|
requirements: []
|
133
134
|
rubyforge_project:
|
134
|
-
rubygems_version: 2.
|
135
|
+
rubygems_version: 2.4.1
|
135
136
|
signing_key:
|
136
137
|
specification_version: 4
|
137
138
|
summary: Resize *.@2x~ipad named images and move em into XCodes atlases.
|