Skip to content
This repository
Browse code

Remove easy app oven script

  • Loading branch information...
commit 66ac4bbfefc17770d91954db0e7a9dd79054baa1 1 parent c977c79
Stefan Ayala BaseInfinity authored

Showing 1 changed file with 0 additions and 179 deletions. Show diff stats Hide diff stats

  1. +0 179 easyAppOven.rb
179 easyAppOven.rb
... ... @@ -1,179 +0,0 @@
1   -#!/usr/bin/env ruby
2   -
3   -#####
4   -# This script will create the code needed when someone comes to us and asks for
5   -# a custom iOS app. We still need to make sure image assets are in the correct
6   -# folder and all images are named accordingly.
7   -#
8   -# How it works: We have comments within the iOS app that the script will use as
9   -# markers, to know where to place new addition of code. It essentially uses
10   -# regex to find the marker, adds the new code in the correct place, then writes
11   -# to the given file.
12   -#
13   -# How to add more: Just add a new dictionary in the array, and the script will
14   -# take care of the rest. For more info about the format of new additions, check
15   -# out the comment regarding the recipe array below. Be sure to place the
16   -# correct marker within the iOS mobile app. in the form of /*EAONewMarker*/
17   -#####
18   -
19   -puts "Easy App Oven!"
20   -configName = nanoSite = appName = configPrivate = answersEnabled = store = ''
21   -
22   -# Ask the user for nanosite
23   -until nanoSite.match(/^[a-z-]+/)
24   - puts "\nEnter the nanosite (ie: failfactory)"
25   - nanoSite = gets.chomp
26   -end
27   -
28   -# Ask the user for a Config variable name
29   -until configName.match(/^Config\w+/)
30   - puts "\nEnter a valid variable name for Config variable. IE: ConfigIfixit"
31   - configName = gets.chomp
32   -end
33   -
34   -# Ask user for App Name
35   -puts "\nEnter the App Name:"
36   -appName = gets.chomp
37   -
38   -# Ask the user if the nanosite is private
39   -until configPrivate.match(/[y|n]/)
40   - puts "\nIs the nanosite private? (y/n)"
41   - configPrivate = gets.chomp
42   -end
43   -
44   -configPrivate = configPrivate.eql?('y') ? 'YES' : 'NO'
45   -
46   -# Ask the user if the nanosite is private
47   -until answersEnabled.match(/[y|n]/)
48   - puts "\nDoes the nanosite have answers enabled? (y/n)"
49   - answersEnabled = gets.chomp
50   -end
51   -
52   -answersEnabled = answersEnabled.eql?('y') ? 'YES' : 'NO'
53   -
54   -# Ask the user if the nanosite has a store
55   -until store.match(/^[a-z-]+/)
56   - puts "\nDoes the nanosite have a store? Enter URL for store, other wise enter 'n'"
57   - store = gets.chomp
58   -end
59   -
60   -store = store.eql?('n') ? 'nil' : store
61   -
62   -####
63   -# Each object in the recipe's array is a 'clump' of code changes
64   -# :file == Path to Class file
65   -# :pattern == Marker we use to search for, ie: /*EAOConfig*/
66   -# :ingredient == Code to replace found pattern
67   -#
68   -# Important: If you have a file that needs multiple :pattern(s) that will
69   -# perform multiple replacements, use an array, with the corresponding
70   -# string replacement stored in an array in 'ingredients'.
71   -####
72   -recipes = [
73   - # Add logo title image, along with resizing logic for portrait/landscape
74   - { :file => 'Classes/Config.h',
75   - :pattern => /\/\*EAOConfig\*\//,
76   - :ingredient => "#{configName},\n" + "\s" * 4 + "/*EAOConfig*/" },
77   -
78   - # Add header logo image for iPads when viewing Guide Intro
79   - { :file => 'Classes/GuideIntroViewController.m',
80   - :pattern => /\/\*EAOGuideIntro\*\//,
81   - :ingredient => "case #{configName}:\n" +
82   - "\s" * 16 + "image = [UIImage imageNamed:@\"#{nanoSite}_logo_transparent.png\"];\n" +
83   - "\s" * 16 + "headerImageLogo.frame = CGRectMake(headerImageLogo.frame.origin.x, headerImageLogo.frame.origin.y, image.size.width, image.size.height);\n" +
84   - "\s" * 16 + "headerImageLogo.image = image;\n" +
85   - "\s" * 16 + "break;\n" + "\s" * 12 + "/*EAOGuideIntro*/" },
86   -
87   - # Add config settings such as base url and other options
88   - { :file => 'Classes/Config.m',
89   - :pattern => /\/\*EAOOptions\*\//,
90   - :ingredient => "case #{configName}:\n" +
91   - "\s" * 12 + "self.host = @\"#{nanoSite}.dozuki.com\";\n" +
92   - "\s" * 12 + "self.baseURL = @\"http://#{nanoSite}.dozuki.com\";\n" +
93   - "\s" * 12 + "answersEnabled = #{answersEnabled};\n" +
94   - "\s" * 12 + "collectionsEnabled = NO;\n" +
95   - "\s" * 12 + "self.store = @\"#{store}\";\n" +
96   - "\s" * 12 + "self.private = #{configPrivate};\n" +
97   - "\s" * 12 + "break;\n" + "\s" * 8 + "/*EAOOptions*/" },
98   -
99   - # Add title image logo and resizing logic for title image logo
100   - { :file => 'Classes/CategoriesViewController.m',
101   - :pattern => [ /\/\*EAOTitle\*\//, /\/\*EAOLandscapeResize\*\//, /\/\*EAOPortraitResize\*\// ],
102   - :ingredient => [ "case #{configName}:\n" +
103   - "\s" * 16 + "titleImage = [UIImage imageNamed:@\"titleImage#{nanoSite.capitalize}.png\"];\n" +
104   - "\s" * 16 + "imageTitle = [[UIImageView alloc] initWithImage:titleImage];\n" +
105   - "\s" * 16 + "self.navigationItem.titleView = imageTitle;\n" +
106   - "\s" * 16 + "break;\n" +
107   - "\s" * 12 + "/*EAOTitle*/",
108   - "case #{configName}:\n" +
109   - "\s" * 16 + "frame = self.navigationItem.titleView.frame;\n" +
110   - "\s" * 16 + "frame.size.width = 0.0;\n" +
111   - "\s" * 16 + "frame.size.height = 0.0;\n" +
112   - "\s" * 16 + "self.navigationItem.titleView.frame = frame;\n" + "\s" * 16 +
113   - "break;\n" + "\s" * 12 + "/*EAOLandscapeResize*/",
114   - "case #{configName}:\n" +
115   - "\s" * 16 + "frame = self.navigationItem.titleView.frame;\n" +
116   - "\s" * 16 + "frame.size.width = 0.0;\n" +
117   - "\s" * 16 + "frame.size.height = 0.0;\n" +
118   - "\s" * 16 + "self.navigationItem.titleView.frame = frame;\n" + "\s" * 16 +
119   - "break;\n" + "\s" * 12 + "/*EAOPortraitResize*/" ] },
120   - # Add large background iPad logo and resizing logic for logo
121   - { :file => 'Classes/DetailGridViewController.m',
122   - :pattern => [ /\/\*EAOiPadSiteLogo\*\// ],
123   - :ingredient => [ "case #{configName}:\n" +
124   - "\s" * 12 + "self.siteLogo.image = [UIImage imageNamed:@\"#{nanoSite}_logo_transparent.png\"];\n" +
125   - "\s" * 12 + "[self.backgroundView addSubview:self.siteLogo];\n"+
126   - "\s" * 12 + "break;\n" + "\s" * 8 + "/*EAOiPadSiteLogo*/" ] },
127   - # Add code to our bash script that switches between iOS apps
128   - { :file => 'dozuki.sh',
129   - :pattern => /#EAOPlist/,
130   - :ingredient => "elif [ \"$1\" == \"#{nanoSite}\" ]; then\n" +
131   - "\s" * 3 + "echo \"#{nanoSite.capitalize}\"\n" +
132   - "\s" * 3 + "cp Graphics/Sites/#{nanoSite.capitalize}/*png .\n" +
133   - "\s" * 3 + "sed -i '.bak' -e 's/com.ifixit.ifixit/com.dozuki.#{nanoSite}/g' iFixit-Info.plist\n" +
134   - "\s" * 3 + "sed -i '.bak' -e 's/iFixit/#{appName}/g' iFixit-Info.plist\n" +
135   - "\s" * 3 + "sed -i '.bak' -e 's/>ifixit</>#{nanoSite}</g' iFixit-Info.plist\n" +
136   - "\s" * 3 + "sed -i '.bak' -e 's/\\[Config currentConfig\\].dozuki = YES;/\\[Config currentConfig\\].dozuki = NO;/' Classes/iFixitAppDelegate.m\n" +
137   - "\s" * 3 + "sed -i '.bak' -e 's/\\[Config currentConfig\\].site = ConfigIFixit;/\\[Config currentConfig\\].site = #{configName};/' Classes/iFixitAppDelegate.m\n" +
138   - "\s" * 3 + "sed -i '.bak' -e 's/ifixit/#{nanosite}/g' Classes/iFixitAPI.m\n" +
139   - "#EAOPlist"}
140   -]
141   -
142   -####
143   -# Search for the correct place to insert new code.
144   -# recipe[:file] => Pointing to path of file to search through
145   -# recipe[:pattern] => Regex Pattern to search for to insert new code
146   -# recipe[:ingredient] => New code to insert
147   -####
148   -def bakeRecipe(recipe)
149   - if File.file?(recipe[:file])
150   - fileContents = File.read(recipe[:file])
151   -
152   - # If pattern is an array, we have multiple inserts to do
153   - if recipe[:pattern].is_a? Array
154   - # Zip: [[pattern1, ingredient1], [pattern2, ingredient2]]
155   - recipe[:pattern].zip(recipe[:ingredient]).each do |recipeArray|
156   - fileContents.sub!(recipeArray[0], recipeArray[1])
157   - end
158   - else
159   - fileContents.sub!(recipe[:pattern], recipe[:ingredient])
160   - end
161   -
162   - File.write(recipe[:file], fileContents)
163   - else
164   - puts "Could not find file: #{recipe[:file]}, unplug the oven!"
165   - exit 1
166   - end
167   -end
168   -
169   -# Let's bake!
170   -recipes.each do |recipe|
171   - bakeRecipe(recipe)
172   -end
173   -
174   -puts "\nRemember: Make sure you have the image assets in the correct path and " +
175   - "they are named accordingly:\n" +
176   - "Graphics/Sites/#{nanoSite.capitalize}/\n" +
177   - "titleImage#{nanoSite.capitalize}.png\n" +
178   - "#{nanoSite}_logo_transparent.png\n" +
179   - "detailViewText#{nanoSite.capitalize}.png"

0 comments on commit 66ac4bb

Please sign in to comment.
Something went wrong with that request. Please try again.