IronRuby Unleashed by Shay Friedman | WHSmith Books
IronRuby Unleashed

IronRuby Unleashed

By: Shay Friedman (author)Paperback

Up to 2 WeeksUsually despatched within 2 weeks


Ruby has built an enormous following of developers attracted by its intuitiveness, flexibility, and simplicity. Meanwhile, Microsoft's .NET has grown and matured into a platform of unparalleled power. IronRuby brings them together, enabling developers to write elegant, efficient Ruby code that seamlessly integrates with .NET objects and leverages .NET's full capabilities. Now, in IronRuby Unleashed, one of IronRuby's most respected early adopters demonstrates how to write outstanding production software with the brand new IronRuby 1.0. Writing for both Ruby and .NET developers, Shay Friedman covers every facet of IronRuby programming. Friedman begins by explaining how IronRuby leverages the new Dynamic Language Runtime (DLR) libraries to run atop the .NET Framework and access its resources. Next, he presents an in-depth IronRuby tutorial that ranges from basic syntax and object-oriented programming techniques through advanced concepts. Building on this foundation, you'll learn how to make the most of a broad spectrum of .NET platform features. IronRuby Unleashed thoroughly illuminates the use of IronRuby and .NET with today's most powerful frameworks and technologies, including WPF, ASP.NET MVC, Ruby on Rails, and Silverlight. You'll also find detailed coverage of unit testing, as well as cutting-edge techniques for extending IronRuby with C# or VB.NET. Detailed information on how to...Install IronRuby and choose the right development environment for your needs Master IronRuby syntax, methods, blocks, classes, modules, libraries, and more Write code that takes advantage of IronRuby's dynamic and metaprogramming features Utilize .NET services and frameworks to write more powerful Ruby code than ever before Incorporate efficient data access into your IronRuby applications Use IronRuby to build Windows software with both WinForms and WPF Rapidly build high-quality Web applications with IronRuby and Ruby on Rails Create rich Web 2.0 applications with IronRuby and Microsoft Silverlight Test .NET code with Ruby's leading unit testing frameworks Run IronRuby code from other .NET code, and create .NET code libraries that fit well with IronRuby code

About Author

Shay Friedman works extensively with IronRuby and other dynamic languages, but got his start writing DOS scripts at age 8. He has been working professionally since age 16-first as a freelance Web developer, coding mainly in ColdFusion and ASP, and later as part of an information security team in an Israel Defense Forces (IDF) unit, where he developed in C#, C++, and Perl. Friedman moved on to join Advantech Technologies as a C# developer, and later as the leader of a Web development team at ActionBase. He currently works as a consultant and teacher of dynamic languages and ASP.NET at The Sela Group, conducting training courses around the world. Feel free to contact the author through his website at


Introduction 1Part I Introduction to IronRuby1 Introduction to the Ruby Language 5History of the Ruby Language 5Implementations 6Features 6Dynamic Language 6Object Oriented 7Duck Typing 8Metaprogramming 9REPL 10Available Libraries 112 Introduction to the .NET Framework 13History of the .NET Framework 13Overview 15Features 16Common Language Infrastructure 16Assemblies 18Base Class Library 19Security 19Memory Management 19Frameworks 203 Introduction to the Dynamic Language Runtime 21Overview 22Features 23Common Hosting Model 23Runtime Components 23Language Implementation 244 Getting Started with IronRuby 25Overview 25Installing IronRuby 26IronRuby Folders 29Getting the Sources 29Executables and Tools 30The IronRuby Interpreter (ir.exe) 31File Execution Mode 32Development Environments 34Ruby in Steel 34NetBeans 35RubyMine 36Others 37The Power of IronRuby 38Part II The Ruby Language5 Ruby Basics 43Basic Syntax 43Comments 43Setting Values to Variables 44Calling Methods 45Code File Structure 46Coding Standards 47Hello World 48Variables 48Numbers 48Text 50Arrays 54Hashes 57Ranges 59Booleans 60Regular Expressions 60Date and Time 62Constants 63Control Structures 64Conditions 64Loops 70The yield Statement 76BEGIN and END 77Exception Handling 78Exception Information 78rescue 78else 81ensure 82raise 83Custom Error Classes 856 Ruby's Code-Containing Structures 87Methods 87Defining Methods 88Method Naming 90Returning a Value from Methods 90Method Name Aliasing 91Default Parameter Values 92Special Parameter Types 93Associate Methods with Objects 94Removing Method Definitions 95Blocks, Procs, and Lambdas 96Blocks 96Procs 97Lambdas 99Flow-Altering Keywords Within Blocks, Procs, and Lambdas 100Classes 101Defining Classes 101Creating a Class Instance 102Defining a Constructor 102Variables Inside Classes 102Accessors 107Methods 109Operator Overloading 111Special Methods 115The self Keyword 118Visibility Control 118Inheritance 120Duck Typing 124Modules 126Module-Contained Objects 126Namespaces 127Mixins 1287 The Standard Library 131Using the Libraries 131Libraries Available in IronRuby 132Libraries Reference 135Abbrev 135Base64 135Benchmark 136BigDecimal 136Complex 137CSV 137Digest 138E2MMAP 139English 140Erb 141FileUtils 143Logger 143Monitor 144Net/http 144Observer 145Open-uri 145Ping 147Rational 152Rexml 153Singleton 154Socket 154Thread 157YAML 157WEBrick 157Zlib 158Finding More Libraries 1598 Advanced Ruby 161Threads 161Exceptions Within Threads 163Passing Data In and Out 164Thread Priority 164Thread State 165Thread Synchronization 167Handling Files 169Reading Files 170Writing Files 172Accessing File Properties 173Listing Directories 174File Operations 175Reflection 176Finding Living Objects 176Investigating Objects 177Invoke Methods and Set Variables Dynamically 178Execute Code Dynamically 180Marshaling 181Binary Marshaling 181Textual Marshaling 182RubyGems 183Installing RubyGems 183Installing Gems 183Using Installed Gems 183Rake 184IronRuby RubyGems Limitations and Expertise 185Finding Gems 185Design Patterns 186The Strategy Pattern 186The Iterator Pattern 188The Command Pattern 190The Singleton Pattern 192The Observer Pattern 194The Builder Pattern 196Domain-Specific Languages 199Part III IronRuby Fundamentals9 .NET Interoperability Fundamentals 207Bringing .NET into Ruby 207require 207load assembly 209load 210The $LOAD PATH Variable 210.NET Code Mapping 210Types Differences 211Coding Standards Collision 211Private Binding Mode 213Using .NET Objects 214Namespaces 214Interfaces 216Classes 216Structs 217Delegates 217Events 218Enums 221Constants 222Methods 222Fields 228Properties 228Generics 229Special IronRuby Methods 231Object Class Methods 231Class Class Methods 232Method Class Methods 233String Class Methods 234The IronRuby Class 235CLR Objects and Ruby's Reflection 237The Basic Object 23710 Object-Oriented .NET in IronRuby 239Inheriting from CLR Classes 239Regular Classes 239Abstract Classes 242Sealed and Static Classes 243Inheriting from CLR Structs 243Inheriting from CLR Interfaces 243Overriding Methods 245Virtual Methods 245Abstract Methods 246Regular Methods 247Static Methods 248Methods with Multiple Overloads 249Sealed Methods 250Overriding Properties 251Overriding Events 253Opening CLR Classes 254Using Mixins 254Opening the Object Class 255Opening Namespaces 256Part IV IronRuby and the .NET World11 Data Access 259Hello, Data Access 259Preparing Your Environment 260Contacting a SQL Server 260Loading the Needed Assemblies 260Building the Class Structure 260Building the Connection String 261Opening a Connection to the SQL Server 262Querying the Database 263Wrapping Up sql.rb 264Using the SqlServerAccessor Class 265Contacting a MySQL Server 265Preparing the MySQL Database 266Loading the Assemblies 267Building the Class Structure 267Building the Connection String 267Opening a Connection to the MySQL Server 268Querying the Database 268Inserting Records 269Deleting Records 269Wrapping Up mysql.rb 270Using the MySQLAccessor Class 272Design Considerations 272The CachedDataAccess Class 276Wrapping Up cached data access.rb 277Using the CachedDataAccess Class 278A Word About LINQ 27912 Windows Forms 281Introduction 281The Application Structure 282Building the Chat Class 282Requiring the Needed Assemblies 282Initiating the Class 282Receiving Messages 283Sending Messages 283Wrapping Up the Chat Class (chat.rb) 284Building the Chat Windows Form 285Loading the Needed Assemblies 285Building the Class 285Initializing the Form 286Setting the Form Properties 287Adding Controls 289Adding Functionality 293Using the Visual Studio Visual Designer 295Wrapping Up the ChatForm Class 297Writing the Execution Code 30013 Windows Presentation Foundation (WPF) 303Hello, WPF 303XAML 305Namespaces 306IronRuby and WPF Fundamentals 307Running XAML 307Retrieving WPF Elements 308Event Handling 308Windows 309Window 309Navigation Window 314Layout Controls 317StackPanel 317Grid 319Canvas 320More Panels 321Graphics and Animations 321Shapes 322Brushes 322Animations 324Data Binding 325Binding to Static Data 325Binding to Dynamic Data 327REPL 32914 Ruby on Rails 331Preparing Your Environment 331Hello, IronRuby on Rails 332Creating the Initial Project Files 333Directory Structure 333Database Configuration 334Running the Server 337The Basic Concepts 339MVC 339REST 339CoC 340DRY 340Main Components 340The Model: ActiveRecord 340The View: ActionView 341The Controller: ActionController 341Routes 341Know Your Environment 342script/server 342script/generate 343db:migrate 345Creating a Page 346Generating the Page Controller and View 346Helper Classes 349Adding Stylesheets 350Adding Layouts 351Adding Functionality 353Creating a Database-Driven Page 354Generating the Page Resources 354Polishing the Index Page 35615 ASP.NET MVC 363Preparing Your Environment 363Installing ASP.NET MVC 364Obtaining the IronRubyMvc DLL 364Adding IronRubyMvc Templates to Visual Studio 365Hello, ASP.NET MVC 365Generating the Initial Project 365MVC 368Models 368Controllers 371alias action 375Views 378Routes 385Custom Routes 386Filters 387Action Filters 387Result Filters 390Authorization Filters 392Exception Filters 393Controller-wide Filters 394Custom Action Filter Classes 395Validations 396Inside the Model 396Inside the Controller 396Inside the View 397Classic ASP.NET Features 398A Word About Classic ASP.NET 39816 Silverlight 401Prepare Your Environment 402Hello, Silverlight 402The sl Tool: The Silverlight Application Creator 402The chr Tool: The Development Server 404Add Silverlight to a Web Page 406XAML 409Layout 410Controls 411Adding Code 411Running XAML 411Retrieving Silverlight Elements 412Event Handling 414Accessing the HTML Page and Window 414Graphics 415Media and Animations 417Data Binding 419Static Data 419Dynamic Data 420Data Templates 42217 Unit Testing 425The Tested Code 426Test::Unit 427Test Cases 427Assertions 428Setup and Teardown 432Test Suites 433Running the Tests 434RSpec 435Install RSpec 436Requiring Needed Libraries 436Running Tests 437Creating a Behavior with describe 438Creating Examples with it 439Expectation Methods 439Before and After 442Cucumber 443Installing Cucumber 445Project Structure 445Features 446Scenarios 447A Background 452Tags 453Hooks 454A World 456Multilanguage 456Executing Cucumber 45718 Using IronRuby from C#/VB.NET 459Hello, IronRuby from CLR 459The Classes of the Process 461ScriptRuntime 462ScriptEngine 463ScriptScope 465ScriptSource 466Executing IronRuby from C#/VB.NET 468Executing an IronRuby File 468Executing IronRuby Code from a String 468Pass Variables to and from IronRuby 469Using IronRuby Objects 470Using External Libraries 472Part V Advanced IronRuby19 Extending IronRuby 477Creating an Extension 478Main Concepts 478The Extension Project 481Target Environments 482Modules 482Classes 488Methods 491Constants 501Using an Extension in IronRuby 501Building an IronRuby Extension 501Creating the Extension Visual Studio Project 502Adding Build Configurations 502Creating the Actual Code 504Creating the Ruby Programming Interface 506Generating the Library Initializer 508Using the IronRuby .NET Extension in IronRuby 509Index 511

Product Details

  • ISBN13: 9780672330780
  • Format: Paperback
  • Number Of Pages: 552
  • ID: 9780672330780
  • weight: 850
  • ISBN10: 0672330784

Delivery Information

  • Saver Delivery: Yes
  • 1st Class Delivery: Yes
  • Courier Delivery: Yes
  • Store Delivery: Yes

Prices are for internet purchases only. Prices and availability in WHSmith Stores may vary significantly