Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Indent cleanup

  • Loading branch information...
commit 0e27a163ede85ab9e5d366b199691df006341bc3 1 parent 61119a2
@jschementi authored
Showing with 128 additions and 126 deletions.
  1. +58 −57 iis-setup.rb
  2. +70 −37 resizer.rb
  3. +0 −32 script.rb
View
115 iis-setup.rb
@@ -1,3 +1,20 @@
+require 'mscorlib'
+require 'system'
+require 'System.Data'
+require 'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
+require 'System.Deployment, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
+require 'System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
+
+include System
+include System::DirectoryServices
+include System::IO
+include System::Collections
+
+ROOT = "IIS://localhost/W3SVC/1/root"
+
+# Is IIS installed?
+raise "Please make sure IIS is installed on this machine." unless DirectoryEntry.exists ROOT
+
class IISSetup
class << self
def do(app_name, app_path)
@@ -26,75 +43,59 @@ def get_direct_parent_app current_entry, current_vpath
end
def create_app entry_parent, app_name, app_path
- new_app = get_app app_name, entry_parent
- unless new_app
- new_app = entry_parent.children.add app_name, "IIsWebVirtualDir"
- new_app.invoke "AppCreate", true
- new_app.commit_changes
- puts "#{app_name} has been created successfully."
- else
- puts "Found #{app_name}"
- end
-
- #new_app.properties.each do |i|
- # puts "#{i.PropertyName} => , #{i.Value}
- #end
- new_app.properties["DirBrowseFlags"].value = -2147483586 # enable directory browsing
- new_app.properties["Path"].value = app_path
- new_app.properties["AccessRead"][0] = true
- new_app.properties["AccessExecute"][0] = false
- new_app.properties["AccessWrite"][0] = false
- new_app.properties["ContentIndexed"][0] = true
- new_app.properties["AppFriendlyName"][0] = app_name
- new_app.properties["AccessScript"][0] = true
+ new_app = get_app app_name, entry_parent
+ unless new_app
+ new_app = entry_parent.children.add app_name, "IIsWebVirtualDir"
+ new_app.invoke "AppCreate", true
new_app.commit_changes
+ puts "#{app_name} has been created successfully."
+ else
+ puts "Found #{app_name}"
+ end
- puts "#{app_name} has been configured successfully."
+ #new_app.properties.each do |i|
+ # puts "#{i.PropertyName} => , #{i.Value}
+ #end
+ new_app.properties["DirBrowseFlags"].value = -2147483586 # enable directory browsing
+ new_app.properties["Path"].value = app_path
+ new_app.properties["AccessRead"][0] = true
+ new_app.properties["AccessExecute"][0] = false
+ new_app.properties["AccessWrite"][0] = false
+ new_app.properties["ContentIndexed"][0] = true
+ new_app.properties["AppFriendlyName"][0] = app_name
+ new_app.properties["AccessScript"][0] = true
+ new_app.commit_changes
+
+ puts "#{app_name} has been configured successfully."
end
def get_app name, entryparent
- entryparent.children.select{|entry| entry.name.to_lower == name.to_lower}.first
+ entryparent.children.select{|entry| entry.name.to_lower == name.to_lower}.first
end
def delete virdir, entry_parent
- entry_parent.invoke "Delete", ["IIsWebVirtualDir", virdir]
- entry_parent.commit_changes
+ entry_parent.invoke "Delete", ["IIsWebVirtualDir", virdir]
+ entry_parent.commit_changes
end
end
end
-require 'mscorlib'
-require 'system'
-require 'System.Data'
-require 'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
-require 'System.Deployment, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
-require 'System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
-
-include System
-include System::DirectoryServices
-include System::IO
-include System::Collections
-
-ROOT = "IIS://localhost/W3SVC/1/root"
-
-# Is IIS installed?
-raise "Please make sure IIS is installed on this machine." unless DirectoryEntry.exists ROOT
-
-def run
- app_name = ARGV[0].to_clr_string rescue(raise(Exception.new("Application name required as first command-line arg")))
- app_path = ARGV[1].to_clr_string rescue(raise(Exception.new("Application path required as second command-line arg")))
- IISSetup.do(app_name, app_path)
-rescue => e
- puts <<-EOS
-Failed with exception: #{e}
-Please make sure following:
- 1. IIS is installed
- 2. On Vista, IIS6 Management Compatibility component is installed.
- 3. On Vista, this tool run as Administrator
-EOS
- exit -1
-end
-
if __FILE__ == $0
+ def run
+ app_name = ARGV[0].to_clr_string rescue(raise(Exception.new("Application name required as first command-line arg")))
+ app_path = ARGV[1].to_clr_string rescue(raise(Exception.new("Application path required as second command-line arg")))
+ IISSetup.do(app_name, app_path)
+ rescue => e
+ puts <<-EOS
+ Failed with exception: #{e}
+ Please make sure following:
+ 1. IIS is installed
+ 2. On Vista, IIS6 Management Compatibility component is installed.
+ 3. On Vista, this tool run as Administrator
+ EOS
+ exit -1
+ end
+
run
end
+
View
107 resizer.rb
@@ -9,41 +9,74 @@
include System::IO
def resize_image image_bytes, target_size
- original = Image.from_stream MemoryStream.new(image_bytes)
-
- target_width, target_height = if original.height > original.width
- [
- (original.width * (target_size / original.height.to_f)).to_i,
- target_size
- ]
- else
- [
- target_size,
- (original.height * (target_size / original.width.to_f)).to_i
- ]
- end
-
- img = Image.from_stream MemoryStream.new(image_bytes)
-
- # Create a new blank canvas. The resized image will be drawn on this canvas.
- bm = Bitmap.new target_width, target_height, PixelFormat.Format24bppRgb
- bm.set_resolution 72, 72
- gr = Graphics.from_image bm
- gr.SmoothingMode = SmoothingMode.AntiAlias
- gr.InterpolationMode = InterpolationMode.HighQualityBicubic
- gr.PixelOffsetMode = PixelOffsetMode.HighQuality
- gr.draw_image img, Rectangle.new(0, 0, target_width, target_height),
- 0, 0, original.width, original.height, GraphicsUnit.Pixel
-
- # Save out to memory and then to a file.
- # We dispose of all objects to make sure the files don't stay locked.
- mm = MemoryStream.new
- bm.save mm, ImageFormat.Jpeg
-
- original.dispose
- img.dispose
- bm.dispose
- gr.dispose
-
- mm.get_buffer
+ original = Image.from_stream MemoryStream.new(image_bytes)
+
+ target_width, target_height = if original.height > original.width
+ [
+ (original.width * (target_size / original.height.to_f)).to_i,
+ target_size
+ ]
+ else
+ [
+ target_size,
+ (original.height * (target_size / original.width.to_f)).to_i
+ ]
+ end
+
+ img = Image.from_stream MemoryStream.new(image_bytes)
+
+ # Create a new blank canvas. The resized image will be drawn on this canvas.
+ bm = Bitmap.new target_width, target_height, PixelFormat.Format24bppRgb
+ bm.set_resolution 72, 72
+ gr = Graphics.from_image bm
+ gr.SmoothingMode = SmoothingMode.AntiAlias
+ gr.InterpolationMode = InterpolationMode.HighQualityBicubic
+ gr.PixelOffsetMode = PixelOffsetMode.HighQuality
+ gr.draw_image img, Rectangle.new(0, 0, target_width, target_height),
+ 0, 0, original.width, original.height, GraphicsUnit.Pixel
+
+ # Save out to memory and then to a file.
+ # We dispose of all objects to make sure the files don't stay locked.
+ mm = MemoryStream.new
+ bm.save mm, ImageFormat.Jpeg
+
+ original.dispose
+ img.dispose
+ bm.dispose
+ gr.dispose
+
+ mm.get_buffer
+end
+
+if __FILE__ == $0
+ size = 640
+ file = 'fel.jpg'
+ new_file = file.split('.').first + "_" + size.to_s + '.' + file.split('.').last
+
+ puts "Resizing \"#{file}\" to \"#{new_file}\""
+
+ puts "Clean up"
+
+ File.delete new_file if File.exist? new_file
+
+ puts "Reading #{file} into memory"
+
+ input = FileStream.new file, FileMode.open
+ reader = BinaryReader.new input
+ input_bytes = reader.ReadBytes(input.length)
+ reader.close
+ input.close
+
+ puts "Resizing"
+ output_bytes = resize_image input_bytes, size
+
+ puts "Outputing #{new_file}"
+
+ output = FileStream.new new_file, FileMode.create_new
+ writer = BinaryWriter.new output
+ writer.write output_bytes
+ writer.close
+ output.close
+
+ puts "Done"
end
View
32 script.rb
@@ -1,32 +0,0 @@
-require 'resizer'
-
-size = 640
-file = 'fel.jpg'
-new_file = file.split('.').first + "_" + size.to_s + '.' + file.split('.').last
-
-puts "Resizing \"#{file}\" to \"#{new_file}\""
-
-puts "Clean up"
-
-File.delete new_file if File.exist? new_file
-
-puts "Reading #{file} into memory"
-
-input = FileStream.new file, FileMode.open
-reader = BinaryReader.new input
-input_bytes = reader.ReadBytes(input.length)
-reader.close
-input.close
-
-puts "Resizing"
-output_bytes = resize_image input_bytes, size
-
-puts "Outputing #{new_file}"
-
-output = FileStream.new new_file, FileMode.create_new
-writer = BinaryWriter.new output
-writer.write output_bytes
-writer.close
-output.close
-
-puts "Done"
Please sign in to comment.
Something went wrong with that request. Please try again.