airservice_build_tools 0.0.6 → 0.0.7
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/README.md +4 -0
- data/lib/airservice/build_tools/obj_c.rb +27 -0
- data/lib/airservice/build_tools/version.rb +1 -1
- data/spec/airservice/build_tools/obj_c_spec.rb +25 -0
- data/spec/fixtures/test_image.png +0 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2b8d434319dde2e092bb3b0efe2903925693ace
|
4
|
+
data.tar.gz: f9e096ade73af6030577eb3fa5910118481272e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8732e2d784b08a65395eeb925653020a02965583ba97ba643f22bb5aa09b0532bd4fd9ae3b63d192d4be79edf5cfb7469afbb7581fe99cfc43bda9d2e376ae1c
|
7
|
+
data.tar.gz: f1fa7bb613c24fb46abb8949d9241a44df0c79207436268e228b9608d645047b07ee782e6c4c19a8ed39d54502512627f77d8c8243f2b8c6b4f1bc1dc438b239
|
data/README.md
CHANGED
@@ -20,6 +20,33 @@ module AirService
|
|
20
20
|
new_plist_content = plist.to_plist
|
21
21
|
File.open(plist_file_path, 'w+') { |f| f.write(new_plist_content) }
|
22
22
|
end
|
23
|
+
|
24
|
+
def create_ios_icons(options={})
|
25
|
+
sizes = [
|
26
|
+
{size: 76, name: 'ipad', scale: [1, 2]},
|
27
|
+
{size: 40, name: 'ipad_spotlight', scale: [1, 2]},
|
28
|
+
{size: 29, name: 'ipad_settings', scale: [1, 2]},
|
29
|
+
{size: 60, name: 'iphone', scale: [2]},
|
30
|
+
{size: 40, name: 'iphone_spotlight', scale: [2]},
|
31
|
+
{size: 29, name: 'iphone_settings', scale: [2]},
|
32
|
+
]
|
33
|
+
source = options.fetch(:source)
|
34
|
+
raise "Source file #{source} doesn't exists" unless File.exists?(source)
|
35
|
+
output_dir = options.fetch(:output_dir)
|
36
|
+
FileUtils.mkdir_p(output_dir)
|
37
|
+
|
38
|
+
sizes.each do |size|
|
39
|
+
size[:scale].each do |scale|
|
40
|
+
scaled_size = size[:size] * scale
|
41
|
+
target_size = "#{scaled_size}x#{scaled_size}"
|
42
|
+
output_file = "#{size[:name]}@#{scale}x}.png"
|
43
|
+
args = %W[#{File.expand_path(source, '.')}
|
44
|
+
-resize #{target_size}
|
45
|
+
#{File.join(output_dir, output_file)}]
|
46
|
+
system('convert', *args)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
23
50
|
end
|
24
51
|
end
|
25
52
|
end
|
@@ -61,4 +61,29 @@ describe AirService::BuildTools::ObjC do
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
64
|
+
|
65
|
+
describe '#create_ios_icons' do
|
66
|
+
before do
|
67
|
+
FileUtils.rmtree('/tmp/icons')
|
68
|
+
end
|
69
|
+
it 'throws exception if it source file is not found' do
|
70
|
+
expect { create_ios_icons(source: 'spec/fixtures/does_not_exist.png', output_dir: '/tmp/icons') }.to raise_error do |error|
|
71
|
+
expect(error.message).to include('source file')
|
72
|
+
end
|
73
|
+
end
|
74
|
+
it 'creates images of non retina sizes' do
|
75
|
+
create_ios_icons(source: 'spec/fixtures/test_image.png', output_dir: '/tmp/icons/')
|
76
|
+
icons = Dir['/tmp/icons/*.png'].map do |file|
|
77
|
+
`identify #{file}`
|
78
|
+
end.join(' ')
|
79
|
+
icons.should include('76x76', '40x40', '29x29')
|
80
|
+
end
|
81
|
+
it 'creates images of retina sizes when specified' do
|
82
|
+
create_ios_icons(source: 'spec/fixtures/test_image.png', output_dir: '/tmp/icons/')
|
83
|
+
icons = Dir['/tmp/icons/*.png'].map do |file|
|
84
|
+
`identify #{file}`
|
85
|
+
end.join(' ')
|
86
|
+
icons.should include('152x152', '80x80', '58x58')
|
87
|
+
end
|
88
|
+
end
|
64
89
|
end
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: airservice_build_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AirService
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: plist
|
@@ -127,6 +127,7 @@ files:
|
|
127
127
|
- lib/airservice/build_tools/obj_c.rb
|
128
128
|
- lib/airservice/build_tools/version.rb
|
129
129
|
- spec/airservice/build_tools/obj_c_spec.rb
|
130
|
+
- spec/fixtures/test_image.png
|
130
131
|
- spec/spec_helper.rb
|
131
132
|
homepage: http://github.com/airservice/build_tools
|
132
133
|
licenses:
|
@@ -154,4 +155,5 @@ specification_version: 4
|
|
154
155
|
summary: Build toolls
|
155
156
|
test_files:
|
156
157
|
- spec/airservice/build_tools/obj_c_spec.rb
|
158
|
+
- spec/fixtures/test_image.png
|
157
159
|
- spec/spec_helper.rb
|