0
MAKE                   YOUR OWN                       TOOLS   ChristopherCotton.com           @_cotton          2013-03-07...
Why?             Repetition Sucks                      Repetition Sucks Repetition Sucks                                  ...
Why?Code Easier than Manual
Why?       Transfer       of Knowledge
What?Simple Lines of RubyCommand Line ToolsSimple WebappsApply lots of Regex, Regex, Regex
HOW?DOES IT WORK?
NOT PRETTY   HOW?
I BUILT WHAT?     HOW?
EXAMPLES
build.rb                                         Android Building    OptionParser.new do |o|  o.on(-d, --deploy [DIR], Dep...
copy_assets.rb              Image Asset Copying  rsync to copy assets  scale for non-retina versions  create .h/.m Object ...
Mini Server
translation helper   def trans2(eng, language)  File.open("otherresources/#{ARGV[0]}_trans2.txt", "w") do |o|    eng.each_...
check_assets.rb     assets = {}total_dirs = 0Dir.glob(File.join(dropbox, "*")).each do |root_dir|!    next unless File.dir...
Image Extraction, Composition  Spaceward Ho!
Share Your Tool Open Source Can Happen Much Later Version Control
Q &A
Upcoming SlideShare
Loading in...5
×

Make Your Own Tools

85

Published on

Why and how you should make your own tools, with some examples. Talk for the Nashville Ruby on Rails Meetup

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
85
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Make Your Own Tools"

  1. 1. MAKE YOUR OWN TOOLS ChristopherCotton.com @_cotton 2013-03-07Nashville Ruby on Rails Meetup
  2. 2. Why? Repetition Sucks Repetition Sucks Repetition Sucks Repetition Repetition Sucks Sucks Repetition Sucks Repetition Sucks Text Repetition Sucks Repetition Sucksepetition Sucks Repetition Sucks Repetition SucksRepetition Sucks Repetition Suckspetition Sucks Repetition Sucks Repetition Sucks Repetition Sucks Repetition
  3. 3. Why?Code Easier than Manual
  4. 4. Why? Transfer of Knowledge
  5. 5. What?Simple Lines of RubyCommand Line ToolsSimple WebappsApply lots of Regex, Regex, Regex
  6. 6. HOW?DOES IT WORK?
  7. 7. NOT PRETTY HOW?
  8. 8. I BUILT WHAT? HOW?
  9. 9. EXAMPLES
  10. 10. build.rb Android Building OptionParser.new do |o| o.on(-d, --deploy [DIR], Deploy to HST, can pass in directory) { |dir|$deploy_dir = dir || "#{ENV[HOME]}/Hst/Dropbox" o.on(-r, --release KEYSTORE, Keystore for the relase build) { |key|$keystore = key } o.on(-h, Print out help) { puts o; exit } o.parse!endensure_local_properies(File.join(buildtarget_dir, "facebook"), android_sdk_location)# modify the AndroidManifest.xmlReplacement.file(File.join(buildtarget_dir, "AndroidManifest.xml")) do |rp| rp.buffer.gsub!(/package="#{package_prefix}.#{old_package}"/, "package="#{package_prefix}.#{package}"")end
  11. 11. copy_assets.rb Image Asset Copying rsync to copy assets scale for non-retina versions create .h/.m Object C for constantsFile.open(File.join(root_dir, "Primer", "AssetConstants.h"),w) do |file| file.puts "// Do not edit this file, it is auto generated by#{File.basename(__FILE__)}" file.puts "" image_files.each do |image| file.puts "FOUNDATION_EXPORT NSString *constkAsset_#{File.basename(image, File.extname(image))};" endend
  12. 12. Mini Server
  13. 13. translation helper def trans2(eng, language) File.open("otherresources/#{ARGV[0]}_trans2.txt", "w") do |o| eng.each_with_index.select do |line, index| if line =~ /<key>(.+)</key>/ o.puts("") o.puts("Categoryt#{unquote($1)}") end if line =~ /<string>(.+)</string>/ o.print("t#{unquote($1)}") language[index] =~ /<string>(!?)(.+)</string>/ o.puts("t#{unquote($2)}t#{$1}") end end endend
  14. 14. check_assets.rb assets = {}total_dirs = 0Dir.glob(File.join(dropbox, "*")).each do |root_dir|! next unless File.directory?(root_dir)! total_dirs += 1! dir_name = File.basename(root_dir)! Dir.glob(File.join(root_dir, "*")).each do |file|! ! name = File.basename(file)! ! assets[name] = (assets[name] || []).push(dir_name) ! !! end!endassets.each do |key,value|!! puts "#{key} = #{value.inspect}" unless total_dirs == value.lengthend
  15. 15. Image Extraction, Composition Spaceward Ho!
  16. 16. Share Your Tool Open Source Can Happen Much Later Version Control
  17. 17. Q &A
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×