ironruby - a brave new world for .net (ndc2010)
DESCRIPTION
Session given at NDC2010, Oslo, Norway on IronRuby.TRANSCRIPT
London (UK) based C# MVPWeb Developer @ 7digital.com
Working on a number of Open Source Projects
Co-Author of Testing ASP.net Web Applicationshttp://www.testingaspnet.com
Today...
• Intro to Ruby \ IronRuby • Taking advantage with existing frameworks• 7digital, scripting, DSLs and the real world• Embedding IronRuby into C#
Tomorrow...
• Testing C# and ASP.net Applications using Ruby• Track 6 (Here)• 13:40
• Lunch-time Ruby meet-up
Why are we here?
http://www.flickr.com/photos/wwworks/2222523486/sizes/l/
Ruby implementation on top of .NET
The right language for the right job
Don’t think of this as a replacement
DEMORUBY RUBY RUBY => IRONRUBY
http://www.flickr.com/photos/vhanes/3053401272/
Community
http://www.flickr.com/photos/tjflex/233574885/
Invest Regularly in Your Knowledge Portfolio
Learn at least one new language every year
The Pragmatic ProgrammerAndrew Hunt \ David Thomas
Continuous Improvement
via @danrough
Programming Dinosaur
http://nickolai.tumblr.com/post/159823820/dilbert-cobol-programming-dinosaur
Real world example
Remote server setup and configuration
consts = “dns = 'ec2-127.0.0.1.amazon.com‘; file = ‘app.config’” command = “contents = System::IO::File.read_all_text(file); " + "contents = contents.replace(‘$(MACHINE_DNS)', dns); " + "System::IO::File.write_all_text(file, contents)"
ir.exe -e ”#{consts}” -e ”#{command}”
ir.exe installed onto every server via svn+teamcity
Ruby as a scripting language
require 'win32ole'excel = WIN32OLE.new("excel.application")excel['Visible'] = true
#Create a new sheetworkbook = excel.Workbooks.Addexcel.Range("a1")['Value'] = 3excel.Range("a2")['Value'] = 2excel.Range("a3")['Value'] = 1excel.Range("a1:a3").Select
# Add a chartexcelchart = workbook.Charts.AddXL3D_COLUMN_CHART_TYPE = -4100excelchart['Type'] = XL3D_COLUMN_CHART_TYPE
Built-in to IronRuby & Excel
DEMOADVANCED RUBY\IRONRUBY
Internal DSLs (Domain Specific Language)
kill ‘ps aux | grep mongrel_rails | grep -v grep | cut -c 10-20’
Rush.processes.filter(:cmdline => /mongrel_rails/).kill
Created using Rush
Bash
Ruby
defaults do color true environment :test role :windows zone :'eu-west-1b' bucket 'rudy-ami-eu'end
machines do region :'us-east-1' do ami 'ami-de4daab7' # Amazon Windows Server 2003 (US) size 'm1.small' end region :'eu-west-1' do ami 'ami-8696bef2' # Rudy Windows 2009-08-24 (EU) endend
Created using Rudy
@hourly cd C:/temp/ && script/runner -e production "SomeModel.ladeeda" >> C:/temp/cron_log.log 2>&1
0 0,3,6,9,12,15,18,21 * * * cd C:/temp/ && script/runner -e production "MyModel.some_process" >> C:/temp/cron_log.log 2>&1
0 0,3,6,9,12,15,18,21 * * * cd C:/temp/ && RAILS_ENV=production /usr/bin/env rake my:rake:task >> C:/temp/cron_log.log 2>&1
0 0,3,6,9,12,15,18,21 * * * /usr/bin/my_great_command >> C:/temp/cron_log.log 2>&1
30 4 * * * cd C:/temp/ && script/runner -e production "MyModel.task_to_run_at_four_thirty_in_the_morning" >> C:/temp/cron_log.log 2>&1
0 12 * * 0 cd C:/temp/ && script/runner -e production "Task.do_something_great" >> C:/temp/cron_log.log 2>&1
Corn job\task
set :path, 'C:/temp/‘set :output, "C:/temp/cron_log.log"
every 3.hours do runner "MyModel.some_process" rake "my:rake:task" command "/usr/bin/my_great_command“end
every 1.day, :at => '4:30 am' do runner "MyModel.task_to_run_at_four_thirty_in_the_morning“end
every :hour do runner "SomeModel.ladeeda“end
every :sunday, :at => '12pm' do runner "Task.do_something_great“end
Created using Whenever
desc "Run a sample build using the MSBuildTask" msbuild do |msb| msb.properties :configuration => :Debug msb.targets :Clean, :Build msb.solution = "spec/support/TestSolution/TestSolution.sln" end
desc "NUnit Test Runner Example" nunit do |nunit| nunit.path_to_command = "NUnit/nunit-console.exe" nunit.assemblies "assemblies/TestSolution.Tests.dll" end
Created using Albacorehttp://albacorebuild.net/
desc "Create Website" create_site :create => :delete do |w| w.name = 'Meerpush_Website' w.home = 'C:\inetpub\wwwroot' end
desc "Start Website" start_site :start do |w| w.name = 'Meerpush_Website' end
Created using Meerpushhttp://www.github.com/benhall/meerpush
DEMOEMBEDDING IRONRUBY
Links• http://ironruby.codeplex.com/• http://twitter.com/#/list/casualjim/ironruby-
community• http://blog.benhall.me.uk
SUMMARY
http://www.bennylingbling.com/2009/04/17/i-see-what-you-did-there/
change
How will IronRuby
your world?
http://lolcatgenerator.com/lolcat/120/