ios-png-check 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/CHANGELOG +3 -0
  2. data/LICENSE +20 -0
  3. data/README.rdoc +17 -0
  4. data/VERSION +1 -0
  5. data/bin/ios-png-check +88 -0
  6. metadata +67 -0
@@ -0,0 +1,3 @@
1
+ v1.1.0. Initial release.
2
+ v1.4.0. Better command line options handling + Bugfixes.
3
+ v1.5.0. Fixed a major bug in localization of XIB files.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Andrey Subbotin
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,17 @@
1
+ = ios-png-check
2
+
3
+ A simple utility to check that your @2x iOS PNG assets targeting iPhone 4 are in a good shape.
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
+ * Send me a pull request. Bonus points for topic branches.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2010 Andrey Subbotin. See LICENSE for details.
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'fileutils'
5
+
6
+ # Main block
7
+
8
+ def main
9
+ files_wo_1x_version = []
10
+ files_wo_2x_version = []
11
+ size_errors = []
12
+
13
+ png_files = Dir.glob('*.png')
14
+
15
+ png_files.each { |png_file|
16
+ name_parts = png_file.split(/[@\.]/)
17
+
18
+ v1x_exists = false
19
+ v2x_exists = false
20
+
21
+ if name_parts.length == 3 then
22
+ v1_name = "#{name_parts[0]}.#{name_parts[2]}"
23
+ v2_name = "#{name_parts[0]}@2x.#{name_parts[2]}"
24
+ v1x_exists = File.exists?(v1_name)
25
+ v2x_exists = File.exists?(v2_name)
26
+ files_wo_1x_version << png_file unless v1x_exists
27
+
28
+ if v1x_exists and v2x_exists then
29
+ v1_info = `file #{v1_name}`.match(/(\d+) x (\d+)/)
30
+ v2_info = `file #{v2_name}`.match(/(\d+) x (\d+)/)
31
+ v1w = v1_info[1].to_i
32
+ v1h = v1_info[2].to_i
33
+ v2w = v2_info[1].to_i
34
+ v2h = v2_info[2].to_i
35
+ v2w_expected = v1w * 2
36
+ v2h_expected = v1h * 2
37
+
38
+ if v2w != v2w_expected or v2h != v2h_expected then
39
+ size_errors << "#{v2_name}: SIZE IS #{v2w} x #{v2h}, EXPECTED #{v2w_expected} x #{v2h_expected}"
40
+ end
41
+ end
42
+
43
+ elsif name_parts.length == 2 then
44
+ v1_name = "#{name_parts[0]}.#{name_parts[1]}"
45
+ v2_name = "#{name_parts[0]}@2x.#{name_parts[1]}"
46
+ v1x_exists = File.exists?(v1_name)
47
+ v2x_exists = File.exists?(v2_name)
48
+ files_wo_2x_version << png_file unless v2x_exists
49
+ end
50
+ }
51
+
52
+ if png_files.empty? then
53
+ puts "HEY, THERE'S NO PNG FILES IN THE CURRENT FOLDER."
54
+ return
55
+ end
56
+
57
+ is_all_okay = true
58
+
59
+ unless files_wo_1x_version.empty? then
60
+ puts "FILES WITHOUT @1x VERSION ============================================"
61
+ puts files_wo_1x_version
62
+ puts
63
+ is_all_okay = false
64
+ end
65
+
66
+ unless files_wo_2x_version.empty? then
67
+ puts "FILES WITHOUT @2x VERSION ============================================"
68
+ puts files_wo_2x_version
69
+ puts
70
+ is_all_okay = false
71
+ end
72
+
73
+ unless size_errors.empty? then
74
+ puts "INVALID IMAGE SIZES DETECTED FOR THE FOLLOWING FILES ================="
75
+ puts size_errors
76
+ puts
77
+ is_all_okay = false
78
+ end
79
+
80
+ if is_all_okay then
81
+ puts "YOUR PNG ASSETS IN THE CURRENT FOLDER ARE FINE, DUDE."
82
+ end
83
+
84
+ end
85
+
86
+ # Aux methods
87
+
88
+ main
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ios-png-check
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 0
9
+ version: 1.0.0
10
+ platform: ruby
11
+ authors:
12
+ - Andrey Subbotin
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-07-26 00:00:00 -04:00
18
+ default_executable:
19
+ - ios-png-check
20
+ dependencies: []
21
+
22
+ description: A simple utility to check that your @2x iOS PNG assets targeting iPhone 4 are in a good shape
23
+ email: andrey@subbotin.me
24
+ executables:
25
+ - ios-png-check
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - LICENSE
30
+ - README.rdoc
31
+ files:
32
+ - CHANGELOG
33
+ - LICENSE
34
+ - README.rdoc
35
+ - VERSION
36
+ has_rdoc: true
37
+ homepage: http://github.com/eploko/ios-png-check
38
+ licenses: []
39
+
40
+ post_install_message:
41
+ rdoc_options:
42
+ - --charset=UTF-8
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ segments:
50
+ - 0
51
+ version: "0"
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ requirements: []
60
+
61
+ rubyforge_project:
62
+ rubygems_version: 1.3.6
63
+ signing_key:
64
+ specification_version: 3
65
+ summary: iPhone 4 @2x assets made easy
66
+ test_files: []
67
+