SlideShare une entreprise Scribd logo
1  sur  30
Télécharger pour lire hors ligne
RUBY ON WINDOWS
                               Up and Runing




Saturday, August 27, 11                        1
WHO AM I?




Saturday, August 27, 11               2
About me
                   張銘軒 (Mason Chang)

                   Was a hardware engineer

                   Love software and programming

                   Start using Ruby since late 2009

                   Twitter: @changmason (I don’t tweet though)

                   Email: changmason@gmail.com


Saturday, August 27, 11                                          3
WHY (ON WINDOWS)?




Saturday, August 27, 11                       4
You are more familiar with
                           Windows environments.
Picture courtesy of yum9me (CC) BY-NC-ND 2.0
http://www.flickr.com/photos/yum9me/532905569
Saturday, August 27, 11                                5
You don’t want to fight against existing
                  tools and workflows inside your company.
Picture courtesy of erix (CC) BY 2.0
http://www.flickr.com/photos/erix/77966968/
Saturday, August 27, 11                                        6
Broader user base, your target
                             users are on Windows.
Picture courtesy of opacity (CC) BY-NC-ND 2.0
http://www.flickr.com/photos/opacity/4483057728/
Saturday, August 27, 11                                    7
WHAT RUBY?
                           ... BECAUSE



Saturday, August 27, 11                  8
Many Rubies (which on Win?)
                          MRI     JRuby      IronRuby      Rubinius    MacRuby    MagLev




                          ◎         ◎            ◎            ▵            ✕        ✕
                    ◎ => Yes.
                    ✕ => No.
                    ▵ => Maybe. (planned to support Windows in the near future)

Saturday, August 27, 11                                                                    9
BUT, Windows users don’t
                           like to compile code!!!



Picture courtesy of TahoeSunsets (CC) BY-NC-SA 2.0
http://www.flickr.com/photos/raparker/236912028
Saturday, August 27, 11                              10
Ruby Installer
                   Compiled executables under MinGW32 dev environment

                   Both newest Ruby 1.8.7p352 and 1.9.2p290 are available




Saturday, August 27, 11                                                     11
JRuby Installer
                   Require JRE (or JDK if you want to compile .rb into .class)

                   Ruby 1.8 compatible and Ruby 1.9 supported




Saturday, August 27, 11                                                          12
Rails Installer
                   All in one package, including MRI Ruby, Rails, Git and DevKit




Saturday, August 27, 11                                                            13
rvm => No, pik => Yes
                   Very similar to rvm, it helps you to install, manage, and switch
                   among all available Rubies on Windows.

                   There are two ways to install pik:

                   1. If you already have a Ruby installed:
                     gem install pik
                     pik_install c:bin
                   2.otherwise, use pik installer:
                     https://github.com/vertiginous/pik/downloads


Saturday, August 27, 11                                                               14
pik help commands




Saturday, August 27, 11                       15
Other Dev Tools

                   Version control:
                   msysgit: http://code.google.com/p/msysgit/

                   git-bash:
                   Provide a *nix-like CLI with colors on Windows.

                   Text editors:
                   Notepad++: http://notepad-plus-plus.org/ (Freeware)
                   E-texteditor: http://www.e-texteditor.com/ (Textmate clone)



Saturday, August 27, 11                                                          16
HOW TO ?




Saturday, August 27, 11              17
How to code?
                   EOL(end of line):
                   To share your code with the community, please convert EOL
                   from Windows format(CRLF) to UNIX format(LF) in your
                   source files. (You text editors can do this for you, check it!!)

                   Pathname:
                   Although Ruby, on Windows, can automatically translate in
                   between “/” and “” of a file path, it is recommended that you
                   use “pathname” to handle a complex file path which is got from
                   the user. (There may be spaces and Chinese characters.)


Saturday, August 27, 11                                                               18
How to install gems?
                   “gem install xxx” will automatically detect your platform and
                   install the right gem for you.

                   For JRuby, please use “jruby -S gem install xxx” instead.

                   You can also manually download and
                   install the gems that correspond to
                   your platform if “gem install xxx” fail
                   to detect the right gems for you.




Saturday, August 27, 11                                                            19
How about gem compatibility?

                   Most gems written in pure Ruby or shipped with precompiled
                   C-extension work out of the box on Windows: sinatra, nokogiri

                   Some gems with native C-extension may need a few tweaks and
                   compilation(DevKit is your friend): mysql2

                   Still there are very few gems that will hardly work on Windows
                   because they are designed for POSIX OS: unicorn



Saturday, August 27, 11                                                             20
How to do Windows automation
                           (use WIN32OLE)?
                   Operate Windows applications just like operate Ruby objects,
                   (no need to write any VB script):
                   InternetExplorer, Excel, Word, PowerPoint...

                   Reflection support through methods with prefix ole_*:
                   :ole_methods, :ole_type, :ole_method_help

                   OLE object’s OLE methods are case insensitive:
                   obj.visible is the same as object.ViSiBlE

                   Please refer to MSDN for API: http://msdn.microsoft.com/


Saturday, August 27, 11                                                           21
WIN32OLE - example
                          https://gist.github.com/1173715




Saturday, August 27, 11                                     22
How to program GUI?


                   Several libraries are available:
                   FoxRuby, WxRuby, Shoes, Bowline

                   However, these gems are not under regular maintenance

                   GUI programming with Swing in JRuby is a good solution




Saturday, August 27, 11                                                     23
Swing GUI - example(p1)
                          https://github.com/changmason/id_maker




Saturday, August 27, 11                                            24
Swing GUI - example(p2)
                                                     import Java classes to
                                                     current Ruby namespace

                                                   Ruby class can inherit Java class


                                                      call Java’s constructor


                                          setter in Java style




                                                                  event handling by a Ruby block



                                                                         tell the swing worker
                                                                         to run in background


                                       setter in Ruby style



Saturday, August 27, 11                                                                            25
Swing GUI - example(p3)
                                         Although JRuby runtime can call Java methods
                                         in camelCaseStyle or in snake_case_style, this
                                         doInBackground method is invoked by Java in
                                         the background thread actually. So we MUST
                                         name it in Java way.




Saturday, August 27, 11                                                                   26
How about packaging
                             your programs?

                   In Ruby use OCRA (One Click Ruby Application):
                   Package all your source files with the Ruby interpreter and
                   required gems into one .exe file.

                   In JRuby use rawr or Warbler:
                   Same as above, but they can also help you to compile your .rb
                   files into .class files. The output can be a standalone .jar, .war
                   or .exe file.



Saturday, August 27, 11                                                                 27
CONCLUSION




Saturday, August 27, 11                28
(J)Ruby on Windows is already good enough to learn and play
                   with. We can get more Windows users to join this community.

                   Ruby's concise syntax and direct access to OLE objects
                   make it a powerful productivity tool on Windows.

                   Stick to JRuby/Java technologies if you really care about cross-
                   platform compatibilities of your programs.

                   Eventually, you would buy a Mac or setup a Linux machine if
                   developing (Rails) on Windows really hurts your productivity.




Saturday, August 27, 11                                                               29
Q&A




Saturday, August 27, 11         30

Contenu connexe

Tendances

Introduction to yocto
Introduction to yoctoIntroduction to yocto
Introduction to yoctoAlex Gonzalez
 
Headless Android at AnDevCon3
Headless Android at AnDevCon3Headless Android at AnDevCon3
Headless Android at AnDevCon3Opersys inc.
 
Embedded Android Workshop part I ESC SV 2012
Embedded Android Workshop part I ESC SV 2012Embedded Android Workshop part I ESC SV 2012
Embedded Android Workshop part I ESC SV 2012Opersys inc.
 
Android Jumpstart ESC SV 2012 Part I
Android Jumpstart ESC SV 2012 Part IAndroid Jumpstart ESC SV 2012 Part I
Android Jumpstart ESC SV 2012 Part IOpersys inc.
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and DevelopmentOpersys inc.
 
Android Variants, Hacks, Tricks and Resources
Android Variants, Hacks, Tricks and ResourcesAndroid Variants, Hacks, Tricks and Resources
Android Variants, Hacks, Tricks and ResourcesOpersys inc.
 
Yocto: Treinamento em Português
Yocto: Treinamento em PortuguêsYocto: Treinamento em Português
Yocto: Treinamento em PortuguêsOtavio Salvador
 
Memory Management in Android
Memory Management in AndroidMemory Management in Android
Memory Management in AndroidOpersys inc.
 

Tendances (10)

Introduction to yocto
Introduction to yoctoIntroduction to yocto
Introduction to yocto
 
Headless Android at AnDevCon3
Headless Android at AnDevCon3Headless Android at AnDevCon3
Headless Android at AnDevCon3
 
Embedded Android Workshop part I ESC SV 2012
Embedded Android Workshop part I ESC SV 2012Embedded Android Workshop part I ESC SV 2012
Embedded Android Workshop part I ESC SV 2012
 
Headless Android
Headless AndroidHeadless Android
Headless Android
 
Android Jumpstart ESC SV 2012 Part I
Android Jumpstart ESC SV 2012 Part IAndroid Jumpstart ESC SV 2012 Part I
Android Jumpstart ESC SV 2012 Part I
 
Mars - ESUG 2010
Mars - ESUG 2010Mars - ESUG 2010
Mars - ESUG 2010
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Android Variants, Hacks, Tricks and Resources
Android Variants, Hacks, Tricks and ResourcesAndroid Variants, Hacks, Tricks and Resources
Android Variants, Hacks, Tricks and Resources
 
Yocto: Treinamento em Português
Yocto: Treinamento em PortuguêsYocto: Treinamento em Português
Yocto: Treinamento em Português
 
Memory Management in Android
Memory Management in AndroidMemory Management in Android
Memory Management in Android
 

En vedette

10 Insightful Quotes On Designing A Better Customer Experience
10 Insightful Quotes On Designing A Better Customer Experience10 Insightful Quotes On Designing A Better Customer Experience
10 Insightful Quotes On Designing A Better Customer ExperienceYuan Wang
 
Learn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionLearn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionIn a Rocket
 
How to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media PlanHow to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media PlanPost Planner
 
SEO: Getting Personal
SEO: Getting PersonalSEO: Getting Personal
SEO: Getting PersonalKirsty Hulse
 

En vedette (6)

Rails Intro & Tutorial
Rails Intro & TutorialRails Intro & Tutorial
Rails Intro & Tutorial
 
Ruby on rails intro
Ruby on rails introRuby on rails intro
Ruby on rails intro
 
10 Insightful Quotes On Designing A Better Customer Experience
10 Insightful Quotes On Designing A Better Customer Experience10 Insightful Quotes On Designing A Better Customer Experience
10 Insightful Quotes On Designing A Better Customer Experience
 
Learn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionLearn BEM: CSS Naming Convention
Learn BEM: CSS Naming Convention
 
How to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media PlanHow to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media Plan
 
SEO: Getting Personal
SEO: Getting PersonalSEO: Getting Personal
SEO: Getting Personal
 

Similaire à Ruby on Windows (RubyConf.tw 2011)

How to build LibreOffice on your desktop
How to build LibreOffice on your desktopHow to build LibreOffice on your desktop
How to build LibreOffice on your desktopMasataka Kondo
 
IronRuby for the Rubyist
IronRuby for the RubyistIronRuby for the Rubyist
IronRuby for the RubyistWill Green
 
How to be productive with Rails... even on Windows
How to be productive with Rails... even on WindowsHow to be productive with Rails... even on Windows
How to be productive with Rails... even on WindowsLuis Lavena
 
Ruby on Rails - An overview
Ruby on Rails -  An overviewRuby on Rails -  An overview
Ruby on Rails - An overviewThomas Asikis
 
Wix Application Framework
Wix Application FrameworkWix Application Framework
Wix Application FrameworkRan Mizrahi
 
A Tour of Open Source on the Mainframe
A Tour of Open Source on the MainframeA Tour of Open Source on the Mainframe
A Tour of Open Source on the MainframeAll Things Open
 
The story of language development
The story of language developmentThe story of language development
The story of language developmentHiroshi SHIBATA
 
ZFS and FreeBSD Jails
ZFS and FreeBSD JailsZFS and FreeBSD Jails
ZFS and FreeBSD Jailsapeiron
 
One RubyStack to Rule them All
One RubyStack to Rule them AllOne RubyStack to Rule them All
One RubyStack to Rule them Allelliando dias
 
A glance at the Rust SWC
A glance at the Rust SWCA glance at the Rust SWC
A glance at the Rust SWCThien Ly
 
Ruby on rails toolbox
Ruby on rails toolboxRuby on rails toolbox
Ruby on rails toolboxBlazing Cloud
 
Linux On V Mware ESXi
Linux On V Mware ESXiLinux On V Mware ESXi
Linux On V Mware ESXiMasafumi Ohta
 
JBoss AS 7 from a user perspective
JBoss AS 7 from a user perspectiveJBoss AS 7 from a user perspective
JBoss AS 7 from a user perspectiveMax Andersen
 
Unikernels - Bristech June 2016
Unikernels - Bristech June 2016 Unikernels - Bristech June 2016
Unikernels - Bristech June 2016 Daniel Drozdzewski
 

Similaire à Ruby on Windows (RubyConf.tw 2011) (20)

How to build LibreOffice on your desktop
How to build LibreOffice on your desktopHow to build LibreOffice on your desktop
How to build LibreOffice on your desktop
 
IronRuby for the Rubyist
IronRuby for the RubyistIronRuby for the Rubyist
IronRuby for the Rubyist
 
How to be productive with Rails... even on Windows
How to be productive with Rails... even on WindowsHow to be productive with Rails... even on Windows
How to be productive with Rails... even on Windows
 
RubyConf 2009
RubyConf 2009RubyConf 2009
RubyConf 2009
 
Ruby on Rails - An overview
Ruby on Rails -  An overviewRuby on Rails -  An overview
Ruby on Rails - An overview
 
Rejectkaigi 2010
Rejectkaigi 2010Rejectkaigi 2010
Rejectkaigi 2010
 
Wix Application Framework
Wix Application FrameworkWix Application Framework
Wix Application Framework
 
A Tour of Open Source on the Mainframe
A Tour of Open Source on the MainframeA Tour of Open Source on the Mainframe
A Tour of Open Source on the Mainframe
 
The story of language development
The story of language developmentThe story of language development
The story of language development
 
Debian on EC2
Debian on EC2Debian on EC2
Debian on EC2
 
ZFS and FreeBSD Jails
ZFS and FreeBSD JailsZFS and FreeBSD Jails
ZFS and FreeBSD Jails
 
Docker
DockerDocker
Docker
 
One RubyStack to Rule them All
One RubyStack to Rule them AllOne RubyStack to Rule them All
One RubyStack to Rule them All
 
A glance at the Rust SWC
A glance at the Rust SWCA glance at the Rust SWC
A glance at the Rust SWC
 
Ruby on rails toolbox
Ruby on rails toolboxRuby on rails toolbox
Ruby on rails toolbox
 
Linux On V Mware ESXi
Linux On V Mware ESXiLinux On V Mware ESXi
Linux On V Mware ESXi
 
App Lego
App LegoApp Lego
App Lego
 
JBoss AS 7 from a user perspective
JBoss AS 7 from a user perspectiveJBoss AS 7 from a user perspective
JBoss AS 7 from a user perspective
 
Unikernels - Bristech June 2016
Unikernels - Bristech June 2016 Unikernels - Bristech June 2016
Unikernels - Bristech June 2016
 
Lightning fast sass
Lightning fast sassLightning fast sass
Lightning fast sass
 

Dernier

A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 

Dernier (20)

A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 

Ruby on Windows (RubyConf.tw 2011)

  • 1. RUBY ON WINDOWS Up and Runing Saturday, August 27, 11 1
  • 2. WHO AM I? Saturday, August 27, 11 2
  • 3. About me 張銘軒 (Mason Chang) Was a hardware engineer Love software and programming Start using Ruby since late 2009 Twitter: @changmason (I don’t tweet though) Email: changmason@gmail.com Saturday, August 27, 11 3
  • 4. WHY (ON WINDOWS)? Saturday, August 27, 11 4
  • 5. You are more familiar with Windows environments. Picture courtesy of yum9me (CC) BY-NC-ND 2.0 http://www.flickr.com/photos/yum9me/532905569 Saturday, August 27, 11 5
  • 6. You don’t want to fight against existing tools and workflows inside your company. Picture courtesy of erix (CC) BY 2.0 http://www.flickr.com/photos/erix/77966968/ Saturday, August 27, 11 6
  • 7. Broader user base, your target users are on Windows. Picture courtesy of opacity (CC) BY-NC-ND 2.0 http://www.flickr.com/photos/opacity/4483057728/ Saturday, August 27, 11 7
  • 8. WHAT RUBY? ... BECAUSE Saturday, August 27, 11 8
  • 9. Many Rubies (which on Win?) MRI JRuby IronRuby Rubinius MacRuby MagLev ◎ ◎ ◎ ▵ ✕ ✕ ◎ => Yes. ✕ => No. ▵ => Maybe. (planned to support Windows in the near future) Saturday, August 27, 11 9
  • 10. BUT, Windows users don’t like to compile code!!! Picture courtesy of TahoeSunsets (CC) BY-NC-SA 2.0 http://www.flickr.com/photos/raparker/236912028 Saturday, August 27, 11 10
  • 11. Ruby Installer Compiled executables under MinGW32 dev environment Both newest Ruby 1.8.7p352 and 1.9.2p290 are available Saturday, August 27, 11 11
  • 12. JRuby Installer Require JRE (or JDK if you want to compile .rb into .class) Ruby 1.8 compatible and Ruby 1.9 supported Saturday, August 27, 11 12
  • 13. Rails Installer All in one package, including MRI Ruby, Rails, Git and DevKit Saturday, August 27, 11 13
  • 14. rvm => No, pik => Yes Very similar to rvm, it helps you to install, manage, and switch among all available Rubies on Windows. There are two ways to install pik: 1. If you already have a Ruby installed: gem install pik pik_install c:bin 2.otherwise, use pik installer: https://github.com/vertiginous/pik/downloads Saturday, August 27, 11 14
  • 15. pik help commands Saturday, August 27, 11 15
  • 16. Other Dev Tools Version control: msysgit: http://code.google.com/p/msysgit/ git-bash: Provide a *nix-like CLI with colors on Windows. Text editors: Notepad++: http://notepad-plus-plus.org/ (Freeware) E-texteditor: http://www.e-texteditor.com/ (Textmate clone) Saturday, August 27, 11 16
  • 17. HOW TO ? Saturday, August 27, 11 17
  • 18. How to code? EOL(end of line): To share your code with the community, please convert EOL from Windows format(CRLF) to UNIX format(LF) in your source files. (You text editors can do this for you, check it!!) Pathname: Although Ruby, on Windows, can automatically translate in between “/” and “” of a file path, it is recommended that you use “pathname” to handle a complex file path which is got from the user. (There may be spaces and Chinese characters.) Saturday, August 27, 11 18
  • 19. How to install gems? “gem install xxx” will automatically detect your platform and install the right gem for you. For JRuby, please use “jruby -S gem install xxx” instead. You can also manually download and install the gems that correspond to your platform if “gem install xxx” fail to detect the right gems for you. Saturday, August 27, 11 19
  • 20. How about gem compatibility? Most gems written in pure Ruby or shipped with precompiled C-extension work out of the box on Windows: sinatra, nokogiri Some gems with native C-extension may need a few tweaks and compilation(DevKit is your friend): mysql2 Still there are very few gems that will hardly work on Windows because they are designed for POSIX OS: unicorn Saturday, August 27, 11 20
  • 21. How to do Windows automation (use WIN32OLE)? Operate Windows applications just like operate Ruby objects, (no need to write any VB script): InternetExplorer, Excel, Word, PowerPoint... Reflection support through methods with prefix ole_*: :ole_methods, :ole_type, :ole_method_help OLE object’s OLE methods are case insensitive: obj.visible is the same as object.ViSiBlE Please refer to MSDN for API: http://msdn.microsoft.com/ Saturday, August 27, 11 21
  • 22. WIN32OLE - example https://gist.github.com/1173715 Saturday, August 27, 11 22
  • 23. How to program GUI? Several libraries are available: FoxRuby, WxRuby, Shoes, Bowline However, these gems are not under regular maintenance GUI programming with Swing in JRuby is a good solution Saturday, August 27, 11 23
  • 24. Swing GUI - example(p1) https://github.com/changmason/id_maker Saturday, August 27, 11 24
  • 25. Swing GUI - example(p2) import Java classes to current Ruby namespace Ruby class can inherit Java class call Java’s constructor setter in Java style event handling by a Ruby block tell the swing worker to run in background setter in Ruby style Saturday, August 27, 11 25
  • 26. Swing GUI - example(p3) Although JRuby runtime can call Java methods in camelCaseStyle or in snake_case_style, this doInBackground method is invoked by Java in the background thread actually. So we MUST name it in Java way. Saturday, August 27, 11 26
  • 27. How about packaging your programs? In Ruby use OCRA (One Click Ruby Application): Package all your source files with the Ruby interpreter and required gems into one .exe file. In JRuby use rawr or Warbler: Same as above, but they can also help you to compile your .rb files into .class files. The output can be a standalone .jar, .war or .exe file. Saturday, August 27, 11 27
  • 29. (J)Ruby on Windows is already good enough to learn and play with. We can get more Windows users to join this community. Ruby's concise syntax and direct access to OLE objects make it a powerful productivity tool on Windows. Stick to JRuby/Java technologies if you really care about cross- platform compatibilities of your programs. Eventually, you would buy a Mac or setup a Linux machine if developing (Rails) on Windows really hurts your productivity. Saturday, August 27, 11 29