SlideShare a Scribd company logo
USE RUBY TO WRITE (AND TEST) YOUR

 
 
 
 NEXT ANDROID APP
Joel Byler
Software Craftsman
@joelbyler
June 1, 2013
Pittsburgh TechFest
La Roche College
Saturday, June 1, 13
WHO AM I?
 
 
 
 JOEL BYLER
 Software Craftsman
 Organizer for CleRb
 Enterprise Java Developer
 Relatively new to Ruby
 ... and Android
Saturday, June 1, 13
Saturday, June 1, 13
NEW TO ANDROID AND RUBY???
 Software Craftsmanship
Reduce risk with TDD / ATDD
 <3 Ruby and want to learn more
 <3 Mobile apps, who doesn’t?
Warning: this may turn out to be a lot of code to absorb in a short
amount of time. Slides and code will be made publicly available
Saturday, June 1, 13
RUBY ON ANDROID USING RUBOTO
JRuby optimized for the Android OS
 JRuby is a JVM language
 Android uses something like the JVM
but actually Dalvik VM
=+
<<< MAGIC >>>
Saturday, June 1, 13
IRB ON YOUR ANDROID DEVICE
 Interactive Ruby Shell
 Edit and run scripts in Android
 demo...
Saturday, June 1, 13
PERFORMANCE CONSIDERATIONS
Other than initial startup to load
JRuby, the performance of the app
appears to be as good as many
native Android apps
Saturday, June 1, 13
RUBOTO CORE
 A separate app available on the
Google Play Store
 Allows Ruboto Runtime (JRuby
on Dalvik VM) to be shared
 An alternative would be to use
the --with-jruby option
Decisions, decisions...
Saturday, June 1, 13
HOW DOES THIS
MAKE YOU FEEL?
This is what your users will
see if they don’t already have
the Ruboto Core installed
Using the --with-jruby
option will add ~10mb
to the size of your app
or
Saturday, June 1, 13
CREATE A NEW PROJECT
Ruboto Application Generator
$ ruboto gen app --package com.leandog.mastermind.ruboto
--name MasterMindRuboto --target android-15
--with-jruby --path=RubotoMasterMind
This will generate application with
'What hath Matz wrought?' sample code.
Saturday, June 1, 13
RUBOTO CLASS GENERATOR
Ruboto Class Generator
$ ruboto gen class Activity --name MasterMindMainActivity
This will generate code for the activity and add it to
the project manifest.
You can also use this to generate a
BroadcastReceiver or Service class
Saturday, June 1, 13
YOUR GENERATED APP
Saturday, June 1, 13
YOUR GENERATED CODE (RUBY .RB)
Saturday, June 1, 13
YOUR GENERATED TEST (ALSO .RB)
Saturday, June 1, 13
RAKE INSTEAD OF ANT
$ rake install start
Install the project on a device or emulator and start
it running.
$ ant debug
$ adb install example.apk
$ adb shell am start -n com.foo.bar...
$ rake update_scripts
Install the project on a device or emulator and start
it running.
$ adb install example.apk
$ rake -T List other available rake tasks
Saturday, June 1, 13
ADD IN THE ATDD
$ gem install testgen
This is one of @chzy 's testing gems
$ testgen project yourapp --with-gametel
This will add everything you need to use cucumber
to test your Ruboto app
Saturday, June 1, 13
NOW FOR SOME UNIT TESTS
$ mkdir spec This is where your specs will live
Add rspec to Rakefile (created by testgen)
Saturday, June 1, 13
UNIT TESTING
Use rspec to test your ruby code, just like you
normally would.
rspec
JUnit 3
rake spec
Saturday, June 1, 13
INTEGRATION TEST?
Instruments and installs app on device when running
rake test
similar to ActivityInstrumentationTestCase2
Saturday, June 1, 13
ACCEPTANCE TESTING
Feature: Input Screen
Scenario: Welcome the user
When the application launches
Then I see "Enter four numbers below and submit your guess"
Scenario: User can guess
Given I enter 4 numbers
When I press the submit button
Then I see "Nice guess!"
rake features
Cucumber
Gametel
Brazenhead
ADB gem
class MainScreen
include Gametel
text(:number1, :index => 0)
text(:number2, :index => 1)
text(:number3, :index => 2)
text(:number4, :index => 3)
def guess (first, second, third, forth)
number1 = first.to_s
number2 = second.to_s
number3 = third.to_s
number4 = forth.to_s
end
end
Then(/^I enter 4 numbers$/) do
on(MainScreen).guess 1, 2, 3, 4
end
Saturday, June 1, 13
YOUR RUBOTO CLASS FILES
 They're just .rb files
 Allows you to make changes without a full
rebuild
 fast feedback
 Ruboto uses ruby classes that are backed by java
classes for improved performance.
 Can still reference Java resources
example:
R::string::header_text
Saturday, June 1, 13
QUICK TOUR OF THE CODE
* Time permitting
Saturday, June 1, 13
Saturday, June 1, 13
THE RUBOTO COMMUNITY IS GROWING
Some of these projects are still young or have a small
user base.
- They will probably continue to change (improve)
- Ruboto is only version 0.12
Example:
Wasn't able to add a menu to the main activity. Instead
I had to wrap it with the 'launch' activity.
The good news is that they could definitely use YOUR
HELP!
Anyone up for trying to make the debugger work?
Saturday, June 1, 13
CONCLUSION
Ruboto is a great Open Source project with a
growing community that promises to get even
better.
Yes, it does increase your app's startup time
slightly, but offers a great dynamic nature for
rapidly changing apps.
Virtually all code can be Ruby, but can also
reference Java resources if you so desire.
Saturday, June 1, 13
RESOURCES
Sample Code
https://github.com/joelbyler/Ruboto-MasterMind
Ruboto
http://ruboto.org/
ATDD Training Resource
https://leanpub.com/cucumber_and_cheese
More In-Depth Personal Training
http://www.TestAutomationBootCamp.com/
Saturday, June 1, 13
DOMO ARIGATO MR. ROBOTO!
Fun fact:
domo arigato actually means
"Thanks a lot!"
in Japanese
http://en.wikipedia.org/wiki/Domo_arigato
So....
Domo Arigato!
Saturday, June 1, 13
THAT’S A WRAP!
Joel Byler
@joelbyler
Saturday, June 1, 13
COME FLOAT WITH US!
Located on a 10,000 square foot boat on the
Cleveland waterfront, our team exemplifies
how Agile values & principles are practiced.
Come float, deliver, and learn with us, or
leverage our expertise to help you change
your company culture.
@leandog www.leandog.com
Saturday, June 1, 13

More Related Content

What's hot (20)

PDF
Librerías Opensoure de Square
betabeers
 
PDF
A tour of React Native
Tadeu Zagallo
 
PDF
React-Native for multi-platform mobile applications @ Codemotion Rome 2017
Matteo Manchi
 
PPTX
Creating books app with react native
Ali Sa'o
 
PDF
React native
Omid Nikrah
 
PDF
What is FED
Sam Lee
 
PDF
Experiences building apps with React Native @DomCode 2016
Adrian Philipp
 
PDF
What's This React Native Thing I Keep Hearing About?
Evan Stone
 
PDF
Building native mobile Apps with ReactNative
Samuel Barbosa
 
PPTX
Flutter Intro
Vladimir Parfenov
 
PDF
React Native for multi-platform mobile applications
Matteo Manchi
 
ODP
Learn Once; Write Anywhere
Prateek Bhatnagar
 
PPTX
Introduction to React Native
Waqqas Jabbar
 
PDF
React Native "A Bad Idea Or A Game Changer" at Code Mania 101
Ranatchai Chernbamrung
 
PDF
Hot and spicy Java with Lombok. Live!
Vladimir Tsukur
 
PDF
Capistrano for non-rubyist
Dimitris Tsironis
 
PDF
DBI for Parrot and Perl 6 Lightning Talk 2007
Tim Bunce
 
PDF
Android is going to Go! Android and Golang
Almog Baku
 
PDF
Use groovy & grails in your spring boot projects
Fátima Casaú Pérez
 
PDF
(Live) build and run golang web server on android.avi
SeongJae Park
 
Librerías Opensoure de Square
betabeers
 
A tour of React Native
Tadeu Zagallo
 
React-Native for multi-platform mobile applications @ Codemotion Rome 2017
Matteo Manchi
 
Creating books app with react native
Ali Sa'o
 
React native
Omid Nikrah
 
What is FED
Sam Lee
 
Experiences building apps with React Native @DomCode 2016
Adrian Philipp
 
What's This React Native Thing I Keep Hearing About?
Evan Stone
 
Building native mobile Apps with ReactNative
Samuel Barbosa
 
Flutter Intro
Vladimir Parfenov
 
React Native for multi-platform mobile applications
Matteo Manchi
 
Learn Once; Write Anywhere
Prateek Bhatnagar
 
Introduction to React Native
Waqqas Jabbar
 
React Native "A Bad Idea Or A Game Changer" at Code Mania 101
Ranatchai Chernbamrung
 
Hot and spicy Java with Lombok. Live!
Vladimir Tsukur
 
Capistrano for non-rubyist
Dimitris Tsironis
 
DBI for Parrot and Perl 6 Lightning Talk 2007
Tim Bunce
 
Android is going to Go! Android and Golang
Almog Baku
 
Use groovy & grails in your spring boot projects
Fátima Casaú Pérez
 
(Live) build and run golang web server on android.avi
SeongJae Park
 

Similar to Use Ruby to Write (and Test) Your Next Android App (20)

PDF
Tools/Processes for serious android app development
Gaurav Lochan
 
PDF
Show an Open Source Project Some Love and Start Using Travis-CI
Joel Byler
 
PDF
RubyMotion: Put your Dreams in Motion with Ruby
Astrails
 
PDF
Reverse engineering and instrumentation of android apps
Gaurav Lochan
 
PPT
Practical JRuby
David Keener
 
PDF
Docker Deployments
Docker, Inc.
 
PPTX
Building native Android applications with Mirah and Pindah
Nick Plante
 
PDF
Developing cross platform desktop application with Ruby
Anis Ahmad
 
PDF
Philly Spring UG Roo Overview
krimple
 
PPTX
JRuby in Java Projects
jazzman1980
 
PDF
Scaling Puppet Usage to a Global Organization
Puppet
 
PDF
Why don't you Groovy?
Orest Ivasiv
 
PDF
Bitter Java, Sweeten with JRuby
Brian Sam-Bodden
 
PPTX
9 reasons why programmers should learn react native
React Sharing
 
PDF
JRuby and Google App Engine
joshsmoore
 
PDF
Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine
Joseph Ku
 
PDF
Languages used by web app development services remotestac x
Remote Stacx
 
PPTX
Take A Gulp at Task Automation
Joel Lord
 
PDF
Mobile development in 2020
Bogusz Jelinski
 
Tools/Processes for serious android app development
Gaurav Lochan
 
Show an Open Source Project Some Love and Start Using Travis-CI
Joel Byler
 
RubyMotion: Put your Dreams in Motion with Ruby
Astrails
 
Reverse engineering and instrumentation of android apps
Gaurav Lochan
 
Practical JRuby
David Keener
 
Docker Deployments
Docker, Inc.
 
Building native Android applications with Mirah and Pindah
Nick Plante
 
Developing cross platform desktop application with Ruby
Anis Ahmad
 
Philly Spring UG Roo Overview
krimple
 
JRuby in Java Projects
jazzman1980
 
Scaling Puppet Usage to a Global Organization
Puppet
 
Why don't you Groovy?
Orest Ivasiv
 
Bitter Java, Sweeten with JRuby
Brian Sam-Bodden
 
9 reasons why programmers should learn react native
React Sharing
 
JRuby and Google App Engine
joshsmoore
 
Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine
Joseph Ku
 
Languages used by web app development services remotestac x
Remote Stacx
 
Take A Gulp at Task Automation
Joel Lord
 
Mobile development in 2020
Bogusz Jelinski
 
Ad

Recently uploaded (20)

PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Ad

Use Ruby to Write (and Test) Your Next Android App

  • 1. USE RUBY TO WRITE (AND TEST) YOUR NEXT ANDROID APP Joel Byler Software Craftsman @joelbyler June 1, 2013 Pittsburgh TechFest La Roche College Saturday, June 1, 13
  • 2. WHO AM I? JOEL BYLER  Software Craftsman  Organizer for CleRb  Enterprise Java Developer  Relatively new to Ruby  ... and Android Saturday, June 1, 13
  • 4. NEW TO ANDROID AND RUBY???  Software Craftsmanship Reduce risk with TDD / ATDD  <3 Ruby and want to learn more  <3 Mobile apps, who doesn’t? Warning: this may turn out to be a lot of code to absorb in a short amount of time. Slides and code will be made publicly available Saturday, June 1, 13
  • 5. RUBY ON ANDROID USING RUBOTO JRuby optimized for the Android OS  JRuby is a JVM language  Android uses something like the JVM but actually Dalvik VM =+ <<< MAGIC >>> Saturday, June 1, 13
  • 6. IRB ON YOUR ANDROID DEVICE  Interactive Ruby Shell  Edit and run scripts in Android  demo... Saturday, June 1, 13
  • 7. PERFORMANCE CONSIDERATIONS Other than initial startup to load JRuby, the performance of the app appears to be as good as many native Android apps Saturday, June 1, 13
  • 8. RUBOTO CORE  A separate app available on the Google Play Store  Allows Ruboto Runtime (JRuby on Dalvik VM) to be shared  An alternative would be to use the --with-jruby option Decisions, decisions... Saturday, June 1, 13
  • 9. HOW DOES THIS MAKE YOU FEEL? This is what your users will see if they don’t already have the Ruboto Core installed Using the --with-jruby option will add ~10mb to the size of your app or Saturday, June 1, 13
  • 10. CREATE A NEW PROJECT Ruboto Application Generator $ ruboto gen app --package com.leandog.mastermind.ruboto --name MasterMindRuboto --target android-15 --with-jruby --path=RubotoMasterMind This will generate application with 'What hath Matz wrought?' sample code. Saturday, June 1, 13
  • 11. RUBOTO CLASS GENERATOR Ruboto Class Generator $ ruboto gen class Activity --name MasterMindMainActivity This will generate code for the activity and add it to the project manifest. You can also use this to generate a BroadcastReceiver or Service class Saturday, June 1, 13
  • 13. YOUR GENERATED CODE (RUBY .RB) Saturday, June 1, 13
  • 14. YOUR GENERATED TEST (ALSO .RB) Saturday, June 1, 13
  • 15. RAKE INSTEAD OF ANT $ rake install start Install the project on a device or emulator and start it running. $ ant debug $ adb install example.apk $ adb shell am start -n com.foo.bar... $ rake update_scripts Install the project on a device or emulator and start it running. $ adb install example.apk $ rake -T List other available rake tasks Saturday, June 1, 13
  • 16. ADD IN THE ATDD $ gem install testgen This is one of @chzy 's testing gems $ testgen project yourapp --with-gametel This will add everything you need to use cucumber to test your Ruboto app Saturday, June 1, 13
  • 17. NOW FOR SOME UNIT TESTS $ mkdir spec This is where your specs will live Add rspec to Rakefile (created by testgen) Saturday, June 1, 13
  • 18. UNIT TESTING Use rspec to test your ruby code, just like you normally would. rspec JUnit 3 rake spec Saturday, June 1, 13
  • 19. INTEGRATION TEST? Instruments and installs app on device when running rake test similar to ActivityInstrumentationTestCase2 Saturday, June 1, 13
  • 20. ACCEPTANCE TESTING Feature: Input Screen Scenario: Welcome the user When the application launches Then I see "Enter four numbers below and submit your guess" Scenario: User can guess Given I enter 4 numbers When I press the submit button Then I see "Nice guess!" rake features Cucumber Gametel Brazenhead ADB gem class MainScreen include Gametel text(:number1, :index => 0) text(:number2, :index => 1) text(:number3, :index => 2) text(:number4, :index => 3) def guess (first, second, third, forth) number1 = first.to_s number2 = second.to_s number3 = third.to_s number4 = forth.to_s end end Then(/^I enter 4 numbers$/) do on(MainScreen).guess 1, 2, 3, 4 end Saturday, June 1, 13
  • 21. YOUR RUBOTO CLASS FILES  They're just .rb files  Allows you to make changes without a full rebuild  fast feedback  Ruboto uses ruby classes that are backed by java classes for improved performance.  Can still reference Java resources example: R::string::header_text Saturday, June 1, 13
  • 22. QUICK TOUR OF THE CODE * Time permitting Saturday, June 1, 13
  • 24. THE RUBOTO COMMUNITY IS GROWING Some of these projects are still young or have a small user base. - They will probably continue to change (improve) - Ruboto is only version 0.12 Example: Wasn't able to add a menu to the main activity. Instead I had to wrap it with the 'launch' activity. The good news is that they could definitely use YOUR HELP! Anyone up for trying to make the debugger work? Saturday, June 1, 13
  • 25. CONCLUSION Ruboto is a great Open Source project with a growing community that promises to get even better. Yes, it does increase your app's startup time slightly, but offers a great dynamic nature for rapidly changing apps. Virtually all code can be Ruby, but can also reference Java resources if you so desire. Saturday, June 1, 13
  • 26. RESOURCES Sample Code https://github.com/joelbyler/Ruboto-MasterMind Ruboto http://ruboto.org/ ATDD Training Resource https://leanpub.com/cucumber_and_cheese More In-Depth Personal Training http://www.TestAutomationBootCamp.com/ Saturday, June 1, 13
  • 27. DOMO ARIGATO MR. ROBOTO! Fun fact: domo arigato actually means "Thanks a lot!" in Japanese http://en.wikipedia.org/wiki/Domo_arigato So.... Domo Arigato! Saturday, June 1, 13
  • 28. THAT’S A WRAP! Joel Byler @joelbyler Saturday, June 1, 13
  • 29. COME FLOAT WITH US! Located on a 10,000 square foot boat on the Cleveland waterfront, our team exemplifies how Agile values & principles are practiced. Come float, deliver, and learn with us, or leverage our expertise to help you change your company culture. @leandog www.leandog.com Saturday, June 1, 13