flavours 0.0.2 → 0.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 33b6ed5c3c07f3ec3e7500f9cd9c4564bc54cddd
4
- data.tar.gz: 8ba157e4878199a58d0c5a1cdd8f8400130ca5b6
3
+ metadata.gz: 114e509b32662c162de75b86d8dc2bebe9c0d60a
4
+ data.tar.gz: 9bdf076d9f6f133c5d125a898730ba0d1eaf579d
5
5
  SHA512:
6
- metadata.gz: 7f6d01667d95938bc2bbc11fe3554e856cfc6d1bc5d003627dfb4af2ecc82af87f6b6f5ae73829904499a708901d29dbfe9c17c1c3141cc3881cf73263891782
7
- data.tar.gz: 3386f86af13bf68b20c92d0165c19b4e3d2810087e4fc1f27f1a59bc1cb2fe9b05bfc0d4776a647ec01ed1036f2ab9cd34e167dd2d35d74df34815b2e31fed08
6
+ metadata.gz: 05e29447d992a6ea264a3f8f047a6b45da8f96a2035f7b6a47b5939708a7261d3c509dfda6ca3781f789dec45348ebdea782cb747972d4b9d780fcff2a1bd108
7
+ data.tar.gz: 377c43b96a2a529eaac9094cbc8819fd9dd39af3719366f63cb575efc1fee75f69322ec6101d98537238202d36e90a104a2e307e8303f6af0a921ed074bf5c63
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- flavours (0.0.1)
4
+ flavours (0.0.5)
5
5
  bundler (~> 1.3)
6
6
  commander (~> 4.2)
7
7
  dotenv (~> 0.11)
data/README.md CHANGED
@@ -1,24 +1,124 @@
1
- # Flavours
1
+ ![banner](resources/banner.png)
2
2
 
3
- TODO: Write a gem description
3
+ **Problem**
4
4
 
5
- ## Installation
5
+ One codebase. Multiple Google Play Store submissions with different icons, XML resources, build configurations, etc.
6
+
7
+ **Solution**
8
+
9
+ ```
10
+ $ flavours install
11
+ $ flavours shoot
12
+ ```
13
+
14
+ **About**
15
+
16
+ Flavours is a command-line run ruby gem that reads from a .json file to create new [Product Flavors](http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Product-flavors) and adds them to your Android application's `build.gradle` file to make creating new apps a breeze. It allows you to have one code-base that can create a multitude of apps without very much involvement from you, the developer.
17
+
18
+ **TL;DR:** You can whitelabel Android apps extremely easily now.
19
+
20
+ **Requirements**
6
21
 
7
- Add this line to your application's Gemfile:
22
+ Flavours requires your Android application use the Gradle build system.
8
23
 
9
- gem 'flavours'
24
+ ## Table of Contents
10
25
 
11
- And then execute:
26
+ * [Installation](#installation)
27
+ * [Set Up](#set-up)
28
+ * [Formatting flavours.json](#formatting-flavours-json)
29
+ * [Creating Flavors](#creating-flavors)
30
+ * [The Future](#the-future)
31
+ * [Contributing](#contributing)
12
32
 
13
- $ bundle
33
+ ## Installation
14
34
 
15
- Or install it yourself as:
35
+ flavours is officially hosted on [RubyGems](http://rubygems.org/gems/flavours), so installation is a breeze:
16
36
 
17
37
  $ gem install flavours
18
38
 
19
- ## Usage
39
+ ## Set Up
40
+
41
+ Run `flavours install` in your app's main directory. This will create a file, `flavours.json`, where the configurations will be used to build out from here. You are almost ready to start creating new apps!
42
+
43
+ ## Formatting flavours.json
44
+
45
+ Here's a basic gist of how to format your `flavours.json` file:
46
+
47
+ ```
48
+ {
49
+ "flavours": [
50
+ {
51
+ "flavourName": "YourFlavor",
52
+ "packageName": "somePackageName",
53
+ "buildConfig": {
54
+ "API_KEY": "someApiKey"
55
+ },
56
+ "iconUrl": "https://someurl.com/image.png",
57
+ "colorsXML": {
58
+ "primaryColor": "#E51919"
59
+ },
60
+ "stringsXML": {
61
+ "someString": "someValue"
62
+ }
63
+ },
64
+ {
65
+ "flavourName": "YourFlavor2",
66
+ "packageName": "somePackageName2",
67
+ "buildConfig": {
68
+ "API_KEY": "someApiKey"
69
+ },
70
+ "iconUrl": "https://someurl.com/image.png",
71
+ "colorsXML": {
72
+ "primaryColor": "#E51919"
73
+ },
74
+ "stringsXML": {
75
+ "someString": "someValue"
76
+ }
77
+ }
78
+ ]
79
+ }
80
+ ```
81
+
82
+ In the top-level of the JSON file, we have the main key/value pair:
83
+
84
+ * `flavours`
85
+
86
+ This section contains an array of key/value pairs that correspond to each product flavor you'd like to create. Here are all of the possiblities:
87
+
88
+ * `flavourName`
89
+ * `iconURL`
90
+ * `packageName`
91
+ * `buildConfig`
92
+ * `colorsXML`
93
+ * `stringsXML`
94
+
95
+ `flavourName` is required to build that Product Flavor. However, the other options are all optional. `[buildConfig, colorsXML, stringsXML]` all house more key/values that will be be turned in to XML, or `String` properties in the `BuildConfig.java` file specific to that Flavor.
96
+
97
+ ## Creating Flavors
98
+
99
+ Now that you're set up - it's time to run this bad boy! Make sure that you have updated your `flavours.json` file with the correct information for your apps, and then run the following command inside the project directory.
100
+
101
+ `flavours create -m NameOfMainAppModule`
102
+
103
+ What this does is goes to your `flavours.json` file and looks for your various flavors and attempts to add them to your `build.gradle` file in that specific module's folder. It will also go to the interwebs and download the file in the `iconURL` parameter if it's present and then chop it up into the different sizes your app needs.
104
+
105
+ **Other Options**
106
+
107
+ * `-d, --directory` - if not in the current directory, specify a new path
108
+ * `-u, --url` - the url of a flavours formatted JSON file
109
+
110
+ `flavours create -m NameOfMainAppModule -d ~/Path/To/App -u http://someurl.com/flavours.json`
111
+
112
+ ## Global Options
113
+
114
+ `--dontlog` will not log the status/operations to the console.
115
+
116
+ `--help` will fill you in on what you need to do for an action.
117
+
118
+ ## The Future
20
119
 
21
- TODO: Write usage instructions here
120
+ * Unit Tests
121
+ * Google Play Store deployment of Apps
22
122
 
23
123
  ## Contributing
24
124
 
@@ -0,0 +1,15 @@
1
+ require 'fileutils'
2
+
3
+ module Flavours
4
+ def self.make_asset_directory directory, m, flavour_name, folder_name
5
+ FileUtils::mkdir_p file_path_with_folder_name directory, folder_name, m, flavour_name
6
+ end
7
+
8
+ def self.assets_file_path directory, m, flavour_name
9
+ return "#{directory}/#{m}/src/#{flavour_name}/res"
10
+ end
11
+
12
+ def self.file_path_with_folder_name directory, folder, m, flavour_name
13
+ return "#{assets_file_path directory, m, flavour_name}/#{folder}"
14
+ end
15
+ end
@@ -2,13 +2,18 @@ $:.push File.expand_path('../', __FILE__)
2
2
  require 'colors'
3
3
  require 'open-uri'
4
4
  require 'json'
5
+ require 'assets'
6
+ require 'xmlres'
5
7
 
6
8
  module Flavours
7
9
  def self.create flavours, directory, m
8
10
  @flavour_string = ''
9
11
  flavours.each do |f|
10
12
  @flavour_string += gradle_string_for_flavour f
11
- Flavours::green " Finished: #{f['flavourName']}" unless $nolog
13
+ Flavours::green " #{f['flavourName']}" unless $nolog
14
+ Flavours::create_images directory, m, f
15
+ Flavours::create_xml_resources directory, m, f
16
+ puts
12
17
  end
13
18
 
14
19
  set_and_save_flavours_text @flavour_string, directory, m
@@ -30,9 +35,9 @@ module Flavours
30
35
 
31
36
 
32
37
  def self.gradle_string_for_flavour flavour
33
- package = "packageName \"#{flavour['packageName']}\"\n" unless flavour['packageName'] == nil
34
- buildConfig = build_config_string_for_flavour flavour
35
- return "#{flavour['flavourName']} {\n#{package}#{buildConfig}}\n"
38
+ package = flavour['packageName'] ? " packageName \"#{flavour['packageName']}\"\n" : ''
39
+ buildConfig = flavour['buildConfig'] ? build_config_string_for_flavour(flavour) : ''
40
+ return " #{flavour['flavourName']} {\n#{package}#{buildConfig} }\n"
36
41
  end
37
42
 
38
43
 
@@ -40,7 +45,7 @@ module Flavours
40
45
  if flavour['buildConfig']
41
46
  @buildconfig = ''
42
47
  flavour['buildConfig'].each_pair do |k, v|
43
- @buildconfig += "buildConfigField \"String\" , \"#{k}\" , \"\\\"#{v}\\\"\"\n"
48
+ @buildconfig += " buildConfigField \"String\" , \"#{k}\" , \"\\\"#{v}\\\"\"\n"
44
49
  end
45
50
  return @buildconfig
46
51
  end
@@ -52,7 +57,7 @@ module Flavours
52
57
  def self.set_and_save_flavours_text flavours_text, directory, m
53
58
  @gradle = gradle_text directory, m
54
59
  matches = @gradle.match /productFlavors \{(?>[^()]|(\g<0>))*\}\n\n/
55
- new_flavour_text = "productFlavors {\n#{flavours_text}}\n\n"
60
+ new_flavour_text = " productFlavors {\n#{flavours_text} }\n\n"
56
61
  if matches
57
62
  @gradle = @gradle.sub(matches[0], new_flavour_text)
58
63
  else
@@ -3,105 +3,52 @@ $:.push File.expand_path('../', __FILE__)
3
3
  require 'RMagick'
4
4
  include Magick
5
5
  require 'colors'
6
+ require 'assets'
6
7
  require 'open-uri'
7
8
 
8
9
  module Flavours
9
10
 
10
11
  # Images
11
- def self.create_images directory, t, obj
12
+ def self.create_images directory, m, flavour_hash
12
13
  # Bad Params
13
- if !directory || !t || !obj
14
+ if !directory || !flavour_hash || !m
14
15
  return false
15
16
  end
16
17
 
17
- # Get Device Information
18
- iPhone = obj['devices'].include? 'iPhone'
19
- iPad = obj['devices'].include? 'iPad'
20
-
21
18
  # Resize Icons
22
- resize_icons directory, t, iPhone, iPad
23
-
24
- # Resize Launch Images
25
- resize_launch_images directory, t
26
-
27
- # Write JSON for Icon Assets
28
- write_json_for_icons directory, t, iPhone, iPad
29
-
30
- # Write JSON for Launch Assets
31
- write_json_for_launch_images directory, t
32
-
19
+ resize_icons directory, m, flavour_hash
33
20
  end
34
21
 
35
22
 
36
23
  # Create & Resize Icons
37
- def self.resize_icons directory, t, iPhone, iPad
24
+ def self.resize_icons directory, m, flavour_hash
38
25
  # Set Up
39
- target = t['name']
26
+ name = flavour_hash['flavourName']
40
27
 
41
28
  # Get Image Information
42
29
  img_path = ''
43
- if t['icon_url']
44
- img_path = self.path_for_downloaded_image_from_url directory, target, t['icon_url'], 'icons'
45
- elsif t['icon_path']
46
- img_path = directory + '/' + t['icon_path']
30
+ if flavour_hash['iconUrl']
31
+ img_path = self.path_for_downloaded_image_from_url directory, name, flavour_hash['iconUrl'], 'icons'
47
32
  end
48
33
 
49
- # Make directory
50
- img_dir = make_asset_directory directory, target, '.appiconset/'
34
+ # Make Assets Directory
35
+ drawables = ['drawable-xxhdpi','drawable-xhdpi','drawable-hdpi','drawable-mdpi']
36
+ drawables.each do |d|
37
+ Flavours::make_asset_directory directory, m, name, d
38
+ end
51
39
 
52
40
  # Resize
53
- image_sizes = []
54
- image_sizes += ['120x120', '114x114', '80x80', '58x58', '57x57', '29x29'] if iPhone
55
- image_sizes += ['152x152', '144x144', '100x100', '80x80', '76x76', '72x72', '58x58', '50x50', '40x40', '29x29'] if iPad
56
- image_sizes.uniq.each do |size|
41
+ image_sizes = ['144x144', '96x96', '72x72', '48x48']
42
+ image_sizes.each_index do |i|
43
+ size = image_sizes[i]
44
+ drawable = drawables[i]
45
+ img_dir = file_path_with_folder_name directory, drawable, m, name
57
46
  image = Image.read(img_path).first
58
47
  next unless image
59
- resize_image_to_directory img_dir, image, size, 'icon'
48
+ resize_image_to_directory img_dir, image, size, 'ic_launcher'
60
49
  end
61
50
 
62
- Flavours::green (' - Created Icon images for ' + target) unless $nolog
63
- return true
64
- end
65
-
66
-
67
- # Create & Resize Launch Images
68
- def self.resize_launch_images directory, t
69
- # Set Up
70
- target = t['name']
71
-
72
- ['launch_phone_p', 'launch_phone_l', 'launch_tablet_p', 'launch_tablet_l'].each do |key|
73
- if t[key + '_url']
74
- img_path = self.path_for_downloaded_image_from_url directory, key + '_' + target, t[key + '_url'], 'launch'
75
- elsif t[key + '_path']
76
- img_path = directory + '/' + t[key + '_path']
77
- else
78
- next
79
- end
80
-
81
- # Make directory
82
- img_dir = make_asset_directory directory, target, '.launchimage/'
83
-
84
- # Make resize sizes
85
- sizes = []
86
- if key == 'launch_phone_p'
87
- sizes = ['640x1136','640x960','320x480']
88
- elsif key == 'launch_phone_l'
89
- sizes = ['1136x640','960x640','480x320']
90
- elsif key == 'launch_tablet_p'
91
- sizes = ['1536x2048','768x1024','1536x2008','768x1004']
92
- elsif key == 'launch_tablet_l'
93
- sizes = ['2048x1536','1024x768','2048x1496','1024x748']
94
- end
95
-
96
- # Resize Images
97
- sizes.each do |size|
98
- image = Image.read(img_path).first
99
- return false unless image
100
- resize_image_to_directory img_dir, image, size, key + '_'
101
- end
102
- end
103
-
104
- Flavours::green (' - Created Launch images for ' + target) unless $nolog
51
+ puts ' - Created Icon images for ' + name unless $nolog
105
52
  return true
106
53
  end
107
54
 
@@ -112,244 +59,10 @@ module Flavours
112
59
  new_w = Integer(sizes[0])
113
60
  new_h = Integer(sizes[1])
114
61
  image.resize_to_fill! new_w, new_h
115
- image.write directory + '/' + tag + size + '.png'
116
- end
117
-
118
-
119
- # Create JSON
120
- def self.write_json_for_icons directory, t, iPhone, iPad
121
- # Set Up
122
- target = t['name']
123
-
124
- # Make directory
125
- img_dir = make_asset_directory directory, target, '.appiconset/'
126
-
127
- # Write the JSON file
128
- File.open(img_dir + '/Contents.json', 'w') do |f|
129
- f.write('{ "images" : [ ')
130
-
131
- if iPhone
132
- f.write( '{ "size" : "29x29", "idiom" : "iphone", "filename" : "icon58x58.png", "scale" : "2x" }, { "size" : "40x40", "idiom" : "iphone", "filename" : "icon80x80.png", "scale" : "2x" }, { "size" : "60x60", "idiom" : "iphone", "filename" : "icon120x120.png", "scale" : "2x" }, { "size" : "29x29", "idiom" : "iphone", "filename" : "icon29x29.png", "scale" : "1x" }, { "size" : "57x57", "idiom" : "iphone", "filename" : "icon57x57.png", "scale" : "1x" }, { "size" : "57x57", "idiom" : "iphone", "filename" : "icon114x114.png", "scale" : "2x" }' + (iPad ? ',' : ''))
133
- end
134
-
135
- if iPad
136
- f.write( '{ "idiom" : "ipad", "size" : "29x29", "scale" : "1x", "filename" : "icon29x29.png" }, { "idiom" : "ipad", "size" : "29x29", "scale" : "2x", "filename" : "icon58x58.png" }, { "idiom" : "ipad", "size" : "40x40", "scale" : "1x", "filename" : "icon40x40.png" }, { "idiom" : "ipad", "size" : "40x40", "scale" : "2x", "filename" : "icon80x80.png" }, { "idiom" : "ipad", "size" : "76x76", "scale" : "1x", "filename" : "icon76x76.png" }, { "idiom" : "ipad", "size" : "76x76", "scale" : "2x", "filename" : "icon152x152.png" }, { "idiom" : "ipad", "size" : "50x50", "scale" : "1x", "filename" : "icon50x50.png" }, { "idiom" : "ipad", "size" : "50x50", "scale" : "2x", "filename" : "icon100x100.png" }, { "idiom" : "ipad", "size" : "72x72", "scale" : "1x", "filename" : "icon72x72.png" }, { "idiom" : "ipad", "size" : "72x72", "scale" : "2x", "filename" : "icon144x144.png" }')
137
- end
138
-
139
- f.write(' ], "info" : { "version" : 1, "author" : "xcode" }, "properties" : { "pre-rendered" : true } }')
140
- end
141
-
142
- # Return true
143
- Flavours::green (' - Created Images.xcassets icon set for ' + target) unless $nolog
144
- return true
62
+ image.write directory + '/' + tag + '.png'
145
63
  end
146
64
 
147
65
 
148
- # JSON for Launch Images
149
- def self.write_json_for_launch_images directory, t
150
- # Set Up
151
- target = t['name']
152
- phone_portrait = t['launch_phone_p_url'] || t['launch_phone_p_path']
153
- phone_landscape = t['launch_phone_l_url'] || t['launch_phone_l_path']
154
- tablet_portrait = t['launch_tablet_p_url'] || t['launch_tablet_p_path']
155
- tablet_landscape = t['launch_tablet_l_url'] || t['launch_tablet_l_path']
156
- return false unless phone_portrait || phone_landscape || tablet_landscape || tablet_portrait
157
-
158
- # Make Directory
159
- img_dir = make_asset_directory directory, target, '.launchimage/'
160
-
161
- File.open(img_dir + '/Contents.json', 'w') do |f|
162
- f.write('{"images" : [')
163
-
164
- if phone_portrait
165
- f.write('{
166
- "orientation" : "portrait",
167
- "idiom" : "iphone",
168
- "extent" : "full-screen",
169
- "minimum-system-version" : "7.0",
170
- "filename" : "launch_phone_p_640x960.png",
171
- "scale" : "2x"
172
- },
173
- {
174
- "extent" : "full-screen",
175
- "idiom" : "iphone",
176
- "subtype" : "retina4",
177
- "filename" : "launch_phone_p_640x1136.png",
178
- "minimum-system-version" : "7.0",
179
- "orientation" : "portrait",
180
- "scale" : "2x"
181
- },
182
- {
183
- "orientation" : "portrait",
184
- "idiom" : "iphone",
185
- "extent" : "full-screen",
186
- "filename" : "launch_phone_p_320x480.png",
187
- "scale" : "1x"
188
- },
189
- {
190
- "orientation" : "portrait",
191
- "idiom" : "iphone",
192
- "extent" : "full-screen",
193
- "filename" : "launch_phone_p_640x960.png",
194
- "scale" : "2x"
195
- },
196
- {
197
- "orientation" : "portrait",
198
- "idiom" : "iphone",
199
- "extent" : "full-screen",
200
- "subtype" : "retina4",
201
- "filename" : "launch_phone_p_640x1136.png",
202
- "scale" : "2x"
203
- }')
204
- f.write ',' if phone_landscape || tablet_portrait || tablet_landscape
205
- end
206
-
207
- if phone_landscape
208
- f.write('{
209
- "orientation" : "landscape",
210
- "idiom" : "iphone",
211
- "extent" : "full-screen",
212
- "minimum-system-version" : "7.0",
213
- "filename" : "launch_phone_l_960x640.png",
214
- "scale" : "2x"
215
- },
216
- {
217
- "extent" : "full-screen",
218
- "idiom" : "iphone",
219
- "subtype" : "retina4",
220
- "filename" : "launch_phone_l_1136x640.png",
221
- "minimum-system-version" : "7.0",
222
- "orientation" : "landscape",
223
- "scale" : "2x"
224
- },
225
- {
226
- "orientation" : "landscape",
227
- "idiom" : "iphone",
228
- "extent" : "full-screen",
229
- "filename" : "launch_phone_l_480x320.png",
230
- "scale" : "1x"
231
- },
232
- {
233
- "orientation" : "landscape",
234
- "idiom" : "iphone",
235
- "extent" : "full-screen",
236
- "filename" : "launch_phone_l_960x640.png",
237
- "scale" : "2x"
238
- },
239
- {
240
- "orientation" : "landscape",
241
- "idiom" : "iphone",
242
- "extent" : "full-screen",
243
- "subtype" : "retina4",
244
- "filename" : "launch_phone_l_1136x640.png",
245
- "scale" : "2x"
246
- }')
247
- f.write ',' if tablet_portrait || tablet_landscape
248
- end
249
-
250
- if tablet_portrait
251
- f.write('{
252
- "orientation" : "portrait",
253
- "idiom" : "ipad",
254
- "extent" : "full-screen",
255
- "filename" : "launch_tablet_p_768x1024.png",
256
- "minimum-system-version" : "7.0",
257
- "scale" : "1x"
258
- },
259
- {
260
- "orientation" : "portrait",
261
- "idiom" : "ipad",
262
- "extent" : "full-screen",
263
- "filename" : "launch_tablet_p_1536x2048.png",
264
- "minimum-system-version" : "7.0",
265
- "scale" : "2x"
266
- },
267
- {
268
- "orientation" : "portrait",
269
- "idiom" : "ipad",
270
- "extent" : "to-status-bar",
271
- "scale" : "1x",
272
- "filename" : "launch_tablet_p_768x1004.png"
273
- },
274
- {
275
- "orientation" : "portrait",
276
- "idiom" : "ipad",
277
- "extent" : "full-screen",
278
- "scale" : "1x",
279
- "filename" : "launch_tablet_p_768x1024.png"
280
- },
281
- {
282
- "orientation" : "portrait",
283
- "idiom" : "ipad",
284
- "extent" : "to-status-bar",
285
- "scale" : "2x",
286
- "filename" : "launch_tablet_p_1536x2008.png"
287
- },
288
- {
289
- "orientation" : "portrait",
290
- "idiom" : "ipad",
291
- "extent" : "full-screen",
292
- "scale" : "2x",
293
- "filename" : "launch_tablet_p_1536x2048.png"
294
- }')
295
- f.write ',' if tablet_landscape
296
- end
297
-
298
- if tablet_landscape
299
- f.write('{
300
- "orientation" : "landscape",
301
- "idiom" : "ipad",
302
- "extent" : "full-screen",
303
- "filename" : "launch_tablet_l_1024x768.png",
304
- "minimum-system-version" : "7.0",
305
- "scale" : "1x"
306
- },
307
- {
308
- "orientation" : "landscape",
309
- "idiom" : "ipad",
310
- "extent" : "full-screen",
311
- "filename" : "launch_tablet_l_2048x1536.png",
312
- "minimum-system-version" : "7.0",
313
- "scale" : "2x"
314
- },
315
- {
316
- "orientation" : "landscape",
317
- "idiom" : "ipad",
318
- "extent" : "to-status-bar",
319
- "scale" : "1x",
320
- "filename" : "launch_tablet_l_1024x748.png"
321
- },
322
- {
323
- "orientation" : "landscape",
324
- "idiom" : "ipad",
325
- "extent" : "full-screen",
326
- "scale" : "1x",
327
- "filename" : "launch_tablet_l_1024x768.png"
328
- },
329
- {
330
- "orientation" : "landscape",
331
- "idiom" : "ipad",
332
- "extent" : "to-status-bar",
333
- "scale" : "2x",
334
- "filename" : "launch_tablet_l_2048x1496.png"
335
- },
336
- {
337
- "orientation" : "landscape",
338
- "idiom" : "ipad",
339
- "extent" : "full-screen",
340
- "scale" : "2x",
341
- "filename" : "launch_tablet_l_2048x1536.png"
342
- }')
343
- end
344
-
345
- f.write('],"info" : {"version" : 1,"author" : "xcode"}}')
346
- end
347
-
348
- # Return true
349
- Flavours::green (' - Created Images.xcassets launch image set for ' + target) unless $nolog
350
- return true
351
- end
352
-
353
66
  # Download Image from URL
354
67
  def self.path_for_downloaded_image_from_url directory, filename, url, folder
355
68
  img_path = directory + '/resources/'+ folder + '/'
data/lib/flavours/json.rb CHANGED
@@ -50,26 +50,36 @@ module Flavours
50
50
 
51
51
  def self.base_json_file_string
52
52
  return '{
53
- "flavours" : [
54
- {
55
- "flavourName" : "YourFlavor",
56
- "packageName" : "somePackageName",
57
- "buildConfig" : {
58
- "API_KEY" : "someApiKey",
59
- "DEALER_COLOR" : "#E51919"
60
- },
61
- "iconUrl" : "https://someurl.com/image.png"
62
- },
63
- {
64
- "flavourName" : "YourFlavor",
65
- "packageName" : "somePackageName",
66
- "buildConfig" : {
67
- "API_KEY" : "someApiKey",
68
- "DEALER_COLOR" : "#E51919"
69
- },
70
- "iconUrl" : "https://someurl.com/image.png"
71
- }
72
- ]
53
+ "flavours": [
54
+ {
55
+ "flavourName": "YourFlavor",
56
+ "packageName": "somePackageName",
57
+ "buildConfig": {
58
+ "API_KEY": "someApiKey"
59
+ },
60
+ "iconUrl": "https://someurl.com/image.png",
61
+ "colorsXML": {
62
+ "primaryColor": "#E51919"
63
+ },
64
+ "stringsXML": {
65
+ "someString": "someValue"
66
+ }
67
+ },
68
+ {
69
+ "flavourName": "YourFlavor2",
70
+ "packageName": "somePackageName2",
71
+ "buildConfig": {
72
+ "API_KEY": "someApiKey"
73
+ },
74
+ "iconUrl": "https://someurl.com/image.png",
75
+ "colorsXML": {
76
+ "primaryColor": "#E51919"
77
+ },
78
+ "stringsXML": {
79
+ "someString": "someValue"
80
+ }
81
+ }
82
+ ]
73
83
  }'
74
84
  end
75
85
 
@@ -1,5 +1,5 @@
1
1
  module Flavours
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.5"
3
3
 
4
4
  def self.check_for_newer_version
5
5
  unless Gem.latest_version_for('flavours').to_s == VERSION
@@ -0,0 +1,53 @@
1
+ require 'colors'
2
+ require 'assets'
3
+ require 'open-uri'
4
+
5
+ module Flavours
6
+
7
+ # Create XML
8
+ def self.create_xml_resources directory, m, flavour_hash
9
+ flavour_name = flavour_hash['flavourName']
10
+ flavour_hash.each_pair do |k, v|
11
+ if k == 'colorsXML'
12
+ create_xml_for_hash directory, m, v, 'values', 'colors', 'color', flavour_name
13
+ puts " - Created colors.xml for #{flavour_name}"
14
+ elsif k == 'stringsXML'
15
+ create_xml_for_hash directory, m, v, 'values', 'strings', 'string', flavour_name
16
+ puts " - Created strings.xml for #{flavour_name}"
17
+ elsif k == 'settingsXML'
18
+ create_xml_for_hash directory, m, v, 'values', 'settings', 'item', flavour_name
19
+ puts " - Created settings.xml for #{flavour_name}"
20
+ end
21
+ end
22
+ end
23
+
24
+ # Main Method
25
+ def self.create_xml_for_hash directory, m, xml_hash, res_folder_name, res_file_name, res_key_name, flavour_name
26
+ # Create Directory
27
+ Flavours::make_asset_directory directory, m, flavour_name, res_folder_name
28
+ # Set Up
29
+ res_path = Flavours::file_path_with_folder_name(directory, res_folder_name, m, flavour_name) + "/#{res_file_name}.xml"
30
+ xmlString = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n <resources>\n"
31
+ # Create Strings
32
+ if xml_hash.kind_of?(Array)
33
+ xml_hash.each do |hash|
34
+ xmlString += res_string res_key_name, hash['name'], hash['value'], hash['type']
35
+ end
36
+ else
37
+ xml_hash.each_pair do |k, v|
38
+ xmlString += res_string res_key_name, k, v, nil
39
+ end
40
+ end
41
+ # Finish Her Off
42
+ xmlString += ' </resources>'
43
+ File.open(res_path, 'w') do |f|
44
+ f.write(xmlString)
45
+ end
46
+ end
47
+
48
+ # Resource String
49
+ def self.res_string res, name, value, type
50
+ type_string = type ? " type=\"#{type}\"" : ''
51
+ return " <#{res} name=\"#{name}\"#{type_string}>#{value}</#{res}>\n"
52
+ end
53
+ end
data/lib/flavours.rb CHANGED
@@ -3,6 +3,8 @@ require 'flavours/colors'
3
3
  require 'flavours/commands'
4
4
  require 'flavours/images'
5
5
  require 'flavours/json'
6
+ require 'flavours/xmlres'
7
+ require 'flavours/assets'
6
8
 
7
9
  module Flavours
8
10
  # Your code goes here...
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flavours
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Gordon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-18 00:00:00.000000000 Z
11
+ date: 2014-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -133,6 +133,7 @@ extra_rdoc_files: []
133
133
  files:
134
134
  - ./Gemfile
135
135
  - ./Gemfile.lock
136
+ - ./lib/flavours/assets.rb
136
137
  - ./lib/flavours/colors.rb
137
138
  - ./lib/flavours/commands/create.rb
138
139
  - ./lib/flavours/commands/install.rb
@@ -141,10 +142,12 @@ files:
141
142
  - ./lib/flavours/images.rb
142
143
  - ./lib/flavours/json.rb
143
144
  - ./lib/flavours/version.rb
145
+ - ./lib/flavours/xmlres.rb
144
146
  - ./lib/flavours.rb
145
147
  - ./LICENSE.txt
146
148
  - ./Rakefile
147
149
  - ./README.md
150
+ - ./resources/banner.png
148
151
  - bin/flavours
149
152
  homepage: https://github.com/intermark/flavours
150
153
  licenses: